diff --git a/test/cases/aws.sh b/test/cases/aws.sh index c18e01806..d4ca5d6ca 100755 --- a/test/cases/aws.sh +++ b/test/cases/aws.sh @@ -131,6 +131,8 @@ sudo composer-cli blueprints depsolve bash WORKER_UNIT=$(sudo systemctl list-units | grep -o -E "osbuild.*worker.*\.service") sudo journalctl -af -n 1 -u "${WORKER_UNIT}" & WORKER_JOURNAL_PID=$! +# Stop watching the worker journal when exiting. +trap 'sudo pkill -P ${WORKER_JOURNAL_PID}' EXIT # Start the compose and upload to AWS. greenprint "🚀 Starting compose" @@ -172,9 +174,6 @@ $AWS_CMD ec2 describe-images \ AMI_IMAGE_ID=$(jq -r '.Images[].ImageId' "$AMI_DATA") -# Stop watching the worker journal. -sudo pkill -P ${WORKER_JOURNAL_PID} - # NOTE(mhayden): Getting TagSpecifications to play along with bash's # parsing of curly braces and square brackets is nuts, so we just write some # json and pass it to the aws command. diff --git a/test/cases/azure.sh b/test/cases/azure.sh index 735a0e10e..071a81a30 100755 --- a/test/cases/azure.sh +++ b/test/cases/azure.sh @@ -150,6 +150,8 @@ sudo composer-cli blueprints depsolve bash WORKER_UNIT=$(sudo systemctl list-units | grep -o -E "osbuild.*worker.*\.service") sudo journalctl -af -n 1 -u "${WORKER_UNIT}" & WORKER_JOURNAL_PID=$! +# Stop watching the worker journal when exiting. +trap 'sudo pkill -P ${WORKER_JOURNAL_PID}' EXIT # Start the compose and upload to Azure. greenprint "🚀 Starting compose" @@ -182,9 +184,6 @@ if [[ $COMPOSE_STATUS != FINISHED ]]; then exit 1 fi -# Stop watching the worker journal. -sudo pkill -P ${WORKER_JOURNAL_PID} - # Set up necessary variables for terraform export TF_VAR_RESOURCE_GROUP="$AZURE_RESOURCE_GROUP" export TF_VAR_STORAGE_ACCOUNT="$AZURE_STORAGE_ACCOUNT" diff --git a/test/cases/ostree-ng.sh b/test/cases/ostree-ng.sh index 28ac4f29d..f3b720ef6 100755 --- a/test/cases/ostree-ng.sh +++ b/test/cases/ostree-ng.sh @@ -119,6 +119,8 @@ build_image() { WORKER_UNIT=$(sudo systemctl list-units | grep -o -E "osbuild.*worker.*\.service") sudo journalctl -af -n 1 -u "${WORKER_UNIT}" & WORKER_JOURNAL_PID=$! + # Stop watching the worker journal when exiting. + trap 'sudo pkill -P ${WORKER_JOURNAL_PID}' EXIT # Start the compose. greenprint "🚀 Starting compose" @@ -155,9 +157,6 @@ build_image() { echo "Something went wrong with the compose. 😢" exit 1 fi - - # Stop watching the worker journal. - sudo pkill -P ${WORKER_JOURNAL_PID} } # Wait for the ssh server up to be. diff --git a/test/cases/ostree.sh b/test/cases/ostree.sh index 228760c1d..6c6a81e05 100755 --- a/test/cases/ostree.sh +++ b/test/cases/ostree.sh @@ -146,6 +146,8 @@ build_image() { WORKER_UNIT=$(sudo systemctl list-units | grep -o -E "osbuild.*worker.*\.service") sudo journalctl -af -n 1 -u "${WORKER_UNIT}" & WORKER_JOURNAL_PID=$! + # Stop watching the worker journal when exiting. + trap 'sudo pkill -P ${WORKER_JOURNAL_PID}' EXIT # Start the compose. greenprint "🚀 Starting compose" @@ -187,9 +189,6 @@ build_image() { echo "Something went wrong with the compose. 😢" exit 1 fi - - # Stop watching the worker journal. - sudo pkill -P ${WORKER_JOURNAL_PID} } # Wait for the ssh server up to be. diff --git a/test/cases/vmware.sh b/test/cases/vmware.sh index cbbece63d..b7ad46457 100755 --- a/test/cases/vmware.sh +++ b/test/cases/vmware.sh @@ -131,6 +131,8 @@ sudo composer-cli blueprints depsolve bash WORKER_UNIT=$(sudo systemctl list-units | grep -o -E "osbuild.*worker.*\.service") sudo journalctl -af -n 1 -u "${WORKER_UNIT}" & WORKER_JOURNAL_PID=$! +# Stop watching the worker journal when exiting. +trap 'sudo pkill -P ${WORKER_JOURNAL_PID}' EXIT # Start the compose and upload to VMWare. greenprint "🚀 Starting compose" @@ -164,9 +166,6 @@ if [[ $COMPOSE_STATUS != FINISHED ]]; then exit 1 fi -# Stop watching the worker journal. -sudo pkill -P ${WORKER_JOURNAL_PID} - greenprint "👷🏻 Building VM in vSphere" $GOVC_CMD vm.create -u "${GOVMOMI_USERNAME}":"${GOVMOMI_PASSWORD}"@"${GOVMOMI_URL}" \ -k=true \ diff --git a/tools/libvirt_test.sh b/tools/libvirt_test.sh index f5ea731c9..a20826c5f 100755 --- a/tools/libvirt_test.sh +++ b/tools/libvirt_test.sh @@ -138,6 +138,8 @@ sudo composer-cli blueprints depsolve bp WORKER_UNIT=$(sudo systemctl list-units | grep -o -E "osbuild.*worker.*\.service") sudo journalctl -af -n 1 -u "${WORKER_UNIT}" & WORKER_JOURNAL_PID=$! +# Stop watching the worker journal when exiting. +trap 'sudo pkill -P ${WORKER_JOURNAL_PID}' EXIT # Start the compose greenprint "🚀 Starting compose" @@ -170,9 +172,6 @@ if [[ $COMPOSE_STATUS != FINISHED ]]; then exit 1 fi -# Stop watching the worker journal. -sudo pkill -P ${WORKER_JOURNAL_PID} - # Download the image. greenprint "📥 Downloading the image"