Skip to content

Commit dd7bd0d

Browse files
Merge pull request #1953 from gangwgr/test-module-infra-only
CNTRLPLANE-1721:Create separate Go module for test extension
2 parents 151f2be + 5af83d1 commit dd7bd0d

File tree

304 files changed

+495
-200547
lines changed

Some content is hidden

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

304 files changed

+495
-200547
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/cluster-kube-apiserver-operator
2-
/cluster-kube-apiserver-operator-tests-ext
2+
/test/extended/tests-extension/bin/
3+
/bin/
34
.idea/
45
/_output/
56
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 cluster-kube-apiserver-operator-tests-ext
7+
&& gzip test/extended/tests-extension/bin/cluster-kube-apiserver-operator-tests-ext
88

99
FROM registry.ci.openshift.org/ocp/4.21: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/cluster-kube-apiserver-operator-tests-ext.gz /usr/bin/
16+
COPY --from=builder /go/src/github.com/openshift/cluster-kube-apiserver-operator/test/extended/tests-extension/bin/cluster-kube-apiserver-operator-tests-ext.gz /usr/bin/
1717

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

Makefile

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ ENCRYPTION_PROVIDERS=aescbc aesgcm
1818
ENCRYPTION_PROVIDER?=aescbc
1919

2020
TESTS_EXT_BINARY := cluster-kube-apiserver-operator-tests-ext
21-
TESTS_EXT_PACKAGE := ./cmd/cluster-kube-apiserver-operator-tests-ext
21+
TESTS_EXT_DIR := ./test/extended/tests-extension
22+
TESTS_EXT_PACKAGE := ./cmd
2223

