ci/tests: Change the way artifacts are collected

We want to be able to safely gather any artifacts without worrying about
any possible secrets leaking. Every artifacts that we want to upload
will now have to be placed in /tmp/artifacts which will then be uploaded
to S3 by the executor and link to the artifacts will be provided in the
logs. Only people with access to our AWS account can see them.
This commit is contained in:
Jakub Rusz 2022-03-23 10:58:03 +01:00 committed by Alexander Todorov
parent d3af314e58
commit efbd5ebd7b
22 changed files with 74 additions and 107 deletions

View file

@ -8,21 +8,18 @@ stages:
.base: .base:
before_script: before_script:
- schutzbot/ci_details.sh > ci-details-before-run - schutzbot/ci_details.sh > ci-details-before-run.txt
- cat schutzbot/team_ssh_keys.txt | tee -a ~/.ssh/authorized_keys > /dev/null - cat schutzbot/team_ssh_keys.txt | tee -a ~/.ssh/authorized_keys > /dev/null
after_script: after_script:
- schutzbot/ci_details.sh > ci-details-after-run || true - schutzbot/ci_details.sh > ci-details-after-run.txt || true
- schutzbot/update_github_status.sh update || true - schutzbot/update_github_status.sh update || true
- schutzbot/save_journal.sh || true - schutzbot/save_journal.sh || true
- schutzbot/upload_artifacts.sh
interruptible: true interruptible: true
tags: tags:
- terraform - terraform
artifacts: artifacts:
paths: paths:
- journal-log.gpg
- ci-artifacts
- ci-details-before-run
- ci-details-after-run
- "*.repo" - "*.repo"
- COMPOSER_NVR - COMPOSER_NVR
when: always when: always
@ -446,17 +443,7 @@ aws.sh:
extends: .integration extends: .integration
variables: variables:
SCRIPT: aws.sh SCRIPT: aws.sh
artifacts:
paths:
- cloud-image-val/report.html
- journal-log.gpg
- ci-artifacts
- ci-details-before-run
- ci-details-after-run
- "*.repo"
- COMPOSER_NVR
when: always
azure.sh: azure.sh:
extends: .integration extends: .integration
variables: variables:
@ -595,18 +582,6 @@ Upgrade:
- /usr/libexec/tests/osbuild-composer/upgrade8to9.sh - /usr/libexec/tests/osbuild-composer/upgrade8to9.sh
variables: variables:
RUNNER: rhos-01/rhel-9.1-nightly-x86_64 RUNNER: rhos-01/rhel-9.1-nightly-x86_64
artifacts:
paths:
- journal-log.gpg
- ci-artifacts
- install_console.log
- upgrade_console.log
- leapp-preupgrade.log
- leapp-upgrade.log
- leapp-report.txt
- osbuild-upgrade8to9.log
- osbuild-upgrade8to9.json
when: always
NIGHTLY_FAIL: NIGHTLY_FAIL:
stage: finish stage: finish

View file

@ -34,7 +34,7 @@ EOF
echo -e "\033[0m" echo -e "\033[0m"
echo "List of system repositories:" echo "List of system repositories:"
yum repolist -v sudo yum repolist -v
echo "------------------------------------------------------------------------------" echo "------------------------------------------------------------------------------"

View file

@ -3,7 +3,5 @@
# use tee, otherwise shellcheck complains # use tee, otherwise shellcheck complains
sudo journalctl --boot | tee journal-log >/dev/null sudo journalctl --boot | tee journal-log >/dev/null
# As it might contain sensitive information and is important for debugging # copy journal to artifacts folder which is then uploaded to secure S3 location
# purposes, encrypt journal-log with a symmetric passphrase. cp journal-log "${ARTIFACTS:-/tmp/artifacts}"
gpg --batch --yes --passphrase "$GPG_SYMMETRIC_PASSPHRASE" -o journal-log.gpg --symmetric journal-log
rm journal-log

21
schutzbot/upload_artifacts.sh Executable file
View file

