Skip to content

Commit bfbc833

Browse files
committed
CNTRLPLANE-1257: set up openshift-tests-extension and add a sanity test
1 parent 216cf83 commit bfbc833

File tree

347 files changed

+202018
-1464
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

347 files changed

+202018
-1464
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/cluster-openshift-apiserver-operator
2+
/cluster-openshift-apiserver-operator-tests-ext
23
.idea/
34
telepresence.log

Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
FROM registry.ci.openshift.org/ocp/builder:rhel-9-golang-1.24-openshift-4.20 AS builder
22
WORKDIR /go/src/github.com/openshift/cluster-openshift-apiserver-operator
33
COPY . .
4-
RUN GODEBUG=tls13=1 go build ./cmd/cluster-openshift-apiserver-operator
4+
RUN GODEBUG=tls13=1 go build ./cmd/cluster-openshift-apiserver-operator \
5+
&& make tests-ext-build \
6+
&& gzip cluster-openshift-apiserver-operator-tests-ext
57

68
FROM registry.ci.openshift.org/ocp/4.20:base-rhel9
79
COPY --from=builder /go/src/github.com/openshift/cluster-openshift-apiserver-operator/cluster-openshift-apiserver-operator /usr/bin/
10+
COPY --from=builder /go/src/github.com/openshift/cluster-openshift-apiserver-operator/cluster-openshift-apiserver-operator-tests-ext.tar.gz /usr/bin/
811
COPY manifests /manifests
912
LABEL io.openshift.release.operator true

Makefile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,21 @@ IMAGE_REGISTRY :=registry.svc.ci.openshift.org
1515
ENCRYPTION_PROVIDERS=aescbc aesgcm
1616
ENCRYPTION_PROVIDER?=aescbc
1717

