Skip to content

Commit 0c2dfc0

Browse files
Merge pull request #1899 from wangke19/test-extd-revise
CNTRLPLANE-1248: Standardized scaffolding for tests extension
2 parents 36917f5 + 1fdf11e commit 0c2dfc0

File tree

6 files changed

+118
-54
lines changed

6 files changed

+118
-54
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/cluster-kube-apiserver-operator
2-
/kube-apiserver-tests-ext
2+
/cluster-kube-apiserver-operator-tests-ext
33
.idea/
44
/_output/
55
telepresence.log

Dockerfile.rhel7

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ COPY . .
44
ENV GO_PACKAGE github.com/openshift/cluster-kube-apiserver-operator
55
RUN make build --warn-undefined-variables \
66
&& make tests-ext-build \
7-
&& gzip kube-apiserver-tests-ext
7+
&& gzip cluster-kube-apiserver-operator-tests-ext
88

99
FROM registry.ci.openshift.org/ocp/4.20:base-rhel9
1010
COPY --from=builder /go/src/github.com/openshift/cluster-kube-apiserver-operator/bindata/bootkube/bootstrap-manifests /usr/share/bootkube/manifests/bootstrap-manifests/
@@ -13,7 +13,7 @@ COPY --from=builder /go/src/github.com/openshift/cluster-kube-apiserver-operator
1313
COPY --from=builder /go/src/github.com/openshift/cluster-kube-apiserver-operator/bindata/bootkube/scc-manifests /usr/share/bootkube/manifests/manifests/
1414
COPY --from=builder /go/src/github.com/openshift/cluster-kube-apiserver-operator/vendor/github.com/openshift/api/apiserver/v1/zz_generated.crd-manifests/kube-apiserver_apirequestcounts.crd.yaml /usr/share/bootkube/manifests/manifests/
1515
COPY --from=builder /go/src/github.com/openshift/cluster-kube-apiserver-operator/cluster-kube-apiserver-operator /usr/bin/
16-
COPY --from=builder /go/src/github.com/openshift/cluster-kube-apiserver-operator/kube-apiserver-tests-ext.gz /usr/bin/cluster-kube-apiserver-operator-tests-ext.gz
16+
COPY --from=builder /go/src/github.com/openshift/cluster-kube-apiserver-operator/cluster-kube-apiserver-operator-tests-ext.gz /usr/bin/
1717

1818
COPY manifests /manifests
1919
COPY bindata/bootkube/scc-manifests /manifests

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ IMAGE_REGISTRY :=registry.svc.ci.openshift.org
1717
ENCRYPTION_PROVIDERS=aescbc aesgcm
1818
ENCRYPTION_PROVIDER?=aescbc
1919

20-
TESTS_EXT_BINARY := kube-apiserver-tests-ext
21-
TESTS_EXT_PACKAGE := ./cmd/kube-apiserver-tests-ext
20+
TESTS_EXT_BINARY := cluster-kube-apiserver-operator-tests-ext
21+
TESTS_EXT_PACKAGE := ./cmd/cluster-kube-apiserver-operator-tests-ext
2222

