Skip to content

Commit

Permalink
Merge pull request #14551 from edsantiago/apiv2_tests_rootless
Browse files Browse the repository at this point in the history
CI: APIv2 tests: add rootless
  • Loading branch information
openshift-ci[bot] authored Jun 14, 2022
2 parents 071b925 + 455f4c7 commit 1cf3e4c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
7 changes: 6 additions & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ unit_test_task:


apiv2_test_task:
name: "APIv2 test on $DISTRO_NV"
name: "APIv2 test on $DISTRO_NV ($PRIV_NAME)"
alias: apiv2_test
# Docs: ./contrib/cirrus/CIModes.md
only_if: *not_tag_branch_build_docs
Expand All @@ -445,6 +445,11 @@ apiv2_test_task:
env:
<<: *stdenvars
TEST_FLAVOR: apiv2
matrix:
- env:
PRIV_NAME: root
- env:
PRIV_NAME: rootless
clone_script: *get_gosrc
setup_script: *setup
main_script: *main
Expand Down
21 changes: 21 additions & 0 deletions test/apiv2/test-apiv2
Original file line number Diff line number Diff line change
Expand Up @@ -380,13 +380,25 @@ function start_service() {
die "Cannot start service on non-localhost ($HOST)"
fi

# FIXME: EXPERIMENTAL: 2022-06-13: podman rootless needs a namespace. If
# system-service is the first podman command run (as is the case in CI)
# this will happen as a fork-exec, where the parent podman creates the
# namespace and the child is the server. Then, when stop_service() kills
# the parent, the child (server) happily stays alive and ruins subsequent
# tests that try to restart service with different settings.
# Workaround: run an unshare to get namespaces initialized.
if [[ $(id -u) != 0 ]]; then
$PODMAN_BIN unshare true
fi

$PODMAN_BIN \
--root $WORKDIR/server_root --syslog=true \
system service \
--time 0 \
tcp:127.0.0.1:$PORT \
&> $WORKDIR/server.log &
service_pid=$!
echo "# started service, pid $service_pid"

wait_for_port $HOST $PORT
}
Expand All @@ -396,7 +408,14 @@ function stop_service() {
if [[ -n $service_pid ]]; then
kill $service_pid || :
wait $service_pid || :
echo "# stopped service, pid $service_pid"
fi
service_pid=

if { exec 3<> /dev/tcp/$HOST/$PORT; } &>/dev/null; then
echo "# WARNING: stop_service: Service still running on port $PORT"
fi

}

####################
Expand Down Expand Up @@ -468,6 +487,7 @@ function start_registry() {
${REGISTRY_IMAGE}

wait_for_port localhost $REGISTRY_PORT 10
echo "# started registry (auth=$auth) on port $PORT"
}

function stop_registry() {
Expand All @@ -482,6 +502,7 @@ function stop_registry() {
if [[ "$1" = "--cleanup" ]]; then
podman $OPTS rmi -f -a
fi
echo "# stopped registry on port $PORT"
fi

REGISTRY_PORT=
Expand Down

0 comments on commit 1cf3e4c

Please sign in to comment.