@@ -134,12 +134,7 @@ func DefaultOptions(t *testing.T) confsuite.ConformanceOptions {
134134 * confflags .ImplementationContact ,
135135 )
136136
137- // Inference Extension Specific Report Fields
138- inferenceExtensionVersion := "v0.3.0"
139- _ = inferenceExtensionVersion // Avoid unused variable error until implemented
140-
141137 baseManifestsValue := "resources/base.yaml"
142-
143138 opts := confsuite.ConformanceOptions {
144139 Client : c ,
145140 ClientOptions : clientOptions ,
@@ -166,7 +161,6 @@ func DefaultOptions(t *testing.T) confsuite.ConformanceOptions {
166161 // TODO: Add the inference extension specific fields to ConformanceOptions struct if needed,
167162 // or handle them during report generation.
168163 // GatewayAPIInferenceExtensionChannel: inferenceExtensionChannel,
169- // GatewayAPIInferenceExtensionVersion: inferenceExtensionVersion,
170164 }
171165
172166 // Populate SupportedFeatures based on the GatewayLayerProfile.
@@ -197,6 +191,8 @@ func RunConformance(t *testing.T) {
197191// RunConformanceWithOptions runs the Inference Extension conformance tests with specific options.
198192func RunConformanceWithOptions (t * testing.T , opts confsuite.ConformanceOptions ) {
199193 t .Helper ()
194+ ctx := context .Background ()
195+
200196 t .Logf ("Running Inference Extension conformance tests with GatewayClass %s" , opts .GatewayClassName )
201197 logDebugf (t , opts .Debug , "RunConformanceWithOptions: BaseManifests path being used by opts: %q" , opts .BaseManifests )
202198
@@ -209,27 +205,36 @@ func RunConformanceWithOptions(t *testing.T, opts confsuite.ConformanceOptions)
209205 cSuite , err := confsuite .NewConformanceTestSuite (opts )
210206 require .NoError (t , err , "error initializing conformance suite" )
211207
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 )
214220 t .Log ("Running Inference Extension conformance tests against all registered tests" )
215221 err = cSuite .Run (t , tests .ConformanceTests )
216222 require .NoError (t , err , "error running conformance tests" )
217223
218- // Generate and write the report if requested.
219224 if opts .ReportOutputPath != "" {
220225 t .Log ("Generating Inference Extension conformance report" )
221226 report , err := cSuite .Report () // Use the existing report generation logic.
222227 require .NoError (t , err , "error generating conformance report" )
223228 inferenceReport := GatewayAPIInferenceExtensionConformanceReport {
224- GatewayAPIInferenceExtensionVersion : version . BundleVersion ,
229+ GatewayAPIInferenceExtensionVersion : apiVersion ,
225230 ConformanceReport : * report ,
226231 }
227232 err = inferenceReport .WriteReport (t .Logf , opts .ReportOutputPath )
228233 require .NoError (t , err , "error writing conformance report" )
229234 }
230235}
231236
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 ) {
233238 suite .Applier .ManifestFS = suite .ManifestFS
234239 if suite .RunTest != "" {
235240 idx := slices .IndexFunc (tests , func (t confsuite.ConformanceTest ) bool {
@@ -257,13 +262,31 @@ func SetupConformanceTestSuite(t *testing.T, suite *confsuite.ConformanceTestSui
257262 }
258263 apikubernetes .NamespacesMustBeReady (t , suite .Client , suite .TimeoutConfig , namespaces )
259264
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
262285}
263286
264287// ensureGatewayAvailableAndReady polls for the specified Gateway to exist and become ready
265288// 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 ) {
267290 t .Helper ()
268291
269292 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
277300
278301 logDebugf (t , opts .Debug , "Waiting up to %v for Gateway object %s/%s to appear after manifest application..." , waitForGatewayCreationTimeout , gatewayNN .Namespace , gatewayNN .Name )
279302
280- ctx := context .TODO ()
281303 pollErr := wait .PollUntilContextTimeout (ctx , extTimeoutConf .GatewayObjectPollInterval , waitForGatewayCreationTimeout , true , func (pollCtx context.Context ) (bool , error ) {
282304 fetchErr := k8sClient .Get (pollCtx , gatewayNN , gw )
283305 if fetchErr == nil {
0 commit comments