2323
TESTS_EXT_GIT_COMMIT := $(shell git rev-parse --short HEAD)
2424
TESTS_EXT_BUILD_DATE := $(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
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+
For further information, please refer to the documentation at:
6+
https://github.com/openshift-eng/openshift-tests-extension/blob/main/cmd/example-tests/main.go
7+
*/
8+
package main
9+
10+
import (
11+
"fmt"
12+
"os"
13+
"strings"
14+
15+
"github.com/openshift-eng/openshift-tests-extension/pkg/cmd"
16+
e "github.com/openshift-eng/openshift-tests-extension/pkg/extension"
17+
et "github.com/openshift-eng/openshift-tests-extension/pkg/extension/extensiontests"
18+
g "github.com/openshift-eng/openshift-tests-extension/pkg/ginkgo"
19+
20+
"github.com/spf13/cobra"
21+
22+
// The import below is necessary to ensure that the OAS operator tests are registered with the extension.
23+
_ "github.com/openshift/cluster-kube-apiserver-operator/test/extended"
24+
)
25+
26+
func main() {
27+
registry := e.NewRegistry()
28+
ext := e.NewExtension("openshift", "payload", "cluster-kube-apiserve-operator")
29+
30+
// Suite: conformance/parallel (fast, parallel-safe)
31+
ext.AddSuite(e.Suite{
32+
Name: "openshift/cluster-kube-apiserve-operator/conformance/parallel",
33+
Parents: []string{"openshift/conformance/parallel"},
34+
Qualifiers: []string{
35+
`!(name.contains("[Serial]") || name.contains("[Slow]"))`,
36+
},
37+
})
38+
39+
// Suite: conformance/serial (explicitly serial tests)
40+
ext.AddSuite(e.Suite{
41+
Name: "openshift/cluster-kube-apiserve-operator/conformance/serial",
42+
Parents: []string{"openshift/conformance/serial"},
43+
Qualifiers: []string{
44+
`name.contains("[Serial]")`,
45+
},
46+
})
47+
48+
// Suite: optional/slow (long-running tests)
49+
ext.AddSuite(e.Suite{
50+
Name: "openshift/cluster-kube-apiserve-operator/optional/slow",
51+
Parents: []string{"openshift/optional/slow"},
52+
Qualifiers: []string{
53+
`name.contains("[Slow]")`,
54+
},
55+
})
56+
57+
// Suite: all (includes everything)
58+
ext.AddSuite(e.Suite{
59+
Name: "openshift/cluster-kube-apiserve-operator/all",
60+
})
61+
62+
specs, err := g.BuildExtensionTestSpecsFromOpenShiftGinkgoSuite()
63+
if err != nil {
64+
panic(fmt.Sprintf("couldn't build extension test specs from ginkgo: %+v", err.Error()))
65+
}
66+
67+
// Ensure [Disruptive] tests are also [Serial]
68+
specs = specs.Walk(func(spec *et.ExtensionTestSpec) {
69+
if strings.Contains(spec.Name, "[Disruptive]") && !strings.Contains(spec.Name, "[Serial]") {
70+
spec.Name = strings.ReplaceAll(
71+
spec.Name,
72+
"[Disruptive]",
73+
"[Serial][Disruptive]",
74+
)
75+
}
76+
})
77+
78+
// Preserve original-name labels for renamed tests
79+
specs = specs.Walk(func(spec *et.ExtensionTestSpec) {
80+
for label := range spec.Labels {
81+
if strings.HasPrefix(label, "original-name:") {
82+
parts := strings.SplitN(label, "original-name:", 2)
83+
if len(parts) > 1 {
84+
spec.OriginalName = parts[1]
85+
}
86+
}
87+
}
88+
})
89+
90+
// Ignore obsolete tests
91+
ext.IgnoreObsoleteTests(
92+
// "[sig-openshift-apiserver] <test name here>",
93+
)
94+
95+
// Initialize environment before running any tests
96+
specs.AddBeforeAll(func() {
97+
// do stuff
98+
})
99+
100+
ext.AddSpecs(specs)
101+
registry.Register(ext)
102+
103+
root := &cobra.Command{
104+
Long: "Cluster OpenShift API Server Operator Tests Extension",
105+
}
106+
107+
root.AddCommand(cmd.DefaultExtensionCommands(registry)...)
108+
109+
if err := root.Execute(); err != nil {
110+
os.Exit(1)
111+
}
112+
}

cmd/kube-apiserver-tests-ext/main.go

Lines changed: 0 additions & 48 deletions
This file was deleted.

test/extended/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
o "github.com/onsi/gomega"
66
)
77

8-
var _ = g.Describe("[Jira:KAS][sig-api-machinery] sanity test", func() {
8+
var _ = g.Describe("[Jira:kube-apiserver][sig-api-machinery] sanity test", func() {
99
g.It("should always pass [Suite:openshift/cluster-kube-apiserver-operator/conformance/parallel]", func() {
1010
o.Expect(true).To(o.BeTrue())
1111
})

0 commit comments

Comments
 (0)