2020-04-15 05:34:03 +00:00
|
|
|
#!/bin/sh
|
|
|
|
set -eux
|
|
|
|
|
|
|
|
# from standard-test-source
|
|
|
|
SOURCE="$(pwd)/source"
|
|
|
|
LOGS="$(pwd)/logs"
|
2020-04-29 05:29:23 +00:00
|
|
|
TESTS="$(pwd)/tests"
|
2020-04-15 05:34:03 +00:00
|
|
|
mkdir -p "$LOGS"
|
|
|
|
chmod a+w "$LOGS"
|
|
|
|
|
2020-04-29 05:29:23 +00:00
|
|
|
# install browser; on RHEL, use chromium from epel
|
|
|
|
if ! rpm -q chromium-headless; then
|
2020-05-15 06:25:32 +00:00
|
|
|
if grep -q 'ID=.*rhel' /etc/os-release; then
|
2020-04-29 05:29:23 +00:00
|
|
|
dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
|
|
|
|
dnf config-manager --enable epel
|
|
|
|
fi
|
|
|
|
dnf install -y chromium-headless
|
|
|
|
fi
|
|
|
|
|
2020-04-15 05:34:03 +00:00
|
|
|
# create user account for logging in
|
|
|
|
if ! id admin 2>/dev/null; then
|
2020-04-29 05:29:23 +00:00
|
|
|
useradd -c Administrator -G wheel admin
|
2020-04-15 05:34:03 +00:00
|
|
|
echo admin:foobar | chpasswd
|
|
|
|
fi
|
2020-04-29 05:29:23 +00:00
|
|
|
|
2020-04-15 05:34:03 +00:00
|
|
|
# avoid sudo lecture during tests
|
|
|
|
su -c 'echo foobar | sudo --stdin whoami' - admin
|
|
|
|
|
2020-04-29 05:29:23 +00:00
|
|
|
# create user account for running the test
|
|
|
|
if ! id runtest 2>/dev/null; then
|
|
|
|
useradd -c 'Test runner' runtest
|
2020-05-18 06:48:04 +00:00
|
|
|
# allow test to set up things on the machine
|
|
|
|
mkdir -p /root/.ssh
|
|
|
|
curl https://raw.githubusercontent.com/cockpit-project/bots/master/machine/identity.pub >> /root/.ssh/authorized_keys
|
|
|
|
chmod 600 /root/.ssh/authorized_keys
|
2020-04-29 05:29:23 +00:00
|
|
|
fi
|
|
|
|
chown -R runtest "$SOURCE"
|
|
|
|
|
2020-04-15 05:34:03 +00:00
|
|
|
# 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
|
2020-04-29 05:29:23 +00:00
|
|
|
loginctl disable-linger $(id -u admin)
|
2020-04-15 05:34:03 +00:00
|
|
|
|
2020-07-15 11:51:03 +00:00
|
|
|
systemctl enable --now cockpit.socket podman.socket
|
2020-04-15 05:34:03 +00:00
|
|
|
|
2020-04-29 05:29:23 +00:00
|
|
|
# Run tests as unprivileged user
|
|
|
|
su - -c "env SOURCE=$SOURCE LOGS=$LOGS $TESTS/run-test.sh" runtest
|
2020-04-15 05:34:03 +00:00
|
|
|
|
2020-04-29 05:29:23 +00:00
|
|
|
RC=$(cat $LOGS/exitcode)
|
|
|
|
exit ${RC:-1}
|