18+
# -------------------------------------------------------------------
19+
# OpenShift Tests Extension (Cluster OpenShift API Server Operator)
20+
# -------------------------------------------------------------------
21+
TESTS_EXT_BINARY := cluster-openshift-apiserver-operator-tests-ext
22+
TESTS_EXT_PACKAGE := ./cmd/cluster-openshift-apiserver-operator-tests-ext
23+
24+
TESTS_EXT_GIT_COMMIT := $(shell git rev-parse --short HEAD)
25+
TESTS_EXT_BUILD_DATE := $(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
26+
TESTS_EXT_GIT_TREE_STATE := $(shell if git diff --quiet; then echo clean; else echo dirty; fi)
27+
28+
TESTS_EXT_LDFLAGS := -X 'github.com/openshift-eng/openshift-tests-extension/pkg/version.CommitFromGit=$(TESTS_EXT_GIT_COMMIT)' \
29+
-X 'github.com/openshift-eng/openshift-tests-extension/pkg/version.BuildDate=$(TESTS_EXT_BUILD_DATE)' \
30+
-X 'github.com/openshift-eng/openshift-tests-extension/pkg/version.GitTreeState=$(TESTS_EXT_GIT_TREE_STATE)'
31+
32+
1833
# This will call a macro called "build-image" which will generate image specific targets based on the parameters:
1934
# $0 - macro name
2035
# $1 - target name
@@ -77,6 +92,24 @@ test-e2e: GO_TEST_PACKAGES :=./test/e2e/...
7792
test-e2e: GO_TEST_FLAGS += -timeout 1h
7893
test-e2e: test-unit
7994

95+
# -------------------------------------------------------------------
96+
# Build binary with metadata (CI-compliant)
97+
# -------------------------------------------------------------------
98+
.PHONY: tests-ext-build
99+
tests-ext-build:
100+
GOOS=$(GOOS) GOARCH=$(GOARCH) GO_COMPLIANCE_POLICY=exempt_all CGO_ENABLED=0 \
101+
go build -o $(TESTS_EXT_BINARY) -ldflags "$(TESTS_EXT_LDFLAGS)" $(TESTS_EXT_PACKAGE)
102+
103+
# -------------------------------------------------------------------
104+
# Run "update" and strip env-specific metadata
105+
# -------------------------------------------------------------------
106+
.PHONY: tests-ext-update
107+
tests-ext-update: tests-ext-build
108+
./$(TESTS_EXT_BINARY) update
109+
for f in .openshift-tests-extension/*.json; do \
110+
jq 'map(del(.codeLocations))' "$$f" > tmpp && mv tmpp "$$f"; \
111+
done
112+
80113
# Configure the 'telepresence' target
81114
# See vendor/github.com/openshift/build-machinery-go/scripts/run-telepresence.sh for usage and configuration details
82115
export TP_DEPLOYMENT_YAML ?=./manifests/0000_30_openshift-apiserver-operator_07_deployment.yaml
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
/*
2+
This command is used to run the Cluster OpenShift API Server Operator tests extension for OpenShift.
3+
It registers the Cluster OpenShift API Server Operator tests with the OpenShift Tests Extension framework
4+
and provides a command-line interface to execute them.
5+
6+
For further information, please refer to the documentation at:
7+
https://github.com/openshift-eng/openshift-tests-extension/blob/main/cmd/example-tests/main.go
8+
*/
9+
package main
10+
11+
import (
12+
"fmt"
13+
"os"
14+
"strings"
15+
16+
"github.com/openshift-eng/openshift-tests-extension/pkg/cmd"
17+
e "github.com/openshift-eng/openshift-tests-extension/pkg/extension"
18+
et "github.com/openshift-eng/openshift-tests-extension/pkg/extension/extensiontests"
19+
g "github.com/openshift-eng/openshift-tests-extension/pkg/ginkgo"
20+
21+
"github.com/spf13/cobra"
22+
23+
// The import below is necessary to ensure that the OAS operator tests are registered with the extension.
24+
_ "github.com/openshift/cluster-openshift-apiserver-operator/test/extended"
25+
)
26+
27+
func main() {
28+
registry := e.NewRegistry()
29+
ext := e.NewExtension("openshift", "payload", "cluster-openshift-apiserver-operator")
30+
31+
// Suite: conformance/parallel (fast, parallel-safe)
32+
ext.AddSuite(e.Suite{
33+
Name: "openshift/cluster-openshift-apiserver-operator/conformance/parallel",
34+
Parents: []string{"openshift/conformance/parallel"},
35+
Qualifiers: []string{
36+
`!(name.contains("[Serial]") || name.contains("[Slow]"))`,
37+
},
38+
})
39+
40+
// Suite: conformance/serial (explicitly serial tests)
41+
ext.AddSuite(e.Suite{
42+
Name: "openshift/cluster-openshift-apiserver-operator/conformance/serial",
43+
Parents: []string{"openshift/conformance/serial"},
44+
Qualifiers: []string{
45+
`name.contains("[Serial]")`,
46+
},
47+
})
48+
49+
// Suite: optional/slow (long-running tests)
50+
ext.AddSuite(e.Suite{
51+
Name: "openshift/cluster-openshift-apiserver-operator/optional/slow",
52+
Parents: []string{"openshift/optional/slow"},
53+
Qualifiers: []string{
54+
`name.contains("[Slow]")`,
55+
},
56+
})
57+
58+
// Suite: all (includes everything)
59+
ext.AddSuite(e.Suite{
60+
Name: "openshift/cluster-openshift-apiserver-operator/all",
61+
})
62+
63+
specs, err := g.BuildExtensionTestSpecsFromOpenShiftGinkgoSuite()
64+
if err != nil {
65+
panic(fmt.Sprintf("couldn't build extension test specs from ginkgo: %+v", err.Error()))
66+
}
67+
68+
// Ensure [Disruptive] tests are also [Serial]
69+
specs = specs.Walk(func(spec *et.ExtensionTestSpec) {
70+
if strings.Contains(spec.Name, "[Disruptive]") && !strings.Contains(spec.Name, "[Serial]") {
71+
spec.Name = strings.ReplaceAll(
72+
spec.Name,
73+
"[Disruptive]",
74+
"[Serial][Disruptive]",
75+
)
76+
}
77+
})
78+
79+
// Preserve original-name labels for renamed tests
80+
specs = specs.Walk(func(spec *et.ExtensionTestSpec) {
81+
for label := range spec.Labels {
82+
if strings.HasPrefix(label, "original-name:") {
83+
parts := strings.SplitN(label, "original-name:", 2)
84+
if len(parts) > 1 {
85+
spec.OriginalName = parts[1]
86+
}
87+
}
88+
}
89+
})
90+
91+
// Ignore obsolete tests
92+
ext.IgnoreObsoleteTests(
93+
// "[sig-openshift-apiserver] <test name here>",
94+
)
95+
96+
// Initialize environment before running any tests
97+
specs.AddBeforeAll(func() {
98+
// do stuff
99+
})
100+
101+
ext.AddSpecs(specs)
102+
registry.Register(ext)
103+
104+
root := &cobra.Command{
105+
Long: "Cluster OpenShift API Server Operator Tests Extension",
106+
}
107+
108+
root.AddCommand(cmd.DefaultExtensionCommands(registry)...)
109+
110+
if err := root.Execute(); err != nil {
111+
os.Exit(1)
112+
}
113+
}

go.mod

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ require (
66
github.com/ghodss/yaml v1.0.0
77
github.com/go-bindata/go-bindata v3.1.2+incompatible
88
github.com/gonum/graph v0.0.0-20190426092945-678096d81a4b
9+
github.com/onsi/ginkgo/v2 v2.23.4
10+
github.com/onsi/gomega v1.38.0
11+
github.com/openshift-eng/openshift-tests-extension v0.0.0-20250804142706-7b3ab438a292
912
github.com/openshift/api v0.0.0-20250724151358-f313adb86331
1013
github.com/openshift/build-machinery-go v0.0.0-20250530140348-dc5b2804eeee
1114
github.com/openshift/client-go v0.0.0-20250710075018-396b36f983ee
@@ -46,6 +49,7 @@ require (
4649
github.com/go-openapi/jsonpointer v0.21.0 // indirect
4750
github.com/go-openapi/jsonreference v0.20.2 // indirect
4851
github.com/go-openapi/swag v0.23.0 // indirect
52+
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
4953
github.com/gogo/protobuf v1.3.2 // indirect
5054
github.com/golang/protobuf v1.5.4 // indirect
5155
github.com/gonum/blas v0.0.0-20181208220705-f22b278b28ac // indirect
@@ -57,7 +61,7 @@ require (
5761
github.com/google/cel-go v0.23.2 // indirect
5862
github.com/google/gnostic-models v0.6.9 // indirect
5963
github.com/google/go-cmp v0.7.0 // indirect
60-
github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db // indirect
64+
github.com/google/pprof v0.0.0-20250403155104-27863c87afa6 // indirect
6165
github.com/google/uuid v1.6.0 // indirect
6266
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
6367
github.com/grpc-ecosystem/grpc-gateway/v2 v2.24.0 // indirect
@@ -96,20 +100,20 @@ require (
96100
go.opentelemetry.io/proto/otlp v1.4.0 // indirect
97101
go.uber.org/multierr v1.11.0 // indirect
98102
go.uber.org/zap v1.27.0 // indirect
99-
golang.org/x/crypto v0.36.0 // indirect
103+
golang.org/x/crypto v0.39.0 // indirect
100104
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
101-
golang.org/x/net v0.38.0 // indirect
105+
golang.org/x/net v0.41.0 // indirect
102106
golang.org/x/oauth2 v0.27.0 // indirect
103-
golang.org/x/sync v0.12.0 // indirect
104-
golang.org/x/sys v0.31.0 // indirect
105-
golang.org/x/term v0.30.0 // indirect
106-
golang.org/x/text v0.23.0 // indirect
107+
golang.org/x/sync v0.15.0 // indirect
108+
golang.org/x/sys v0.33.0 // indirect
109+
golang.org/x/term v0.32.0 // indirect
110+
golang.org/x/text v0.26.0 // indirect
107111
golang.org/x/time v0.9.0 // indirect
108-
golang.org/x/tools v0.26.0 // indirect
112+
golang.org/x/tools v0.33.0 // indirect
109113
google.golang.org/genproto/googleapis/api v0.0.0-20241209162323-e6fa225c2576 // indirect
110114
google.golang.org/genproto/googleapis/rpc v0.0.0-20241209162323-e6fa225c2576 // indirect
111115
google.golang.org/grpc v1.68.1 // indirect
112-
google.golang.org/protobuf v1.36.5 // indirect
116+
google.golang.org/protobuf v1.36.6 // indirect
113117
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
114118
gopkg.in/inf.v0 v0.9.1 // indirect
115119
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
@@ -123,3 +127,6 @@ require (
123127
sigs.k8s.io/structured-merge-diff/v4 v4.6.0 // indirect
124128
sigs.k8s.io/yaml v1.4.0 // indirect
125129
)
130+
131+
// This replace is required for we use the OCP fork of Ginkgo.
132+
replace github.com/onsi/ginkgo/v2 => github.com/openshift/onsi-ginkgo/v2 v2.6.1-0.20241205171354-8006f302fd12

0 commit comments

Comments
 (0)