Skip to content

Commit fed0ad5

Browse files
authored
🐛 Client go version metrics endpoint test (#1821)
* Adds TEST_FILTER env var to e2e run Signed-off-by: Brett Tofel <[email protected]> * Rewrite metrics endpoint test to use client-go test/utils.go deleted because no used funcs Signed-off-by: Brett Tofel <[email protected]> * Rm pointer helpers, use k8s ones. Signed-off-by: Brett Tofel <[email protected]> * Rename main test client to globalClient (de-shadow "c") Signed-off-by: Brett Tofel <[email protected]> * Use apierrors, move deferred cleanup, less nesting Signed-off-by: Brett Tofel <[email protected]> * Rename main test cfg->globalConfig de-shadow "cfg" Signed-off-by: Brett Tofel <[email protected]> * Allow test-unit filter on package and test Have to have package filter too, to not run all the unit tests due to UNIT_TEST_DIRS Signed-off-by: Brett Tofel <[email protected]> * Drop UNIT_TEST_DIRS for TEST_PKGS + TEST_FILTER Signed-off-by: Brett Tofel <[email protected]> * Remove ENVTEST_VERSION dupe in Makefile Signed-off-by: Brett Tofel <[email protected]> --------- Signed-off-by: Brett Tofel <[email protected]>
1 parent 7fc18c6 commit fed0ad5

File tree

5 files changed

+361
-270
lines changed

5 files changed

+361
-270
lines changed

Diff for: Makefile

+7-3
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ test: manifests generate fmt lint test-unit test-e2e #HELP Run all tests.
192192

193193
.PHONY: e2e
194194
e2e: #EXHELP Run the e2e tests.
195-
go test -count=1 -v ./test/e2e/...
195+
go test -count=1 -v -run "$(if $(TEST_FILTER),$(TEST_FILTER),.)" ./test/e2e/...
196196

197197
E2E_REGISTRY_NAME := docker-registry
198198
E2E_REGISTRY_NAMESPACE := operator-controller-e2e
@@ -208,7 +208,10 @@ test-ext-dev-e2e: $(OPERATOR_SDK) $(KUSTOMIZE) $(KIND) #HELP Run extension creat
208208
test/extension-developer-e2e/setup.sh $(OPERATOR_SDK) $(CONTAINER_RUNTIME) $(KUSTOMIZE) $(KIND) $(KIND_CLUSTER_NAME) $(E2E_REGISTRY_NAMESPACE)
209209
go test -count=1 -v ./test/extension-developer-e2e/...
210210

211-
UNIT_TEST_DIRS := $(shell go list ./... | grep -v /test/)
211+
# Define TEST_PKGS to be either user-specified or a default set of packages:
212+
ifeq ($(origin TEST_PKGS), undefined)
213+
TEST_PKGS := $(shell go list ./... | grep -v /test/)
214+
endif
212215
COVERAGE_UNIT_DIR := $(ROOT_DIR)/coverage/unit
213216

214217
.PHONY: envtest-k8s-bins #HELP Uses setup-envtest to download and install the binaries required to run ENVTEST-test based locally at the project/bin directory.
@@ -224,7 +227,8 @@ test-unit: $(SETUP_ENVTEST) envtest-k8s-bins #HELP Run the unit tests
224227
-tags '$(GO_BUILD_TAGS)' \
225228
-cover -coverprofile ${ROOT_DIR}/coverage/unit.out \
226229
-count=1 -race -short \
227-
$(UNIT_TEST_DIRS) \
230+
-run "$(if $(TEST_FILTER),$(TEST_FILTER),.)" \
231+
$(TEST_PKGS) \
228232
-test.gocoverdir=$(COVERAGE_UNIT_DIR)
229233

230234
.PHONY: image-registry

0 commit comments

Comments
 (0)