Skip to content

Commit c5979ee

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

File tree

2 files changed

+44
-10
lines changed

2 files changed

+44
-10
lines changed

Makefile

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -164,24 +164,20 @@ setup-venv:
164164
$(Q)$(PYTHON_VENV_DIR)/bin/pip install --upgrade setuptools
165165
$(Q)$(PYTHON_VENV_DIR)/bin/pip install --upgrade pip
166166

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-
173167
.PHONY: get-test-namespace
174-
get-test-namespace: out/test-namespace
175-
$(eval TEST_NAMESPACE := $(shell cat $(OUTPUT_DIR)/test-namespace))
168+
get-test-namespace:
169+
$(Q)mkdir -p $(OUTPUT_DIR)
170+
$(eval TEST_NAMESPACE := $(shell $(HACK_DIR)/get-test-namespace $(OUTPUT_DIR)))
171+
echo $(TEST_NAMESPACE)
176172

177173
# Testing setup
178174
.PHONY: deploy-test-3rd-party-crds
179175
deploy-test-3rd-party-crds: get-test-namespace
180176
$(Q)kubectl --namespace $(TEST_NAMESPACE) apply -f ./test/third-party-crds/
181177

182178
.PHONY: create-test-namespace
183-
create-test-namespace:
184-
$(Q)kubectl create namespace $(TEST_NAMESPACE)
179+
create-test-namespace: get-test-namespace
180+
$(Q)kubectl get namespace $(TEST_NAMESPACE) || kubectl create namespace $(TEST_NAMESPACE)
185181

186182
.PHONY: test-setup
187183
test-setup: test-cleanup create-test-namespace deploy-test-3rd-party-crds

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)