diff --git a/tests/.gitignore b/tests/.gitignore new file mode 100644 index 0000000..eae05e5 --- /dev/null +++ b/tests/.gitignore @@ -0,0 +1,3 @@ +*.retry +artifacts/ +source/ diff --git a/tests/browser.sh b/tests/browser.sh new file mode 100755 index 0000000..bef25bf --- /dev/null +++ b/tests/browser.sh @@ -0,0 +1,56 @@ +#!/bin/sh +set -eux + +# from standard-test-source +SOURCE="$(pwd)/source" +LOGS="$(pwd)/logs" +mkdir -p "$LOGS" +chmod a+w "$LOGS" + +# create user account for logging in +if ! id admin 2>/dev/null; then + useradd admin -G wheel + echo admin:foobar | chpasswd +fi +# avoid sudo lecture during tests +su -c 'echo foobar | sudo --stdin whoami' - admin + +# disable core dumps, we rather investigate them upstream where test VMs are accessible +echo core > /proc/sys/kernel/core_pattern + +# pull images for system podman tests +podman pull docker.io/busybox +podman pull docker.io/alpine +podman pull docker.io/registry:2 + +# pull images for user podman tests; podman insists on user session +loginctl enable-linger $(id -u admin) +sudo -i -u admin bash << EOF +podman pull docker.io/busybox +podman pull docker.io/alpine +podman pull docker.io/registry:2 +EOF + +systemctl enable --now cockpit.socket io.podman.socket + +# tests need cockpit's bots/ libraries and test infrastructure +cd $SOURCE +git init +make bots test/common + +# only install a subset to save time/space +npm install chrome-remote-interface sizzle + +export TEST_OS=fedora-32 +export TEST_AUDIT_NO_SELINUX=1 + +# run tests +RC=0 +test/check-application -tv --machine 127.0.0.1:22 --browser 127.0.0.1:9090 TestApplication.testBasicSystem || { RC=$? ; cp --verbose Test* $LOGS || true; } + +# reset system changes from tests, for running this multiple times in a row +rm -f /etc/systemd/system/cockpit.service.d/notls.conf +systemctl daemon-reload +systemctl stop cockpit.service + +exit $RC diff --git a/tests/tests.yml b/tests/tests.yml new file mode 100644 index 0000000..88353b5 --- /dev/null +++ b/tests/tests.yml @@ -0,0 +1,24 @@ +--- +- hosts: localhost + roles: + - role: standard-test-source + tags: + - always + + - role: standard-test-basic + tags: + - classic + required_packages: + - cockpit-podman + - cockpit-ws + - chromium-headless + - git + - libvirt-python3 + - make + - npm + - python3 + tests: + - verify: + dir: . + run: ./browser.sh + save-files: ["logs/*"]