Skip to content

Commit 91cfa4f

Browse files
committed
chore: parametrize RABBITMQ_START_TIMEOUT in scripts/test
1 parent 4258cd5 commit 91cfa4f

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

.github/workflows/build_container.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,6 @@ jobs:
1818
run: scripts/build_container -g scratch -e BASE_IMAGE=scratch
1919

2020
- name: Run test script
21+
env:
22+
RABBITMQ_START_TIMEOUT: 180
2123
run: scripts/test

scripts/test

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,21 @@ set -e
44

55
DIRNAME="$(dirname "$(readlink -f "$0")")"
66

7+
: "${RABBITMQ_START_TIMEOUT:=20}"
8+
79
trap rm_containters EXIT
10+
trap errors_found ERR
811

912
rm_containters() {
1013
docker kill rdq-rabbitmq >/dev/null 2>&1
1114
docker kill rdq-busybox >/dev/null 2>&1
1215
docker kill rdq-test >/dev/null 2>&1
1316
}
1417

18+
errors_found() {
19+
echo -e "[\033[31mERROR\033[0m] $0 didn't finish correctly"
20+
}
21+
1522
# build docker image
1623
"${DIRNAME}/build_container" --target test \
1724
>/dev/null 2>&1
@@ -25,10 +32,15 @@ docker run --network=host --rm -q \
2532
echo -e "[\033[34mINFO\033[0m] Wait for rabbitmq listener"
2633
docker run --network=host --rm -q \
2734
--name rdq-busybox \
35+
-e N="$RABBITMQ_START_TIMEOUT" \
2836
busybox \
29-
sh -c 'nc -w 20 -z localhost 5672 >/dev/null'
37+
sh -c 'while [ $N -ge 0 ]; do nc -z localhost 5672 >/dev/null && exit 0; sleep 1; N=$((N - 1)); done; exit 1'
3038

3139
echo -e "[\033[34mINFO\033[0m] Run tests"
3240
docker run --network=host --rm \
3341
--name rdq-test\
3442
rabbitmq-dump-queue:test
43+
44+
echo $?
45+
46+
exit 0

0 commit comments

Comments
 (0)