Skip to content

Commit 17cf340

Browse files
authored
test: fix the rollout integration tests flakiness (#110)
1 parent 03e265d commit 17cf340

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

pkg/controllers/rollout/controller_integration_test.go

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ var _ = Describe("Test the rollout Controller", func() {
102102
bindings = append(bindings, binding)
103103
}
104104
// Check that all bindings are bound.
105-
verifyBindingsRolledOut(bindings, masterSnapshot)
105+
verifyBindingsRolledOut(bindings, masterSnapshot, timeout)
106106
})
107107

108108
It("should push apply strategy changes to all the bindings (if applicable) and refresh their status", func() {
@@ -333,7 +333,7 @@ var _ = Describe("Test the rollout Controller", func() {
333333
bindings = append(bindings, binding)
334334
}
335335
// Check that all bindings are bound.
336-
verifyBindingsRolledOut(bindings, masterSnapshot)
336+
verifyBindingsRolledOut(bindings, masterSnapshot, timeout)
337337
})
338338

339339
It("Should rollout the selected and unselected bindings (not trackable resources)", func() {
@@ -357,7 +357,7 @@ var _ = Describe("Test the rollout Controller", func() {
357357
bindings = append(bindings, binding)
358358
}
359359
// Check that all bindings are bound.
360-
verifyBindingsRolledOut(bindings, masterSnapshot)
360+
verifyBindingsRolledOut(bindings, masterSnapshot, timeout)
361361

362362
// simulate that some of the bindings are available and not trackable.
363363
firstApplied := 3
@@ -447,7 +447,7 @@ var _ = Describe("Test the rollout Controller", func() {
447447
bindings = append(bindings, binding)
448448
}
449449
// Check that all bindings are bound.
450-
verifyBindingsRolledOut(bindings, masterSnapshot)
450+
verifyBindingsRolledOut(bindings, masterSnapshot, timeout)
451451

452452
// simulate that some of the bindings are available
453453
firstApplied := 3
@@ -608,7 +608,11 @@ var _ = Describe("Test the rollout Controller", func() {
608608
}, timeout, interval).Should(BeTrue(), "the second deleting binding should now be deleted")
609609
By("Verified that the second deleting binding is deleted")
610610
// Check that the bindings are rolledout.
611-
verifyBindingsRolledOut(bindings, latestSnapshot)
611+
// When there is a binding assigned to a cluster with another deleting bindings, the controller
612+
// will wait until the deleting binding is deleted before it rolls out the bindings.
613+
// It requeues the bindings every 5 sceconds by checking waitForResourcesToCleanUp func.
614+
// Leave 5 seconds for the controller to requeue the bindings and roll them out.
615+
verifyBindingsRolledOut(bindings, latestSnapshot, 5*time.Second+timeout)
612616
By("Verified that the rollout is finally unblocked")
613617
})
614618

@@ -633,7 +637,7 @@ var _ = Describe("Test the rollout Controller", func() {
633637
bindings = append(bindings, binding)
634638
}
635639
// Check that all bindings are bound.
636-
verifyBindingsRolledOut(bindings, masterSnapshot)
640+
verifyBindingsRolledOut(bindings, masterSnapshot, timeout)
637641

638642
// simulate that some of the bindings are available successfully
639643
applySuccessfully := 3
@@ -694,7 +698,7 @@ var _ = Describe("Test the rollout Controller", func() {
694698
bindings = append(bindings, binding)
695699
}
696700
// Check that all bindings are bound.
697-
verifyBindingsRolledOut(bindings, masterSnapshot)
701+
verifyBindingsRolledOut(bindings, masterSnapshot, timeout)
698702

699703
// simulate that some of the bindings are available successfully
700704
applySuccessfully := 3
@@ -773,7 +777,7 @@ var _ = Describe("Test the rollout Controller", func() {
773777
}
774778

775779
// Check that all bindings are bound..
776-
verifyBindingsRolledOut(bindings, masterSnapshot)
780+
verifyBindingsRolledOut(bindings, masterSnapshot, timeout)
777781

778782
// mark one binding as ready i.e. applied and available.
779783
availableBinding := 1
@@ -873,7 +877,7 @@ var _ = Describe("Test the rollout Controller", func() {
873877
}
874878

875879
// Check that all bindings are bound.
876-
verifyBindingsRolledOut(bindings, masterSnapshot)
880+
verifyBindingsRolledOut(bindings, masterSnapshot, timeout)
877881

878882
// Note: This scenario is very unlikely in production user has to change the target from 2->3->2,
879883
// where scheduler created new scheduled binding but user changed the target number from 3->2 again, before rollout controller reads CRP.
@@ -956,7 +960,7 @@ var _ = Describe("Test the rollout Controller", func() {
956960
Expect(k8sClient.Update(ctx, rolloutCRP)).Should(Succeed(), "Failed to update CRP")
957961

958962
By("Verifying that rollout is unblocked")
959-
verifyBindingsRolledOut(bindings, masterSnapshot)
963+
verifyBindingsRolledOut(bindings, masterSnapshot, timeout)
960964
})
961965

962966
It("Should rollout all the selected bindings when strategy type is changed from External to empty", func() {
@@ -991,7 +995,7 @@ var _ = Describe("Test the rollout Controller", func() {
991995
Expect(k8sClient.Update(ctx, rolloutCRP)).Should(Succeed(), "Failed to update CRP")
992996

993997
By("Verifying that rollout is unblocked")
994-
verifyBindingsRolledOut(bindings, masterSnapshot)
998+
verifyBindingsRolledOut(bindings, masterSnapshot, timeout)
995999
})
9961000

9971001
It("Should not rollout anymore if the rollout strategy type is changed from RollingUpdate to External", func() {
@@ -1018,7 +1022,7 @@ var _ = Describe("Test the rollout Controller", func() {
10181022
}
10191023

10201024
By("Checking bindings are rolled out")
1021-
verifyBindingsRolledOut(bindings, masterSnapshot)
1025+
verifyBindingsRolledOut(bindings, masterSnapshot, timeout)
10221026

10231027
By("Updating CRP rollout strategy type to External")
10241028
rolloutCRP.Spec.Strategy.Type = fleetv1beta1.ExternalRolloutStrategyType
@@ -1084,7 +1088,7 @@ func verifyBindingsNotRolledOutConsistently(bindings []*fleetv1beta1.ClusterReso
10841088
}, consistentTimeout, consistentInterval).Should(Succeed(), "rollout controller should not roll any binding to Bound state")
10851089
}
10861090

1087-
func verifyBindingsRolledOut(bindings []*fleetv1beta1.ClusterResourceBinding, masterSnapshot *fleetv1beta1.ClusterResourceSnapshot) {
1091+
func verifyBindingsRolledOut(bindings []*fleetv1beta1.ClusterResourceBinding, masterSnapshot *fleetv1beta1.ClusterResourceSnapshot, timeout time.Duration) {
10881092
// Check that all bindings are bound and updated to the latest snapshot.
10891093
Eventually(func() error {
10901094
for _, binding := range bindings {

0 commit comments

Comments
 (0)