Skip to content

Commit

Permalink
Propagate gomega.Gomega on integration/controller/core tests. (kubern…
Browse files Browse the repository at this point in the history
…etes-sigs#3327)

* Propagate gomega.Gomega on admissioncheck_controller_test.go.

* Propagate gomega.Gomega on clusterqueue_controller_test.go.

* Propagate gomega.Gomega on resourceflavor_controller_test.go.

* Propagate gomega.Gomega on workload_controller_test.go.
  • Loading branch information
mbobrovskyi authored and PBundyra committed Nov 5, 2024
1 parent 579d1cb commit b1bea0c
Show file tree
Hide file tree
Showing 4 changed files with 444 additions and 452 deletions.
41 changes: 19 additions & 22 deletions test/integration/controller/core/admissioncheck_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,47 +86,44 @@ var _ = ginkgo.Describe("AdmissionCheck controller", ginkgo.Ordered, ginkgo.Cont
ginkgo.By("Try to delete admissionCheck")
gomega.Expect(util.DeleteObject(ctx, k8sClient, admissionCheck)).To(gomega.Succeed())
var ac kueue.AdmissionCheck
gomega.Eventually(func() []string {
gomega.Expect(k8sClient.Get(ctx, client.ObjectKeyFromObject(admissionCheck), &ac)).To(gomega.Succeed())
return ac.GetFinalizers()
}, util.Timeout, util.Interval).Should(gomega.BeComparableTo([]string{kueue.ResourceInUseFinalizerName}))
gomega.Eventually(func(g gomega.Gomega) {
g.Expect(k8sClient.Get(ctx, client.ObjectKeyFromObject(admissionCheck), &ac)).To(gomega.Succeed())
g.Expect(ac.GetFinalizers()).Should(gomega.BeComparableTo([]string{kueue.ResourceInUseFinalizerName}))
}, util.Timeout, util.Interval).Should(gomega.Succeed())
gomega.Expect(ac.GetDeletionTimestamp()).ShouldNot(gomega.BeNil())

ginkgo.By("Update clusterQueue's cohort")
var cq kueue.ClusterQueue
gomega.Eventually(func() error {
gomega.Expect(k8sClient.Get(ctx, client.ObjectKeyFromObject(clusterQueue), &cq)).To(gomega.Succeed())
gomega.Eventually(func(g gomega.Gomega) {
g.Expect(k8sClient.Get(ctx, client.ObjectKeyFromObject(clusterQueue), &cq)).To(gomega.Succeed())
cq.Spec.Cohort = "foo-cohort"
return k8sClient.Update(ctx, &cq)
g.Expect(k8sClient.Update(ctx, &cq)).Should(gomega.Succeed())
}, util.Timeout, util.Interval).Should(gomega.Succeed())

gomega.Eventually(func() error {
return k8sClient.Get(ctx, client.ObjectKeyFromObject(admissionCheck), &ac)
gomega.Eventually(func(g gomega.Gomega) {
g.Expect(k8sClient.Get(ctx, client.ObjectKeyFromObject(admissionCheck), &ac)).Should(gomega.Succeed())
}, util.Timeout, util.Interval).Should(gomega.Succeed())

ginkgo.By("Change clusterQueue's checks")
gomega.Eventually(func() error {
err := k8sClient.Get(ctx, client.ObjectKeyFromObject(clusterQueue), &cq)
if err != nil {
return err
}
gomega.Eventually(func(g gomega.Gomega) {
g.Expect(k8sClient.Get(ctx, client.ObjectKeyFromObject(clusterQueue), &cq)).Should(gomega.Succeed())
cq.Spec.AdmissionChecks = []string{"check2"}
return k8sClient.Update(ctx, &cq)
g.Expect(k8sClient.Update(ctx, &cq)).Should(gomega.Succeed())
}, util.Timeout, util.Interval).Should(gomega.Succeed())

gomega.Eventually(func() error {
return k8sClient.Get(ctx, client.ObjectKeyFromObject(admissionCheck), &ac)
}, util.Timeout, util.Interval).Should(utiltesting.BeNotFoundError())
gomega.Eventually(func(g gomega.Gomega) {
g.Expect(k8sClient.Get(ctx, client.ObjectKeyFromObject(admissionCheck), &ac)).Should(utiltesting.BeNotFoundError())
}, util.Timeout, util.Interval).Should(gomega.Succeed())
})

ginkgo.It("Should delete the admissionCheck when the corresponding clusterQueue is deleted", func() {
gomega.Expect(util.DeleteObject(ctx, k8sClient, admissionCheck)).To(gomega.Succeed())

var rf kueue.AdmissionCheck
gomega.Eventually(func() []string {
gomega.Expect(k8sClient.Get(ctx, client.ObjectKeyFromObject(admissionCheck), &rf)).To(gomega.Succeed())
return rf.GetFinalizers()
}, util.Timeout, util.Interval).Should(gomega.BeComparableTo([]string{kueue.ResourceInUseFinalizerName}))
gomega.Eventually(func(g gomega.Gomega) {
g.Expect(k8sClient.Get(ctx, client.ObjectKeyFromObject(admissionCheck), &rf)).To(gomega.Succeed())
g.Expect(rf.GetFinalizers()).Should(gomega.BeComparableTo([]string{kueue.ResourceInUseFinalizerName}))
}, util.Timeout, util.Interval).Should(gomega.Succeed())
gomega.Expect(rf.GetDeletionTimestamp()).ShouldNot(gomega.BeNil())

gomega.Expect(util.DeleteObject(ctx, k8sClient, clusterQueue)).To(gomega.Succeed())
Expand Down
Loading

0 comments on commit b1bea0c

Please sign in to comment.