diff --git a/schutzbot/Jenkinsfile b/schutzbot/Jenkinsfile index 65f703a1..907e29c0 100644 --- a/schutzbot/Jenkinsfile +++ b/schutzbot/Jenkinsfile @@ -101,7 +101,11 @@ pipeline { parallel { stage('Fedora 31') { agent { label "f31cloudbase && x86_64 && psi" } - environment { TEST_TYPE = "image" } + environment { + TEST_TYPE = "image" + AWS_CREDS = credentials('aws-credentials-osbuildci') + DISTRO_CODE = "fedora31" + } steps { unstash 'fedora31' run_tests() @@ -114,7 +118,11 @@ pipeline { } stage('Fedora 32') { agent { label "f32cloudbase && x86_64 && psi" } - environment { TEST_TYPE = "image" } + environment { + TEST_TYPE = "image" + AWS_CREDS = credentials('aws-credentials-osbuildci') + DISTRO_CODE = "fedora32" + } steps { unstash 'fedora32' run_tests() @@ -130,6 +138,8 @@ pipeline { environment { TEST_TYPE = "image" RHN_REGISTRATION_SCRIPT = credentials('rhn-register-script-production') + AWS_CREDS = credentials('aws-credentials-osbuildci') + DISTRO_CODE = "rhel8" } steps { unstash 'rhel8cdn' @@ -146,6 +156,8 @@ pipeline { environment { TEST_TYPE = "image" RHN_REGISTRATION_SCRIPT = credentials('rhn-register-script-production-beta') + AWS_CREDS = credentials('aws-credentials-osbuildci') + DISTRO_CODE = "rhel83" } steps { unstash 'rhel83' diff --git a/schutzbot/run_image_tests.sh b/schutzbot/run_image_tests.sh index ae50d86c..cac03020 100755 --- a/schutzbot/run_image_tests.sh +++ b/schutzbot/run_image_tests.sh @@ -21,7 +21,7 @@ test_divider () { get_test_cases () { TEST_CASE_SELECTOR="${ID}_${VERSION_ID%.*}-${ARCH}*.json" pushd $IMAGE_TEST_CASES_PATH > /dev/null - ls $TEST_CASE_SELECTOR + ls "$TEST_CASE_SELECTOR" popd > /dev/null } @@ -29,19 +29,40 @@ get_test_cases () { run_test_case () { TEST_RUNNER=$1 TEST_CASE_FILENAME=$2 - TEST_NAME=$(basename $TEST_CASE_FILENAME) + TEST_NAME=$(basename "$TEST_CASE_FILENAME") echo test_divider echo "🏃🏻 Running test: ${TEST_NAME}" test_divider - # Set up the testing command. - TEST_CMD="$TEST_RUNNER -test.v ${IMAGE_TEST_CASES_PATH}/${TEST_CASE_FILENAME}" + # Set up the testing command with Azure secrets in the environment. + # + # This works by having a text file stored in Jenkins credentials. + # In Jenkinsfile, the following line assigns the path to this secret file + # to an environment variable called AZURE_CREDS: + # AZURE_CREDS = credentials('azure') + # + # The file is in the following format: + # KEY1=VALUE1 + # KEY2=VALUE2 + # + # Using `env $(cat $AZURE_CREDS)` we can take all the key-value pairs and + # save them as environment variables. + # Read test/README.md to see all required environment variables for Azure + # uploads + # + # AZURE_CREDS might not be defined in all cases (e.g. Azure doesn't + # support aarch64), therefore the following line sets AZURE_CREDS to + # /dev/null if the variable is undefined. + AZURE_CREDS=${AZURE_CREDS-/dev/null} + OPENSTACK_CREDS=${OPENSTACK_CREDS-/dev/null} + VCENTER_CREDS=${VCENTER_CREDS-/dev/null} + TEST_CMD="env $(cat "$AZURE_CREDS" "$OPENSTACK_CREDS" "$VCENTER_CREDS") BRANCH_NAME=${BRANCH_NAME-master} BUILD_ID=$BUILD_ID DISTRO_CODE=$DISTRO_CODE $TEST_RUNNER -test.v ${IMAGE_TEST_CASES_PATH}/${TEST_CASE_FILENAME}" # Run the test and add the test name to the list of passed or failed # tests depending on the result. - if sudo $TEST_CMD 2>&1 | tee ${WORKSPACE}/${TEST_NAME}.log; then + if sudo "$TEST_CMD" 2>&1 | tee "${WORKSPACE}"/"${TEST_NAME}".log; then PASSED_TESTS+=("$TEST_NAME") else FAILED_TESTS+=("$TEST_NAME") @@ -61,13 +82,7 @@ cd $WORKING_DIRECTORY # Run each test case. for TEST_CASE in $(get_test_cases); do - # The fedora_32-x86_64-fedora_iot_commit-boot test has some bugs that - # still need to be worked out. See this bug for details: - # https://github.com/osbuild/osbuild-composer/issues/798 - if [[ $TEST_CASE == *fedora_iot_commit* ]]; then - continue - fi - run_test_case $IMAGE_TEST_CASE_RUNNER $TEST_CASE + run_test_case $IMAGE_TEST_CASE_RUNNER "$TEST_CASE" done # Print a report of the test results. @@ -83,4 +98,4 @@ if [ ${#FAILED_TESTS[@]} -eq 0 ]; then else echo "🔥 One or more tests failed." exit 1 -fi \ No newline at end of file +fi