Skip to content

Commit

Permalink
TEST nspawn
Browse files Browse the repository at this point in the history
  • Loading branch information
martinpitt committed Mar 18, 2024
1 parent 106e47c commit 35ddf5e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 19 deletions.
32 changes: 17 additions & 15 deletions test/browser/browser.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,25 +49,27 @@ for retry in $(seq 5); do
sleep $((5 * retry * retry))
done

CONTAINER="$(cat .cockpit-ci/container)"

# import the test CONTAINER image as a directory tree for nspawn
mkdir /var/tmp/tasks
podman export "$(podman create --name tasks-import $CONTAINER)" | tar -x -C /var/tmp/tasks
podman rm tasks-import
podman rmi $CONTAINER

# image setup, shared with upstream tests
sh -x test/vm.install

systemctl enable --now cockpit.socket podman.socket

# Run tests in the cockpit tasks container, as unprivileged user
CONTAINER="$(cat .cockpit-ci/container)"

# Use docker to avoid the tests killing the tasks container itself
# docker doesn't have --volume=,U so we have to apply hax
# Use nspawn to avoid the tests killing the tasks container itself
chown -R 1111:1111 "${TMT_TEST_DATA}" .
systemctl start docker
exec docker \
run \
--rm \
--shm-size=1024m \
--security-opt=label=disable \
--volume="${TMT_TEST_DATA}":/logs:rw --env=LOGS=/logs \
--volume="$(pwd)":/source:rw --env=SOURCE=/source \
--name=cockpit-tasks \
"${CONTAINER}" \
sh /source/test/browser/run-test.sh "$@"

SYSTEMD_SECCOMP=0 systemd-nspawn \
-D /var/tmp/tasks/ \
--ephemeral \
--user user \
--bind="${TMT_TEST_DATA}":/logs --setenv=LOGS=/logs \
--bind="$(pwd)":/source:rw --setenv=SOURCE=/source \
sh /source/test/browser/run-test.sh "$@"
2 changes: 1 addition & 1 deletion test/browser/main.fmf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require:
- docker
- systemd-container
- cockpit-podman
- cockpit-ws
- cockpit-system
Expand Down
5 changes: 2 additions & 3 deletions test/browser/run-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,11 @@ EXCLUDES=""
echo "TEST_ALLOW_JOURNAL_MESSAGES: ${TEST_ALLOW_JOURNAL_MESSAGES:-}"
echo "TEST_AUDIT_NO_SELINUX: ${TEST_AUDIT_NO_SELINUX:-}"

GATEWAY="$(python3 -c 'import socket; print(socket.gethostbyname("_gateway"))')"
RC=0
./test/common/run-tests \
--nondestructive \
--machine "${GATEWAY}":22 \
--browser "${GATEWAY}":9090 \
--machine localhost:22 \
--browser localhost:9090 \
$TESTS \
$EXCLUDES \
|| RC=$?
Expand Down

0 comments on commit 35ddf5e

Please sign in to comment.