@@ -18,6 +18,7 @@ package llmisvc_test
1818
1919import (
2020 "context"
21+ "fmt"
2122 "time"
2223
2324 "k8s.io/apimachinery/pkg/api/errors"
@@ -231,10 +232,13 @@ var _ = Describe("LLMInferenceService Controller", func() {
231232 return envTest .Client .Get (ctx , client.ObjectKey {Name : svcName + "-inference-pool" , Namespace : llmSvc .GetNamespace ()}, & ip )
232233 }).WithContext (ctx ).Should (Succeed ())
233234
234- Eventually (LLMInferenceServiceIsReady (llmSvc )).WithContext (ctx ).Should (Succeed ())
235+ Eventually (LLMInferenceServiceIsReady (llmSvc , func (g Gomega , current * v1alpha1.LLMInferenceService ) {
236+ g .Expect (current .Status ).To (HaveCondition (string (v1alpha1 .HTTPRoutesReady ), "True" ))
237+ g .Expect (current .Status ).To (HaveCondition (string (v1alpha1 .InferencePoolReady ), "True" ))
238+ })).WithContext (ctx ).Should (Succeed ())
235239 })
236240
237- It ("should reference external InferencePool" , func (ctx SpecContext ) {
241+ It ("should use referenced external InferencePool" , func (ctx SpecContext ) {
238242 // given
239243 svcName := "test-llm-create-http-route-inf-pool-ref"
240244 nsName := kmeta .ChildName (svcName , "-test" )
@@ -310,105 +314,12 @@ var _ = Describe("LLMInferenceService Controller", func() {
310314 Expect (expectedHTTPRoute ).To (HaveBackendRefs (BackendRefInferencePool (infPoolName )))
311315 Expect (expectedHTTPRoute ).To (Not (HaveBackendRefs (BackendRefService (svcName + "-kserve-workload-svc" ))))
312316
313- ensureRouterManagedResourcesAreReady (ctx , envTest .Client , llmSvc )
314-
315- Eventually (LLMInferenceServiceIsReady (llmSvc )).WithContext (ctx ).Should (Succeed ())
316- })
317-
318- It ("should evaluate InferencePool readiness conditions" , func (ctx SpecContext ) {
319- // given
320- svcName := "test-llm-infpool-conditions"
321- nsName := kmeta .ChildName (svcName , "-test" )
322- namespace := & corev1.Namespace {
323- ObjectMeta : metav1.ObjectMeta {
324- Name : nsName ,
325- },
326- }
327- Expect (envTest .Client .Create (ctx , namespace )).To (Succeed ())
328- Expect (envTest .Client .Create (ctx , IstioShadowService (svcName , nsName ))).To (Succeed ())
329- defer func () {
330- envTest .DeleteAll (namespace )
331- }()
332-
333- modelURL , err := apis .ParseURL ("hf://facebook/opt-125m" )
334- Expect (err ).ToNot (HaveOccurred ())
335-
336- // Create the Gateway
337- ingressGateway := DefaultGateway (nsName )
338- Expect (envTest .Client .Create (ctx , ingressGateway )).To (Succeed ())
339- ensureGatewayReady (ctx , envTest .Client , ingressGateway )
340- defer func () {
341- Expect (envTest .Delete (ctx , ingressGateway )).To (Succeed ())
342- }()
343-
344- // Create the inference pool
345- infPoolName := kmeta .ChildName (svcName , "-my-inf-pool" )
346- infPool := InferencePool (infPoolName ,
347- InNamespace [* igwapi.InferencePool ](nsName ),
348- WithSelector ("app" , "workload" ),
349- WithTargetPort (8000 ),
350- WithExtensionRef ("" , "Service" , kmeta .ChildName (svcName , "-epp-service" )),
351- )
352- Expect (envTest .Create (ctx , infPool )).To (Succeed ())
353- defer func () {
354- Expect (envTest .Delete (ctx , infPool )).To (Succeed ())
355- }()
356-
357- // Create the llmd inference service
358- llmSvc := & v1alpha1.LLMInferenceService {
359- ObjectMeta : metav1.ObjectMeta {
360- Name : svcName ,
361- Namespace : nsName ,
362- },
363- Spec : v1alpha1.LLMInferenceServiceSpec {
364- Model : v1alpha1.LLMModelSpec {
365- URI : * modelURL ,
366- },
367- WorkloadSpec : v1alpha1.WorkloadSpec {},
368- Router : & v1alpha1.RouterSpec {
369- Scheduler : & v1alpha1.SchedulerSpec {
370- Pool : & v1alpha1.InferencePoolSpec {
371- Ref : & corev1.LocalObjectReference {
372- Name : infPoolName ,
373- },
374- },
375- },
376- },
377- },
378- }
379-
380- // when
381- Expect (envTest .Create (ctx , llmSvc )).To (Succeed ())
382- defer func () {
383- Expect (envTest .Delete (ctx , llmSvc )).To (Succeed ())
384- }()
385-
386- // then - verify InferencePoolsReady condition is False because the pool is not ready
387- Eventually (func (g Gomega , ctx context.Context ) {
388- current := & v1alpha1.LLMInferenceService {}
389- g .Expect (envTest .Get (ctx , client .ObjectKeyFromObject (llmSvc ), current )).To (Succeed ())
390- g .Expect (current .Status ).To (HaveCondition (string (v1alpha1 .InferencePoolsReady ), "False" ))
391- g .Expect (current .Status ).To (HaveCondition (string (v1alpha1 .RouterReady ), "False" ))
392- }).WithContext (ctx ).Should (Succeed ())
393-
394- // when - we make the inference pool ready
395317 ensureInferencePoolReady (ctx , envTest .Client , infPool )
396-
397- // then - verify InferencePoolsReady condition becomes True
398- Eventually (func (g Gomega , ctx context.Context ) error {
399- current := & v1alpha1.LLMInferenceService {}
400- g .Expect (envTest .Get (ctx , client .ObjectKeyFromObject (llmSvc ), current )).To (Succeed ())
401-
402- // Check that InferencePoolsReady condition exists and is True
403- poolsCondition := current .Status .GetCondition (v1alpha1 .InferencePoolsReady )
404- g .Expect (poolsCondition ).ToNot (BeNil (), "InferencePoolsReady condition should be set" )
405- g .Expect (poolsCondition .IsTrue ()).To (BeTrue (), "InferencePoolsReady condition should be True" )
406-
407- return nil
408- }).WithContext (ctx ).Should (Succeed (), "InferencePoolsReady condition should be set to True" )
318+ ensureRouterManagedResourcesAreReady (ctx , envTest .Client , llmSvc )
409319
410320 Eventually (LLMInferenceServiceIsReady (llmSvc , func (g Gomega , current * v1alpha1.LLMInferenceService ) {
411- g .Expect (current .Status ).To (HaveCondition (string (v1alpha1 .InferencePoolsReady ), "True" ))
321+ g .Expect (current .Status ).To (HaveCondition (string (v1alpha1 .HTTPRoutesReady ), "True" ))
322+ g .Expect (current .Status ).To (HaveCondition (string (v1alpha1 .InferencePoolReady ), "True" ))
412323 })).WithContext (ctx ).Should (Succeed ())
413324 })
414325
@@ -974,49 +885,18 @@ func ensureInferencePoolReady(ctx context.Context, c client.Client, pool *igwapi
974885 return
975886 }
976887
977- // Get the current InferencePool
978888 createdPool := & igwapi.InferencePool {}
979889 Expect (c .Get (ctx , client .ObjectKeyFromObject (pool ), createdPool )).To (Succeed ())
980-
981- // Set the status conditions to simulate the controller making the InferencePool ready
982- createdPool .Status .Parents = []igwapi.PoolStatus {
983- {
984- GatewayRef : corev1.ObjectReference {
985- Name : "kserve-ingress-gateway" , // Example gateway
986- },
987- Conditions : []metav1.Condition {
988- {
989- Type : "Accepted" ,
990- Status : metav1 .ConditionTrue ,
991- Reason : "Accepted" ,
992- Message : "InferencePool accepted" ,
993- LastTransitionTime : metav1 .Now (),
994- },
995- },
996- },
997- }
998-
999- // Update the status
890+ WithInferencePoolReadyStatus ()(createdPool )
1000891 Expect (c .Status ().Update (ctx , createdPool )).To (Succeed ())
1001892
1002893 // Verify the InferencePool is now ready
894+ updatedPool := & igwapi.InferencePool {}
1003895 Eventually (func (g Gomega , ctx context.Context ) bool {
1004- updatedPool : = & igwapi.InferencePool {}
896+ updatedPool = & igwapi.InferencePool {}
1005897 g .Expect (c .Get (ctx , client .ObjectKeyFromObject (pool ), updatedPool )).To (Succeed ())
1006- isReady := false
1007- for _ , parent := range updatedPool .Status .Parents {
1008- for _ , cond := range parent .Conditions {
1009- if cond .Type == "Accepted" && cond .Status == metav1 .ConditionTrue {
1010- isReady = true
1011- break
1012- }
1013- }
1014- if isReady {
1015- break
1016- }
1017- }
1018- return isReady
1019- }).WithContext (ctx ).Should (BeTrue ())
898+ return llmisvc .IsInferencePoolReady (updatedPool )
899+ }).WithContext (ctx ).Should (BeTrue (), fmt .Sprintf ("Expected InferencePool to be ready, got: %#v" , updatedPool .Status ))
1020900}
1021901
1022902// Only runs in non-cluster mode
@@ -1063,6 +943,23 @@ func ensureRouterManagedResourcesAreReady(ctx context.Context, c client.Client,
1063943 // Ensure at least one HTTPRoute was found and made ready
1064944 g .Expect (httpRoutes .Items ).To (gomega .HaveLen (1 ), "Expected exactly one managed HTTPRoute" )
1065945
946+ infPoolsListOpts := & client.ListOptions {
947+ Namespace : llmSvc .Namespace ,
948+ LabelSelector : labels .SelectorFromSet (llmisvc .SchedulerLabels (llmSvc )),
949+ }
950+
951+ infPools := & igwapi.InferencePoolList {}
952+ err = c .List (ctx , infPools , infPoolsListOpts )
953+ if err != nil && ! errors .IsNotFound (err ) {
954+ g .Expect (err ).NotTo (gomega .HaveOccurred ())
955+ }
956+ logf .FromContext (ctx ).Info ("Marking InferencePool resources ready" , "inferencepools" , infPools )
957+ for _ , pool := range infPools .Items {
958+ updatedPool := pool .DeepCopy ()
959+ WithInferencePoolReadyStatus ()(updatedPool )
960+ g .Expect (c .Status ().Update (ctx , updatedPool )).To (gomega .Succeed ())
961+ }
962+
1066963 ensureSchedulerDeploymentReady (ctx , c , llmSvc )
1067964 }).WithContext (ctx ).Should (gomega .Succeed ())
1068965}
0 commit comments