Skip to content

Commit 9bdfbf6

Browse files
Merge pull request #138 from wangke19/test-extd
CNTRLPLANE-1259: set up openshift-tests-extension and add a sanity test
2 parents 85499f4 + ab7b7bd commit 9bdfbf6

File tree

475 files changed

+227441
-20535
lines changed

Some content is hidden

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

475 files changed

+227441
-20535
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@
1212
*.out
1313

1414
/oauth-apiserver
15+
/oauth-apiserver-tests-ext

Makefile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,19 @@ include $(addprefix ./vendor/github.com/openshift/build-machinery-go/make/, \
99
)
1010

1111
IMAGE_REGISTRY?=registry.svc.ci.openshift.org
12+
# -------------------------------------------------------------------
13+
# OpenShift Tests Extension (OpenShift Oauth APIServer)
14+
# -------------------------------------------------------------------
15+
TESTS_EXT_BINARY := oauth-apiserver-tests-ext
16+
TESTS_EXT_PACKAGE := ./cmd/oauth-apiserver-tests-ext
17+
18+
TESTS_EXT_GIT_COMMIT := $(shell git rev-parse --short HEAD)
19+
TESTS_EXT_BUILD_DATE := $(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
20+
TESTS_EXT_GIT_TREE_STATE := $(shell if git diff --quiet; then echo clean; else echo dirty; fi)
21+
22+
TESTS_EXT_LDFLAGS := -X 'github.com/openshift-eng/openshift-tests-extension/pkg/version.CommitFromGit=$(TESTS_EXT_GIT_COMMIT)' \
23+
-X 'github.com/openshift-eng/openshift-tests-extension/pkg/version.BuildDate=$(TESTS_EXT_BUILD_DATE)' \
24+
-X 'github.com/openshift-eng/openshift-tests-extension/pkg/version.GitTreeState=$(TESTS_EXT_GIT_TREE_STATE)'
1225

1326
# This will call a macro called "build-image" which will generate image specific targets based on the parameters:
1427
# $0 - macro name
@@ -54,3 +67,21 @@ run-e2e-test: GO_TEST_FLAGS += ^${WHAT}$$
5467
run-e2e-test: GO_TEST_PACKAGES += -count 1
5568
run-e2e-test: test-unit
5669
.PHONY: run-e2e-test
70+
71+
# -------------------------------------------------------------------
72+
# Build binary with metadata (CI-compliant)
73+
# -------------------------------------------------------------------
74+
.PHONY: tests-ext-build
75+
tests-ext-build:
76+
GOOS=$(GOOS) GOARCH=$(GOARCH) GO_COMPLIANCE_POLICY=exempt_all CGO_ENABLED=0 \
77+
go build -o $(TESTS_EXT_BINARY) -ldflags "$(TESTS_EXT_LDFLAGS)" $(TESTS_EXT_PACKAGE)
78+
79+
# -------------------------------------------------------------------
80+
# Run "update" and strip env-specific metadata
81+
# -------------------------------------------------------------------
82+
.PHONY: tests-ext-update
83+
tests-ext-update: tests-ext-build
84+
./$(TESTS_EXT_BINARY) update
85+
for f in .openshift-tests-extension/*.json; do \
86+
jq 'map(del(.codeLocations))' "$f" > tmpp && mv tmpp "$f"; \
87+
done

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

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 OpenShift OAuth API Server tests extension for OpenShift.
3+
It registers the OpenShift OAuth API Server 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 Oauth APIServer tests are registered with the extension.
23+
_ "github.com/openshift/oauth-apiserver/test/extended"
24+
)
25+
26+
func main() {
27+
registry := e.NewRegistry()
28+
ext := e.NewExtension("openshift", "payload", "oauth-apiserver")
29+
30+
// Suite: conformance/parallel (fast, parallel-safe)
31+
ext.AddSuite(e.Suite{
32+
Name: "openshift/oauth-apiserver/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/oauth-apiserver/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/oauth-apiserver/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/oauth-apiserver/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: "OpenShift OAuth API Server Tests Extension",
105+
}
106+
107+
root.AddCommand(cmd.DefaultExtensionCommands(registry)...)
108+
109+
if err := root.Execute(); err != nil {
110+
os.Exit(1)
111+
}
112+
}

go.mod

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@ go 1.24.0
55
require (
66
github.com/MakeNowJust/heredoc v1.0.0
77
github.com/google/btree v1.1.2
8-
github.com/google/go-cmp v0.6.0
8+
github.com/google/go-cmp v0.7.0
99
github.com/google/gofuzz v1.2.0
1010
github.com/google/uuid v1.6.0
1111
github.com/jteeuwen/go-bindata v3.0.8-0.20151023091102-a0ff2567cfb7+incompatible
12+
github.com/onsi/ginkgo/v2 v2.23.4
13+
github.com/onsi/gomega v1.38.0
14+
github.com/openshift-eng/openshift-tests-extension v0.0.0-20250804142706-7b3ab438a292
1215
github.com/openshift/api v0.0.0-20250425163235-9b80d67473bc
1316
github.com/openshift/apiserver-library-go v0.0.0-20241021160823-f6d544efa1ab
1417
github.com/openshift/build-machinery-go v0.0.0-20240613134303-8359781da660
@@ -54,12 +57,13 @@ require (
5457
github.com/go-openapi/jsonpointer v0.21.0 // indirect
5558
github.com/go-openapi/jsonreference v0.20.2 // indirect
5659
github.com/go-openapi/swag v0.23.0 // indirect
60+
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
5761
github.com/gogo/protobuf v1.3.2 // indirect
5862
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
5963
github.com/golang/protobuf v1.5.4 // indirect
6064
github.com/google/cel-go v0.22.0 // indirect
6165
github.com/google/gnostic-models v0.6.8 // indirect
62-
github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db // indirect
66+
github.com/google/pprof v0.0.0-20250403155104-27863c87afa6 // indirect
6367
github.com/gorilla/websocket v1.5.0 // indirect
6468
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect
6569
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
@@ -105,22 +109,22 @@ require (
105109
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
106110
go.uber.org/multierr v1.11.0 // indirect
107111
go.uber.org/zap v1.27.0 // indirect
108-
golang.org/x/crypto v0.36.0 // indirect
112+
golang.org/x/crypto v0.39.0 // indirect
109113
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
110-
golang.org/x/mod v0.21.0 // indirect
111-
golang.org/x/net v0.37.0 // indirect
114+
golang.org/x/mod v0.25.0 // indirect
115+
golang.org/x/net v0.41.0 // indirect
112116
golang.org/x/oauth2 v0.23.0 // indirect
113-
golang.org/x/sync v0.12.0 // indirect
114-
golang.org/x/sys v0.31.0 // indirect
115-
golang.org/x/term v0.30.0 // indirect
116-
golang.org/x/text v0.23.0 // indirect
117+
golang.org/x/sync v0.15.0 // indirect
118+
golang.org/x/sys v0.33.0 // indirect
119+
golang.org/x/term v0.32.0 // indirect
120+
golang.org/x/text v0.26.0 // indirect
117121
golang.org/x/time v0.7.0 // indirect
118-
golang.org/x/tools v0.26.0 // indirect
122+
golang.org/x/tools v0.33.0 // indirect
119123
google.golang.org/genproto v0.0.0-20240123012728-ef4313101c80 // indirect
120124
google.golang.org/genproto/googleapis/api v0.0.0-20240826202546-f6391c0de4c7 // indirect
121-
google.golang.org/genproto/googleapis/rpc v0.0.0-20240826202546-f6391c0de4c7 // indirect
125+
google.golang.org/genproto/googleapis/rpc v0.0.0-20240924160255-9d4c2d233b61 // indirect
122126
google.golang.org/grpc v1.65.0 // indirect
123-
google.golang.org/protobuf v1.35.1 // indirect
127+
google.golang.org/protobuf v1.36.6 // indirect
124128
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
125129
gopkg.in/inf.v0 v0.9.1 // indirect
126130
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
@@ -134,6 +138,7 @@ require (
134138
)
135139

136140
replace (
141+
github.com/onsi/ginkgo/v2 => github.com/openshift/onsi-ginkgo/v2 v2.6.1-0.20241205171354-8006f302fd12 // This replace is required for we use the OCP fork of Ginkgo
137142
k8s.io/api => k8s.io/api v0.32.3
138143
k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.32.3
139144
k8s.io/apimachinery => k8s.io/apimachinery v0.32.3

0 commit comments

Comments
 (0)