2020-04-15 05:34:03 +00:00
|
|
|
#!/bin/sh
|
|
|
|
set -eux
|
|
|
|
|
2021-01-19 06:54:36 +00:00
|
|
|
TESTS="$(realpath $(dirname "$0"))"
|
|
|
|
if [ -d source ]; then
|
|
|
|
# path for standard-test-source
|
|
|
|
SOURCE="$(pwd)/source"
|
|
|
|
else
|
|
|
|
SOURCE="$(realpath $TESTS/..)"
|
|
|
|
fi
|
2020-04-15 05:34:03 +00:00
|
|
|
LOGS="$(pwd)/logs"
|
|
|
|
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
|
|
|
|
2021-01-07 12:58:42 +00:00
|
|
|
# set root's password
|
|
|
|
echo root:foobar | chpasswd
|
|
|
|
|
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
|
|
|
|
|
2021-01-07 11:11:10 +00:00
|
|
|
# grab a few images to play with; tests run offline, so they cannot download images
|
|
|
|
podman rmi --all
|
|
|
|
podman pull quay.io/libpod/busybox
|
|
|
|
podman pull quay.io/libpod/alpine
|
|
|
|
podman pull quay.io/cockpit/registry:2
|
2020-11-05 10:39:35 +00:00
|
|
|
|
2021-01-07 11:11:10 +00:00
|
|
|
# copy images for user podman tests; podman insists on user session
|
2020-04-15 05:34:03 +00:00
|
|
|
loginctl enable-linger $(id -u admin)
|
2021-01-07 11:11:10 +00:00
|
|
|
for img in quay.io/libpod/busybox quay.io/libpod/alpine quay.io/cockpit/registry:2; do
|
|
|
|
podman save $img | sudo -i -u admin podman load
|
|
|
|
done
|
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}
|