Skip to content

Commit f047fce

Browse files
committed
ci: set routable IP addresses to increase test coverage
With `1.1.1.1` and `2.2.2.2` set on the machine, the tests `feature_bind_port_discover.py` and `feature_bind_port_externalip.py` will run.
1 parent be887da commit f047fce

File tree

4 files changed

+42
-3
lines changed

4 files changed

+42
-3
lines changed

ci/test/00_setup_env.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export BASE_OUTDIR=${BASE_OUTDIR:-$BASE_SCRATCH_DIR/out}
6464
# The folder for previous release binaries.
6565
# This folder exists only on the ci guest, and on the ci host as a volume.
6666
export PREVIOUS_RELEASES_DIR=${PREVIOUS_RELEASES_DIR:-$BASE_ROOT_DIR/prev_releases}
67-
export CI_BASE_PACKAGES=${CI_BASE_PACKAGES:-build-essential pkgconf curl ca-certificates ccache python3 rsync git procps bison e2fsprogs cmake ninja-build}
67+
export CI_BASE_PACKAGES=${CI_BASE_PACKAGES:-build-essential pkgconf curl ca-certificates ccache python3 rsync git procps bison e2fsprogs cmake ninja-build net-tools iproute2}
6868
export GOAL=${GOAL:-install}
6969
export DIR_QA_ASSETS=${DIR_QA_ASSETS:-${BASE_SCRATCH_DIR}/qa-assets}
7070
export CI_RETRY_EXE=${CI_RETRY_EXE:-"retry --"}

ci/test/00_setup_env_native_centos.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export LC_ALL=C.UTF-8
88

99
export CONTAINER_NAME=ci_native_centos
1010
export CI_IMAGE_NAME_TAG="quay.io/centos/centos:stream10"
11-
export CI_BASE_PACKAGES="gcc-c++ glibc-devel libstdc++-devel ccache make ninja-build git python3 python3-pip which patch xz procps-ng rsync coreutils bison e2fsprogs cmake dash"
11+
export CI_BASE_PACKAGES="gcc-c++ glibc-devel libstdc++-devel ccache make ninja-build git python3 python3-pip which patch xz procps-ng rsync coreutils bison e2fsprogs cmake dash net-tools iproute"
1212
export PIP_PACKAGES="pyzmq pycapnp"
1313
export DEP_OPTS="DEBUG=1"
1414
export GOAL="install"

ci/test/02_run_container.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,15 @@ if [ -z "$DANGER_RUN_CI_ON_HOST" ]; then
8686
docker image prune --force --filter "label=$CI_IMAGE_LABEL"
8787

8888
# shellcheck disable=SC2086
89-
CI_CONTAINER_ID=$(docker run --cap-add LINUX_IMMUTABLE $CI_CONTAINER_CAP --rm --interactive --detach --tty \
89+
CI_CONTAINER_ID=$(docker run \
90+
--cap-add LINUX_IMMUTABLE \
91+
--cap-add NET_ADMIN \
92+
--cap-add NET_RAW \
93+
$CI_CONTAINER_CAP \
94+
--rm \
95+
--interactive \
96+
--detach \
97+
--tty \
9098
--mount "type=bind,src=$BASE_READ_ONLY_DIR,dst=$BASE_READ_ONLY_DIR,readonly" \
9199
--mount "${CI_CCACHE_MOUNT}" \
92100
--mount "${CI_DEPENDS_MOUNT}" \

ci/test/03_test_script.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,28 @@ if [ "$RUN_CHECK_DEPS" = "true" ]; then
167167
"${BASE_ROOT_DIR}/contrib/devtools/check-deps.sh" "${BASE_BUILD_DIR}"
168168
fi
169169

170+
function get_interfaces()
171+
{
172+
set -o pipefail
173+
ifconfig | awk -F ':| ' '/^[^[:space:]]/ { if (!match($1, /^lo/)) { print $1 } }'
174+
set +o pipefail
175+
}
176+
177+
# ip_addr_on_interface (add|del) ip_address interface_name
178+
function ip_addr_on_interface()
179+
{
180+
op=$1
181+
ip_addr=$2
182+
interface=$3
183+
if which ip > /dev/null 2>&1 ; then
184+
if [ "$op" = "add" ] ; then
185+
ip addr add "$ip_addr" dev "$interface"
186+
else
187+
ip addr del "$ip_addr" dev "$interface"
188+
fi
189+
fi
190+
}
191+
170192
if [ "$RUN_UNIT_TESTS" = "true" ]; then
171193
DIR_UNIT_TEST_DATA="${DIR_UNIT_TEST_DATA}" \
172194
LD_LIBRARY_PATH="${DEPENDS_DIR}/${HOST}/lib" \
@@ -178,6 +200,11 @@ if [ "$RUN_UNIT_TESTS" = "true" ]; then
178200
fi
179201

180202
if [ "$RUN_FUNCTIONAL_TESTS" = "true" ]; then
203+
non_loopback_interface=$(get_interfaces |head -1)
204+
if [ -n "$non_loopback_interface" ] ; then
205+
ip_addr_on_interface "add" "1.1.1.1/32" "$non_loopback_interface"
206+
ip_addr_on_interface "add" "2.2.2.2/32" "$non_loopback_interface"
207+
fi
181208
# parses TEST_RUNNER_EXTRA as an array which allows for multiple arguments such as TEST_RUNNER_EXTRA='--exclude "rpc_bind.py --ipv6"'
182209
eval "TEST_RUNNER_EXTRA=($TEST_RUNNER_EXTRA)"
183210
LD_LIBRARY_PATH="${DEPENDS_DIR}/${HOST}/lib" \
@@ -190,6 +217,10 @@ if [ "$RUN_FUNCTIONAL_TESTS" = "true" ]; then
190217
"${TEST_RUNNER_EXTRA[@]}" \
191218
--quiet \
192219
--failfast
220+
if [ -n "$non_loopback_interface" ] ; then
221+
ip_addr_on_interface "del" "1.1.1.1/32" "$non_loopback_interface"
222+
ip_addr_on_interface "del" "2.2.2.2/32" "$non_loopback_interface"
223+
fi
193224
fi
194225

195226
if [ "${RUN_TIDY}" = "true" ]; then

0 commit comments

Comments
 (0)