Skip to content

Commit 4aa565f

Browse files
committed
test: Add FMF test metadata and scripts
Copy and adjust the browser.sh and run-test.sh scripts from Fedora's downstream dist-git gating tests [1], and translate the STI yaml to an FMF metadata file test/verify.fmf. This replaces the previous test/main.fmf, which was not functional and just a stub. With this we can share the same test scripts upstream (for testing in Packit) and downstream. [1] https://src.fedoraproject.org/rpms/cockpit/blob/71ee0da592bd10d8dde9d9271e3e2c62ab93a6bb/f/tests
1 parent daeeaf8 commit 4aa565f

File tree

7 files changed

+206
-7
lines changed

7 files changed

+206
-7
lines changed
File renamed without changes.

plans/all.fmf

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
summary:
2+
Run all tests
3+
discover:
4+
how: fmf
5+
execute:
6+
how: tmt

test/main.fmf

-6
This file was deleted.

test/run-verify-host-user.sh

+116
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
#!/bin/sh
2+
set -eux
3+
4+
cd "$SOURCE"
5+
6+
. /etc/os-release
7+
test_optional=
8+
test_basic=
9+
10+
if ls ../cockpit-appstream* 1> /dev/null 2>&1; then
11+
test_optional=1
12+
else
13+
test_basic=1
14+
fi
15+
16+
if [ "$ID" = "fedora" ]; then
17+
test_basic=1
18+
test_optional=1
19+
fi
20+
21+
# tests need cockpit's bots/ libraries
22+
git clone --depth=1 https://github.com/cockpit-project/bots
23+
24+
# support running from clean git tree
25+
if [ ! -d node_modules/chrome-remote-interface ]; then
26+
npm install chrome-remote-interface sizzle
27+
fi
28+
29+
export TEST_OS="${ID}-${VERSION_ID/./-}"
30+
# HACK: upstream does not yet know about rawhide
31+
if [ "$TEST_OS" = "fedora-35" ]; then
32+
export TEST_OS=fedora-33
33+
fi
34+
35+
# HACK: CI hits this selinux denial. Unrelated to our tests.
36+
export TEST_ALLOW_JOURNAL_MESSAGES=".*Permission denied:.*/var/cache/app-info/xmls.*"
37+
38+
# select tests
39+
TESTS=""
40+
EXCLUDES=""
41+
RC=0
42+
if [ -n "$test_optional" ]; then
43+
# pre-download cirros image for Machines tests
44+
bots/image-download cirros
45+
46+
# triggers SELinux violation
47+
# See journal: SELinux is preventing /usr/libexec/qemu-kvm from open access on the file /var/lib/cockpittest/nfs_pool/nfs-volume-0.
48+
EXCLUDES="$EXCLUDES TestMachinesDisks.testAddDiskNFS"
49+
# not investigated yet
50+
EXCLUDES="$EXCLUDES
51+
TestAutoUpdates.testPrivilegeChange"
52+
53+
# TestUpdates: we can't run rebooting tests
54+
TESTS="$TESTS
55+
TestAutoUpdates
56+
TestStorage
57+
TestUpdates.testBasic
58+
TestUpdates.testSecurityOnly"
59+
60+
# Fedora gating tests are running on infra without /dev/kvm; Machines tests are too darn slow there
61+
if [ "$ID" = "fedora" ]; then
62+
TESTS="$TESTS TestMachinesCreate.testCreateImportDisk"
63+
else
64+
TESTS="$TESTS TestMachines"
65+
fi
66+
fi
67+
68+
if [ -n "$test_basic" ]; then
69+
# still too unstable
70+
EXCLUDES="$EXCLUDES TestFirewall.testNetworkingPage"
71+
72+
# TODO: fix for CI environment
73+
EXCLUDES="$EXCLUDES TestLogin.testTally"
74+
EXCLUDES="$EXCLUDES TestAccounts.testBasic"
75+
76+
# PCI devices list is not predictable
77+
EXCLUDES="$EXCLUDES TestSystemInfo.testHardwareInfo"
78+
79+
# Known issue #1008
80+
EXCLUDES="$EXCLUDES TestTuned.testBasic"
81+
82+
TESTS="$TESTS
83+
TestAccounts
84+
TestBonding
85+
TestBridge
86+
TestFirewall
87+
TestKdump
88+
TestLogin
89+
TestNetworking
90+
TestServices
91+
TestSOS
92+
TestSystemInfo
93+
TestTeam
94+
TestTerminal
95+
TestTuned
96+
"
97+
fi
98+
99+
exclude_options=""
100+
for t in $EXCLUDES; do
101+
exclude_options="$exclude_options --exclude $t"
102+
done
103+
104+
# execute run-tests
105+
test/common/run-tests --test-dir test/verify --nondestructive $exclude_options \
106+
--machine localhost:22 --browser localhost:9090 $TESTS || RC=$?
107+
108+
# check-shell-menu is not @nondestructive yet, keep it last
109+
if [ -n "$test_basic" ]; then
110+
test/verify/check-shell-menu --machine localhost:22 --browser localhost:9090 || RC=$?
111+
fi
112+
113+
echo $RC > "$LOGS/exitcode"
114+
cp --verbose Test* "$LOGS" || true
115+
# deliver test result via exitcode file
116+
exit 0

