mirror of
https://github.com/kernelkit/infix.git
synced 2026-07-22 01:13:00 +02:00
test: run all CI tests with a random container name
Fixes #568 Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
@@ -50,6 +50,11 @@ usage: test/env [<OPTS>] -f <IMAGE> -q <QENETH-DIR> <COMMAND> [<ARGS>...]
|
||||
resulting topology is used as the default physical topology when
|
||||
running tests
|
||||
|
||||
-r
|
||||
Use random container names instead of "infamyN". Useful for the
|
||||
unit tests running in CI environments which may see occasional
|
||||
name clashes for "infamy0" due to race conditions.
|
||||
|
||||
-t <TOPOLOGY>
|
||||
Rather than starting a qeneth network, attach to this existing
|
||||
topology. If the command is containerized, it will be launched
|
||||
@@ -91,6 +96,11 @@ name()
|
||||
nm=infamy
|
||||
id=0
|
||||
|
||||
if [ -n "$random" ]; then
|
||||
# Let podman/docker allocate random hostname and container name
|
||||
return
|
||||
fi
|
||||
|
||||
names=$($(runner) ps -f name='infamy.*' --format '{{.Names}}')
|
||||
while true; do
|
||||
name="$nm$id"
|
||||
@@ -109,7 +119,7 @@ name()
|
||||
break;
|
||||
done
|
||||
|
||||
echo "$name"
|
||||
echo "--hostname $name --name $name"
|
||||
}
|
||||
|
||||
# Global options
|
||||
@@ -117,7 +127,7 @@ containerize=yes
|
||||
[ -c /dev/kvm ] && kvm="--device=/dev/kvm"
|
||||
files=
|
||||
|
||||
while getopts "cCDf:hiKp:q:t:" opt; do
|
||||
while getopts "cCDf:hiKp:q:rt:" opt; do
|
||||
case ${opt} in
|
||||
c)
|
||||
$(runner) image prune -af
|
||||
@@ -150,6 +160,9 @@ while getopts "cCDf:hiKp:q:t:" opt; do
|
||||
qenethdir="$OPTARG"
|
||||
network="--sysctl net.ipv6.conf.all.disable_ipv6=0"
|
||||
;;
|
||||
r)
|
||||
random=true
|
||||
;;
|
||||
t)
|
||||
topology="$OPTARG"
|
||||
network="--network host --volume $topology:$topology:ro"
|
||||
@@ -186,8 +199,7 @@ if [ "$containerize" ]; then
|
||||
--env PROMPT_DIRTRIM="$ixdir" \
|
||||
--env PS1="$(build_ps1)" \
|
||||
--expose 9001-9010 --publish-all \
|
||||
--hostname "$(name)" \
|
||||
--name "$(name)" \
|
||||
$(name) \
|
||||
$interactive \
|
||||
--rm \
|
||||
--security-opt seccomp=unconfined \
|
||||
|
||||
+4
-2
@@ -15,12 +15,14 @@ binaries-x86_64 += OVMF.fd
|
||||
binaries := $(foreach bin,$(binaries-$(ARCH)),-f $(BINARIES_DIR)/$(bin))
|
||||
|
||||
test:
|
||||
$(test-dir)/env $(mode) $(binaries) $(ninepm) $(INFIX_TESTS)
|
||||
$(test-dir)/env -r $(mode) $(binaries) $(ninepm) $(INFIX_TESTS)
|
||||
|
||||
test-sh:
|
||||
$(test-dir)/env $(mode) $(binaries) -i /bin/sh
|
||||
|
||||
# Unit tests run with random (-r) hostname and container name to
|
||||
# prevent race conditions when running in CI environments.
|
||||
test-unit:
|
||||
$(test-dir)/env $(ninepm) $(UNIT_TESTS)
|
||||
$(test-dir)/env -r $(ninepm) $(UNIT_TESTS)
|
||||
|
||||
.PHONY: test test-sh test-unit
|
||||
|
||||
Reference in New Issue
Block a user