#! /bin/bash# This is the expected entry point for Cockpit CI; will be called without# arguments but with an appropriate $TEST_OS, and optionally $TEST_SCENARIO# Currently supported scenarios:## expensive - expensive tests (test which run a full installation)# storage - storage related tests# cockpit - storage related tests that utilize Cockpit Storage plugin# other - all remaining tests# bios - tests in BIOS mode (they might be tests which are also present in other scenarios)# compose-{compose-id} - tests defined in wiki-testmap.json ran against given compose# bootoptns-net1 - tests run for installation with network configuration via boot optionsset -euxmake codecheckmake botsif [ "$(git rev-parse HEAD)" = "$(git rev-parse origin/main)" ]; thenTESTING_BRANCH=mainelseTESTING_BRANCH=$(git rev-parse HEAD)fiRUN_OPTS=""ALL_TESTS="$(test/common/run-tests --test-dir test -l)"RE_EXPENSIVE='E2E'RE_DNF_PAYLOAD='PayloadDNF'# Pre-filtered test sets for common patternsBASIC_TESTS="$(echo "$ALL_TESTS" | grep -vE "$RE_EXPENSIVE" | grep -vE "$RE_DNF_PAYLOAD")"# every known case needs to set RUN_OPTS to something non-empty, so that we can check if we hit any branchcase "${TEST_SCENARIO:=}" in*bios*) export TEST_FIRMWARE="bios";;&*bootopts-net1*) export TEST_EXTRA_BOOT_ARGS="net.ifnames.prefix=net ip=net0:dhcp" TEST_VM_SETUP="bootopts-net1";;&*compose-*)# Supported values are: compose-<compose-id> or compose-<compose-id>-stagingfor test in $ALL_TESTS; doif grep "$test" test/fedora-wiki/wiki-testmap.json; thenRUN_OPTS="$RUN_OPTS $test"fidoneexport TEST_COMPOSE="${TEST_SCENARIO#*compose-}"if [[ "$TEST_COMPOSE" == *"-staging" ]]; thenexport TEST_COMPOSE="${TEST_COMPOSE%-staging}"TEST_FEDORA_WIKI_STAGING="true"fi;;*dnf*)RUN_OPTS="$(echo "$ALL_TESTS" | grep -E "$RE_DNF_PAYLOAD")";;*expensive*)RUN_OPTS="$(echo "$ALL_TESTS" | grep -E "$RE_EXPENSIVE" | grep -vE "$RE_DNF_PAYLOAD")";;*storage*)RUN_OPTS="$(echo "$BASIC_TESTS" | grep "Storage" | grep -v "Cockpit")";;*other*)RUN_OPTS="$(echo "$BASIC_TESTS" | grep -v "Cockpit" | grep -v "Storage")";;*cockpit*)RUN_OPTS="$(echo "$BASIC_TESTS" | grep "Cockpit")";;*)RUN_OPTS="$ALL_TESTS";;esac# If TEST_COMPOSE is defined checkout the git repo to the corresponding tagif [ -n "${TEST_COMPOSE-}" ]; thenCOMPOSE_BASE_URL=$(python3 test/helpers/compose_path.py "$TEST_COMPOSE")COMPOSE_A_PACKAGES="${COMPOSE_BASE_URL}/compose/Everything/x86_64/os/Packages/a/"ANACONDA_WEBUI_TAG=$(curl -sfL "$COMPOSE_A_PACKAGES" | grep -oE 'anaconda-webui-[0-9]+' | sed 's/anaconda-webui-//' | sort -n | tail -1)git fetch --tags origingit checkout "$ANACONDA_WEBUI_TAG"# FIXME: Do not run pixel tests as we need a newer tasks container than the pixel tests used for generating the reference imagesecho "FIXME" > test/reference-imagefi# We need to know if a TEST_COMPOSE is specified before we start downloading the test imagesmake create-updates.img# If TEST_COMPOSE is defined and we are testing main branch prepare the test reportif [ -n "${TEST_COMPOSE-}" ] && [ "$TESTING_BRANCH" == "main" ]; thentest/fedora-wiki/prepare-reportfi# test runs in kernel_t context and triggers massive amounts of SELinux# denials; SELinux gets disabled, but would still trigger unexpected messagesif [ -z "${TEST_OS-}" ]; thenTEST_OS=fedora-rawhide-bootfi# Allow wiki-reporting even if test suite partially failedset +e# Create tmp storage pool to avoid parallel test runs to conflictecho "<pool type='dir'><name>tmp</name><target><path>/var/tmp/</path></target></pool>" > /tmp/storage-pool.xmlvirsh pool-define --file /tmp/storage-pool.xmlexport TEST_OS# Keep the scheduler's RAM budget in sync with VirtInstallMachine (capacity planning).# Actual VM memory is also enforced in VirtInstallMachine.__init__.INSTALLER_VM_MEMORY_MB=$(python3 -c "import sys; sys.path.insert(0, 'test'); from machine_install import INSTALLER_VM_MEMORY_MB; print(INSTALLER_VM_MEMORY_MB)")RUN_TESTS_COMMON_OPTS="--nondestructive-memory-mb ${INSTALLER_VM_MEMORY_MB} --capacity-factor 0.5"TEST_AUDIT_NO_SELINUX=1 test/common/run-tests $RUN_TESTS_COMMON_OPTS --test-dir test/ $RUN_OPTSexit_code=$?if [ -n "${TEST_COMPOSE-}" ] && [ "$TESTING_BRANCH" == "main" ]; then# Log the report file that we are about to useecho "Using the following report file:"cat test/report.json# Copy the wiki token to the correct locationif [ ! -f "$COCKPIT_FEDORA_WIKI_STAGING_TOKEN" ]; thenecho "The wiki token file does not exist"exit 1fimkdir -p ~/.openidcif [ "${TEST_FEDORA_WIKI_STAGING-}" = "true" ]; thencp $COCKPIT_FEDORA_WIKI_STAGING_TOKEN ~/.openidc/oidc_wikitcms.jsontest/fedora-wiki/wiki-report.py --staging test/report.jsonelsecp $COCKPIT_FEDORA_WIKI_TOKEN ~/.openidc/oidc_wikitcms.jsontest/fedora-wiki/wiki-report.py test/report.jsonfireport_exit=$?if [ $report_exit -ne 0 ]; thenexit_code=$report_exitfifiexit $exit_code