From e1bb8ab47cda84d0e4bb5cd04f8bb752fc97e9e2 Mon Sep 17 00:00:00 2001 From: Jakub Rusz Date: Wed, 30 Mar 2022 14:30:02 +0200 Subject: [PATCH] tests/ci: split regression tests Regression test suite has grown considerably and is taking too long to run with a single wrapper. Splitting them into individual standalone tests instead and making them run in parallel. --- .gitlab-ci.yml | 34 +++++++- test/cases/regression-bigiso.sh | 11 +-- ...omposer-works-behind-satellite-fallback.sh | 13 +-- ...ression-composer-works-behind-satellite.sh | 16 ++-- test/cases/regression-excluded-dependency.sh | 13 +-- .../regression-include-excluded-packages.sh | 17 ++-- .../regression-old-worker-new-composer.sh | 17 +++- test/cases/regression.sh | 79 ------------------- 8 files changed, 88 insertions(+), 112 deletions(-) delete mode 100644 test/cases/regression.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 213880b26..7ac41982e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -195,7 +195,7 @@ Manifests: - aws/rhel-9.0-nightly-x86_64 INTERNAL_NETWORK: ["true"] -Regression: +.regression: stage: test extends: .terraform rules: @@ -203,7 +203,7 @@ Regression: - !reference [.nightly_rules, rules] script: - schutzbot/deploy.sh - - /usr/libexec/tests/osbuild-composer/regression.sh + - /usr/libexec/tests/osbuild-composer/${SCRIPT} parallel: matrix: - RUNNER: @@ -224,6 +224,36 @@ Regression: - aws/centos-stream-9-aarch64 INTERNAL_NETWORK: ["true"] +regression-bigiso: + extends: .regression + variables: + SCRIPT: regression-bigiso.sh + +regression-composer-works-behind-satellite-fallback: + extends: .regression + variables: + SCRIPT: regression-composer-works-behind-satellite-fallback.sh + +regression-composer-works-behind-satellite: + extends: .regression + variables: + SCRIPT: regression-composer-works-behind-satellite.sh + +regression-excluded-dependency: + extends: .regression + variables: + SCRIPT: regression-excluded-dependency.sh + +regression-include-excluded-packages: + extends: .regression + variables: + SCRIPT: regression-include-excluded-packages.sh + +regression-old-worker-new-composer.sh: + extends: .regression + variables: + SCRIPT: regression-old-worker-new-composer.sh + Image Tests: stage: test extends: .terraform diff --git a/test/cases/regression-bigiso.sh b/test/cases/regression-bigiso.sh index d995220e3..1e7a77746 100644 --- a/test/cases/regression-bigiso.sh +++ b/test/cases/regression-bigiso.sh @@ -4,11 +4,8 @@ # Get OS data. source /usr/libexec/osbuild-composer-test/set-env-variables.sh -# Provision the software under test. -/usr/libexec/osbuild-composer-test/provision.sh - case "${ID}-${VERSION_ID}" in - "rhel-8.6" | "rhel-9.0" | "centos-9") + "rhel-8.6" | "rhel-9.0" | "centos-9" | "centos-8") ;; *) echo "$0 is not enabled for ${ID}-${VERSION_ID} skipping..." @@ -34,6 +31,7 @@ function get_build_info() { } # Provision the software under test. +/usr/libexec/osbuild-composer-test/provision.sh BLUEPRINT_FILE=/tmp/blueprint.toml COMPOSE_START=/tmp/compose-start.json COMPOSE_INFO=/tmp/compose-info.json @@ -94,7 +92,10 @@ sudo composer-cli compose delete "${COMPOSE_ID}" >/dev/null jq . "${COMPOSE_INFO}" # Did the compose finish with success? -if [[ $COMPOSE_STATUS != FINISHED ]]; then +if [[ $COMPOSE_STATUS == FINISHED ]]; then + echo "Test passed!" + exit 0 +else echo "Something went wrong with the compose. 😢" exit 1 fi diff --git a/test/cases/regression-composer-works-behind-satellite-fallback.sh b/test/cases/regression-composer-works-behind-satellite-fallback.sh index 14dae7cd4..802cdfd14 100644 --- a/test/cases/regression-composer-works-behind-satellite-fallback.sh +++ b/test/cases/regression-composer-works-behind-satellite-fallback.sh @@ -38,9 +38,7 @@ function generate_certificates { sudo openssl x509 -req -in client.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out client.crt -days 365 -sha256 } - -source /etc/os-release -ARCH=$(uname -m) +source /usr/libexec/osbuild-composer-test/set-env-variables.sh # Skip if running on subscribed RHEL if [[ "$ID" == rhel ]] && sudo subscription-manager status; then @@ -325,7 +323,10 @@ function try_image_build { sudo journalctl -xe --unit "${WORKER_UNIT}" # Did the compose finish with success? - if [[ $COMPOSE_STATUS != FINISHED ]]; then + if [[ $COMPOSE_STATUS == FINISHED ]]; then + echo "Test passed!" + exit 0 + else echo "Something went wrong with the compose. 😢" exit 1 fi @@ -338,7 +339,7 @@ if [ -f "${REDHAT_REPO}" ]; then echo "The ${REDHAT_REPO} file shouldn't exist, removing it for the test" REDHAT_REPO_BACKUP="${REDHAT_REPO}.backup" - chattr -i ${REDHAT_REPO} + sudo chattr -i ${REDHAT_REPO} sudo mv "${REDHAT_REPO}" "${REDHAT_REPO_BACKUP}" fi @@ -369,7 +370,7 @@ CLIENT_CERT="/etc/pki/entitlement/0.pem" sudo cp "${PKI_DIR}/ca1/client.key" "${CLIENT_KEY}" sudo cp "${PKI_DIR}/ca1/client.crt" "${CLIENT_CERT}" -update-ca-trust +sudo update-ca-trust # Allow httpd process to create network connections sudo setsebool httpd_can_network_connect on diff --git a/test/cases/regression-composer-works-behind-satellite.sh b/test/cases/regression-composer-works-behind-satellite.sh index 8fd669478..612f27fcb 100644 --- a/test/cases/regression-composer-works-behind-satellite.sh +++ b/test/cases/regression-composer-works-behind-satellite.sh @@ -44,14 +44,14 @@ function cleanup { set +eu greenprint "Display httpd logs" - cat /var/log/httpd/access_log - cat /var/log/httpd/error_log + sudo cat /var/log/httpd/access_log + sudo cat /var/log/httpd/error_log greenprint "Putting things back to their previous configuration" if [ -n "${REDHAT_REPO}" ] && [ -n "${REDHAT_REPO_BACKUP}" ]; then lsattr "${REDHAT_REPO}" - chattr -i "${REDHAT_REPO}" + sudo chattr -i "${REDHAT_REPO}" sudo rm -f "${REDHAT_REPO}" sudo mv "${REDHAT_REPO_BACKUP}" "${REDHAT_REPO}" || echo "no redhat.repo backup" sudo mv "${REPOSITORY_OVERRIDE}.backup" "${REPOSITORY_OVERRIDE}" || echo "no repo override backup" @@ -66,8 +66,7 @@ function cleanup { sudo systemctl stop httpd || echo "failed to stop httpd" } -source /etc/os-release -ARCH=$(uname -m) +source /usr/libexec/osbuild-composer-test/set-env-variables.sh # Skip if running on subscribed RHEL if [[ "$ID" == rhel ]] && sudo subscription-manager status; then @@ -271,7 +270,7 @@ metadata_expire = 86400 enabled_metadata = 0 STOPHERE -chattr +i ${REDHAT_REPO} +sudo chattr +i ${REDHAT_REPO} lsattr ${REDHAT_REPO} cat ${REDHAT_REPO} @@ -363,7 +362,10 @@ function try_image_build { sudo journalctl -xe --unit "${WORKER_UNIT}" # Did the compose finish with success? - if [[ $COMPOSE_STATUS != FINISHED ]]; then + if [[ $COMPOSE_STATUS == FINISHED ]]; then + echo "Test passed!" + exit 0 + else echo "Something went wrong with the compose. 😢" exit 1 fi diff --git a/test/cases/regression-excluded-dependency.sh b/test/cases/regression-excluded-dependency.sh index 7af7220ef..94d6fae40 100644 --- a/test/cases/regression-excluded-dependency.sh +++ b/test/cases/regression-excluded-dependency.sh @@ -12,13 +12,10 @@ # Bug report: https://github.com/osbuild/osbuild-composer/issues/921 # Get OS data. -source /etc/os-release - -# Provision the software under test. -/usr/libexec/osbuild-composer-test/provision.sh +source /usr/libexec/osbuild-composer-test/set-env-variables.sh case "${ID}-${VERSION_ID}" in - "rhel-8.6" | "rhel-9.0" | "centos-9") + "rhel-8.6" | "rhel-9.0" | "centos-9" | "centos-8") ;; *) echo "$0 is not enabled for ${ID}-${VERSION_ID} skipping..." @@ -39,6 +36,7 @@ function get_build_info() { } # Provision the software under test. +/usr/libexec/osbuild-composer-test/provision.sh BLUEPRINT_FILE=/tmp/blueprint.toml COMPOSE_START=/tmp/compose-start.json COMPOSE_INFO=/tmp/compose-info.json @@ -80,7 +78,10 @@ sudo composer-cli compose delete "${COMPOSE_ID}" >/dev/null jq . "${COMPOSE_INFO}" # Did the compose finish with success? -if [[ $COMPOSE_STATUS != FINISHED ]]; then +if [[ $COMPOSE_STATUS == FINISHED ]]; then + echo "Test passed!" + exit 0 +else echo "Something went wrong with the compose. 😢" exit 1 fi diff --git a/test/cases/regression-include-excluded-packages.sh b/test/cases/regression-include-excluded-packages.sh index ad078ef4a..83829d28d 100644 --- a/test/cases/regression-include-excluded-packages.sh +++ b/test/cases/regression-include-excluded-packages.sh @@ -14,17 +14,19 @@ set -xeuo pipefail -# Provision the software under test. -BLUEPRINT_FILE=/tmp/blueprint.toml -COMPOSE_START=/tmp/compose-start.json -COMPOSE_INFO=/tmp/compose-info.json +source /usr/libexec/osbuild-composer-test/set-env-variables.sh -source /etc/os-release if [[ "${ID}" == "fedora" ]]; then echo "$0 is only enabled for rhel like systems; skipping..." exit 0 fi +# Provision the software under test. +/usr/libexec/osbuild-composer-test/provision.sh +BLUEPRINT_FILE=/tmp/blueprint.toml +COMPOSE_START=/tmp/compose-start.json +COMPOSE_INFO=/tmp/compose-info.json + # Write a basic blueprint for our image. tee "$BLUEPRINT_FILE" > /dev/null << EOF name = "nss-devel" @@ -74,7 +76,10 @@ sudo composer-cli compose delete "${COMPOSE_ID}" >/dev/null jq . "${COMPOSE_INFO}" # Did the compose finish with success? -if [[ $COMPOSE_STATUS != FINISHED ]]; then +if [[ $COMPOSE_STATUS == FINISHED ]]; then + echo "Test passed!" + exit 0 +else echo "Something went wrong with the compose. 😢" exit 1 fi diff --git a/test/cases/regression-old-worker-new-composer.sh b/test/cases/regression-old-worker-new-composer.sh index 9f4bd5fab..434c49e08 100644 --- a/test/cases/regression-old-worker-new-composer.sh +++ b/test/cases/regression-old-worker-new-composer.sh @@ -7,6 +7,18 @@ set -exuo pipefail +source /usr/libexec/osbuild-composer-test/set-env-variables.sh + +# Only run this on x86 and rhel8 GA; since the container is based on the ubi +# container, and we use the weldr api +if [ "$ARCH" != "x86_64" ] || [ "$ID" != rhel ] || ! sudo subscription-manager status; then + echo "Test only supported on GA RHEL." + exit 0 +fi + +# Provision the software under test. +/usr/libexec/osbuild-composer-test/provision.sh + function get_build_info() { key="$1" fname="$2" @@ -153,9 +165,12 @@ tee "dnf-json-request.json" <