Skip to content

Commit

Permalink
test: improve test success rate.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rory-Z committed Jul 30, 2023
1 parent a9206ca commit c5f0edd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions controllers/apps/v2beta1/sync_pods_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,27 +225,27 @@ var _ = Describe("Check sync pods controller", Ordered, Label("node"), func() {
Eventually(func() map[string]string {
_ = k8sClient.Get(context.Background(), client.ObjectKeyFromObject(currentRsPod), currentRsPod)
return currentRsPod.Annotations
}).Should(HaveKeyWithValue("controller.kubernetes.io/pod-deletion-cost", "-99999"))
}).WithTimeout(timeout).WithPolling(interval).Should(HaveKeyWithValue("controller.kubernetes.io/pod-deletion-cost", "-99999"))

By("should scale down rs")
Eventually(func() int32 {
_ = k8sClient.Get(context.Background(), client.ObjectKeyFromObject(currentRs), currentRs)
return *currentRs.Spec.Replicas
}).Should(Equal(int32(0)))
}).WithTimeout(timeout).WithPolling(interval).Should(Equal(int32(0)))

By("before scale down rs, do nothing for sts")
Eventually(func() int32 {
_ = k8sClient.Get(context.Background(), client.ObjectKeyFromObject(currentSts), currentSts)
return *currentSts.Spec.Replicas
}).Should(Equal(int32(1)))
}).WithTimeout(timeout).WithPolling(interval).Should(Equal(int32(1)))

instance.Status.ReplicantNodesStatus.CurrentRevision = instance.Status.ReplicantNodesStatus.UpdateRevision
Eventually(s.reconcile(ctx, instance, fakeR)).WithTimeout(timeout).WithPolling(interval).Should(Equal(subResult{}))
By("should scale down sts")
Eventually(func() int32 {
_ = k8sClient.Get(context.Background(), client.ObjectKeyFromObject(currentSts), currentSts)
return *currentSts.Spec.Replicas
}).Should(Equal(int32(0)))
}).WithTimeout(timeout).WithPolling(interval).Should(Equal(int32(0)))
})

})
Expand Down

0 comments on commit c5f0edd

Please sign in to comment.