Skip to content

Commit

Permalink
test cleanup: replace equality.DeepEqual by gomega.BeComparableTo (#3260
Browse files Browse the repository at this point in the history
)
  • Loading branch information
dgrove-oss authored Oct 18, 2024
1 parent 7dfe921 commit 9332a5a
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions test/integration/scheduler/workload_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"github.com/onsi/gomega"
corev1 "k8s.io/api/core/v1"
nodev1 "k8s.io/api/node/v1"
"k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand Down Expand Up @@ -362,7 +361,7 @@ var _ = ginkgo.Describe("Workload controller with scheduler", func() {
ginkgo.By("Check podSets spec", func() {
wlRead := kueue.Workload{}
gomega.Expect(k8sClient.Get(ctx, client.ObjectKeyFromObject(wl), &wlRead)).To(gomega.Succeed())
gomega.Expect(equality.Semantic.DeepEqual(wl.Spec.PodSets, wlRead.Spec.PodSets)).To(gomega.BeTrue())
gomega.Expect(wl.Spec.PodSets).Should(gomega.BeComparableTo(wlRead.Spec.PodSets))
})
})
ginkgo.It("Should not use the range defined requests, if provided by the workload", func() {
Expand Down Expand Up @@ -404,7 +403,7 @@ var _ = ginkgo.Describe("Workload controller with scheduler", func() {
ginkgo.By("Check podSets spec", func() {
wlRead := kueue.Workload{}
gomega.Expect(k8sClient.Get(ctx, client.ObjectKeyFromObject(wl), &wlRead)).To(gomega.Succeed())
gomega.Expect(equality.Semantic.DeepEqual(wl.Spec.PodSets, wlRead.Spec.PodSets)).To(gomega.BeTrue())
gomega.Expect(wl.Spec.PodSets).Should(gomega.BeComparableTo(wlRead.Spec.PodSets))
})
})
})
Expand Down Expand Up @@ -465,7 +464,7 @@ var _ = ginkgo.Describe("Workload controller with scheduler", func() {
ginkgo.By("Check podSets spec", func() {
wlRead := kueue.Workload{}
gomega.Expect(k8sClient.Get(ctx, client.ObjectKeyFromObject(wl), &wlRead)).To(gomega.Succeed())
gomega.Expect(equality.Semantic.DeepEqual(wl.Spec.PodSets, wlRead.Spec.PodSets)).To(gomega.BeTrue())
gomega.Expect(wl.Spec.PodSets).Should(gomega.BeComparableTo(wlRead.Spec.PodSets))
})
})
})
Expand Down Expand Up @@ -521,7 +520,7 @@ var _ = ginkgo.Describe("Workload controller with scheduler", func() {
ginkgo.By("Check podSets spec", func() {
wlRead := kueue.Workload{}
gomega.Expect(k8sClient.Get(ctx, client.ObjectKeyFromObject(wl), &wlRead)).To(gomega.Succeed())
gomega.Expect(equality.Semantic.DeepEqual(wl.Spec.PodSets, wlRead.Spec.PodSets)).To(gomega.BeTrue())
gomega.Expect(wl.Spec.PodSets).Should(gomega.BeComparableTo(wlRead.Spec.PodSets))
})

ginkgo.By("Create a pending workload and validate its resourceRequests", func() {
Expand All @@ -534,10 +533,10 @@ var _ = ginkgo.Describe("Workload controller with scheduler", func() {
util.ExpectWorkloadsToBePending(ctx, k8sClient, wl2)
wl2Read := kueue.Workload{}
gomega.Expect(k8sClient.Get(ctx, client.ObjectKeyFromObject(wl2), &wl2Read)).To(gomega.Succeed())
gomega.Expect(equality.Semantic.DeepEqual(wl2Read.Status.ResourceRequests, []kueue.PodSetRequest{{
gomega.Expect(wl2Read.Status.ResourceRequests).Should(gomega.BeComparableTo([]kueue.PodSetRequest{{
Name: "main",
Resources: corev1.ResourceList{corev1.ResourceCPU: resource.MustParse("4")}},
})).To(gomega.BeTrue())
}))
})

ginkgo.By("Finishing the first workload causes the second one to be admitted", func() {
Expand Down Expand Up @@ -622,7 +621,7 @@ var _ = ginkgo.Describe("Workload controller with scheduler", func() {
ginkgo.By("Check podSets spec", func() {
wlRead := kueue.Workload{}
gomega.Expect(k8sClient.Get(ctx, client.ObjectKeyFromObject(wl), &wlRead)).To(gomega.Succeed())
gomega.Expect(equality.Semantic.DeepEqual(wl.Spec.PodSets, wlRead.Spec.PodSets)).To(gomega.BeTrue())
gomega.Expect(wl.Spec.PodSets).Should(gomega.BeComparableTo(wlRead.Spec.PodSets))
})

ginkgo.By("Create a pending workload and validate resourceRequests is not created", func() {
Expand Down Expand Up @@ -661,10 +660,10 @@ var _ = ginkgo.Describe("Workload controller with scheduler", func() {
util.ExpectWorkloadsToBePending(ctx, k8sClient, wl)
read := kueue.Workload{}
gomega.Expect(k8sClient.Get(ctx, client.ObjectKeyFromObject(wl), &read)).To(gomega.Succeed())
gomega.Expect(equality.Semantic.DeepEqual(read.Status.ResourceRequests, []kueue.PodSetRequest{{
gomega.Expect(read.Status.ResourceRequests).Should(gomega.BeComparableTo([]kueue.PodSetRequest{{
Name: "main",
Resources: corev1.ResourceList{pseudoCPU: resource.MustParse("1")}},
})).To(gomega.BeTrue())
Resources: corev1.ResourceList{pseudoCPU: resource.MustParse("1")},
}}))
})
})
})
Expand Down

0 comments on commit 9332a5a

Please sign in to comment.