@@ -233,7 +233,7 @@ func TestGetAllServicesWithPagination(t *testing.T) {
233233 tCtxs := make ([]* End2EndTestingContext , numberOfNamespaces )
234234 expectedServiceNames := make ([][]string , numberOfNamespaces )
235235
236- // Create Services for each namespace
236+ // Create services for each namespace
237237 for i := range numberOfNamespaces {
238238 tCtx , err := NewEnd2EndTestingContext (t )
239239 require .NoError (t , err , "No error expected when creating testing context" )
@@ -257,7 +257,7 @@ func TestGetAllServicesWithPagination(t *testing.T) {
257257
258258 var pageToken string
259259 tCtx := tCtxs [0 ]
260- // Test pagination with limit 1, which is less than the total number of services.
260+ // Test pagination with limit 1, which is less than the total number of services in all namespaces .
261261 t .Run ("Test pagination return part of the result services" , func (t * testing.T ) {
262262 pageToken = ""
263263 gotServices := make ([][]bool , numberOfNamespaces )
@@ -306,19 +306,47 @@ func TestGetAllServicesWithPagination(t *testing.T) {
306306 }
307307 })
308308
309- // // Test pagination with limit 3, which is larger than the total number of services.
310- // t.Run("Test pagination return all result services", func(t *testing.T) {
311- // pageToken = ""
312- // gotServices := make([]bool, numberOfNamespaces)
309+ // // Test pagination with limit 7, which is larger than the total number of services in all namespaces.
310+ t .Run ("Test pagination return all result services" , func (t * testing.T ) {
311+ pageToken = ""
312+ gotServices := make ([][]bool , numberOfNamespaces )
313+ for i := range numberOfNamespaces {
314+ gotServices [i ] = make ([]bool , numberOfNamespaces )
315+ }
316+
317+ response , actualRPCStatus , err := tCtx .GetRayAPIServerClient ().ListAllRayServices (& api.ListAllRayServicesRequest {
318+ PageToken : pageToken ,
319+ PageSize : totalServices + 1 ,
320+ })
321+
322+ require .NoError (t , err , "No error expected" )
323+ require .Nil (t , actualRPCStatus , "No RPC status expected" )
324+ require .NotNil (t , response , "A response is expected" )
325+ require .NotEmpty (t , response .Services , "A list of services is required" )
326+ require .Len (t , response .Services , totalServices )
327+ require .Empty (t , pageToken , "Page token should be empty" )
313328
314- // for i := range numberOfNamespaces {
315- // response, actualRPCStatus, err := tCtx.GetRayAPIServerClient().ListAllRayServices(&api.ListAllRayServicesRequest{
316- // PageToken: pageToken,
317- // PageSize: servic,
318- // })
319- // }
329+ for _ , service := range response .Services {
330+ for namespaceIdx , ctx := range tCtxs {
331+ for serviceIdx := range numberOfService {
332+ if service .Namespace == ctx .GetNamespaceName () &&
333+ service .Name == expectedServiceNames [namespaceIdx ][serviceIdx ] {
334+ gotServices [namespaceIdx ][serviceIdx ] = true
335+ break
336+ }
337+ }
338+ }
339+ }
320340
321- // })
341+ for namespaceIdx , ctx := range tCtxs {
342+ for serviceIdx := range numberOfService {
343+ if ! gotServices [namespaceIdx ][serviceIdx ] {
344+ t .Errorf ("ListAllRayServices did not return expected service %s from namespace %s" ,
345+ expectedServiceNames [namespaceIdx ][serviceIdx ], ctx .GetNamespaceName ())
346+ }
347+ }
348+ }
349+ })
322350}
323351
324352func TestGetServicesInNamespace (t * testing.T ) {
0 commit comments