Skip to content

Commit db7055b

Browse files
committed
Create separate Go module for test extension
This commit isolates test dependencies from production code by creating a separate Go module for the test extension at test/extended/tests-extension/. Key changes: - Move test files to test/extended/tests-extension/ directory structure - Create separate go.mod for test dependencies (ginkgo, gomega, openshift-tests-extension) - Remove test dependencies from root go.mod (~XXX lines removed from vendor) - Update root Makefile to use delegation pattern for test extension targets - Update Dockerfile.rhel7 paths to reference new binary location - Update .gitignore to ignore test/extended/tests-extension/bin/ Benefits: - Smaller production images (test dependencies not included in production builds) - Faster builds (production builds don't need to vendor test dependencies) - Cleaner dependency management (test dependencies isolated) - Better CI performance (smaller images, faster pulls, less storage) Related: Similar to openshift/openshift-apiserver#571
1 parent f7a23c8 commit db7055b

File tree

303 files changed

+404
-200695
lines changed

Some content is hidden

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

303 files changed

+404
-200695
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/cluster-kube-controller-manager-operator
2-
/cluster-kube-controller-manager-operator-tests-ext
32
.idea/
43
_output
54
telepresence.log
6-
.openshift-tests-extension/openshift_payload_*.json
5+
/test/extended/tests-extension/bin/
76

Dockerfile.rhel7

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
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 \
6-
&& gzip cluster-kube-controller-manager-operator-tests-ext
4+
RUN make build --warn-undefined-variables \
5+
&& make tests-ext-build \
6+
&& gzip test/extended/tests-extension/bin/cluster-kube-controller-manager-operator-tests-ext
77

88
FROM registry.ci.openshift.org/ocp/4.21:base-rhel9
99
RUN mkdir -p /usr/share/bootkube/manifests/bootstrap-manifests/ /usr/share/bootkube/manifests/config/ /usr/share/bootkube/manifests/manifests/
1010
COPY --from=builder /go/src/github.com/openshift/cluster-kube-controller-manager-operator/bindata/bootkube/bootstrap-manifests /usr/share/bootkube/manifests/bootstrap-manifests/
1111
COPY --from=builder /go/src/github.com/openshift/cluster-kube-controller-manager-operator/bindata/bootkube/config /usr/share/bootkube/manifests/config/
1212
COPY --from=builder /go/src/github.com/openshift/cluster-kube-controller-manager-operator/bindata/bootkube/manifests /usr/share/bootkube/manifests/manifests/
1313
COPY --from=builder /go/src/github.com/openshift/cluster-kube-controller-manager-operator/cluster-kube-controller-manager-operator /usr/bin/
14-
COPY --from=builder /go/src/github.com/openshift/cluster-kube-controller-manager-operator/cluster-kube-controller-manager-operator-tests-ext.gz /usr/bin/
14+
COPY --from=builder /go/src/github.com/openshift/cluster-kube-controller-manager-operator/test/extended/tests-extension/bin/cluster-kube-controller-manager-operator-tests-ext.gz /usr/bin/
1515
COPY manifests /manifests
1616
LABEL io.openshift.release.operator true

go.mod

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ 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
129
github.com/openshift/api v0.0.0-20251015095338-264e80a2b6e7
1310
github.com/openshift/build-machinery-go v0.0.0-20250530140348-dc5b2804eeee
1411
github.com/openshift/client-go v0.0.0-20251015124057-db0dee36e235
@@ -49,7 +46,6 @@ require (
4946
github.com/go-openapi/jsonpointer v0.21.0 // indirect
5047
github.com/go-openapi/jsonreference v0.20.2 // indirect
5148
github.com/go-openapi/swag v0.23.0 // indirect
52-
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
5349
github.com/gogo/protobuf v1.3.2 // indirect
5450
github.com/golang/protobuf v1.5.4 // indirect
5551
github.com/gonum/blas v0.0.0-20181208220705-f22b278b28ac // indirect
@@ -128,6 +124,3 @@ require (
128124
sigs.k8s.io/structured-merge-diff/v6 v6.3.0 // indirect
129125
sigs.k8s.io/yaml v1.6.0 // indirect
130126
)
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: 5 additions & 6 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=
@@ -152,10 +153,10 @@ 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=
159160
github.com/openshift/api v0.0.0-20251015095338-264e80a2b6e7 h1:Ot2fbEEPmF3WlPQkyEW/bUCV38GMugH/UmZvxpWceNc=
160161
github.com/openshift/api v0.0.0-20251015095338-264e80a2b6e7/go.mod h1:d5uzF0YN2nQQFA0jIEWzzOZ+edmo6wzlGLvx5Fhz4uY=
161162
github.com/openshift/build-machinery-go v0.0.0-20250530140348-dc5b2804eeee h1:+Sp5GGnjHDhT/a/nQ1xdp43UscBMr7G5wxsYotyhzJ4=
@@ -164,8 +165,6 @@ github.com/openshift/client-go v0.0.0-20251015124057-db0dee36e235 h1:9JBeIXmnHlp
164165
github.com/openshift/client-go v0.0.0-20251015124057-db0dee36e235/go.mod h1:L49W6pfrZkfOE5iC1PqEkuLkXG4W0BX4w8b+L2Bv7fM=
165166
github.com/openshift/library-go v0.0.0-20251015151611-6fc7a74b67c5 h1:bANtDc8SgetSK4nQehf59x3+H9FqVJCprgjs49/OTg0=
166167
github.com/openshift/library-go v0.0.0-20251015151611-6fc7a74b67c5/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=
169168
github.com/orisano/pixelmatch v0.0.0-20220722002657-fb0b55479cde/go.mod h1:nZgzbfBr3hhjoZnS66nKrHmduYNpc34ny7RK4z5/HM0=
170169
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
171170
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=

test/extended/README.md

Lines changed: 0 additions & 184 deletions
This file was deleted.
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
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-controller-manager-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 To tidy the go.mod and go.sum files
29+
tidy:
30+
go mod tidy
31+
32+
.PHONY: fmt #HELP To run go fmt
33+
fmt:
34+
go fmt ./...
35+
36+
.PHONY: vet #HELP To run go vet
37+
vet:
38+
go vet ./...
39+
40+
#SECTION Build
41+
.PHONY: build
42+
build: #HELP Build the extended tests binary
43+
@mkdir -p $(TOOLS_BIN_DIR)
44+
GO_COMPLIANCE_POLICY="exempt_all" CGO_ENABLED=0 go build -mod=mod -ldflags "$(LDFLAGS)" -o $(TOOLS_BIN_DIR)/$(BINARY_NAME) ./cmd/...
45+
46+
.PHONY: update-metadata
47+
update-metadata: build #HELP Build and run 'update-metadata' to generate test metadata
48+
$(TOOLS_BIN_DIR)/$(BINARY_NAME) update --output-dir=$(METADATA)
49+
50+
.PHONY: build-update
51+
build-update: build #HELP Build and update test metadata (strips machine-specific codeLocations)
52+
$(TOOLS_BIN_DIR)/$(BINARY_NAME) update --output-dir=$(METADATA)
53+
for f in $(METADATA)/*.json; do \
54+
jq 'map(del(.codeLocations))' "$$f" > tmpp && mv tmpp "$$f"; \
55+
done
56+
57+
.PHONY: clean
58+
clean: #HELP Remove the bin directory
59+
rm -rf $(TOOLS_BIN_DIR)
60+
61+
.PHONY: run-suite
62+
run-suite: build #HELP Run a test suite (usage: make run-suite SUITE=<suite-name> [JUNIT_DIR=<dir>])
63+
@if [ -z "$(SUITE)" ]; then \
64+
echo "Error: SUITE variable is required. Usage: make run-suite SUITE=<suite-name> [JUNIT_DIR=<dir>]"; \
65+
exit 1; \
66+
fi
67+
@JUNIT_ARG=""; \
68+
if [ -n "$(JUNIT_DIR)" ]; then \
69+
mkdir -p $(JUNIT_DIR); \
70+
JUNIT_ARG="--junit-path=$(JUNIT_DIR)/junit.xml"; \
71+
fi; \
72+
$(TOOLS_BIN_DIR)/$(BINARY_NAME) run-suite $(SUITE) $$JUNIT_ARG
73+
74+
.PHONY: list-test-names
75+
list-test-names: build #HELP List all test names
76+
$(TOOLS_BIN_DIR)/$(BINARY_NAME) list
77+
78+
.PHONY: verify-metadata
79+
verify-metadata: build #HELP Verify metadata is up to date
80+
@echo "Verifying metadata is up to date..."
81+
@$(TOOLS_BIN_DIR)/$(BINARY_NAME) update --output-dir=$(METADATA) --dry-run || \
82+
(echo "Error: metadata is not up to date. Run 'make build-update' to update it."; exit 1)
83+
@echo "Metadata is up to date."

0 commit comments

Comments
 (0)