@@ -134,12 +134,7 @@ func DefaultOptions(t *testing.T) confsuite.ConformanceOptions {
134
134
* confflags .ImplementationContact ,
135
135
)
136
136
137
- // Inference Extension Specific Report Fields
138
- inferenceExtensionVersion := "v0.3.0"
139
- _ = inferenceExtensionVersion // Avoid unused variable error until implemented
140
-
141
137
baseManifestsValue := "resources/base.yaml"
142
-
143
138
opts := confsuite.ConformanceOptions {
144
139
Client : c ,
145
140
ClientOptions : clientOptions ,
@@ -166,7 +161,6 @@ func DefaultOptions(t *testing.T) confsuite.ConformanceOptions {
166
161
// TODO: Add the inference extension specific fields to ConformanceOptions struct if needed,
167
162
// or handle them during report generation.
168
163
// GatewayAPIInferenceExtensionChannel: inferenceExtensionChannel,
169
- // GatewayAPIInferenceExtensionVersion: inferenceExtensionVersion,
170
164
}
171
165
172
166
// Populate SupportedFeatures based on the GatewayLayerProfile.
@@ -197,6 +191,8 @@ func RunConformance(t *testing.T) {
197
191
// RunConformanceWithOptions runs the Inference Extension conformance tests with specific options.
198
192
func RunConformanceWithOptions (t * testing.T , opts confsuite.ConformanceOptions ) {
199
193
t .Helper ()
194
+ ctx := context .Background ()
195
+
200
196
t .Logf ("Running Inference Extension conformance tests with GatewayClass %s" , opts .GatewayClassName )
201
197
logDebugf (t , opts .Debug , "RunConformanceWithOptions: BaseManifests path being used by opts: %q" , opts .BaseManifests )
202
198
@@ -209,27 +205,36 @@ func RunConformanceWithOptions(t *testing.T, opts confsuite.ConformanceOptions)
209
205
cSuite , err := confsuite .NewConformanceTestSuite (opts )
210
206
require .NoError (t , err , "error initializing conformance suite" )
211
207
212
- SetupConformanceTestSuite (t , cSuite , opts , tests .ConformanceTests )
213
-
208
+ installedCRDs := & apiextensionsv1.CustomResourceDefinitionList {}
209
+ err = opts .Client .List (ctx , installedCRDs )
210
+ require .NoError (t , err , "error getting installedCRDs" )
211
+ apiVersion , err := getGatewayInferenceExtentionVersion (installedCRDs .Items )
212
+ if err != nil {
213
+ if opts .AllowCRDsMismatch {
214
+ apiVersion = "UNDEFINED"
215
+ } else {
216
+ require .NoError (t , err , "error getting the gateway ineference extension version" )
217
+ }
218
+ }
219
+ SetupConformanceTestSuite (ctx , t , cSuite , opts , tests .ConformanceTests )
214
220
t .Log ("Running Inference Extension conformance tests against all registered tests" )
215
221
err = cSuite .Run (t , tests .ConformanceTests )
216
222
require .NoError (t , err , "error running conformance tests" )
217
223
218
- // Generate and write the report if requested.
219
224
if opts .ReportOutputPath != "" {
220
225
t .Log ("Generating Inference Extension conformance report" )
221
226
report , err := cSuite .Report () // Use the existing report generation logic.
222
227
require .NoError (t , err , "error generating conformance report" )
223
228
inferenceReport := GatewayAPIInferenceExtensionConformanceReport {
224
- GatewayAPIInferenceExtensionVersion : version . BundleVersion ,
229
+ GatewayAPIInferenceExtensionVersion : apiVersion ,
225
230
ConformanceReport : * report ,
226
231
}
227
232
err = inferenceReport .WriteReport (t .Logf , opts .ReportOutputPath )
228
233
require .NoError (t , err , "error writing conformance report" )
229
234
}
230
235
}
231
236
232
- func SetupConformanceTestSuite (t * testing.T , suite * confsuite.ConformanceTestSuite , opts confsuite.ConformanceOptions , tests []confsuite.ConformanceTest ) {
237
+ func SetupConformanceTestSuite (ctx context. Context , t * testing.T , suite * confsuite.ConformanceTestSuite , opts confsuite.ConformanceOptions , tests []confsuite.ConformanceTest ) {
233
238
suite .Applier .ManifestFS = suite .ManifestFS
234
239
if suite .RunTest != "" {
235
240
idx := slices .IndexFunc (tests , func (t confsuite.ConformanceTest ) bool {
@@ -257,13 +262,31 @@ func SetupConformanceTestSuite(t *testing.T, suite *confsuite.ConformanceTestSui
257
262
}
258
263
apikubernetes .NamespacesMustBeReady (t , suite .Client , suite .TimeoutConfig , namespaces )
259
264
260
- ensureGatewayAvailableAndReady (t , suite .Client , opts , resources .PrimaryGatewayNN )
261
- ensureGatewayAvailableAndReady (t , suite .Client , opts , resources .SecondaryGatewayNN )
265
+ ensureGatewayAvailableAndReady (ctx , t , suite .Client , opts , resources .PrimaryGatewayNN )
266
+ ensureGatewayAvailableAndReady (ctx , t , suite .Client , opts , resources .SecondaryGatewayNN )
267
+ }
268
+
269
+ func getGatewayInferenceExtentionVersion (crds []apiextensionsv1.CustomResourceDefinition ) (string , error ) {
270
+ var inferenceVersion string
271
+ for _ , crd := range crds {
272
+ v , okv := crd .Annotations [version .BundleVersionAnnotation ]
273
+ if ! okv {
274
+ continue
275
+ }
276
+ if inferenceVersion != "" && v != inferenceVersion {
277
+ return "" , errors .New ("multiple gateway api inference extension CRDs versions detected" )
278
+ }
279
+ inferenceVersion = v
280
+ }
281
+ if inferenceVersion == "" {
282
+ return "" , errors .New ("no gateway api inference extension CRDs with the proper annotations found in the cluster" )
283
+ }
284
+ return inferenceVersion , nil
262
285
}
263
286
264
287
// ensureGatewayAvailableAndReady polls for the specified Gateway to exist and become ready
265
288
// with an address and programmed condition.
266
- func ensureGatewayAvailableAndReady (t * testing.T , k8sClient client.Client , opts confsuite.ConformanceOptions , gatewayNN types.NamespacedName ) {
289
+ func ensureGatewayAvailableAndReady (ctx context. Context , t * testing.T , k8sClient client.Client , opts confsuite.ConformanceOptions , gatewayNN types.NamespacedName ) {
267
290
t .Helper ()
268
291
269
292
t .Logf ("Attempting to fetch Gateway %s/%s." , gatewayNN .Namespace , gatewayNN .Name )
@@ -277,7 +300,6 @@ func ensureGatewayAvailableAndReady(t *testing.T, k8sClient client.Client, opts
277
300
278
301
logDebugf (t , opts .Debug , "Waiting up to %v for Gateway object %s/%s to appear after manifest application..." , waitForGatewayCreationTimeout , gatewayNN .Namespace , gatewayNN .Name )
279
302
280
- ctx := context .TODO ()
281
303
pollErr := wait .PollUntilContextTimeout (ctx , extTimeoutConf .GatewayObjectPollInterval , waitForGatewayCreationTimeout , true , func (pollCtx context.Context ) (bool , error ) {
282
304
fetchErr := k8sClient .Get (pollCtx , gatewayNN , gw )
283
305
if fetchErr == nil {
0 commit comments