Skip to content

Commit c68844f

Browse files
jadhajclaude
andcommitted
Add OpenShift Tests Extension (OTE) for baremetal E2E tests
Implements OTE framework to migrate baremetal E2E tests from openshift-tests-private to cluster-baremetal-operator repository. Changes: - Add cmd/cluster-baremetal-tests-ext/main.go: OTE binary entry point that registers as openshift:payload:cluster-baremetal extension - Add test/e2e/baremetal/deployment_sanity.go: 6 migrated baremetal tests * Cluster operators running check (OCP-29146) * Nodes running check (OCP-29147) * Deployment availability check (OCP-29148) * Worker node validation (OCP-29149) * CPU usage check (OCP-29150) * Memory check (OCP-29151) - Add test/e2e/baremetal/utils.go: Helper functions using compat_otp - Update go.mod/go.sum: Add OTE dependencies and OpenShift kubernetes replaces - Update Makefile: Add build-tests target with -mod=mod approach Build system: - Main CBO builds continue using vendor/ (no changes to existing workflow) - OTE build uses -mod=mod flag to download deps to Go module cache - GONOSUMDB bypasses checksum verification for origin pseudo-versions - CGO_ENABLED=0 produces static binary for container compatibility - GO_COMPLIANCE_POLICY="exempt_all" exempts test binaries from internal checks Tests use platform=="baremetal" selector and run under origin CI. Binary: cluster-baremetal-tests-ext (payload test extension) Fixes from code review: - Updated kubernetes dependencies to latest commit (73359c58edaa) - Added comprehensive build flag documentation in Makefile - Fixed topology-aware replica sizing (SNO/HighlyAvailable/External) - Fixed malformed jsonpath in deployment status check - Fixed Prometheus memory parsing to use ParseFloat instead of Atoi - Fixed defer Close() placement to prevent nil pointer panics - Fixed swapped iLO6 firmware URLs - Removed shell injection vulnerabilities in certificate parsing - Lowered go version to 1.25.5 for CI compatibility Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 6a7e66f commit c68844f

6 files changed

Lines changed: 2094 additions & 237 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)