Skip to content

Commit b5be747

Browse files
committed
[Refactor] Do not use RAYCLUSTER_DEFAULT_REQUEUE_SECONDS_ENV as timeout of status check in tests
It is only an insurance to keep reconciliation continuously triggered to hopefully fix an unexpected state. Relying on it to fix state transitions is not a good pratice. Therefore, We should not reference it in tests at all.
1 parent 1594e88 commit b5be747

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

ray-operator/controllers/ray/raycluster_controller_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ var _ = Context("Inside the default namespace", func() {
205205
// We need to figure out the behavior. See https://github.com/ray-project/kuberay/issues/1736 for more details.
206206
Eventually(
207207
getClusterState(ctx, "default", myRayCluster.Name),
208-
time.Second*(utils.RAYCLUSTER_DEFAULT_REQUEUE_SECONDS+5), time.Millisecond*500).Should(Equal(rayv1.Ready))
208+
time.Second*15, time.Millisecond*500).Should(Equal(rayv1.Ready))
209209
})
210210

211211
It("should re-create a deleted worker", func() {
@@ -311,7 +311,7 @@ var _ = Context("Inside the default namespace", func() {
311311
It("cluster's .status.state should be updated to 'suspended' shortly after all Pods are terminated", func() {
312312
Eventually(
313313
getClusterState(ctx, "default", myRayCluster.Name),
314-
time.Second*(utils.RAYCLUSTER_DEFAULT_REQUEUE_SECONDS+5), time.Millisecond*500).Should(Equal(rayv1.Suspended))
314+
time.Second*15, time.Millisecond*500).Should(Equal(rayv1.Suspended))
315315
})
316316

317317
It("set suspend to false and then revert it to true before all Pods are running", func() {
@@ -363,7 +363,7 @@ var _ = Context("Inside the default namespace", func() {
363363
// RayCluster should be in Suspended state.
364364
Eventually(
365365
getClusterState(ctx, "default", myRayCluster.Name),
366-
time.Second*(utils.RAYCLUSTER_DEFAULT_REQUEUE_SECONDS+5), time.Millisecond*500).Should(Equal(rayv1.Suspended))
366+
time.Second*15, time.Millisecond*500).Should(Equal(rayv1.Suspended))
367367
})
368368

369369
It("should run all head and worker pods if un-suspended", func() {
@@ -402,7 +402,7 @@ var _ = Context("Inside the default namespace", func() {
402402
It("cluster's .status.state should be updated back to 'ready' after being un-suspended", func() {
403403
Eventually(
404404
getClusterState(ctx, "default", myRayCluster.Name),
405-
time.Second*(utils.RAYCLUSTER_DEFAULT_REQUEUE_SECONDS+5), time.Millisecond*500).Should(Equal(rayv1.Ready))
405+
time.Second*15, time.Millisecond*500).Should(Equal(rayv1.Ready))
406406
})
407407
})
408408
})

ray-operator/controllers/ray/rayjob_controller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ var _ = Context("Inside the default namespace", func() {
270270
// The RayCluster.Status.State should be Ready.
271271
Eventually(
272272
getClusterState(ctx, "default", myRayCluster.Name),
273-
time.Second*(utils.RAYCLUSTER_DEFAULT_REQUEUE_SECONDS+5), time.Millisecond*500).Should(Equal(rayv1.Ready))
273+
time.Second*15, time.Millisecond*500).Should(Equal(rayv1.Ready))
274274
})
275275

276276
It("Dashboard URL should be set", func() {

ray-operator/controllers/ray/suite_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,10 @@ var _ = BeforeSuite(func(ctx SpecContext) {
7979
Expect(err).ToNot(HaveOccurred())
8080
Expect(k8sClient).ToNot(BeNil())
8181

82-
// Suggested way to run tests
82+
// The RAYCLUSTER_DEFAULT_REQUEUE_SECONDS_ENV is an insurance to keep reconciliation continuously triggered to hopefully fix an unexpected state.
83+
// In a production environment, the requeue period is set to five minutes by default, which is relatively infrequent.
84+
// TODO: We probably should not shorten RAYCLUSTER_DEFAULT_REQUEUE_SECONDS_ENV here just to make tests pass.
85+
// Instead, we should fix the reconciliation if any unexpected happened.
8386
os.Setenv(utils.RAYCLUSTER_DEFAULT_REQUEUE_SECONDS_ENV, "10")
8487
mgr, err := ctrl.NewManager(cfg, ctrl.Options{
8588
Scheme: scheme.Scheme,

0 commit comments

Comments
 (0)