test/run-verify-host.sh

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/bin/sh
2+
# This script is meant to be run on an ephemeral CI host, for packit/Fedora/RHEL gating.
3+
set -eux
4+
5+
TESTS="$(realpath $(dirname "$0"))"
6+
if [ -d source ]; then
7+
# path for standard-test-source
8+
SOURCE="$(pwd)/source"
9+
else
10+
SOURCE="$(realpath $TESTS/..)"
11+
fi
12+
LOGS="$(pwd)/logs"
13+
mkdir -p "$LOGS"
14+
chmod a+w "$LOGS"
15+
16+
# install browser; on RHEL, use chromium from epel
17+
# HACK: chromium-headless ought to be enough, but version 88 has a crash: https://bugs.chromium.org/p/chromium/issues/detail?id=1170634
18+
if ! rpm -q chromium; then
19+
if grep -q 'ID=.*rhel' /etc/os-release; then
20+
dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
21+
dnf config-manager --enable epel
22+
fi
23+
dnf install -y chromium
24+
fi
25+
26+
# make libpwquality less aggressive, so that our "foobar" password works
27+
printf 'dictcheck = 0\nminlen = 6\n' >> /etc/security/pwquality.conf
28+
29+
# set root password for logging in
30+
echo root:foobar | chpasswd
31+
32+
# create user account for logging in
33+
if ! id admin 2>/dev/null; then
34+
useradd -c Administrator -G wheel admin
35+
echo admin:foobar | chpasswd
36+
fi
37+
38+
# create user account for running the test
39+
if ! id runtest 2>/dev/null; then
40+
useradd -c 'Test runner' runtest
41+
# allow test to set up things on the machine
42+
mkdir -p /root/.ssh
43+
curl https://raw.githubusercontent.com/cockpit-project/bots/master/machine/identity.pub >> /root/.ssh/authorized_keys
44+
chmod 600 /root/.ssh/authorized_keys
45+
fi
46+
chown -R runtest "$SOURCE"
47+
48+
# disable core dumps, we rather investigate them upstream where test VMs are accessible
49+
echo core > /proc/sys/kernel/core_pattern
50+
51+
# make sure that we can access cockpit through the firewall
52+
systemctl start firewalld
53+
firewall-cmd --add-service=cockpit --permanent
54+
firewall-cmd --add-service=cockpit
55+
56+
# Run tests as unprivileged user
57+
su - -c "env SOURCE=$SOURCE LOGS=$LOGS $TESTS/run-verify-host-user.sh" runtest
58+
59+
RC=$(cat $LOGS/exitcode)
60+
exit ${RC:-1}

test/verify.fmf

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
summary: Run browser integration tests on the host
2+
require:
3+
- cockpit
4+
- cockpit-tests
5+
- cockpit-machines
6+
- cockpit-sosreport
7+
- cockpit-storaged
8+
- createrepo_c
9+
- cryptsetup
10+
- dnf-automatic
11+
- firewalld
12+
- git
13+
- libvirt-daemon-config-network
14+
- libvirt-python3
15+
- make
16+
- NetworkManager-team
17+
- npm
18+
- python3
19+
- sssd-dbus
20+
- targetcli
21+
- tlog
22+
test: ./run-verify-host.sh
23+
duration: 2h

tools/test-static-code

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ if [ -z "${PYTHON_STYLE_CHECKER-}" ]; then
120120
echo "ok 7 pycodestyle test # SKIP pycodestyle not installed"
121121
else
122122
# FIXME: Fix code for the warnings and re-enable them
123-
out=$(python3 -m "$PYTHON_STYLE_CHECKER" --ignore E501,E265,E261,W504,W605 test/* --exclude=test/verify/nested-kvm,test/README.md,test/run,test/main.fmf) || true
123+
out=$(python3 -m "$PYTHON_STYLE_CHECKER" --ignore E501,E265,E261,W504,W605 test/* --exclude=test/verify/nested-kvm,test/README.md,test/run,test/verify.fmf,test/run-verify-host.sh,test/run-verify-host-user.sh) || true
124124
if [ -n "$out" ]; then
125125
echo "$out" >&2
126126
echo "not ok 7 $PYTHON_STYLE_CHECKER test"

0 commit comments

Comments
 (0)