Skip to content

Commit 4e35750

Browse files
authored
Merge pull request kubernetes#86156 from tanjunchen/use-framework-Equal-test-e2e_node
test/e2e_node/:use framework.Equal() instead of using gomega.Expect(b…
2 parents 6c98d55 + 35b0f1f commit 4e35750

File tree

5 files changed

+13
-15
lines changed

5 files changed

+13
-15
lines changed

test/e2e/common/init_container.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ var _ = framework.KubeDescribe("InitContainer [NodeConformance]", func() {
215215

216216
framework.ExpectEqual(len(endPod.Status.InitContainerStatuses), 2)
217217
for _, status := range endPod.Status.InitContainerStatuses {
218-
gomega.Expect(status.Ready).To(gomega.BeTrue())
218+
framework.ExpectEqual(status.Ready, true)
219219
gomega.Expect(status.State.Terminated).NotTo(gomega.BeNil())
220220
gomega.Expect(status.State.Terminated.ExitCode).To(gomega.BeZero())
221221
}
@@ -285,7 +285,7 @@ var _ = framework.KubeDescribe("InitContainer [NodeConformance]", func() {
285285

286286
framework.ExpectEqual(len(endPod.Status.InitContainerStatuses), 2)
287287
for _, status := range endPod.Status.InitContainerStatuses {
288-
gomega.Expect(status.Ready).To(gomega.BeTrue())
288+
framework.ExpectEqual(status.Ready, true)
289289
gomega.Expect(status.State.Terminated).NotTo(gomega.BeNil())
290290
gomega.Expect(status.State.Terminated.ExitCode).To(gomega.BeZero())
291291
}

test/e2e_node/critical_pod_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import (
3232
imageutils "k8s.io/kubernetes/test/utils/image"
3333

3434
"github.com/onsi/ginkgo"
35-
"github.com/onsi/gomega"
3635
)
3736

3837
const (
@@ -86,7 +85,7 @@ var _ = framework.KubeDescribe("CriticalPod [Serial] [Disruptive] [NodeFeature:C
8685
})
8786

8887
_, err = f.ClientSet.SchedulingV1().PriorityClasses().Create(systemCriticalPriority)
89-
gomega.Expect(err == nil || errors.IsAlreadyExists(err)).To(gomega.BeTrue(), "failed to create PriorityClasses with an error: %v", err)
88+
framework.ExpectEqual(err == nil || errors.IsAlreadyExists(err), true, "failed to create PriorityClasses with an error: %v", err)
9089

9190
// Create pods, starting with non-critical so that the critical preempts the other pods.
9291
f.PodClient().CreateBatch([]*v1.Pod{nonCriticalBestEffort, nonCriticalBurstable, nonCriticalGuaranteed})
@@ -157,9 +156,9 @@ func getTestPod(critical bool, name string, resources v1.ResourceRequirements) *
157156
pod.Spec.PriorityClassName = systemCriticalPriorityName
158157
pod.Spec.Priority = &value
159158

160-
gomega.Expect(kubelettypes.IsCriticalPod(pod)).To(gomega.BeTrue(), "pod should be a critical pod")
159+
framework.ExpectEqual(kubelettypes.IsCriticalPod(pod), true, "pod should be a critical pod")
161160
} else {
162-
gomega.Expect(kubelettypes.IsCriticalPod(pod)).To(gomega.BeFalse(), "pod should not be a critical pod")
161+
framework.ExpectEqual(kubelettypes.IsCriticalPod(pod), false, "pod should not be a critical pod")
163162
}
164163
return pod
165164
}

test/e2e_node/e2e_node_suite_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ func getNode(c *clientset.Clientset) (*v1.Node, error) {
307307
if nodes == nil {
308308
return nil, fmt.Errorf("the node list is nil")
309309
}
310-
gomega.Expect(len(nodes.Items) > 1).NotTo(gomega.BeTrue(), "the number of nodes is more than 1.")
310+
framework.ExpectEqual(len(nodes.Items) > 1, false, "the number of nodes is more than 1.")
311311
if len(nodes.Items) == 0 {
312312
return nil, fmt.Errorf("empty node list: %+v", nodes)
313313
}

test/e2e_node/eviction_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323
"strings"
2424
"time"
2525

26-
"k8s.io/api/core/v1"
26+
v1 "k8s.io/api/core/v1"
2727
schedulingv1 "k8s.io/api/scheduling/v1"
2828
"k8s.io/apimachinery/pkg/api/errors"
2929
"k8s.io/apimachinery/pkg/api/resource"
@@ -302,7 +302,7 @@ var _ = framework.KubeDescribe("PriorityMemoryEvictionOrdering [Slow] [Serial] [
302302
})
303303
ginkgo.BeforeEach(func() {
304304
_, err := f.ClientSet.SchedulingV1().PriorityClasses().Create(&schedulingv1.PriorityClass{ObjectMeta: metav1.ObjectMeta{Name: highPriorityClassName}, Value: highPriority})
305-
gomega.Expect(err == nil || errors.IsAlreadyExists(err)).To(gomega.BeTrue())
305+
framework.ExpectEqual(err == nil || errors.IsAlreadyExists(err), true)
306306
})
307307
ginkgo.AfterEach(func() {
308308
err := f.ClientSet.SchedulingV1().PriorityClasses().Delete(highPriorityClassName, &metav1.DeleteOptions{})
@@ -359,7 +359,7 @@ var _ = framework.KubeDescribe("PriorityLocalStorageEvictionOrdering [Slow] [Ser
359359
})
360360
ginkgo.BeforeEach(func() {
361361
_, err := f.ClientSet.SchedulingV1().PriorityClasses().Create(&schedulingv1.PriorityClass{ObjectMeta: metav1.ObjectMeta{Name: highPriorityClassName}, Value: highPriority})
362-
gomega.Expect(err == nil || errors.IsAlreadyExists(err)).To(gomega.BeTrue())
362+
framework.ExpectEqual(err == nil || errors.IsAlreadyExists(err), true)
363363
})
364364
ginkgo.AfterEach(func() {
365365
err := f.ClientSet.SchedulingV1().PriorityClasses().Delete(highPriorityClassName, &metav1.DeleteOptions{})
@@ -412,7 +412,7 @@ var _ = framework.KubeDescribe("PriorityPidEvictionOrdering [Slow] [Serial] [Dis
412412
})
413413
ginkgo.BeforeEach(func() {
414414
_, err := f.ClientSet.SchedulingV1().PriorityClasses().Create(&schedulingv1.PriorityClass{ObjectMeta: metav1.ObjectMeta{Name: highPriorityClassName}, Value: highPriority})
415-
gomega.Expect(err == nil || errors.IsAlreadyExists(err)).To(gomega.BeTrue())
415+
framework.ExpectEqual(err == nil || errors.IsAlreadyExists(err), true)
416416
})
417417
ginkgo.AfterEach(func() {
418418
err := f.ClientSet.SchedulingV1().PriorityClasses().Delete(highPriorityClassName, &metav1.DeleteOptions{})
@@ -661,7 +661,7 @@ func verifyEvictionEvents(f *framework.Framework, testSpecs []podEvictSpec, expe
661661
if expectedStarvedResource != noStarvedResource {
662662
// Check the eviction.StarvedResourceKey
663663
starved, found := event.Annotations[eviction.StarvedResourceKey]
664-
gomega.Expect(found).To(gomega.BeTrue(), "Expected to find an annotation on the eviction event for pod %s containing the starved resource %s, but it was not found",
664+
framework.ExpectEqual(found, true, "Expected to find an annotation on the eviction event for pod %s containing the starved resource %s, but it was not found",
665665
pod.Name, expectedStarvedResource)
666666
starvedResource := v1.ResourceName(starved)
667667
framework.ExpectEqual(starvedResource, expectedStarvedResource, "Expected to the starved_resource annotation on pod %s to contain %s, but got %s instead",
@@ -671,7 +671,7 @@ func verifyEvictionEvents(f *framework.Framework, testSpecs []podEvictSpec, expe
671671
if expectedStarvedResource == v1.ResourceMemory {
672672
// Check the eviction.OffendingContainersKey
673673
offendersString, found := event.Annotations[eviction.OffendingContainersKey]
674-
gomega.Expect(found).To(gomega.BeTrue(), "Expected to find an annotation on the eviction event for pod %s containing the offending containers, but it was not found",
674+
framework.ExpectEqual(found, true, "Expected to find an annotation on the eviction event for pod %s containing the offending containers, but it was not found",
675675
pod.Name)
676676
offendingContainers := strings.Split(offendersString, ",")
677677
framework.ExpectEqual(len(offendingContainers), 1, "Expected to find the offending container's usage in the %s annotation, but no container was found",

test/e2e_node/startup_probe_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import (
3030
imageutils "k8s.io/kubernetes/test/utils/image"
3131

3232
"github.com/onsi/ginkgo"
33-
"github.com/onsi/gomega"
3433
)
3534

3635
const (
@@ -179,7 +178,7 @@ var _ = framework.KubeDescribe("StartupProbe [Serial] [Disruptive] [NodeAlphaFea
179178

180179
isReady, err := testutils.PodRunningReady(p)
181180
framework.ExpectNoError(err)
182-
gomega.Expect(isReady).To(gomega.BeTrue(), "pod should be ready")
181+
framework.ExpectEqual(isReady, true, "pod should be ready")
183182

184183
// We assume the pod became ready when the container became ready. This
185184
// is true for a single container pod.

0 commit comments

Comments
 (0)