@@ -24,6 +24,7 @@ import (
24
24
"fmt"
25
25
"io/fs"
26
26
"os"
27
+ "slices"
27
28
"testing"
28
29
29
30
"github.com/stretchr/testify/require"
@@ -48,6 +49,7 @@ import (
48
49
confflags "sigs.k8s.io/gateway-api/conformance/utils/flags"
49
50
apikubernetes "sigs.k8s.io/gateway-api/conformance/utils/kubernetes"
50
51
confsuite "sigs.k8s.io/gateway-api/conformance/utils/suite"
52
+ "sigs.k8s.io/gateway-api/conformance/utils/tlog"
51
53
"sigs.k8s.io/gateway-api/pkg/features"
52
54
53
55
// Import the test definitions package to access the ConformanceTests slice
@@ -65,10 +67,16 @@ import (
65
67
inferenceconfig "sigs.k8s.io/gateway-api-inference-extension/conformance/utils/config"
66
68
)
67
69
68
- // Constants for the shared Gateway
69
70
const (
70
- SharedGatewayName = "conformance-primary-gateway" // Name of the Gateway in manifests.yaml
71
- SharedGatewayNamespace = "gateway-conformance-infra" // Namespace of the Gateway
71
+ infraNameSpace = "gateway-conformance-infra"
72
+ appBackendNameSpace = "gateway-conformance-app-backend"
73
+ primaryGatewayName = "conformance-primary-gateway"
74
+ secondaryGatewayName = "conformance-secondary-gateway"
75
+ )
76
+
77
+ var (
78
+ primaryGatewayNN = types.NamespacedName {Name : primaryGatewayName , Namespace : infraNameSpace }
79
+ secondaryGatewayNN = types.NamespacedName {Name : secondaryGatewayName , Namespace : infraNameSpace }
72
80
)
73
81
74
82
// GatewayLayerProfileName defines the name for the conformance profile that tests
@@ -225,12 +233,8 @@ func RunConformanceWithOptions(t *testing.T, opts confsuite.ConformanceOptions)
225
233
cSuite , err := confsuite .NewConformanceTestSuite (opts )
226
234
require .NoError (t , err , "error initializing conformance suite" )
227
235
228
- cSuite . Setup ( t , tests .ConformanceTests )
236
+ SetupConformanceTestSuite ( t , cSuite , opts , tests .ConformanceTests )
229
237
230
- sharedGwNN := types.NamespacedName {Name : SharedGatewayName , Namespace : SharedGatewayNamespace }
231
-
232
- // Validate Gateway setup.
233
- ensureGatewayAvailableAndReady (t , cSuite .Client , opts , sharedGwNN )
234
238
t .Log ("Running Inference Extension conformance tests against all registered tests" )
235
239
err = cSuite .Run (t , tests .ConformanceTests )
236
240
require .NoError (t , err , "error running conformance tests" )
@@ -251,6 +255,38 @@ func RunConformanceWithOptions(t *testing.T, opts confsuite.ConformanceOptions)
251
255
}
252
256
}
253
257
258
+ func SetupConformanceTestSuite (t * testing.T , suite * confsuite.ConformanceTestSuite , opts confsuite.ConformanceOptions , tests []confsuite.ConformanceTest ) {
259
+ suite .Applier .ManifestFS = suite .ManifestFS
260
+ if suite .RunTest != "" {
261
+ idx := slices .IndexFunc (tests , func (t confsuite.ConformanceTest ) bool {
262
+ return t .ShortName == suite .RunTest
263
+ })
264
+
265
+ if idx == - 1 {
266
+ require .FailNow (t , fmt .Sprintf ("Test %q does not exist" , suite .RunTest ))
267
+ }
268
+ }
269
+
270
+ tlog .Logf (t , "Test Setup: Ensuring GatewayClass has been accepted" )
271
+ suite .ControllerName = apikubernetes .GWCMustHaveAcceptedConditionTrue (t , suite .Client , suite .TimeoutConfig , suite .GatewayClassName )
272
+
273
+ suite .Applier .GatewayClass = suite .GatewayClassName
274
+ suite .Applier .ControllerName = suite .ControllerName
275
+
276
+ tlog .Logf (t , "Test Setup: Applying base manifests" )
277
+ suite .Applier .MustApplyWithCleanup (t , suite .Client , suite .TimeoutConfig , suite .BaseManifests , suite .Cleanup )
278
+
279
+ tlog .Logf (t , "Test Setup: Ensuring Gateways and Pods from base manifests are ready" )
280
+ namespaces := []string {
281
+ infraNameSpace ,
282
+ appBackendNameSpace ,
283
+ }
284
+ apikubernetes .NamespacesMustBeReady (t , suite .Client , suite .TimeoutConfig , namespaces )
285
+
286
+ ensureGatewayAvailableAndReady (t , suite .Client , opts , primaryGatewayNN )
287
+ ensureGatewayAvailableAndReady (t , suite .Client , opts , secondaryGatewayNN )
288
+ }
289
+
254
290
// ensureGatewayAvailableAndReady polls for the specified Gateway to exist and become ready
255
291
// with an address and programmed condition.
256
292
func ensureGatewayAvailableAndReady (t * testing.T , k8sClient client.Client , opts confsuite.ConformanceOptions , gatewayNN types.NamespacedName ) {
0 commit comments