Skip to content
This repository was archived by the owner on Jun 26, 2024. It is now read-only.

Commit d9908ba

Browse files
committed
Fix regression: previously create test namespace is used across test runs
This fixes regression introduced in PR #848 - we should reuse created test namespace across multiple runs of acceptance tests Signed-off-by: Predrag Knezevic <[email protected]>
1 parent 9e10117 commit d9908ba

File tree

2 files changed

+42
-13
lines changed

2 files changed

+42
-13
lines changed

Makefile

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ TEST_ACCEPTANCE_START_SBO ?= local
4545
TEST_ACCEPTANCE_OUTPUT_DIR ?= $(OUTPUT_DIR)/acceptance-tests
4646
TEST_ACCEPTANCE_REPORT_DIR ?= $(OUTPUT_DIR)/acceptance-tests-report
4747
TEST_ACCEPTANCE_ARTIFACTS ?= /tmp/artifacts
48+
TEST_NAMESPACE = $(shell $(HACK_DIR)/get-test-namespace $(OUTPUT_DIR))
4849

4950
TEST_ACCEPTANCE_TAGS ?=
5051

@@ -164,30 +165,20 @@ setup-venv:
164165
$(Q)$(PYTHON_VENV_DIR)/bin/pip install --upgrade setuptools
165166
$(Q)$(PYTHON_VENV_DIR)/bin/pip install --upgrade pip
166167

167-
.PHONY: out/test-namespace
168-
# Generate namespace name for test
169-
out/test-namespace:
170-
$(Q)mkdir -p $(OUTPUT_DIR)
171-
@echo -n "test-namespace-$(shell uuidgen | tr '[:upper:]' '[:lower:]' | head -c 8)" > $(OUTPUT_DIR)/test-namespace
172-
173-
.PHONY: get-test-namespace
174-
get-test-namespace: out/test-namespace
175-
$(eval TEST_NAMESPACE := $(shell cat $(OUTPUT_DIR)/test-namespace))
176-
177168
# Testing setup
178169
.PHONY: deploy-test-3rd-party-crds
179-
deploy-test-3rd-party-crds: get-test-namespace
170+
deploy-test-3rd-party-crds:
180171
$(Q)kubectl --namespace $(TEST_NAMESPACE) apply -f ./test/third-party-crds/
181172

182173
.PHONY: create-test-namespace
183174
create-test-namespace:
184-
$(Q)kubectl create namespace $(TEST_NAMESPACE)
175+
$(Q)kubectl get namespace $(TEST_NAMESPACE) || kubectl create namespace $(TEST_NAMESPACE)
185176

186177
.PHONY: test-setup
187178
test-setup: test-cleanup create-test-namespace deploy-test-3rd-party-crds
188179

189180
.PHONY: test-cleanup
190-
test-cleanup: get-test-namespace
181+
test-cleanup:
191182
$(Q)-TEST_NAMESPACE=$(TEST_NAMESPACE) $(HACK_DIR)/test-cleanup.sh
192183

193184
.PHONY: deploy-rbac

hack/get-test-namespace

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env bash
2+
3+
OUTPUT_DIR=$1
4+
NS_FILE=${OUTPUT_DIR}/test-namespace
5+
6+
# https://gist.github.com/markusfisch/6110640
7+
uuid()
8+
{
9+
local N B C='89ab'
10+
11+
for (( N=0; N < 16; ++N ))
12+
do
13+
B=$(( $RANDOM%256 ))
14+
15+
case $N in
16+
6)
17+
printf '4%x' $(( B%16 ))
18+
;;
19+
8)
20+
printf '%c%x' ${C:$RANDOM%${#C}:1} $(( B%16 ))
21+
;;
22+
3 | 5 | 7 | 9)
23+
printf '%02x-' $B
24+
;;
25+
*)
26+
printf '%02x' $B
27+
;;
28+
esac
29+
done
30+
31+
echo
32+
}
33+
34+
mkdir -p "$OUTPUT_DIR"
35+
36+
[ -f "$NS_FILE" ] || echo "test-namespace-$(uuid | cut -d '-' -f 5)" > "$NS_FILE"
37+
38+
cat "$NS_FILE"

0 commit comments

Comments
 (0)