Skip to content

Commit 395de96

Browse files
Merge pull request #891 from gangwgr/test-module-infra-only
CNTRLPLANE-1275:Refactor OTE to single-module architecture
2 parents 51942ed + 51f99cc commit 395de96

File tree

288 files changed

+892
-198415
lines changed

Some content is hidden

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

288 files changed

+892
-198415
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@
33
.idea/
44
_output
55
telepresence.log
6-
.openshift-tests-extension/openshift_payload_*.json
76

Dockerfile.rhel7

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
FROM registry.ci.openshift.org/ocp/builder:rhel-9-golang-1.24-openshift-4.21 AS builder
22
WORKDIR /go/src/github.com/openshift/cluster-kube-controller-manager-operator
33
COPY . .
4-
RUN make build --warn-undefined-variables
5-
RUN make tests-ext-build --warn-undefined-variables \
4+
RUN make build --warn-undefined-variables \
65
&& gzip cluster-kube-controller-manager-operator-tests-ext
76

87
FROM registry.ci.openshift.org/ocp/4.21:base-rhel9

Makefile

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,3 @@ test-e2e-preferred-host: test-unit
3838
# See vendor/github.com/openshift/build-machinery-go/scripts/run-telepresence.sh for usage and configuration details
3939
export TP_DEPLOYMENT_YAML ?=./manifests/0000_25_kube-controller-manager-operator_06_deployment.yaml
4040
export TP_CMD_PATH ?=./cmd/cluster-kube-controller-manager-operator
41-
42-
# Build the openshift-tests-extension binary
43-
tests-ext-build:
44-
GOOS=$(GOOS) GOARCH=$(GOARCH) GO_COMPLIANCE_POLICY=exempt_all CGO_ENABLED=0 \
45-
go build -o cluster-kube-controller-manager-operator-tests-ext \
46-
-ldflags "-X 'main.CommitFromGit=$(shell git rev-parse --short HEAD)' \
47-
-X 'main.BuildDate=$(shell date -u +%Y-%m-%dT%H:%M:%SZ)' \
48-
-X 'main.GitTreeState=$(shell if git diff-index --quiet HEAD --; then echo clean; else echo dirty; fi)'" \
49-
./cmd/cluster-kube-controller-manager-operator-tests-ext
50-
.PHONY: tests-ext-build

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,35 @@ $ docker push <user>/origin-release:latest
164164
$ cd ../installer
165165
$ OPENSHIFT_INSTALL_RELEASE_IMAGE_OVERRIDE=docker.io/<user>/origin-release:latest bin/openshift-install cluster ...
166166
```
167+
168+
## Tests
169+
170+
The repository is compatible with the "OpenShift Tests Extension (OTE)" framework.
171+
172+
### Building the test binary
173+
```bash
174+
make build
175+
```
176+
177+
### Running test suites and tests
178+
```bash
179+
# Run a specific test suite or test
180+
./cluster-kube-controller-manager-operator-tests-ext run-suite openshift/cluster-kube-controller-manager-operator/all
181+
./cluster-kube-controller-manager-operator-tests-ext run-test "test-name"
182+
183+
# Run with JUnit output
184+
./cluster-kube-controller-manager-operator-tests-ext run-suite openshift/cluster-kube-controller-manager-operator/all --junit-path=/tmp/junit-results/junit.xml
185+
./cluster-kube-controller-manager-operator-tests-ext run-test "test-name" --junit-path=/tmp/junit-results/junit.xml
186+
```
187+
188+
### Listing available tests and suites
189+
```bash
190+
# List all test suites
191+
./cluster-kube-controller-manager-operator-tests-ext list suites
192+
193+
# List tests in a suite
194+
./cluster-kube-controller-manager-operator-tests-ext list tests --suite=openshift/cluster-kube-controller-manager-operator/all
195+
196+
#for concurrency
197+
./cluster-kube-controller-manager-operator-tests-ext run-suite openshift/cluster-kube-controller-manager-operator/all -c 1
198+
```
Lines changed: 33 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,105 +1,53 @@
11
package main
22

33
import (
4-
"fmt"
4+
"context"
55
"os"
6-
"strings"
7-
8-
"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"
126

137
"github.com/spf13/cobra"
8+
"k8s.io/component-base/cli"
9+
10+
otecmd "github.com/openshift-eng/openshift-tests-extension/pkg/cmd"
11+
oteextension "github.com/openshift-eng/openshift-tests-extension/pkg/extension"
12+
"github.com/openshift/cluster-kube-controller-manager-operator/pkg/version"
1413

15-
// The import below is necessary to ensure that the kube controller manager operator tests are registered with the extension.
16-
_ "github.com/openshift/cluster-kube-controller-manager-operator/test/extended"
14+
"k8s.io/klog/v2"
1715
)
1816

1917
func main() {
20-
registry := e.NewRegistry()
21-
ext := e.NewExtension("openshift", "payload", "cluster-kube-controller-manager-operator")
18+
command := newOperatorTestCommand(context.Background())
19+
code := cli.Run(command)
20+
os.Exit(code)
21+
}
2222

23-
// Suite: conformance/parallel (fast, parallel-safe)
24-
ext.AddSuite(e.Suite{
25-
Name: "openshift/cluster-kube-controller-manager-operator/conformance/parallel",
26-
Parents: []string{"openshift/conformance/parallel"},
27-
Qualifiers: []string{
28-
`!(name.contains("[Serial]") || name.contains("[Slow]"))`,
29-
},
30-
})
23+
func newOperatorTestCommand(ctx context.Context) *cobra.Command {
24+
registry := prepareOperatorTestsRegistry()
3125

32-
// Suite: conformance/serial (explicitly serial tests)
33-
ext.AddSuite(e.Suite{
34-
Name: "openshift/cluster-kube-controller-manager-operator/conformance/serial",
35-
Parents: []string{"openshift/conformance/serial"},
36-
Qualifiers: []string{
37-
`name.contains("[Serial]")`,
38-
},
39-
})
40-
41-
// Suite: optional/slow (long-running tests)
42-
ext.AddSuite(e.Suite{
43-
Name: "openshift/cluster-kube-controller-manager-operator/optional/slow",
44-
Parents: []string{"openshift/optional/slow"},
45-
Qualifiers: []string{
46-
`name.contains("[Slow]")`,
26+
cmd := &cobra.Command{
27+
Use: "cluster-kube-controller-manager-operator-tests-ext",
28+
Short: "A binary used to run cluster-kube-controller-manager-operator tests as part of OTE.",
29+
Run: func(cmd *cobra.Command, args []string) {
30+
if err := cmd.Help(); err != nil {
31+
klog.Fatal(err)
32+
}
4733
},
48-
})
49-
50-
// Suite: all (includes everything)
51-
ext.AddSuite(e.Suite{
52-
Name: "openshift/cluster-kube-controller-manager-operator/all",
53-
})
54-
55-
specs, err := g.BuildExtensionTestSpecsFromOpenShiftGinkgoSuite()
56-
if err != nil {
57-
panic(fmt.Sprintf("couldn't build extension test specs from ginkgo: %+v", err.Error()))
5834
}
5935

60-
// Ensure [Disruptive] tests are also [Serial] (for any future tests that might need this)
61-
specs = specs.Walk(func(spec *et.ExtensionTestSpec) {
62-
if strings.Contains(spec.Name, "[Disruptive]") && !strings.Contains(spec.Name, "[Serial]") {
63-
spec.Name = strings.ReplaceAll(
64-
spec.Name,
65-
"[Disruptive]",
66-
"[Serial][Disruptive]",
67-
)
68-
}
69-
})
70-
71-
// Preserve original-name labels for renamed tests
72-
specs = specs.Walk(func(spec *et.ExtensionTestSpec) {
73-
for label := range spec.Labels {
74-
if strings.HasPrefix(label, "original-name:") {
75-
parts := strings.SplitN(label, "original-name:", 2)
76-
if len(parts) > 1 {
77-
spec.OriginalName = parts[1]
78-
}
79-
}
80-
}
81-
})
82-
83-
// Ignore obsolete tests
84-
ext.IgnoreObsoleteTests(
85-
// "[sig-kube-controller-manager] <test name here>",
86-
)
87-
88-
// Initialize environment before running any tests
89-
specs.AddBeforeAll(func() {
90-
// do stuff
91-
})
36+
if v := version.Get().String(); len(v) == 0 {
37+
cmd.Version = "<unknown>"
38+
} else {
39+
cmd.Version = v
40+
}
9241

93-
ext.AddSpecs(specs)
94-
registry.Register(ext)
42+
cmd.AddCommand(otecmd.DefaultExtensionCommands(registry)...)
9543

96-
root := &cobra.Command{
97-
Long: "Cluster Kube Controller Manager Operator Tests Extension",
98-
}
44+
return cmd
45+
}
9946

100-
root.AddCommand(cmd.DefaultExtensionCommands(registry)...)
47+
func prepareOperatorTestsRegistry() *oteextension.Registry {
48+
registry := oteextension.NewRegistry()
49+
extension := oteextension.NewExtension("openshift", "payload", "cluster-kube-controller-manager-operator")
10150

102-
if err := root.Execute(); err != nil {
103-
os.Exit(1)
104-
}
51+
registry.Register(extension)
52+
return registry
10553
}

go.mod

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ require (
66
github.com/ghodss/yaml v1.0.0
77
github.com/gonum/graph v0.0.0-20190426092945-678096d81a4b
88
github.com/google/go-cmp v0.7.0
9-
github.com/onsi/ginkgo/v2 v2.22.1
10-
github.com/onsi/gomega v1.36.1
11-
github.com/openshift-eng/openshift-tests-extension v0.0.0-20250804142706-7b3ab438a292
9+
github.com/openshift-eng/openshift-tests-extension v0.0.0-20251113163031-356b66aa5c24
1210
github.com/openshift/api v0.0.0-20251015095338-264e80a2b6e7
1311
github.com/openshift/build-machinery-go v0.0.0-20250530140348-dc5b2804eeee
1412
github.com/openshift/client-go v0.0.0-20251015124057-db0dee36e235
@@ -18,7 +16,7 @@ require (
1816
github.com/spf13/cobra v1.9.1
1917
github.com/spf13/pflag v1.0.6
2018
github.com/stretchr/testify v1.10.0
21-
google.golang.org/protobuf v1.36.5 // indirect; to improve error handling
19+
google.golang.org/protobuf v1.36.6 // indirect; to improve error handling
2220
k8s.io/api v0.34.1
2321
k8s.io/apimachinery v0.34.1
2422
k8s.io/apiserver v0.34.1
@@ -49,7 +47,6 @@ require (
4947
github.com/go-openapi/jsonpointer v0.21.0 // indirect
5048
github.com/go-openapi/jsonreference v0.20.2 // indirect
5149
github.com/go-openapi/swag v0.23.0 // indirect
52-
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
5350
github.com/gogo/protobuf v1.3.2 // indirect
5451
github.com/golang/protobuf v1.5.4 // indirect
5552
github.com/gonum/blas v0.0.0-20181208220705-f22b278b28ac // indirect
@@ -60,7 +57,7 @@ require (
6057
github.com/google/btree v1.1.3 // indirect
6158
github.com/google/cel-go v0.26.0 // indirect
6259
github.com/google/gnostic-models v0.7.0 // indirect
63-
github.com/google/pprof v0.0.0-20241210010833-40e02aabc2ad // indirect
60+
github.com/google/pprof v0.0.0-20250403155104-27863c87afa6 // indirect
6461
github.com/google/uuid v1.6.0 // indirect
6562
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
6663
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3 // indirect
@@ -128,6 +125,3 @@ require (
128125
sigs.k8s.io/structured-merge-diff/v6 v6.3.0 // indirect
129126
sigs.k8s.io/yaml v1.6.0 // indirect
130127
)
131-
132-
// This replace is required for we use the OCP fork of Ginkgo.
133-
replace github.com/onsi/ginkgo/v2 => github.com/openshift/onsi-ginkgo/v2 v2.6.1-0.20241205171354-8006f302fd12

go.sum

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ github.com/go-openapi/jsonreference v0.20.2/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En
6363
github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14=
6464
github.com/go-openapi/swag v0.23.0 h1:vsEVJDUo2hPJ2tu0/Xc+4noaxyEffXNIs3cOULZ+GrE=
6565
github.com/go-openapi/swag v0.23.0/go.mod h1:esZ8ITTYEsH1V2trKHjAN8Ai7xHb8RV+YSZ577vPjgQ=
66+
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI=
6667
github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI=
6768
github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8=
6869
github.com/gobwas/httphead v0.1.0/go.mod h1:O/RXo79gxV8G+RqlR/otEwx4Q36zl9rqC5u12GKvMCM=
@@ -98,8 +99,8 @@ github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX
9899
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
99100
github.com/google/pprof v0.0.0-20211214055906-6f57359322fd/go.mod h1:KgnwoLYCZ8IQu3XUZ8Nc/bM9CCZFOyjUNOSygVozoDg=
100101
github.com/google/pprof v0.0.0-20240227163752-401108e1b7e7/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik=
101-
github.com/google/pprof v0.0.0-20241210010833-40e02aabc2ad h1:a6HEuzUHeKH6hwfN/ZoQgRgVIWFJljSWa/zetS2WTvg=
102-
github.com/google/pprof v0.0.0-20241210010833-40e02aabc2ad/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144=
102+
github.com/google/pprof v0.0.0-20250403155104-27863c87afa6 h1:BHT72Gu3keYf3ZEu2J0b1vyeLSOYI8bm5wbJM/8yDe8=
103+
github.com/google/pprof v0.0.0-20250403155104-27863c87afa6/go.mod h1:boTsfXsheKC2y+lKOCMpSfarhxDeIzfZG1jqGcPl3cA=
103104
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
104105
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
105106
github.com/gorilla/websocket v1.5.4-0.20250319132907-e064f32e3674 h1:JeSE6pjso5THxAzdVpqr6/geYxZytqFMBCOtn/ujyeo=
@@ -152,10 +153,12 @@ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq
152153
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
153154
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f h1:KUppIJq7/+SVif2QVs3tOP0zanoHgBEVAwHxUSIzRqU=
154155
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
155-
github.com/onsi/gomega v1.36.1 h1:bJDPBO7ibjxcbHMgSCoo4Yj18UWbKDlLwX1x9sybDcw=
156-
github.com/onsi/gomega v1.36.1/go.mod h1:PvZbdDc8J6XJEpDK4HCuRBm8a6Fzp9/DmhC9C7yFlog=
157-
github.com/openshift-eng/openshift-tests-extension v0.0.0-20250804142706-7b3ab438a292 h1:3athg6KQ+TaNfW4BWZDlGFt1ImSZEJWgzXtPC1VPITI=
158-
github.com/openshift-eng/openshift-tests-extension v0.0.0-20250804142706-7b3ab438a292/go.mod h1:6gkP5f2HL0meusT0Aim8icAspcD1cG055xxBZ9yC68M=
156+
github.com/onsi/ginkgo/v2 v2.21.0 h1:7rg/4f3rB88pb5obDgNZrNHrQ4e6WpjonchcpuBRnZM=
157+
github.com/onsi/ginkgo/v2 v2.21.0/go.mod h1:7Du3c42kxCUegi0IImZ1wUQzMBVecgIHjR1C+NkhLQo=
158+
github.com/onsi/gomega v1.35.1 h1:Cwbd75ZBPxFSuZ6T+rN/WCb/gOc6YgFBXLlZLhC7Ds4=
159+
github.com/onsi/gomega v1.35.1/go.mod h1:PvZbdDc8J6XJEpDK4HCuRBm8a6Fzp9/DmhC9C7yFlog=
160+
github.com/openshift-eng/openshift-tests-extension v0.0.0-20251113163031-356b66aa5c24 h1:bwmjtFaipakIwAyZxnDLgtkLY1Nf1nK9lRCmADvHirE=
161+
github.com/openshift-eng/openshift-tests-extension v0.0.0-20251113163031-356b66aa5c24/go.mod h1:6gkP5f2HL0meusT0Aim8icAspcD1cG055xxBZ9yC68M=
159162
github.com/openshift/api v0.0.0-20251015095338-264e80a2b6e7 h1:Ot2fbEEPmF3WlPQkyEW/bUCV38GMugH/UmZvxpWceNc=
160163
github.com/openshift/api v0.0.0-20251015095338-264e80a2b6e7/go.mod h1:d5uzF0YN2nQQFA0jIEWzzOZ+edmo6wzlGLvx5Fhz4uY=
161164
github.com/openshift/build-machinery-go v0.0.0-20250530140348-dc5b2804eeee h1:+Sp5GGnjHDhT/a/nQ1xdp43UscBMr7G5wxsYotyhzJ4=
@@ -164,8 +167,6 @@ github.com/openshift/client-go v0.0.0-20251015124057-db0dee36e235 h1:9JBeIXmnHlp
164167
github.com/openshift/client-go v0.0.0-20251015124057-db0dee36e235/go.mod h1:L49W6pfrZkfOE5iC1PqEkuLkXG4W0BX4w8b+L2Bv7fM=
165168
github.com/openshift/library-go v0.0.0-20251104164011-e9c2485b059c h1:fCvbOJjMSbJaDK53vBo2nCL0xpvqO2zuvFyJxI0HTgM=
166169
github.com/openshift/library-go v0.0.0-20251104164011-e9c2485b059c/go.mod h1:OlFFws1AO51uzfc48MsStGE4SFMWlMZD0+f5a/zCtKI=
167-
github.com/openshift/onsi-ginkgo/v2 v2.6.1-0.20241205171354-8006f302fd12 h1:AKx/w1qpS8We43bsRgf8Nll3CGlDHpr/WAXvuedTNZI=
168-
github.com/openshift/onsi-ginkgo/v2 v2.6.1-0.20241205171354-8006f302fd12/go.mod h1:7Du3c42kxCUegi0IImZ1wUQzMBVecgIHjR1C+NkhLQo=
169170
github.com/orisano/pixelmatch v0.0.0-20220722002657-fb0b55479cde/go.mod h1:nZgzbfBr3hhjoZnS66nKrHmduYNpc34ny7RK4z5/HM0=
170171
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
171172
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
@@ -320,8 +321,8 @@ google.golang.org/genproto/googleapis/rpc v0.0.0-20250303144028-a0af3efb3deb h1:
320321
google.golang.org/genproto/googleapis/rpc v0.0.0-20250303144028-a0af3efb3deb/go.mod h1:LuRYeWDFV6WOn90g357N17oMCaxpgCnbi/44qJvDn2I=
321322
google.golang.org/grpc v1.72.1 h1:HR03wO6eyZ7lknl75XlxABNVLLFc2PAb6mHlYh756mA=
322323
google.golang.org/grpc v1.72.1/go.mod h1:wH5Aktxcg25y1I3w7H69nHfXdOG3UiadoBtjh3izSDM=
323-
google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM=
324-
google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
324+
google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY=
325+
google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
325326
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
326327
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
327328
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=

test/OWNERS

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
reviewers:
2+
- atiratree
3+
- deads2k
4+
- ingvagabund
5+
- gangwgr
6+
- zhouying7780
7+
approvers:
8+
- atiratree
9+
- deads2k
10+
- ingvagabund
11+
- gangwgr
12+
- zhouying7780
13+
component: "kube-controller-manager"
14+

0 commit comments

Comments
 (0)