Add initial upstream integration test

Re-use the test skeleton from cockpit. Just run a single integration
test for now, until we make them properly @nondestructive upstream [1].

Run chromium and the test directly on the test bed. For cockpit-podman
tests it's not practical to run them in a cockpit/tasks podman
container, as that container interferes too much with the tests.

[1] https://github.com/cockpit-project/cockpit-podman/pull/356
This commit is contained in:
Martin Pitt 2020-04-15 07:34:03 +02:00
parent 6b6f29bd60
commit 70257534e1
3 changed files with 83 additions and 0 deletions

3
tests/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
*.retry
artifacts/
source/

56
tests/browser.sh Executable file
View File

@ -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

24
tests/tests.yml Normal file
View File

@ -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/*"]