Skip to content
Closed
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
15 changes: 15 additions & 0 deletions images/router/haproxy/Dockerfile.ocp
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# Test extension builder stage (added by ote-migration)
FROM registry.ci.openshift.org/ocp/builder:rhel-9-golang-1.25-openshift-4.22 AS test-extension-builder
RUN mkdir -p /go/src/github.com/openshift/router
WORKDIR /go/src/github.com/openshift/router
COPY . .
RUN cd tests-extension && \
make build && \
cd bin && \
tar -czvf router-test-extension.tar.gz router-tests-ext && \
rm -f router-tests-ext

FROM registry.ci.openshift.org/ocp/4.22:haproxy-router-base
RUN INSTALL_PKGS="socat haproxy28 rsyslog procps-ng util-linux" && \
yum install -y --setopt=install_weak_deps=0 $INSTALL_PKGS && \
Expand All @@ -11,6 +22,10 @@ RUN INSTALL_PKGS="socat haproxy28 rsyslog procps-ng util-linux" && \
chmod -R g+w /var/lib/haproxy && \
sed -i 's/SECLEVEL=2/SECLEVEL=1/g' /etc/crypto-policies/back-ends/opensslcnf.config
COPY images/router/haproxy/ /var/lib/haproxy/

# Copy test extension binary (added by ote-migration)
COPY --from=test-extension-builder /go/src/github.com/openshift/router/tests-extension/bin/router-test-extension.tar.gz /usr/bin/

LABEL io.k8s.display-name="OpenShift HAProxy Router" \
io.k8s.description="This component offers ingress to an OpenShift cluster via Ingress and Route rules." \
io.openshift.tags="openshift,router,haproxy"
Expand Down
20 changes: 20 additions & 0 deletions tests-extension/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
BINARY := bin/router-tests-ext

.PHONY: build
build:
@echo "Building extension binary..."
@cd test/e2e && $(MAKE) -f bindata.mk update-bindata
@mkdir -p bin
GOTOOLCHAIN=auto GOSUMDB=sum.golang.org go build -o $(BINARY) ./cmd
@echo "✅ Binary built: $(BINARY)"

.PHONY: clean
clean:
@rm -f $(BINARY)
@cd test/e2e && $(MAKE) -f bindata.mk clean-bindata

.PHONY: help
help:
@echo "Available targets:"
@echo " build - Build extension binary"
@echo " clean - Remove binaries and bindata"
159 changes: 159 additions & 0 deletions tests-extension/cmd/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
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 this module
_ "github.com/openshift/router-tests-extension/test/e2e/testdata"

// Import test packages from this module
_ "github.com/openshift/router-tests-extension/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/e2e/ 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/e2e/ 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)
}
// Set testsStarted = true to allow OTP functions like oc.Run() to work
// WithCleanup sets this flag and it remains true for all subsequent tests
util.WithCleanup(func() {
// Empty function - we just need WithCleanup to set testsStarted = true
})
})

// 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