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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,23 @@ check:
verify:
hack/verify-gofmt.sh
hack/verify-deps.sh

# OTE test extension binary configuration
TESTS_EXT_BINARY := bin/router-tests-ext

.PHONY: tests-ext-build
tests-ext-build:
@echo "Building OTE test extension binary..."
@$(MAKE) -f bindata.mk update-bindata
@mkdir -p bin
GOTOOLCHAIN=auto GOSUMDB=sum.golang.org go build -mod=vendor -o $(TESTS_EXT_BINARY) ./cmd/extension
@echo "βœ… Extension binary built: $(TESTS_EXT_BINARY)"

.PHONY: extension
extension: tests-ext-build

.PHONY: clean-extension
clean-extension:
@echo "Cleaning extension binary..."
@rm -f $(TESTS_EXT_BINARY)
@$(MAKE) -f bindata.mk clean-bindata 2>/dev/null || true
34 changes: 34 additions & 0 deletions bindata.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
TESTDATA_PATH := test/e2e/testdata
GOPATH ?= $(shell go env GOPATH)
GO_BINDATA := $(GOPATH)/bin/go-bindata

$(GO_BINDATA):
@echo "Installing go-bindata..."
@GOFLAGS= go install github.com/go-bindata/go-bindata/v3/go-bindata@latest

.PHONY: update-bindata
update-bindata: $(GO_BINDATA)
@echo "Generating bindata for testdata files..."
$(GO_BINDATA) \
-nocompress \
-nometadata \
-prefix "test/e2e/testdata" \
-pkg testdata \
-o test/e2e/testdata/bindata.go \
test/e2e/testdata/...
@gofmt -s -w test/e2e/testdata/bindata.go
@echo "βœ… Bindata generated successfully"

.PHONY: verify-bindata
verify-bindata: update-bindata
@echo "Verifying bindata is up to date..."
git diff --exit-code $(TESTDATA_PATH)/bindata.go || (echo "❌ Bindata is out of date" && exit 1)
@echo "βœ… Bindata is up to date"

.PHONY: bindata
bindata: clean-bindata update-bindata

.PHONY: clean-bindata
clean-bindata:
@echo "Cleaning bindata..."
@rm -f $(TESTDATA_PATH)/bindata.go
154 changes: 154 additions & 0 deletions cmd/extension/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
package main

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

"github.com/spf13/cobra"
"k8s.io/component-base/logs"

"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"
"github.com/openshift/origin/test/extended/util"
compat_otp "github.com/openshift/origin/test/extended/util/compat_otp"
framework "k8s.io/kubernetes/test/e2e/framework"

// Import testdata package from same module
_ "github.com/openshift/router/test/e2e/testdata"

// Import test packages from same module
_ "github.com/openshift/router/test/e2e"
)

func main() {
// Initialize test framework flags (required for kubeconfig, provider, etc.)
util.InitStandardFlags()
framework.AfterReadingAllFlags(&framework.TestContext)

logs.InitLogs()
defer logs.FlushLogs()

registry := e.NewRegistry()
ext := e.NewExtension("openshift", "payload", "router")

// Register test suites (parallel, serial, disruptive, all)
registerSuites(ext)

// Build test specs from Ginkgo
// Note: ModuleTestsOnly() is applied by default, which filters out /vendor/ and k8s.io/kubernetes tests
allSpecs, err := g.BuildExtensionTestSpecsFromOpenShiftGinkgoSuite()
if err != nil {
panic(fmt.Sprintf("couldn't build extension test specs from ginkgo: %+v", err.Error()))
}

// Filter to only include tests from this module's test directory
// Excludes tests from /go/pkg/mod/ (module cache) and /vendor/
componentSpecs := allSpecs.Select(func(spec *et.ExtensionTestSpec) bool {
for _, loc := range spec.CodeLocations {
// Include tests from local test directory (not from module cache or vendor)
if strings.Contains(loc, "/test/e2e/") && !strings.Contains(loc, "/go/pkg/mod/") && !strings.Contains(loc, "/vendor/") {
return true
}
}
return false
})

// Initialize test framework before all tests
componentSpecs.AddBeforeAll(func() {
if err := compat_otp.InitTest(false); err != nil {
panic(err)
}
})

// Process all specs
componentSpecs.Walk(func(spec *et.ExtensionTestSpec) {
// Apply platform filters based on Platform: labels
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
re := regexp.MustCompile(`\[platform:([a-z]+)\]`)
if match := re.FindStringSubmatch(spec.Name); match != nil {
platform := match[1]
spec.Include(et.PlatformEquals(platform))
}

// Set lifecycle to Informing
spec.Lifecycle = et.LifecycleInforming
})

// Add filtered component specs to extension
ext.AddSpecs(componentSpecs)

registry.Register(ext)

root := &cobra.Command{
Long: "Router Tests",
}

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

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

// registerSuites registers test suites with proper categorization
func registerSuites(ext *e.Extension) {
suites := []e.Suite{
{
Name: "router/conformance/parallel",
Parents: []string{
"openshift/conformance/parallel",
},
Description: "Parallel conformance tests (Level0, non-serial, non-disruptive)",
Qualifiers: []string{
`name.contains("[Level0]") && !(name.contains("[Serial]") || name.contains("[Disruptive]"))`,
},
},
{
Name: "router/conformance/serial",
Parents: []string{
"openshift/conformance/serial",
},
Description: "Serial conformance tests (must run sequentially)",
Qualifiers: []string{
`name.contains("[Level0]") && name.contains("[Serial]") && !name.contains("[Disruptive]")`,
},
},
{
Name: "router/disruptive",
Parents: []string{"openshift/disruptive"},
Description: "Disruptive tests (may affect cluster state)",
Qualifiers: []string{
`name.contains("[Disruptive]")`,
},
},
{
Name: "router/non-disruptive",
Description: "All non-disruptive tests (safe for development clusters)",
Qualifiers: []string{
`!name.contains("[Disruptive]")`,
},
},
{
Name: "router/all",
Description: "All router tests",
// No qualifiers means all tests from this extension will be included
},
}

for _, suite := range suites {
ext.AddSuite(suite)
}
}
Loading