Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 29 additions & 23 deletions cmd/machine-api-tests-ext/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,37 +45,43 @@ func main() {
Qualifiers: []string{`labels.exists(l, l == "Serial") && labels.exists(l, l == "Conformance")`},
})

// Build our specs from ginkgo
specs, err := g.BuildExtensionTestSpecsFromOpenShiftGinkgoSuite()
if err != nil {
panic(err)
}

// Initialization for kube ginkgo test framework needs to run before all tests execute
specs.AddBeforeAll(func() {
if err := initializeTestFramework(os.Getenv("TEST_PROVIDER")); err != nil {
// Build our specs from ginkgo only when not running a single test
// When running in parallel, child processes are spawned with "run-test" command
// and should not rebuild the Ginkgo suite tree to avoid "cannot clone suite after tree has been built" error
isRunningTest := len(os.Args) > 1 && os.Args[1] == "run-test"
if !isRunningTest {
// Build our specs from ginkgo
specs, err := g.BuildExtensionTestSpecsFromOpenShiftGinkgoSuite()
if err != nil {
panic(err)
}
})

// Let's scan for tests with a platform label and create the rule for them such as [platform:vsphere]
foundPlatforms := make(map[string]string)
for _, test := range specs.Select(extensiontests.NameContains("[platform:")).Names() {
re := regexp.MustCompile(`\[platform:[a-z]*]`)
match := re.FindStringSubmatch(test)
for _, platformDef := range match {
if _, ok := foundPlatforms[platformDef]; !ok {
platform := platformDef[strings.Index(platformDef, ":")+1 : len(platformDef)-1]
foundPlatforms[platformDef] = platform
specs.Select(extensiontests.NameContains(platformDef)).
Include(extensiontests.PlatformEquals(platform))
// Initialization for kube ginkgo test framework needs to run before all tests execute
specs.AddBeforeAll(func() {
if err := initializeTestFramework(os.Getenv("TEST_PROVIDER")); err != nil {
panic(err)
}
})

// Let's scan for tests with a platform label and create the rule for them such as [platform:vsphere]
foundPlatforms := make(map[string]string)
for _, test := range specs.Select(extensiontests.NameContains("[platform:")).Names() {
re := regexp.MustCompile(`\[platform:[a-z]*]`)
match := re.FindStringSubmatch(test)
for _, platformDef := range match {
if _, ok := foundPlatforms[platformDef]; !ok {
platform := platformDef[strings.Index(platformDef, ":")+1 : len(platformDef)-1]
foundPlatforms[platformDef] = platform
specs.Select(extensiontests.NameContains(platformDef)).
Include(extensiontests.PlatformEquals(platform))
}
}

}

kubeTestsExtension.AddSpecs(specs)
}

kubeTestsExtension.AddSpecs(specs)

// Cobra stuff
root := &cobra.Command{
Long: "Machine API Operator tests extension for OpenShift",
Expand Down