@@ -35,6 +35,7 @@ import (
35
35
clientset "k8s.io/client-go/kubernetes"
36
36
"k8s.io/client-go/rest"
37
37
"sigs.k8s.io/controller-runtime/pkg/client"
38
+ clicfg "sigs.k8s.io/controller-runtime/pkg/client/config"
38
39
39
40
"sigs.k8s.io/gateway-api/apis/v1beta1"
40
41
confv1 "sigs.k8s.io/gateway-api/conformance/apis/v1"
@@ -307,6 +308,10 @@ func NewConformanceTestSuite(options ConformanceOptions) (*ConformanceTestSuite,
307
308
// Conformance Test Suite - Public Methods
308
309
// -----------------------------------------------------------------------------
309
310
311
+ const (
312
+ testSuiteUserAgentPrefix = "gateway-api-conformance.test"
313
+ )
314
+
310
315
// Setup ensures the base resources required for conformance tests are installed
311
316
// in the cluster. It also ensures that all relevant resources are ready.
312
317
func (suite * ConformanceTestSuite ) Setup (t * testing.T , tests []ConformanceTest ) {
@@ -374,6 +379,35 @@ func (suite *ConformanceTestSuite) Setup(t *testing.T, tests []ConformanceTest)
374
379
}
375
380
}
376
381
382
+ func (suite * ConformanceTestSuite ) setClientsetForTest (test ConformanceTest ) error {
383
+ featureNames := []string {}
384
+ for _ , v := range test .Features {
385
+ featureNames = append (featureNames , string (v ))
386
+ }
387
+ if len (test .Features ) == 0 {
388
+ featureNames = []string {"unknownFeature" }
389
+ }
390
+ suite .RestConfig .UserAgent = strings .Join (
391
+ []string {
392
+ testSuiteUserAgentPrefix ,
393
+ suite .apiVersion ,
394
+ test .ShortName ,
395
+ strings .Join (featureNames , "," ),
396
+ },
397
+ "::" )
398
+ client , err := client .New (suite .RestConfig , client.Options {})
399
+ if err != nil {
400
+ return err
401
+ }
402
+ clientset , err := clientset .NewForConfig (suite .RestConfig )
403
+ if err != nil {
404
+ return err
405
+ }
406
+ suite .Client = client
407
+ suite .Clientset = clientset
408
+ return nil
409
+ }
410
+
377
411
// Run runs the provided set of conformance tests.
378
412
func (suite * ConformanceTestSuite ) Run (t * testing.T , tests []ConformanceTest ) error {
379
413
// verify that the test suite isn't already running, don't start a new run
@@ -410,6 +444,8 @@ func (suite *ConformanceTestSuite) Run(t *testing.T, tests []ConformanceTest) er
410
444
}
411
445
412
446
succeeded := t .Run (test .ShortName , func (t * testing.T ) {
447
+ err := suite .setClientsetForTest (test )
448
+ require .NoError (t , err , "failed to create new clientset for test" )
413
449
test .Run (t , suite )
414
450
})
415
451
if ! succeeded {
0 commit comments