Skip to content

Commit 205da96

Browse files
Merge pull request #30470 from neisw/extension_spec
TRT-2403: Extension spec k8s isolation
2 parents 9579913 + 9b677a4 commit 205da96

File tree

1 file changed

+34
-5
lines changed

1 file changed

+34
-5
lines changed

pkg/test/ginkgo/cmd_runsuite.go

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,13 @@ func (o *GinkgoRunSuiteOptions) Run(suite *TestSuite, clusterConfig *clusterdisc
243243
return fmt.Errorf("no tests to run")
244244
}
245245

246+
k8sTestNames := map[string]bool{}
247+
for _, t := range specs {
248+
if strings.Contains(t.ExtensionTestSpec.Source, "hyperkube") {
249+
k8sTestNames[t.Name] = true
250+
}
251+
}
252+
246253
tests, err := extensionTestSpecsToOriginTestCases(specs)
247254
if err != nil {
248255
return errors.WithMessage(err, "could not convert test specs to origin test cases")
@@ -421,22 +428,30 @@ func (o *GinkgoRunSuiteOptions) Run(suite *TestSuite, clusterConfig *clusterdisc
421428
return err
422429
}
423430

424-
storageTests, openshiftTests := splitTests(primaryTests, func(t *testCase) bool {
431+
kubeTests, openshiftTests := splitTests(primaryTests, func(t *testCase) bool {
432+
return k8sTestNames[t.name]
433+
})
434+
435+
storageTests, kubeTests := splitTests(kubeTests, func(t *testCase) bool {
425436
return strings.Contains(t.name, "[sig-storage]")
426437
})
427438

428-
cliTests, openshiftTests := splitTests(openshiftTests, func(t *testCase) bool {
439+
cliTests, kubeTests := splitTests(kubeTests, func(t *testCase) bool {
429440
return strings.Contains(t.name, "[sig-cli]")
430441
})
431442

432-
appsTests, openshiftTests := splitTests(openshiftTests, func(t *testCase) bool {
443+
appsTests, kubeTests := splitTests(kubeTests, func(t *testCase) bool {
433444
return strings.Contains(t.name, "[sig-apps]")
434445
})
435446

436-
nodeTests, openshiftTests := splitTests(openshiftTests, func(t *testCase) bool {
447+
nodeTests, kubeTests := splitTests(kubeTests, func(t *testCase) bool {
437448
return strings.Contains(t.name, "[sig-node]")
438449
})
439450

451+
networkK8sTests, kubeTests := splitTests(kubeTests, func(t *testCase) bool {
452+
return strings.Contains(t.name, "[sig-network]")
453+
})
454+
440455
networkTests, openshiftTests := splitTests(openshiftTests, func(t *testCase) bool {
441456
return strings.Contains(t.name, "[sig-network]")
442457
})
@@ -451,7 +466,9 @@ func (o *GinkgoRunSuiteOptions) Run(suite *TestSuite, clusterConfig *clusterdisc
451466
})
452467

453468
logrus.Infof("Found %d openshift tests", len(openshiftTests))
469+
logrus.Infof("Found %d kubernetes tests", len(kubeTests))
454470
logrus.Infof("Found %d storage tests", len(storageTests))
471+
logrus.Infof("Found %d network k8s tests", len(networkK8sTests))
455472
logrus.Infof("Found %d cli tests", len(cliTests))
456473
logrus.Infof("Found %d apps tests", len(appsTests))
457474
logrus.Infof("Found %d node tests", len(nodeTests))
@@ -462,8 +479,10 @@ func (o *GinkgoRunSuiteOptions) Run(suite *TestSuite, clusterConfig *clusterdisc
462479
// If user specifies a count, duplicate the kube and openshift tests that many times.
463480
expectedTestCount := len(early) + len(late)
464481
if count != -1 {
482+
originalKube := kubeTests
465483
originalOpenshift := openshiftTests
466484
originalStorage := storageTests
485+
originalNetworkK8s := networkK8sTests
467486
originalCLI := cliTests
468487
originalApps := appsTests
469488
originalNode := nodeTests
@@ -472,17 +491,19 @@ func (o *GinkgoRunSuiteOptions) Run(suite *TestSuite, clusterConfig *clusterdisc
472491
originalMustGather := mustGatherTests
473492

474493
for i := 1; i < count; i++ {
494+
kubeTests = append(kubeTests, copyTests(originalKube)...)
475495
openshiftTests = append(openshiftTests, copyTests(originalOpenshift)...)
476496
storageTests = append(storageTests, copyTests(originalStorage)...)
477497
cliTests = append(cliTests, copyTests(originalCLI)...)
478498
appsTests = append(appsTests, copyTests(originalApps)...)
479499
nodeTests = append(nodeTests, copyTests(originalNode)...)
500+
networkK8sTests = append(networkK8sTests, copyTests(originalNetworkK8s)...)
480501
networkTests = append(networkTests, copyTests(originalNetwork)...)
481502
buildsTests = append(buildsTests, copyTests(originalBuilds)...)
482503
mustGatherTests = append(mustGatherTests, copyTests(originalMustGather)...)
483504
}
484505
}
485-
expectedTestCount += len(openshiftTests) + len(storageTests) + len(cliTests) + len(appsTests) + len(nodeTests) + len(networkTests) + len(buildsTests) + len(mustGatherTests)
506+
expectedTestCount += len(openshiftTests) + len(kubeTests) + len(storageTests) + len(cliTests) + len(appsTests) + len(nodeTests) + len(networkK8sTests) + len(networkTests) + len(buildsTests) + len(mustGatherTests)
486507

487508
abortFn := neverAbort
488509
testCtx := ctx
@@ -504,11 +525,19 @@ func (o *GinkgoRunSuiteOptions) Run(suite *TestSuite, clusterConfig *clusterdisc
504525
// we loop indefinitely.
505526
for i := 0; (i < 1 || count == -1) && testCtx.Err() == nil; i++ {
506527

528+
kubeTestsCopy := copyTests(kubeTests)
529+
q.Execute(testCtx, kubeTestsCopy, parallelism, testOutputConfig, abortFn)
530+
tests = append(tests, kubeTestsCopy...)
531+
507532
// I thought about randomizing the order of the kube, storage, and openshift tests, but storage dominates our e2e runs, so it doesn't help much.
508533
storageTestsCopy := copyTests(storageTests)
509534
q.Execute(testCtx, storageTestsCopy, max(1, parallelism/2), testOutputConfig, abortFn) // storage tests only run at half the parallelism, so we can avoid cloud provider quota problems.
510535
tests = append(tests, storageTestsCopy...)
511536

537+
networkK8sTestsCopy := copyTests(networkK8sTests)
538+
q.Execute(testCtx, networkK8sTestsCopy, max(1, parallelism/2), testOutputConfig, abortFn) // run network tests separately.
539+
tests = append(tests, networkK8sTestsCopy...)
540+
512541
cliTestsCopy := copyTests(cliTests)
513542
q.Execute(testCtx, cliTestsCopy, max(1, parallelism/2), testOutputConfig, abortFn) // cli tests only run at half the parallelism, so we can avoid high cpu problems.
514543
tests = append(tests, cliTestsCopy...)

0 commit comments

Comments
 (0)