@@ -23,7 +23,6 @@ import (
23
23
"fmt"
24
24
"reflect"
25
25
"testing"
26
- "time"
27
26
28
27
"github.com/stretchr/testify/require"
29
28
apierrors "k8s.io/apimachinery/pkg/api/errors"
@@ -36,7 +35,7 @@ import (
36
35
inferenceapi "sigs.k8s.io/gateway-api-inference-extension/api/v1alpha2" // Adjust if your API version is different
37
36
38
37
// 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"
40
39
)
41
40
42
41
// checkCondition is a helper function similar to findConditionInList or CheckCondition
@@ -67,45 +66,48 @@ func checkCondition(t *testing.T, conditions []metav1.Condition, expectedConditi
67
66
// InferencePoolMustHaveCondition waits for the specified InferencePool resource
68
67
// to exist and report the expected status condition within one of its parent statuses.
69
68
// 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 ) {
71
70
t .Helper () // Marks this function as a test helper
72
71
72
+ var timeoutConfig config.InferenceExtensionTimeoutConfig = config .DefaultInferenceExtensionTimeoutConfig ()
73
73
var lastObservedPool * inferenceapi.InferencePool
74
74
var lastError error
75
75
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 )
85
91
lastError = err
86
92
return false , nil
87
93
}
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
95
97
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
+ }
100
102
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
+ }
105
108
}
106
- }
107
- return false , nil
108
- })
109
+ return false , nil
110
+ })
109
111
110
112
if waitErr != nil || ! conditionFound {
111
113
debugMsg := ""
0 commit comments