@ -0,0 +1,21 @@
#!/bin/bash
# This script uploads all files from ARTIFACTS folder to S3
S3_URL="s3://image-builder-ci-artifacts/osbuild-composer/$CI_COMMIT_BRANCH/$CI_JOB_ID/"
BROWSER_URL="https://s3.console.aws.amazon.com/s3/buckets/image-builder-ci-artifacts?region=us-east-1&prefix=osbuild-composer/$CI_COMMIT_BRANCH/$CI_JOB_ID/&showversions=false"
ARTIFACTS=${ARTIFACTS:-/tmp/artifacts}
# Colorful output.
function greenprint {
echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m"
}
sudo dnf -y install s3cmd
greenprint "Job artifacts will be uploaded to: $S3_URL"
AWS_SECRET_ACCESS_KEY="$V2_AWS_SECRET_ACCESS_KEY" \
AWS_ACCESS_KEY_ID="$V2_AWS_ACCESS_KEY_ID" \
s3cmd --acl-private put "$ARTIFACTS"/* "$S3_URL"
greenprint "Please login to 438669297788 AWS account and visit $BROWSER_URL to access job artifacts."

View file

@ -80,8 +80,7 @@ function greenprint {
echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m" echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m"
} }
ARTIFACTS=ci-artifacts ARTIFACTS="${ARTIFACTS:-/tmp/artifacts}"
mkdir -p "${ARTIFACTS}"
source /usr/libexec/osbuild-composer-test/set-env-variables.sh source /usr/libexec/osbuild-composer-test/set-env-variables.sh
@ -194,7 +193,7 @@ function dump_db() {
# Save the result, including the manifest, for the job, straight from the db # Save the result, including the manifest, for the job, straight from the db
sudo ${CONTAINER_RUNTIME} exec "${DB_CONTAINER_NAME}" psql -U postgres -d osbuildcomposer -c "SELECT result FROM jobs WHERE type='manifest-id-only'" \ sudo ${CONTAINER_RUNTIME} exec "${DB_CONTAINER_NAME}" psql -U postgres -d osbuildcomposer -c "SELECT result FROM jobs WHERE type='manifest-id-only'" \
| gpg --batch --yes --passphrase "${GPG_SYMMETRIC_PASSPHRASE}" -o "${ARTIFACTS}/build-result.gpg" --symmetric - | sudo tee "${ARTIFACTS}/build-result.txt"
set -x set -x
} }

View file

@ -60,12 +60,7 @@ else
TEST_ID=$(uuidgen); TEST_ID=$(uuidgen);
fi fi
ARTIFACTS="${ARTIFACTS:-/tmp/artifacts}"
# Jenkins sets WORKSPACE to the job workspace, but if this script runs
# outside of Jenkins, we can set up a temporary directory instead.
if [[ ${WORKSPACE:-empty} == empty ]]; then
WORKSPACE=$(mktemp -d)
fi
# Set up temporary files. # Set up temporary files.
AWS_CONFIG=${TEMPDIR}/aws.toml AWS_CONFIG=${TEMPDIR}/aws.toml
@ -93,7 +88,7 @@ $AWS_CMD --version
# Get the compose log. # Get the compose log.
get_compose_log () { get_compose_log () {
COMPOSE_ID=$1 COMPOSE_ID=$1
LOG_FILE=${WORKSPACE}/osbuild-${ID}-${VERSION_ID}-aws.log LOG_FILE=${ARTIFACTS}/osbuild-${ID}-${VERSION_ID}-aws.log
# Download the logs. # Download the logs.
sudo composer-cli compose log "$COMPOSE_ID" | tee "$LOG_FILE" > /dev/null sudo composer-cli compose log "$COMPOSE_ID" | tee "$LOG_FILE" > /dev/null
@ -102,7 +97,7 @@ get_compose_log () {
# Get the compose metadata. # Get the compose metadata.
get_compose_metadata () { get_compose_metadata () {
COMPOSE_ID=$1 COMPOSE_ID=$1
METADATA_FILE=${WORKSPACE}/osbuild-${ID}-${VERSION_ID}-aws.json METADATA_FILE=${ARTIFACTS}/osbuild-${ID}-${VERSION_ID}-aws.json
# Download the metadata. # Download the metadata.
sudo composer-cli compose metadata "$COMPOSE_ID" > /dev/null sudo composer-cli compose metadata "$COMPOSE_ID" > /dev/null
@ -257,6 +252,9 @@ AWS_ACCESS_KEY_ID=${V2_AWS_ACCESS_KEY_ID} \
AWS_SECRET_ACCESS_KEY=${V2_AWS_SECRET_ACCESS_KEY} \ AWS_SECRET_ACCESS_KEY=${V2_AWS_SECRET_ACCESS_KEY} \
python3 cloud-image-val.py -r resource-file.json -d -o report.xml -m 'not pub' && RESULTS=1 || RESULTS=0 python3 cloud-image-val.py -r resource-file.json -d -o report.xml -m 'not pub' && RESULTS=1 || RESULTS=0
# copy the report to artifacts folder
cp report.html "${ARTIFACTS}"
popd popd
# Clean up our mess. # Clean up our mess.

View file

@ -94,11 +94,7 @@ ARCH=$(uname -m)
TEST_ID="$DISTRO_CODE-$ARCH-$BRANCH_NAME-$BUILD_ID" TEST_ID="$DISTRO_CODE-$ARCH-$BRANCH_NAME-$BUILD_ID"
IMAGE_KEY=image-${TEST_ID} IMAGE_KEY=image-${TEST_ID}
# Jenkins sets WORKSPACE to the job workspace, but if this script runs ARTIFACTS="${ARTIFACTS:-/tmp/artifacts}"
# outside of Jenkins, we can set up a temporary directory instead.
if [[ ${WORKSPACE:-empty} == empty ]]; then
WORKSPACE=$(mktemp -d)
fi
# Set up temporary files. # Set up temporary files.
AZURE_CONFIG=${TEMPDIR}/azure.toml AZURE_CONFIG=${TEMPDIR}/azure.toml
@ -119,7 +115,7 @@ smoke_test_check () {
# Get the compose log. # Get the compose log.
get_compose_log () { get_compose_log () {
COMPOSE_ID=$1 COMPOSE_ID=$1
LOG_FILE=${WORKSPACE}/osbuild-${ID}-${VERSION_ID}-azure.log LOG_FILE=${ARTIFACTS}/osbuild-${ID}-${VERSION_ID}-azure.log
# Download the logs. # Download the logs.
sudo composer-cli compose log "$COMPOSE_ID" | tee "$LOG_FILE" > /dev/null sudo composer-cli compose log "$COMPOSE_ID" | tee "$LOG_FILE" > /dev/null
@ -128,7 +124,7 @@ get_compose_log () {
# Get the compose metadata. # Get the compose metadata.
get_compose_metadata () { get_compose_metadata () {
COMPOSE_ID=$1 COMPOSE_ID=$1
METADATA_FILE=${WORKSPACE}/osbuild-${ID}-${VERSION_ID}-azure.json METADATA_FILE=${ARTIFACTS}/osbuild-${ID}-${VERSION_ID}-azure.json
# Download the metadata. # Download the metadata.
sudo composer-cli compose metadata "$COMPOSE_ID" > /dev/null sudo composer-cli compose metadata "$COMPOSE_ID" > /dev/null

View file

@ -23,6 +23,7 @@ source /usr/libexec/osbuild-composer-test/set-env-variables.sh
/usr/libexec/osbuild-composer-test/provision.sh /usr/libexec/osbuild-composer-test/provision.sh
ARTIFACTS="${ARTIFACTS:-/tmp/artifacts}"
TEMPDIR=$(mktemp -d) TEMPDIR=$(mktemp -d)
function cleanup() { function cleanup() {
greenprint "== Script execution stopped or finished - Cleaning up ==" greenprint "== Script execution stopped or finished - Cleaning up =="
@ -33,7 +34,7 @@ trap cleanup EXIT
# Get the compose log. # Get the compose log.
get_compose_log () { get_compose_log () {
COMPOSE_ID=$1 COMPOSE_ID=$1
LOG_FILE=${TEMPDIR}/osbuild-${ID}-${VERSION_ID}-azure.log LOG_FILE=${ARTIFACTS}/osbuild-${ID}-${VERSION_ID}-azure.log
# Download the logs. # Download the logs.
sudo composer-cli compose log "$COMPOSE_ID" | tee "$LOG_FILE" > /dev/null sudo composer-cli compose log "$COMPOSE_ID" | tee "$LOG_FILE" > /dev/null
@ -42,7 +43,7 @@ get_compose_log () {
# Get the compose metadata. # Get the compose metadata.
get_compose_metadata () { get_compose_metadata () {
COMPOSE_ID=$1 COMPOSE_ID=$1
METADATA_FILE=${TEMPDIR}/osbuild-${ID}-${VERSION_ID}-azure.json METADATA_FILE=${ARTIFACTS}/osbuild-${ID}-${VERSION_ID}-azure.json
# Download the metadata. # Download the metadata.
sudo composer-cli compose metadata "$COMPOSE_ID" > /dev/null sudo composer-cli compose metadata "$COMPOSE_ID" > /dev/null

View file

@ -85,12 +85,7 @@ else
TEST_ID=$(uuidgen); TEST_ID=$(uuidgen);
fi fi
ARTIFACTS="${ARTIFACTS:-/tmp/artifacts}"
# Jenkins sets WORKSPACE to the job workspace, but if this script runs
# outside of Jenkins, we can set up a temporary directory instead.
if [[ ${WORKSPACE:-empty} == empty ]]; then
WORKSPACE=$(mktemp -d)
fi
# Set up temporary files. # Set up temporary files.
GCP_CONFIG=${TEMPDIR}/gcp.toml GCP_CONFIG=${TEMPDIR}/gcp.toml
@ -199,7 +194,7 @@ function _instanceCheck() {
# Get the compose log. # Get the compose log.
get_compose_log () { get_compose_log () {
COMPOSE_ID=$1 COMPOSE_ID=$1
LOG_FILE=${WORKSPACE}/osbuild-${ID}-${VERSION_ID}-gcp.log LOG_FILE=${ARTIFACTS}/osbuild-${ID}-${VERSION_ID}-gcp.log
# Download the logs. # Download the logs.
sudo composer-cli compose log "$COMPOSE_ID" | tee "$LOG_FILE" > /dev/null sudo composer-cli compose log "$COMPOSE_ID" | tee "$LOG_FILE" > /dev/null
@ -208,7 +203,7 @@ get_compose_log () {
# Get the compose metadata. # Get the compose metadata.
get_compose_metadata () { get_compose_metadata () {
COMPOSE_ID=$1 COMPOSE_ID=$1
METADATA_FILE=${WORKSPACE}/osbuild-${ID}-${VERSION_ID}-gcp.json METADATA_FILE=${ARTIFACTS}/osbuild-${ID}-${VERSION_ID}-gcp.json
# Download the metadata. # Download the metadata.
sudo composer-cli compose metadata "$COMPOSE_ID" > /dev/null sudo composer-cli compose metadata "$COMPOSE_ID" > /dev/null

View file

@ -138,9 +138,7 @@ SSH_USER="admin"
IMAGE_KEY="osbuild-composer-installer-test-${TEST_UUID}" IMAGE_KEY="osbuild-composer-installer-test-${TEST_UUID}"
GUEST_ADDRESS=192.168.100.50 GUEST_ADDRESS=192.168.100.50
if [[ ${WORKSPACE:-empty} == empty ]]; then ARTIFACTS="${ARTIFACTS:-/tmp/artifacts}"
WORKSPACE=$(mktemp -d)
fi
# Set up temporary files. # Set up temporary files.
TEMPDIR=$(mktemp -d) TEMPDIR=$(mktemp -d)
@ -154,8 +152,6 @@ SSH_DATA_DIR=$(/usr/libexec/osbuild-composer-test/gen-ssh.sh)
SSH_KEY=${SSH_DATA_DIR}/id_rsa SSH_KEY=${SSH_DATA_DIR}/id_rsa
SSH_KEY_PUB=$(cat "${SSH_KEY}".pub) SSH_KEY_PUB=$(cat "${SSH_KEY}".pub)
ARTIFACTS="ci-artifacts"
mkdir -p "${ARTIFACTS}"
# Get the compose log. # Get the compose log.
get_compose_log () { get_compose_log () {
COMPOSE_ID=$1 COMPOSE_ID=$1
@ -169,8 +165,8 @@ get_compose_log () {
# Get the compose metadata. # Get the compose metadata.
get_compose_metadata () { get_compose_metadata () {
COMPOSE_ID=$1 COMPOSE_ID=$1
METADATA_FILE=${ARTIFACTS}/osbuild-${ID}-${VERSION_ID}-${COMPOSE_ID}.json
greenprint "Saving manifest for ${COMPOSE_ID}" greenprint "Saving manifest for ${COMPOSE_ID}"
METADATA_FILE=${ARTIFACTS}/osbuild-${ID}-${VERSION_ID}-${COMPOSE_ID}.json
# Download the metadata. # Download the metadata.
sudo composer-cli compose metadata "$COMPOSE_ID" > /dev/null sudo composer-cli compose metadata "$COMPOSE_ID" > /dev/null

View file

@ -6,8 +6,7 @@ DNF_JSON_PATH="/usr/libexec/osbuild-composer/dnf-json"
IMAGE_TEST_CASES_PATH="/usr/share/tests/osbuild-composer/manifests" IMAGE_TEST_CASES_PATH="/usr/share/tests/osbuild-composer/manifests"
WORKING_DIRECTORY=/usr/libexec/osbuild-composer WORKING_DIRECTORY=/usr/libexec/osbuild-composer
mkdir --parents /tmp/logs ARTIFACTS="${ARTIFACTS:-/tmp/artifacts}"
LOGS_DIRECTORY=$(mktemp --directory --tmpdir=/tmp/logs)
# Print out a nice test divider so we know when tests stop and start. # Print out a nice test divider so we know when tests stop and start.
test_divider () { test_divider () {
@ -27,7 +26,7 @@ test_divider
echo "🏃🏻 Running test: ${TEST_NAME}" echo "🏃🏻 Running test: ${TEST_NAME}"
test_divider test_divider
if sudo "$MANIFEST_TESTS_RUNNER" -test.v -manifests-path "$IMAGE_TEST_CASES_PATH" -dnf-json-path "$DNF_JSON_PATH" | tee "${LOGS_DIRECTORY}"/"${TEST_NAME}".log; then if sudo "$MANIFEST_TESTS_RUNNER" -test.v -manifests-path "$IMAGE_TEST_CASES_PATH" -dnf-json-path "$DNF_JSON_PATH" | tee "${ARTIFACTS}"/"${TEST_NAME}".log; then
echo "🎉 Test passed." echo "🎉 Test passed."
exit 0 exit 0
else else

View file

@ -84,13 +84,12 @@ QUAY_REPO_URL="quay.io/osbuild/testing-rhel-edge-push"
QUAY_REPO_TAG=$(tr -dc a-z0-9 < /dev/urandom | head -c 4 ; echo '') QUAY_REPO_TAG=$(tr -dc a-z0-9 < /dev/urandom | head -c 4 ; echo '')
STAGE_OCP4_SERVER_NAME="edge-stage-server" STAGE_OCP4_SERVER_NAME="edge-stage-server"
STAGE_OCP4_REPO_URL="http://${STAGE_OCP4_SERVER_NAME}-${QUAY_REPO_TAG}-frontdoor.apps.ocp.ci.centos.org/repo/" STAGE_OCP4_REPO_URL="http://${STAGE_OCP4_SERVER_NAME}-${QUAY_REPO_TAG}-frontdoor.apps.ocp.ci.centos.org/repo/"
ARTIFACTS="ci-artifacts" ARTIFACTS="${ARTIFACTS:-/tmp/artifacts}"
# For CS8, CS9, RHEL 8.5 and above # For CS8, CS9, RHEL 8.5 and above
CONTAINER_TYPE=edge-container CONTAINER_TYPE=edge-container
CONTAINER_FILENAME=container.tar CONTAINER_FILENAME=container.tar
INSTALLER_TYPE=edge-installer INSTALLER_TYPE=edge-installer
INSTALLER_FILENAME=installer.iso INSTALLER_FILENAME=installer.iso
mkdir -p "${ARTIFACTS}"
ANSIBLE_USER_FOR_BIOS="installeruser" ANSIBLE_USER_FOR_BIOS="installeruser"
OSTREE_OSNAME=rhel OSTREE_OSNAME=rhel

View file

@ -76,12 +76,11 @@ PROD_REPO_URL=http://192.168.100.1/repo
PROD_REPO=/var/www/html/repo PROD_REPO=/var/www/html/repo
STAGE_REPO_ADDRESS=192.168.200.1 STAGE_REPO_ADDRESS=192.168.200.1
STAGE_REPO_URL="http://${STAGE_REPO_ADDRESS}:8080/repo/" STAGE_REPO_URL="http://${STAGE_REPO_ADDRESS}:8080/repo/"
ARTIFACTS="ci-artifacts" ARTIFACTS="${ARTIFACTS:-/tmp/artifacts}"
CONTAINER_TYPE=edge-container CONTAINER_TYPE=edge-container
CONTAINER_FILENAME=container.tar CONTAINER_FILENAME=container.tar
INSTALLER_TYPE=edge-raw-image INSTALLER_TYPE=edge-raw-image
INSTALLER_FILENAME=image.raw.xz INSTALLER_FILENAME=image.raw.xz
mkdir -p "${ARTIFACTS}"
# Set up temporary files. # Set up temporary files.
TEMPDIR=$(mktemp -d) TEMPDIR=$(mktemp -d)

View file

@ -78,10 +78,9 @@ BIOS_GUEST_ADDRESS=192.168.100.50
UEFI_GUEST_ADDRESS=192.168.100.51 UEFI_GUEST_ADDRESS=192.168.100.51
PROD_REPO_ADDRESS=192.168.200.1 PROD_REPO_ADDRESS=192.168.200.1
PROD_REPO_URL="http://${PROD_REPO_ADDRESS}:8080/repo/" PROD_REPO_URL="http://${PROD_REPO_ADDRESS}:8080/repo/"
ARTIFACTS="ci-artifacts" ARTIFACTS="${ARTIFACTS:-/tmp/artifacts}"
CONTAINER_TYPE=edge-container CONTAINER_TYPE=edge-container
CONTAINER_FILENAME=container.tar CONTAINER_FILENAME=container.tar
mkdir -p "${ARTIFACTS}"
# Set up temporary files. # Set up temporary files.
TEMPDIR=$(mktemp -d) TEMPDIR=$(mktemp -d)

View file

@ -94,12 +94,11 @@ FDO_SERVER_ADDRESS=192.168.200.2
FDO_ADMIN_CLI_VERSION=0.4.0 FDO_ADMIN_CLI_VERSION=0.4.0
# FDO Manualfacture server image version # FDO Manualfacture server image version
FDO_MF_SERVER_VERSION=0.4.0 FDO_MF_SERVER_VERSION=0.4.0
ARTIFACTS="ci-artifacts" ARTIFACTS="${ARTIFACTS:-/tmp/artifacts}"
CONTAINER_TYPE=edge-container CONTAINER_TYPE=edge-container
CONTAINER_FILENAME=container.tar CONTAINER_FILENAME=container.tar
INSTALLER_TYPE=edge-simplified-installer INSTALLER_TYPE=edge-simplified-installer
INSTALLER_FILENAME=simplified-installer.iso INSTALLER_FILENAME=simplified-installer.iso
mkdir -p "${ARTIFACTS}"
# Set up temporary files. # Set up temporary files.
TEMPDIR=$(mktemp -d) TEMPDIR=$(mktemp -d)

View file

@ -151,8 +151,7 @@ TEST_UUID=$(uuidgen)
IMAGE_KEY="osbuild-composer-ostree-test-${TEST_UUID}" IMAGE_KEY="osbuild-composer-ostree-test-${TEST_UUID}"
GUEST_ADDRESS=192.168.100.50 GUEST_ADDRESS=192.168.100.50
SSH_USER="admin" SSH_USER="admin"
ARTIFACTS="ci-artifacts" ARTIFACTS="${ARTIFACTS:-/tmp/artifacts}"
mkdir -p "${ARTIFACTS}"
# Set up temporary files. # Set up temporary files.
TEMPDIR=$(mktemp -d) TEMPDIR=$(mktemp -d)

View file

@ -12,8 +12,7 @@ function greenprint {
echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m" echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m"
} }
ARTIFACTS=ci-artifacts ARTIFACTS="${ARTIFACTS:-/tmp/artifacts}"
mkdir -p "${ARTIFACTS}"
source /usr/libexec/osbuild-composer-test/set-env-variables.sh source /usr/libexec/osbuild-composer-test/set-env-variables.sh

View file

@ -4,6 +4,8 @@ set -uxo pipefail
# Get OS data. # Get OS data.
source /usr/libexec/osbuild-composer-test/set-env-variables.sh source /usr/libexec/osbuild-composer-test/set-env-variables.sh
ARTIFACTS="${ARTIFACTS:-/tmp/artifacts}"
# Colorful output. # Colorful output.
function greenprint { function greenprint {
echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m" echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m"
@ -123,9 +125,9 @@ sudo scp "${SSH_OPTIONS[@]}" -q -i "${SSH_KEY}" /usr/share/tests/osbuild-compose
sudo ssh "${SSH_OPTIONS[@]}" -q -i "${SSH_KEY}" root@"$INSTANCE_ADDRESS" 'sed -i "s/PermitRootLogin yes/PermitRootLogin yes #for sure/" /etc/ssh/sshd_config' sudo ssh "${SSH_OPTIONS[@]}" -q -i "${SSH_KEY}" root@"$INSTANCE_ADDRESS" 'sed -i "s/PermitRootLogin yes/PermitRootLogin yes #for sure/" /etc/ssh/sshd_config'
set +e set +e
sudo ssh "${SSH_OPTIONS[@]}" -q -i "${SSH_KEY}" root@"$INSTANCE_ADDRESS" 'source /root/upgrade_prepare.sh' sudo ssh "${SSH_OPTIONS[@]}" -q -i "${SSH_KEY}" root@"$INSTANCE_ADDRESS" 'source /root/upgrade_prepare.sh'
sudo scp "${SSH_OPTIONS[@]}" -q -i "${SSH_KEY}" root@"$INSTANCE_ADDRESS":/var/log/leapp/leapp-preupgrade.log . sudo scp "${SSH_OPTIONS[@]}" -q -i "${SSH_KEY}" root@"$INSTANCE_ADDRESS":/var/log/leapp/leapp-preupgrade.log "$ARTIFACTS"
sudo scp "${SSH_OPTIONS[@]}" -q -i "${SSH_KEY}" root@"$INSTANCE_ADDRESS":/var/log/leapp/leapp-upgrade.log . sudo scp "${SSH_OPTIONS[@]}" -q -i "${SSH_KEY}" root@"$INSTANCE_ADDRESS":/var/log/leapp/leapp-upgrade.log "$ARTIFACTS"
sudo scp "${SSH_OPTIONS[@]}" -q -i "${SSH_KEY}" root@"$INSTANCE_ADDRESS":/var/log/leapp/leapp-report.txt . sudo scp "${SSH_OPTIONS[@]}" -q -i "${SSH_KEY}" root@"$INSTANCE_ADDRESS":/var/log/leapp/leapp-report.txt "$ARTIFACTS"
set -e set -e
# watch and log the console during upgrade # watch and log the console during upgrade
@ -143,7 +145,7 @@ RESULT="$?"
set -e set -e
# copy over osbuild-composer logs # copy over osbuild-composer logs
sudo scp "${SSH_OPTIONS[@]}" -q -i "${SSH_KEY}" root@"$INSTANCE_ADDRESS":logs/* . sudo scp "${SSH_OPTIONS[@]}" -q -i "${SSH_KEY}" root@"$INSTANCE_ADDRESS":logs/* "$ARTIFACTS"
if [[ "$RESULT" == 0 ]]; then if [[ "$RESULT" == 0 ]]; then
greenprint "💚 Success" greenprint "💚 Success"

View file

@ -59,11 +59,7 @@ fi
TEST_UUID=$(uuidgen) TEST_UUID=$(uuidgen)
IMAGE_KEY=osbuild-composer-vmware-test-${TEST_UUID} IMAGE_KEY=osbuild-composer-vmware-test-${TEST_UUID}
# Jenkins sets WORKSPACE to the job workspace, but if this script runs ARTIFACTS="${ARTIFACTS:-/tmp/artifacts}"
# outside of Jenkins, we can set up a temporary directory instead.
if [[ ${WORKSPACE:-empty} == empty ]]; then
WORKSPACE=$(mktemp -d)
fi
# Set up temporary files # Set up temporary files
TEMPDIR=$(mktemp -d) TEMPDIR=$(mktemp -d)
@ -89,7 +85,7 @@ running_test_check () {
# Get the compose log. # Get the compose log.
get_compose_log () { get_compose_log () {
COMPOSE_ID=$1 COMPOSE_ID=$1
LOG_FILE=${WORKSPACE}/osbuild-${ID}-${VERSION_ID}-vmware.log LOG_FILE=${ARTIFACTS}/osbuild-${ID}-${VERSION_ID}-vmware.log
# Download the logs. # Download the logs.
sudo composer-cli compose log "$COMPOSE_ID" | tee "$LOG_FILE" > /dev/null sudo composer-cli compose log "$COMPOSE_ID" | tee "$LOG_FILE" > /dev/null
@ -98,7 +94,7 @@ get_compose_log () {
# Get the compose metadata. # Get the compose metadata.
get_compose_metadata () { get_compose_metadata () {
COMPOSE_ID=$1 COMPOSE_ID=$1
METADATA_FILE=${WORKSPACE}/osbuild-${ID}-${VERSION_ID}-vmware.json METADATA_FILE=${ARTIFACTS}/osbuild-${ID}-${VERSION_ID}-vmware.json
# Download the metadata. # Download the metadata.
sudo composer-cli compose metadata "$COMPOSE_ID" > /dev/null sudo composer-cli compose metadata "$COMPOSE_ID" > /dev/null

View file

@ -90,10 +90,7 @@ BLUEPRINT_FILE=${TEMPDIR}/blueprint.toml
COMPOSE_START=${TEMPDIR}/compose-start-${IMAGE_KEY}.json COMPOSE_START=${TEMPDIR}/compose-start-${IMAGE_KEY}.json
COMPOSE_INFO=${TEMPDIR}/compose-info-${IMAGE_KEY}.json COMPOSE_INFO=${TEMPDIR}/compose-info-${IMAGE_KEY}.json
if [[ ${WORKSPACE:-empty} == empty ]]; then ARTIFACTS="${ARTIFACTS:-/tmp/artifacts}"
WORKSPACE=$(mktemp -d)
fi
SSH_DATA_DIR=$(/usr/libexec/osbuild-composer-test/gen-ssh.sh) SSH_DATA_DIR=$(/usr/libexec/osbuild-composer-test/gen-ssh.sh)
SSH_KEY=${SSH_DATA_DIR}/id_rsa SSH_KEY=${SSH_DATA_DIR}/id_rsa
@ -112,7 +109,7 @@ smoke_test_check () {
# Get the compose log. # Get the compose log.
get_compose_log () { get_compose_log () {
COMPOSE_ID=$1 COMPOSE_ID=$1
LOG_FILE=${WORKSPACE}/osbuild-${ID}-${VERSION_ID}-${IMAGE_TYPE}.log LOG_FILE=${ARTIFACTS}/osbuild-${ID}-${VERSION_ID}-${IMAGE_TYPE}.log
# Download the logs. # Download the logs.
sudo composer-cli compose log "$COMPOSE_ID" | tee "$LOG_FILE" > /dev/null sudo composer-cli compose log "$COMPOSE_ID" | tee "$LOG_FILE" > /dev/null
@ -121,7 +118,7 @@ get_compose_log () {
# Get the compose metadata. # Get the compose metadata.
get_compose_metadata () { get_compose_metadata () {
COMPOSE_ID=$1 COMPOSE_ID=$1
METADATA_FILE=${WORKSPACE}/osbuild-${ID}-${VERSION_ID}-${IMAGE_TYPE}.json METADATA_FILE=${ARTIFACTS}/osbuild-${ID}-${VERSION_ID}-${IMAGE_TYPE}.json
# Download the metadata. # Download the metadata.
sudo composer-cli compose metadata "$COMPOSE_ID" > /dev/null sudo composer-cli compose metadata "$COMPOSE_ID" > /dev/null

View file

@ -3,6 +3,10 @@ set -euxo pipefail
source /usr/libexec/osbuild-composer-test/set-env-variables.sh source /usr/libexec/osbuild-composer-test/set-env-variables.sh
# create artifacts folder
ARTIFACTS="${ARTIFACTS:=/tmp/artifacts}"
mkdir -p "${ARTIFACTS}"
# koji and ansible are not in RHEL repositories. Depending on them in the spec # koji and ansible are not in RHEL repositories. Depending on them in the spec
# file breaks RHEL gating (see OSCI-1541). Therefore, we need to enable epel # file breaks RHEL gating (see OSCI-1541). Therefore, we need to enable epel
# and install koji and ansible here. # and install koji and ansible here.

View file

@ -29,11 +29,7 @@ function cleanup() {
} }
trap cleanup EXIT trap cleanup EXIT
# Jenkins sets WORKSPACE to the job workspace, but if this script runs ARTIFACTS="${ARTIFACTS:-/tmp/artifacts}"
# outside of Jenkins, we can set up a temporary directory instead.
if [[ ${WORKSPACE:-empty} == empty ]]; then
WORKSPACE=$(mktemp -d)
fi
# Set up temporary files. # Set up temporary files.
BLUEPRINT_FILE=${TEMPDIR}/blueprint.toml BLUEPRINT_FILE=${TEMPDIR}/blueprint.toml
@ -44,7 +40,7 @@ COMPOSE_INFO=${TEMPDIR}/compose-info-${TEST_ID}.json
# Get the compose log. # Get the compose log.
get_compose_log () { get_compose_log () {
COMPOSE_ID=$1 COMPOSE_ID=$1
LOG_FILE=${WORKSPACE}/osbuild-${ID}-${VERSION_ID}-aws.log LOG_FILE=${ARTIFACTS}/osbuild-${ID}-${VERSION_ID}-aws.log
# Download the logs. # Download the logs.
sudo composer-cli compose log "$COMPOSE_ID" | tee "$LOG_FILE" > /dev/null sudo composer-cli compose log "$COMPOSE_ID" | tee "$LOG_FILE" > /dev/null
@ -53,7 +49,7 @@ get_compose_log () {
# Get the compose metadata. # Get the compose metadata.
get_compose_metadata () { get_compose_metadata () {
COMPOSE_ID=$1 COMPOSE_ID=$1
METADATA_FILE=${WORKSPACE}/osbuild-${ID}-${VERSION_ID}-aws.json METADATA_FILE=${ARTIFACTS}/osbuild-${ID}-${VERSION_ID}-aws.json
# Download the metadata. # Download the metadata.
sudo composer-cli compose metadata "$COMPOSE_ID" > /dev/null sudo composer-cli compose metadata "$COMPOSE_ID" > /dev/null