2324
TESTS_EXT_GIT_COMMIT := $(shell git rev-parse --short HEAD)
2425
TESTS_EXT_BUILD_DATE := $(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
@@ -101,18 +102,28 @@ test-e2e-sno-disruptive: test-unit
101102
# -------------------------------------------------------------------
102103
.PHONY: tests-ext-build
103104
tests-ext-build:
104-
GOOS=$(GOOS) GOARCH=$(GOARCH) GO_COMPLIANCE_POLICY=exempt_all CGO_ENABLED=0 \
105-
go build -o $(TESTS_EXT_BINARY) -ldflags "$(TESTS_EXT_LDFLAGS)" $(TESTS_EXT_PACKAGE)
105+
$(MAKE) -C test/extended/tests-extension build
106106

107107
# -------------------------------------------------------------------
108108
# Run "update" and strip env-specific metadata
109109
# -------------------------------------------------------------------
110110
.PHONY: tests-ext-update
111-
tests-ext-update: tests-ext-build
112-
./$(TESTS_EXT_BINARY) update
113-
for f in .openshift-tests-extension/*.json; do \
114-
jq 'map(del(.codeLocations))' "$$f" > tmpp && mv tmpp "$$f"; \
115-
done
111+
tests-ext-update:
112+
$(MAKE) -C test/extended/tests-extension build-update
113+
114+
# -------------------------------------------------------------------
115+
# Clean test extension binaries
116+
# -------------------------------------------------------------------
117+
.PHONY: tests-ext-clean
118+
tests-ext-clean:
119+
$(MAKE) -C $(TESTS_EXT_DIR) clean
120+
121+
# -------------------------------------------------------------------
122+
# Run test suite
123+
# -------------------------------------------------------------------
124+
.PHONY: run-suite
125+
run-suite:
126+
$(MAKE) -C $(TESTS_EXT_DIR) run-suite SUITE=$(SUITE) JUNIT_DIR=$(JUNIT_DIR)
116127

117128
# -------------------------------------------------------------------
118129
# Run go test on ./test/extended/... with proper flags
@@ -126,7 +137,7 @@ test-extended: test-unit
126137
test-extended:
127138
GO111MODULE=on go test $(GO_TEST_FLAGS) $(GO_TEST_PACKAGES)
128139

129-
clean:
140+
clean: tests-ext-clean
130141
$(RM) ./cluster-kube-apiserver-operator
131142
.PHONY: clean
132143

go.mod

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ require (
1212
github.com/google/go-cmp v0.7.0
1313
github.com/imdario/mergo v0.3.8
1414
github.com/miekg/dns v1.1.61
15-
github.com/onsi/ginkgo/v2 v2.22.0
16-
github.com/onsi/gomega v1.36.1
17-
github.com/openshift-eng/openshift-tests-extension v0.0.0-20250804142706-7b3ab438a292
1815
github.com/openshift/api v0.0.0-20251015095338-264e80a2b6e7
1916
github.com/openshift/build-machinery-go v0.0.0-20250530140348-dc5b2804eeee
2017
github.com/openshift/client-go v0.0.0-20251015124057-db0dee36e235
@@ -57,7 +54,6 @@ require (
5754
github.com/go-openapi/jsonpointer v0.21.0 // indirect
5855
github.com/go-openapi/jsonreference v0.20.2 // indirect
5956
github.com/go-openapi/swag v0.23.0 // indirect
60-
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
6157
github.com/gogo/protobuf v1.3.2 // indirect
6258
github.com/golang/protobuf v1.5.4 // indirect
6359
github.com/gonum/blas v0.0.0-20181208220705-f22b278b28ac // indirect
@@ -133,5 +129,3 @@ require (
133129
sigs.k8s.io/structured-merge-diff/v6 v6.3.0 // indirect
134130
sigs.k8s.io/yaml v1.6.0 // indirect
135131
)
136-
137-
replace github.com/onsi/ginkgo/v2 => github.com/openshift/onsi-ginkgo/v2 v2.6.1-0.20241205171354-8006f302fd12

go.sum

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ github.com/go-openapi/jsonreference v0.20.2/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En
6767
github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14=
6868
github.com/go-openapi/swag v0.23.0 h1:vsEVJDUo2hPJ2tu0/Xc+4noaxyEffXNIs3cOULZ+GrE=
6969
github.com/go-openapi/swag v0.23.0/go.mod h1:esZ8ITTYEsH1V2trKHjAN8Ai7xHb8RV+YSZ577vPjgQ=
70+
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI=
7071
github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI=
7172
github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8=
7273
github.com/gobwas/httphead v0.1.0/go.mod h1:O/RXo79gxV8G+RqlR/otEwx4Q36zl9rqC5u12GKvMCM=
@@ -155,10 +156,10 @@ github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee h1:W5t00kpgFd
155156
github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
156157
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
157158
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
158-
github.com/onsi/gomega v1.36.1 h1:bJDPBO7ibjxcbHMgSCoo4Yj18UWbKDlLwX1x9sybDcw=
159-
github.com/onsi/gomega v1.36.1/go.mod h1:PvZbdDc8J6XJEpDK4HCuRBm8a6Fzp9/DmhC9C7yFlog=
160-
github.com/openshift-eng/openshift-tests-extension v0.0.0-20250804142706-7b3ab438a292 h1:3athg6KQ+TaNfW4BWZDlGFt1ImSZEJWgzXtPC1VPITI=
161-
github.com/openshift-eng/openshift-tests-extension v0.0.0-20250804142706-7b3ab438a292/go.mod h1:6gkP5f2HL0meusT0Aim8icAspcD1cG055xxBZ9yC68M=
159+
github.com/onsi/ginkgo/v2 v2.21.0 h1:7rg/4f3rB88pb5obDgNZrNHrQ4e6WpjonchcpuBRnZM=
160+
github.com/onsi/ginkgo/v2 v2.21.0/go.mod h1:7Du3c42kxCUegi0IImZ1wUQzMBVecgIHjR1C+NkhLQo=
161+
github.com/onsi/gomega v1.35.1 h1:Cwbd75ZBPxFSuZ6T+rN/WCb/gOc6YgFBXLlZLhC7Ds4=
162+
github.com/onsi/gomega v1.35.1/go.mod h1:PvZbdDc8J6XJEpDK4HCuRBm8a6Fzp9/DmhC9C7yFlog=
162163
github.com/openshift/api v0.0.0-20251015095338-264e80a2b6e7 h1:Ot2fbEEPmF3WlPQkyEW/bUCV38GMugH/UmZvxpWceNc=
163164
github.com/openshift/api v0.0.0-20251015095338-264e80a2b6e7/go.mod h1:d5uzF0YN2nQQFA0jIEWzzOZ+edmo6wzlGLvx5Fhz4uY=
164165
github.com/openshift/build-machinery-go v0.0.0-20250530140348-dc5b2804eeee h1:+Sp5GGnjHDhT/a/nQ1xdp43UscBMr7G5wxsYotyhzJ4=
@@ -167,8 +168,6 @@ github.com/openshift/client-go v0.0.0-20251015124057-db0dee36e235 h1:9JBeIXmnHlp
167168
github.com/openshift/client-go v0.0.0-20251015124057-db0dee36e235/go.mod h1:L49W6pfrZkfOE5iC1PqEkuLkXG4W0BX4w8b+L2Bv7fM=
168169
github.com/openshift/library-go v0.0.0-20251015151611-6fc7a74b67c5 h1:bANtDc8SgetSK4nQehf59x3+H9FqVJCprgjs49/OTg0=
169170
github.com/openshift/library-go v0.0.0-20251015151611-6fc7a74b67c5/go.mod h1:OlFFws1AO51uzfc48MsStGE4SFMWlMZD0+f5a/zCtKI=
170-
github.com/openshift/onsi-ginkgo/v2 v2.6.1-0.20241205171354-8006f302fd12 h1:AKx/w1qpS8We43bsRgf8Nll3CGlDHpr/WAXvuedTNZI=
171-
github.com/openshift/onsi-ginkgo/v2 v2.6.1-0.20241205171354-8006f302fd12/go.mod h1:7Du3c42kxCUegi0IImZ1wUQzMBVecgIHjR1C+NkhLQo=
172171
github.com/orisano/pixelmatch v0.0.0-20220722002657-fb0b55479cde/go.mod h1:nZgzbfBr3hhjoZnS66nKrHmduYNpc34ny7RK4z5/HM0=
173172
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
174173
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Get the directory where this Makefile is, so we can use it below for including
2+
DIR := $(strip $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))))
3+
4+
# Definitions for the extended tests
5+
GO_PKG_NAME := github.com/openshift-eng/openshift-tests-extension
6+
7+
GIT_COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo 'unknown')
8+
BUILD_DATE := $(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
9+
GIT_TREE_STATE := $(shell if git rev-parse --git-dir > /dev/null 2>&1; then if git diff --quiet; then echo clean; else echo dirty; fi; else echo unknown; fi)
10+
11+
LDFLAGS := -X '$(GO_PKG_NAME)/pkg/version.CommitFromGit=$(GIT_COMMIT)' \
12+
-X '$(GO_PKG_NAME)/pkg/version.BuildDate=$(BUILD_DATE)' \
13+
-X '$(GO_PKG_NAME)/pkg/version.GitTreeState=$(GIT_TREE_STATE)'
14+
15+
METADATA := $(shell pwd)/.openshift-tests-extension
16+
17+
TOOLS_BIN_DIR := $(CURDIR)/bin
18+
BINARY_NAME := cluster-kube-apiserver-operator-tests-ext
19+
20+
.PHONY: help
21+
help: #HELP Display essential help.
22+
@awk 'BEGIN {FS = ":[^#]*#HELP"; printf "\nUsage:\n make \033[36m<target>\033[0m\n\n"} /^[a-zA-Z_0-9-]+:.*#HELP / { printf " \033[36m%-17s\033[0m %s\n", $$1, $$2 } ' $(MAKEFILE_LIST)
23+
24+
#SECTION Development
25+
.PHONY: verify #HELP To verify the code
26+
verify: tidy fmt vet
27+
28+
.PHONY: tidy #HELP Run go mod tidy.
29+
tidy:
30+
go mod tidy
31+
32+
.PHONY: fmt
33+
fmt: #HELP Run go fmt against code.
34+
go fmt ./...
35+
36+
.PHONY: vet
37+
vet: #HELP Run go vet against code.
38+
go vet ./...
39+
40+
.PHONY: build
41+
build: #HELP Build the extended tests binary
42+
@mkdir -p $(TOOLS_BIN_DIR)
43+
GO_COMPLIANCE_POLICY="exempt_all" CGO_ENABLED=0 go build -mod=mod -ldflags "$(LDFLAGS)" -o $(TOOLS_BIN_DIR)/$(BINARY_NAME) ./cmd/...
44+
45+
.PHONY: update-metadata
46+
update-metadata: build #HELP Build and run 'update-metadata' to generate test metadata
47+
$(TOOLS_BIN_DIR)/$(BINARY_NAME) update
48+
$(MAKE) clean-metadata
49+
50+
.PHONY: build-update
51+
build-update: build update-metadata #HELP Build and update metadata and sanitize output
52+
53+
.PHONY: clean
54+
clean: #HELP Remove build artifacts
55+
rm -rf $(TOOLS_BIN_DIR)
56+
57+
#SECTION Metadata
58+
59+
.PHONY: list-test-names
60+
list-test-names: build #HELP Show current full test names
61+
@$(TOOLS_BIN_DIR)/$(BINARY_NAME) list -o names
62+
63+
.PHONY: run-suite
64+
run-suite: build #HELP Run a test suite (usage: make run-suite SUITE=<suite-name> [JUNIT_DIR=<dir>])
65+
@if [ -z "$(SUITE)" ]; then \
66+
echo "Error: SUITE variable is required. Usage: make run-suite SUITE=<suite-name> [JUNIT_DIR=<dir>]"; \
67+
exit 1; \
68+
fi
69+
@JUNIT_ARG=""; \
70+
if [ -n "$(JUNIT_DIR)" ]; then \
71+
mkdir -p $(JUNIT_DIR); \
72+
JUNIT_ARG="--junit-path=$(JUNIT_DIR)/junit.xml"; \
73+
fi; \
74+
$(TOOLS_BIN_DIR)/$(BINARY_NAME) run-suite $(SUITE) $$JUNIT_ARG
75+
76+
.PHONY: clean-metadata
77+
clean-metadata: #HELP Remove 'codeLocations' from metadata JSON
78+
@echo "Cleaning metadata (removing codeLocations)..."
79+
@for f in $(METADATA)/*.json; do \
80+
jq 'map(del(.codeLocations))' "$$f" > "$$f.tmp" && mv "$$f.tmp" "$$f"; \
81+
done
82+
83+
.PHONY: verify-metadata #HELP To verify that the metadata was properly updated
84+
verify-metadata: update-metadata
85+
@if ! git diff --exit-code $(METADATA); then \
86+
echo "ERROR: Metadata is out of date. Please run 'make build-update' and commit the result."; \
87+
exit 1; \
88+
fi
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
reviewers:
2+
- p0lyn0mial
3+
- tkashem
4+
- benluddy
5+
- xingxingxia
6+
- wangke19
7+
- gangwgr
8+
- dgrisonnet
9+
- dinhxuanvu
10+
approvers:
11+
- p0lyn0mial
12+
- tkashem
13+
- benluddy
14+
- xingxingxia
15+
- wangke19
16+
- gangwgr
17+
- dgrisonnet
18+
- dinhxuanvu
19+
component: "Kube APIServer"
20+
subcomponent: cluster-kube-apiserver-operator

0 commit comments

Comments
 (0)