@@ -23,7 +23,6 @@ import (
2323 "fmt"
2424 "reflect"
2525 "testing"
26- "time"
2726
2827 "github.com/stretchr/testify/require"
2928 apierrors "k8s.io/apimachinery/pkg/api/errors"
@@ -36,7 +35,7 @@ import (
3635 inferenceapi "sigs.k8s.io/gateway-api-inference-extension/api/v1alpha2" // Adjust if your API version is different
3736
3837 // Import necessary utilities from the core Gateway API conformance suite
39- "sigs.k8s.io/gateway-api/conformance/utils/config"
38+ "sigs.k8s.io/gateway-api-inference-extension /conformance/utils/config"
4039)
4140
4241// checkCondition is a helper function similar to findConditionInList or CheckCondition
@@ -67,45 +66,48 @@ func checkCondition(t *testing.T, conditions []metav1.Condition, expectedConditi
6766// InferencePoolMustHaveCondition waits for the specified InferencePool resource
6867// to exist and report the expected status condition within one of its parent statuses.
6968// It polls the InferencePool's status until the condition is met or the timeout occurs.
70- func InferencePoolMustHaveCondition (t * testing.T , c client.Client , timeoutConfig config. TimeoutConfig , poolNN types.NamespacedName , expectedCondition metav1.Condition ) {
69+ func InferencePoolMustHaveCondition (t * testing.T , c client.Client , poolNN types.NamespacedName , expectedCondition metav1.Condition ) {
7170 t .Helper () // Marks this function as a test helper
7271
72+ var timeoutConfig config.InferenceExtensionTimeoutConfig = config .DefaultInferenceExtensionTimeoutConfig ()
7373 var lastObservedPool * inferenceapi.InferencePool
7474 var lastError error
7575 var conditionFound bool
76- var interval time.Duration = 5 * time .Second // pull interval for status checks.
77-
78- // TODO: Make retry interval configurable.
79- waitErr := wait .PollUntilContextTimeout (context .Background (), interval , timeoutConfig .DefaultTestTimeout , true , func (ctx context.Context ) (bool , error ) {
80- pool := & inferenceapi.InferencePool {} // This is the type instance used for Get
81- err := c .Get (ctx , poolNN , pool )
82- if err != nil {
83- if apierrors .IsNotFound (err ) {
84- t .Logf ("InferencePool %s not found yet. Retrying." , poolNN .String ())
76+
77+ waitErr := wait .PollUntilContextTimeout (
78+ context .Background (),
79+ timeoutConfig .InferencePoolMustHaveConditionInterval ,
80+ timeoutConfig .InferencePoolMustHaveConditionTimeout ,
81+ true , func (ctx context.Context ) (bool , error ) {
82+ pool := & inferenceapi.InferencePool {} // This is the type instance used for Get
83+ err := c .Get (ctx , poolNN , pool )
84+ if err != nil {
85+ if apierrors .IsNotFound (err ) {
86+ t .Logf ("InferencePool %s not found yet. Retrying." , poolNN .String ())
87+ lastError = err
88+ return false , nil
89+ }
90+ t .Logf ("Error fetching InferencePool %s (type: %s): %v. Retrying." , poolNN .String (), reflect .TypeOf (pool ).String (), err )
8591 lastError = err
8692 return false , nil
8793 }
88- t .Logf ("Error fetching InferencePool %s (type: %s): %v. Retrying." , poolNN .String (), reflect .TypeOf (pool ).String (), err )
89- lastError = err
90- return false , nil
91- }
92- lastObservedPool = pool
93- lastError = nil
94- conditionFound = false
94+ lastObservedPool = pool
95+ lastError = nil
96+ conditionFound = false
9597
96- if len (pool .Status .Parents ) == 0 {
97- t .Logf ("InferencePool %s has no parent statuses reported yet." , poolNN .String ())
98- return false , nil
99- }
98+ if len (pool .Status .Parents ) == 0 {
99+ t .Logf ("InferencePool %s has no parent statuses reported yet." , poolNN .String ())
100+ return false , nil
101+ }
100102
101- for _ , parentStatus := range pool .Status .Parents {
102- if checkCondition (t , parentStatus .Conditions , expectedCondition ) {
103- conditionFound = true
104- return true , nil
103+ for _ , parentStatus := range pool .Status .Parents {
104+ if checkCondition (t , parentStatus .Conditions , expectedCondition ) {
105+ conditionFound = true
106+ return true , nil
107+ }
105108 }
106- }
107- return false , nil
108- })
109+ return false , nil
110+ })
109111
110112 if waitErr != nil || ! conditionFound {
111113 debugMsg := ""
0 commit comments