@@ -30,14 +30,8 @@ func TestStaticRayService(t *testing.T) {
30
30
LogWithTimestamp (test .T (), "Created ConfigMap %s/%s successfully" , configMap .Namespace , configMap .Name )
31
31
32
32
// Create the RayService for testing
33
- KubectlApplyYAML (test , rayserviceYamlFile , namespace .Name )
34
- rayService , err := GetRayService (test , namespace .Name , "test-rayservice" )
35
- g .Expect (err ).NotTo (HaveOccurred ())
36
- LogWithTimestamp (test .T (), "Created RayService %s/%s successfully" , rayService .Namespace , rayService .Name )
37
-
38
- LogWithTimestamp (test .T (), "Waiting for RayService %s/%s to be ready" , rayService .Namespace , rayService .Name )
39
- g .Eventually (RayService (test , rayService .Namespace , rayService .Name ), TestTimeoutMedium ).
40
- Should (WithTransform (IsRayServiceReady , BeTrue ()))
33
+ rayServiceName := "test-rayservice"
34
+ applyRayServiceYAMLAndWaitReady (g , test , rayserviceYamlFile , namespace .Name , rayServiceName )
41
35
42
36
// Create Locust RayCluster
43
37
KubectlApplyYAML (test , locustYamlFile , namespace .Name )
@@ -80,17 +74,11 @@ func TestAutoscalingRayService(t *testing.T) {
80
74
LogWithTimestamp (test .T (), "Created ConfigMap %s/%s successfully" , configMap .Namespace , configMap .Name )
81
75
82
76
// Create the RayService for testing
83
- KubectlApplyYAML (test , rayserviceYamlFile , namespace .Name )
84
- rayService , err := GetRayService (test , namespace .Name , "test-rayservice" )
85
- g .Expect (err ).NotTo (HaveOccurred ())
86
- LogWithTimestamp (test .T (), "Created RayService %s/%s successfully" , rayService .Namespace , rayService .Name )
87
-
88
- LogWithTimestamp (test .T (), "Waiting for RayService %s/%s to be ready" , rayService .Namespace , rayService .Name )
89
- g .Eventually (RayService (test , rayService .Namespace , rayService .Name ), TestTimeoutMedium ).
90
- Should (WithTransform (IsRayServiceReady , BeTrue ()))
77
+ rayServiceName := "test-rayservice"
78
+ applyRayServiceYAMLAndWaitReady (g , test , rayserviceYamlFile , namespace .Name , rayServiceName )
91
79
92
80
// Get the underlying RayCluster of the RayService
93
- rayService , err = GetRayService (test , namespace .Name , rayService . Name )
81
+ rayService , err : = GetRayService (test , namespace .Name , rayServiceName )
94
82
g .Expect (err ).NotTo (HaveOccurred ())
95
83
rayServiceUnderlyingRayCluster , err := GetRayCluster (test , namespace .Name , rayService .Status .ActiveServiceStatus .RayClusterName )
96
84
g .Expect (err ).NotTo (HaveOccurred ())
@@ -150,14 +138,8 @@ func TestRayServiceZeroDowntimeUpgrade(t *testing.T) {
150
138
LogWithTimestamp (test .T (), "Created ConfigMap %s/%s successfully" , configMap .Namespace , configMap .Name )
151
139
152
140
// Create the RayService for testing
153
- KubectlApplyYAML (test , rayserviceYamlFile , namespace .Name )
154
- rayService , err := GetRayService (test , namespace .Name , "test-rayservice" )
155
- g .Expect (err ).NotTo (HaveOccurred ())
156
- LogWithTimestamp (test .T (), "Created RayService %s/%s successfully" , rayService .Namespace , rayService .Name )
157
-
158
- LogWithTimestamp (test .T (), "Waiting for RayService %s/%s to be ready" , rayService .Namespace , rayService .Name )
159
- g .Eventually (RayService (test , rayService .Namespace , rayService .Name ), TestTimeoutMedium ).
160
- Should (WithTransform (IsRayServiceReady , BeTrue ()))
141
+ rayServiceName := "test-rayservice"
142
+ applyRayServiceYAMLAndWaitReady (g , test , rayserviceYamlFile , namespace .Name , rayServiceName )
161
143
162
144
// Create Locust RayCluster
163
145
KubectlApplyYAML (test , locustYamlFile , namespace .Name )
@@ -187,7 +169,7 @@ func TestRayServiceZeroDowntimeUpgrade(t *testing.T) {
187
169
time .Sleep (30 * time .Second )
188
170
189
171
LogWithTimestamp (test .T (), "Updating RayService" )
190
- rayService , err := GetRayService (test , namespace .Name , "test-rayservice" )
172
+ rayService , err := GetRayService (test , namespace .Name , rayServiceName )
191
173
g .Expect (err ).NotTo (HaveOccurred ())
192
174
rayClusterName := rayService .Status .ActiveServiceStatus .RayClusterName
193
175
@@ -224,20 +206,14 @@ func TestRayServiceGCSFaultTolerance(t *testing.T) {
224
206
LogWithTimestamp (test .T (), "Created ConfigMap %s/%s successfully" , configMap .Namespace , configMap .Name )
225
207
226
208
// Create the RayService for testing
227
- KubectlApplyYAML (test , rayserviceYamlFile , namespace .Name )
228
- rayService , err := GetRayService (test , namespace .Name , "test-rayservice" )
229
- g .Expect (err ).NotTo (HaveOccurred ())
230
- LogWithTimestamp (test .T (), "Created RayService %s/%s successfully" , rayService .Namespace , rayService .Name )
231
-
232
- LogWithTimestamp (test .T (), "Waiting for RayService %s/%s to be ready" , rayService .Namespace , rayService .Name )
233
- g .Eventually (RayService (test , rayService .Namespace , rayService .Name ), TestTimeoutMedium ).
234
- Should (WithTransform (IsRayServiceReady , BeTrue ()))
209
+ rayServiceName := "test-rayservice"
210
+ applyRayServiceYAMLAndWaitReady (g , test , rayserviceYamlFile , namespace .Name , rayServiceName )
235
211
236
- g .Eventually (RayService (test , rayService . Namespace , rayService . Name ), TestTimeoutShort ).
212
+ g .Eventually (RayService (test , namespace . Name , rayServiceName ), TestTimeoutShort ).
237
213
Should (WithTransform (RayServicesNumEndPoints , Equal (int32 (1 ))))
238
214
239
215
// Get the underlying RayCluster of the RayService
240
- rayService , err = GetRayService (test , namespace .Name , rayService . Name )
216
+ rayService , err : = GetRayService (test , namespace .Name , rayServiceName )
241
217
g .Expect (err ).NotTo (HaveOccurred ())
242
218
rayServiceUnderlyingRayCluster , err := GetRayCluster (test , namespace .Name , rayService .Status .ActiveServiceStatus .RayClusterName )
243
219
g .Expect (err ).NotTo (HaveOccurred ())
@@ -287,3 +263,29 @@ func TestRayServiceGCSFaultTolerance(t *testing.T) {
287
263
g .Expect (GetHeadPod (test , rayServiceUnderlyingRayCluster )).Should (WithTransform (IsPodRunningAndReady , BeTrue ()))
288
264
g .Expect (GetWorkerPods (test , rayServiceUnderlyingRayCluster )).Should (WithTransform (AllPodsRunningAndReady , BeTrue ()))
289
265
}
266
+
267
+ func TestRayServiceRayClusterDeletionDelaySeconds (t * testing.T ) {
268
+ rayserviceYamlFile := "testdata/rayservice.deletiondelay.yaml"
269
+
270
+ test := With (t )
271
+ g := NewWithT (t )
272
+ namespace := test .NewTestNamespace ()
273
+
274
+ // Apply the RayService YAML with deletion delay set to 10 seconds
275
+ rayServiceName := "test-rayservice-deletion-delay"
276
+ applyRayServiceYAMLAndWaitReady (g , test , rayserviceYamlFile , namespace .Name , rayServiceName )
277
+
278
+ // Save the current RayCluster name
279
+ rayService , err := GetRayService (test , namespace .Name , rayServiceName )
280
+ g .Expect (err ).NotTo (HaveOccurred ())
281
+ oldClusterName := rayService .Status .ActiveServiceStatus .RayClusterName
282
+
283
+ // Try updating and see if the new cluster created
284
+ LogWithTimestamp (test .T (), "Updating RayService" )
285
+ newRayService := rayService .DeepCopy ()
286
+ newRayService .Spec .RayClusterSpec .RayVersion = ""
287
+ newRayService , err = test .Client ().Ray ().RayV1 ().RayServices (newRayService .Namespace ).Update (test .Ctx (), newRayService , metav1.UpdateOptions {})
288
+ g .Expect (err ).NotTo (HaveOccurred ())
289
+
290
+ waitingForRayClusterSwitchWithDeletionDelay (g , test , newRayService , oldClusterName , 10 * time .Second )
291
+ }
0 commit comments