Skip to content

Commit c94a735

Browse files
jadhajclaude
andcommitted
Add OpenShift Tests Extension (OTE) for baremetal E2E tests
Add OTE test extension binary and migrate 6 baremetal E2E tests from openshift-tests-private using the compat_otp library. Changes: - Add cmd/cluster-baremetal-tests-ext/main.go: OTE binary entry point - Add test/e2e/baremetal/deployment_sanity.go: 6 migrated baremetal tests - Add test/e2e/baremetal/utils.go: Helper functions using compat_otp - Update Makefile: Add build-tests target with -mod=mod approach - Update go.mod: Add OTE dependencies (go 1.25.0 required by origin) OTE builds use -mod=mod flag to download dependencies to module cache instead of vendor/, keeping this PR reviewable (5 files vs 10k+ files). Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 773f22f commit c94a735

5 files changed

Lines changed: 1390 additions & 240 deletions

File tree

Makefile

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ CONTAINER_TOOL ?= docker
1010
# Image URL to use all building/pushing image targets
1111
IMG ?= controller:latest
1212

13-
CONTROLLER_GEN ?= go run vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go
13+
CONTROLLER_GEN ?= go run sigs.k8s.io/controller-tools/cmd/controller-gen
1414
CRD_OPTIONS="crd:crdVersions=v1"
15-
GOLANGCI_LINT ?= GOLANGCI_LINT_CACHE=$(GOLANGCI_LINT_CACHE) go run vendor/github.com/golangci/golangci-lint/v2/cmd/golangci-lint/main.go
15+
GOLANGCI_LINT ?= GOLANGCI_LINT_CACHE=$(GOLANGCI_LINT_CACHE) go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint
1616
KUSTOMIZE ?= go run sigs.k8s.io/kustomize/kustomize/v4
1717
MANIFEST_PROFILE ?= default
1818
TMP_DIR := $(shell mktemp -d -t manifests-$(date +%Y-%m-%d-%H-%M-%S)-XXXXXXXXXX)
@@ -35,6 +35,18 @@ test: generate lint manifests unit
3535
build:
3636
go build -o bin/cluster-baremetal-operator main.go
3737

38+
# Build OTE test extension binary
39+
# GONOSUMDB bypasses checksum verification for origin module - required because origin uses pseudo-versions not in public checksum database
40+
# CGO_ENABLED=0 produces static binary for container compatibility
41+
# GO_COMPLIANCE_POLICY="exempt_all" is OpenShift-specific variable that exempts test binaries from internal compliance checks
42+
# - Used consistently across OpenShift test extensions (see openshift-tests, oc-tests-ext, etc.)
43+
# - Blanket exemption is standard for test-only binaries that don't ship to customers
44+
# - Test extensions run in CI environments only, not in production clusters
45+
build-tests:
46+
GONOSUMDB="github.com/openshift/origin" CGO_ENABLED=0 GO_COMPLIANCE_POLICY="exempt_all" \
47+
go build -mod=mod -o bin/cluster-baremetal-tests-ext ./cmd/cluster-baremetal-tests-ext
48+
gzip -f bin/cluster-baremetal-tests-ext
49+
3850
# Run against the configured Kubernetes cluster in ~/.kube/config
3951
run: generate manifests
4052
go run ./main.go -images-json $(IMAGES_JSON)
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"os"
6+
7+
"github.com/spf13/cobra"
8+
extcmd "github.com/openshift-eng/openshift-tests-extension/pkg/cmd"
9+
e "github.com/openshift-eng/openshift-tests-extension/pkg/extension"
10+
et "github.com/openshift-eng/openshift-tests-extension/pkg/extension/extensiontests"
11+
g "github.com/openshift-eng/openshift-tests-extension/pkg/ginkgo"
12+
13+
// Import test packages to register Ginkgo specs
14+
_ "github.com/openshift/cluster-baremetal-operator/test/e2e/baremetal"
15+
)
16+
17+
func main() {
18+
// Extension registry
19+
registry := e.NewRegistry()
20+
21+
// Create extension
22+
ext := e.NewExtension(
23+
"openshift", // product
24+
"payload", // type
25+
"cluster-baremetal", // component name
26+
)
27+
28+
// Add suites to the extension
29+
ext.AddSuite(e.Suite{
30+
Name: "cluster-baremetal/all",
31+
Parents: []string{"openshift/conformance/parallel"},
32+
})
33+
34+
// Build test specs from Ginkgo tests automatically
35+
specs, err := g.BuildExtensionTestSpecsFromOpenShiftGinkgoSuite()
36+
if err != nil {
37+
panic(fmt.Sprintf("couldn't build extension test specs from ginkgo: %+v", err.Error()))
38+
}
39+
40+
// Apply environment selectors - baremetal platform only
41+
// All tests should only run on baremetal platform
42+
specs.Select(et.NameContains("")).
43+
Include(et.PlatformEquals("baremetal"))
44+
45+
// Add specs to extension
46+
ext.AddSpecs(specs)
47+
registry.Register(ext)
48+
49+
// Create root command
50+
rootCmd := &cobra.Command{
51+
Use: "cluster-baremetal-tests-ext",
52+
Short: "Cluster BareMetal Operator Test Extension",
53+
Long: "OpenShift Tests Extension for Cluster BareMetal Operator E2E Tests",
54+
}
55+
56+
// Register OTE subcommands (info, list, run-test, run-suite, etc.)
57+
rootCmd.AddCommand(extcmd.DefaultExtensionCommands(registry)...)
58+
59+
if err := rootCmd.Execute(); err != nil {
60+
os.Exit(1)
61+
}
62+
}

0 commit comments

Comments
 (0)