Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
.idea/
coverage.out
/cloud-credential-tests-ext

/cloud-credential-operator-tests-ext
27 changes: 27 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -208,3 +208,30 @@ update-go-modules-k8s:
done
go mod tidy
go mod vendor

# OTE binary configuration
TESTS_EXT_DIR := ./cmd/extension
TESTS_EXT_BINARY := cloud-credential-operator-tests-ext

# Build OTE extension binary (following machine-config-operator PR #4665 pattern)
.PHONY: tests-ext-build
tests-ext-build:
@echo "Building OTE test extension binary..."
@cd test && $(MAKE) bindata
go build -mod=vendor -o $(TESTS_EXT_DIR)/$(TESTS_EXT_BINARY) $(TESTS_EXT_DIR)
@echo "OTE binary built successfully at $(TESTS_EXT_DIR)/$(TESTS_EXT_BINARY)"

# Alias for backward compatibility
.PHONY: extension
extension: tests-ext-build

# List all tests
.PHONY: list-tests
list-tests: tests-ext-build
$(TESTS_EXT_DIR)/$(TESTS_EXT_BINARY) list

# Clean extension binary
.PHONY: clean-extension
clean-extension:
rm -f $(TESTS_EXT_DIR)/$(TESTS_EXT_BINARY)
@cd test && $(MAKE) clean-bindata
93 changes: 93 additions & 0 deletions cmd/extension/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
package main

import (
"fmt"
"os"
"regexp"
"strings"

"github.com/spf13/cobra"

"github.com/openshift-eng/openshift-tests-extension/pkg/cmd"
e "github.com/openshift-eng/openshift-tests-extension/pkg/extension"
et "github.com/openshift-eng/openshift-tests-extension/pkg/extension/extensiontests"
g "github.com/openshift-eng/openshift-tests-extension/pkg/ginkgo"

// Import testdata package from local test module
testdata "github.com/openshift/cloud-credential-operator/test/testdata"

// Import test packages from local test module
_ "github.com/openshift/cloud-credential-operator/test/e2e"
)

func main() {
registry := e.NewRegistry()
ext := e.NewExtension("openshift", "payload", "cloud-credential-operator")

// Add main test suite
ext.AddSuite(e.Suite{
Name: "openshift/cloud-credential-operator/tests",
Parents: []string{"openshift/conformance/parallel"},
})

// Build test specs from Ginkgo
specs, err := g.BuildExtensionTestSpecsFromOpenShiftGinkgoSuite()
if err != nil {
panic(fmt.Sprintf("couldn't build extension test specs from ginkgo: %+v", err.Error()))
}

// Apply platform filters based on Platform: labels
specs.Walk(func(spec *et.ExtensionTestSpec) {
for label := range spec.Labels {
if strings.HasPrefix(label, "Platform:") {
platformName := strings.TrimPrefix(label, "Platform:")
spec.Include(et.PlatformEquals(platformName))
}
}
})

// Apply platform filters based on [platform:xxx] in test names
specs.Walk(func(spec *et.ExtensionTestSpec) {
re := regexp.MustCompile(`\[platform:([a-z]+)\]`)
if match := re.FindStringSubmatch(spec.Name); match != nil {
platform := match[1]
spec.Include(et.PlatformEquals(platform))
}
})

// Add testdata validation and cleanup hooks
specs.AddBeforeAll(func() {
// List available fixtures
fixtures := testdata.ListFixtures()
fmt.Printf("Loaded %d test fixtures\n", len(fixtures))

// Optional: Validate required fixtures
// requiredFixtures := []string{
// "credentials_request.yaml",
// }
// if err := testdata.ValidateFixtures(requiredFixtures); err != nil {
// panic(fmt.Sprintf("Missing required fixtures: %v", err))
// }
})

specs.AddAfterAll(func() {
if err := testdata.CleanupFixtures(); err != nil {
fmt.Printf("Warning: failed to cleanup fixtures: %v\n", err)
}
})

ext.AddSpecs(specs)
registry.Register(ext)

root := &cobra.Command{
Long: "Cloud Credential Operator Tests",
}

root.AddCommand(cmd.DefaultExtensionCommands(registry)...)

if err := func() error {
return root.Execute()
}(); err != nil {
os.Exit(1)
}
}
Loading