@@ -234,7 +234,7 @@ func TestGetAllServicesWithPagination(t *testing.T) {
234234 expectedServiceNames := make ([][]string , numberOfNamespaces )
235235
236236 // Create services for each namespace
237- for i := range numberOfNamespaces {
237+ for i := 0 ; i < numberOfNamespaces ; i ++ {
238238 tCtx , err := NewEnd2EndTestingContext (t )
239239 require .NoError (t , err , "No error expected when creating testing context" )
240240
@@ -244,7 +244,7 @@ func TestGetAllServicesWithPagination(t *testing.T) {
244244 })
245245
246246 expectedServiceNames [i ] = make ([]string , 0 , numberOfService )
247- for range numberOfService {
247+ for j := 0 ; j < numberOfService ; j ++ {
248248 testServiceRequest := createTestServiceV2 (t , tCtx )
249249 t .Cleanup (func () {
250250 tCtx .DeleteRayService (t , testServiceRequest .Service .Name )
@@ -261,11 +261,11 @@ func TestGetAllServicesWithPagination(t *testing.T) {
261261 t .Run ("Test pagination return part of the result services" , func (t * testing.T ) {
262262 pageToken = ""
263263 gotServices := make ([][]bool , numberOfNamespaces )
264- for i := range numberOfNamespaces {
265- gotServices [i ] = make ([]bool , numberOfNamespaces )
264+ for i := 0 ; i < numberOfNamespaces ; i ++ {
265+ gotServices [i ] = make ([]bool , numberOfService )
266266 }
267267
268- for i := range totalServices {
268+ for i := 0 ; i < totalServices ; i ++ {
269269 response , actualRPCStatus , err := tCtx .GetRayAPIServerClient ().ListAllRayServices (& api.ListAllRayServicesRequest {
270270 PageToken : pageToken ,
271271 PageSize : int32 (1 ),
@@ -278,7 +278,7 @@ func TestGetAllServicesWithPagination(t *testing.T) {
278278
279279 for _ , service := range response .Services {
280280 for namespaceIdx , ctx := range tCtxs {
281- for serviceIdx := range numberOfService {
281+ for serviceIdx := 0 ; serviceIdx < numberOfService ; serviceIdx ++ {
282282 if service .Namespace == ctx .GetNamespaceName () &&
283283 service .Name == expectedServiceNames [namespaceIdx ][serviceIdx ] {
284284 gotServices [namespaceIdx ][serviceIdx ] = true
@@ -296,8 +296,9 @@ func TestGetAllServicesWithPagination(t *testing.T) {
296296 }
297297 }
298298
299+ // Check all services were found
299300 for namespaceIdx , ctx := range tCtxs {
300- for serviceIdx := range numberOfService {
301+ for serviceIdx := 0 ; serviceIdx < numberOfService ; serviceIdx ++ {
301302 if ! gotServices [namespaceIdx ][serviceIdx ] {
302303 t .Errorf ("ListAllRayServices did not return expected service %s from namespace %s" ,
303304 expectedServiceNames [namespaceIdx ][serviceIdx ], ctx .GetNamespaceName ())
@@ -306,29 +307,29 @@ func TestGetAllServicesWithPagination(t *testing.T) {
306307 }
307308 })
308309
309- // // Test pagination with limit 7, which is larger than the total number of services in all namespaces.
310+ // Test pagination with limit 7, which is larger than the total number of services in all namespaces.
310311 t .Run ("Test pagination return all result services" , func (t * testing.T ) {
311312 pageToken = ""
312313 gotServices := make ([][]bool , numberOfNamespaces )
313- for i := range numberOfNamespaces {
314- gotServices [i ] = make ([]bool , numberOfNamespaces )
314+ for i := 0 ; i < numberOfNamespaces ; i ++ {
315+ gotServices [i ] = make ([]bool , numberOfService )
315316 }
316317
317318 response , actualRPCStatus , err := tCtx .GetRayAPIServerClient ().ListAllRayServices (& api.ListAllRayServicesRequest {
318319 PageToken : pageToken ,
319- PageSize : totalServices + 1 ,
320+ PageSize : int32 ( totalServices + 1 ) ,
320321 })
321322
322323 require .NoError (t , err , "No error expected" )
323324 require .Nil (t , actualRPCStatus , "No RPC status expected" )
324325 require .NotNil (t , response , "A response is expected" )
325326 require .NotEmpty (t , response .Services , "A list of services is required" )
326327 require .Len (t , response .Services , totalServices )
327- require .Empty (t , pageToken , "Page token should be empty" )
328+ require .Empty (t , response . NextPageToken , "Page token should be empty" )
328329
329330 for _ , service := range response .Services {
330331 for namespaceIdx , ctx := range tCtxs {
331- for serviceIdx := range numberOfService {
332+ for serviceIdx := 0 ; serviceIdx < numberOfService ; serviceIdx ++ {
332333 if service .Namespace == ctx .GetNamespaceName () &&
333334 service .Name == expectedServiceNames [namespaceIdx ][serviceIdx ] {
334335 gotServices [namespaceIdx ][serviceIdx ] = true
@@ -339,7 +340,7 @@ func TestGetAllServicesWithPagination(t *testing.T) {
339340 }
340341
341342 for namespaceIdx , ctx := range tCtxs {
342- for serviceIdx := range numberOfService {
343+ for serviceIdx := 0 ; serviceIdx < numberOfService ; serviceIdx ++ {
343344 if ! gotServices [namespaceIdx ][serviceIdx ] {
344345 t .Errorf ("ListAllRayServices did not return expected service %s from namespace %s" ,
345346 expectedServiceNames [namespaceIdx ][serviceIdx ], ctx .GetNamespaceName ())
0 commit comments