From d0e947fe3b720af30e7df8166120063fbe80ac62 Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Wed, 10 Jul 2019 08:58:24 -0700 Subject: [PATCH] tests: Add check to make sure the compose actually finished Previously it was looping, waiting for FINISHED|FAILED but was not actually failing the test if the compose failed to build. This adds a function to check the status of the compose and calls it after each compose. --- tests/cli/lib/lib.sh | 9 +++++++++ tests/cli/test_compose_ext4-filesystem.sh | 1 + tests/cli/test_compose_google.sh | 1 + tests/cli/test_compose_live-iso.sh | 1 + tests/cli/test_compose_partitioned-disk.sh | 1 + tests/cli/test_compose_qcow2.sh | 1 + tests/cli/test_compose_sanity.sh | 1 + tests/cli/test_compose_tar.sh | 1 + 8 files changed, 16 insertions(+) diff --git a/tests/cli/lib/lib.sh b/tests/cli/lib/lib.sh index 98fa1a76..c517ea02 100755 --- a/tests/cli/lib/lib.sh +++ b/tests/cli/lib/lib.sh @@ -64,3 +64,12 @@ check_kernel_cmdline() { rlRun -t -c "ssh $SSH_OPTS ${SSH_USER}@${SSH_MACHINE} 'grep custom_cmdline_arg /proc/cmdline'" 0 \ "System booted from the image contains specified parameter on kernel command line" } + +# Fail if the compose failed, only call after checking for FINISHED|FAILED +check_compose_status() { + UUID="$1" + if "$CLI" compose info "$UUID" | grep FAILED; then + rlFail "compose $UUID FAILED" + return 1 + fi +} diff --git a/tests/cli/test_compose_ext4-filesystem.sh b/tests/cli/test_compose_ext4-filesystem.sh index e31fe8d7..7ba1d231 100755 --- a/tests/cli/test_compose_ext4-filesystem.sh +++ b/tests/cli/test_compose_ext4-filesystem.sh @@ -32,6 +32,7 @@ rlJournalStart sleep 10 rlLogInfo "Waiting for compose to finish ..." done; + check_compose_status "$UUID" else rlFail "Compose UUID is empty!" fi diff --git a/tests/cli/test_compose_google.sh b/tests/cli/test_compose_google.sh index 7842bf1d..84e5b112 100755 --- a/tests/cli/test_compose_google.sh +++ b/tests/cli/test_compose_google.sh @@ -28,6 +28,7 @@ rlJournalStart sleep 10 rlLogInfo "Waiting for compose to finish..." done + check_compose_status "$UUID" else flFail "Compose UUID is empty!" fi diff --git a/tests/cli/test_compose_live-iso.sh b/tests/cli/test_compose_live-iso.sh index 840004fd..c3d8a1e8 100755 --- a/tests/cli/test_compose_live-iso.sh +++ b/tests/cli/test_compose_live-iso.sh @@ -37,6 +37,7 @@ rlJournalStart sleep 20 rlLogInfo "Waiting for compose to finish ..." done; + check_compose_status "$UUID" else rlFail "Compose UUID is empty!" fi diff --git a/tests/cli/test_compose_partitioned-disk.sh b/tests/cli/test_compose_partitioned-disk.sh index b229a52e..ce3e9138 100755 --- a/tests/cli/test_compose_partitioned-disk.sh +++ b/tests/cli/test_compose_partitioned-disk.sh @@ -32,6 +32,7 @@ rlJournalStart sleep 10 rlLogInfo "Waiting for compose to finish ..." done; + check_compose_status "$UUID" else rlFail "Compose UUID is empty!" fi diff --git a/tests/cli/test_compose_qcow2.sh b/tests/cli/test_compose_qcow2.sh index f9f65ace..dd23f709 100755 --- a/tests/cli/test_compose_qcow2.sh +++ b/tests/cli/test_compose_qcow2.sh @@ -65,6 +65,7 @@ __EOF__ sleep 20 rlLogInfo "Waiting for compose to finish ..." done; + check_compose_status "$UUID" else rlFail "Compose UUID is empty!" fi diff --git a/tests/cli/test_compose_sanity.sh b/tests/cli/test_compose_sanity.sh index 38ba65e4..0b401026 100755 --- a/tests/cli/test_compose_sanity.sh +++ b/tests/cli/test_compose_sanity.sh @@ -36,6 +36,7 @@ rlJournalStart sleep 5 rlLogInfo "Waiting for compose to finish ..." done; + check_compose_status "$UUID" rlRun -t -c "$CLI compose image $UUID" rlAssertExists "$UUID-root.tar.xz" diff --git a/tests/cli/test_compose_tar.sh b/tests/cli/test_compose_tar.sh index ad035a7d..cb163f1a 100755 --- a/tests/cli/test_compose_tar.sh +++ b/tests/cli/test_compose_tar.sh @@ -34,6 +34,7 @@ rlJournalStart sleep 10 rlLogInfo "Waiting for compose to finish ..." done; + check_compose_status "$UUID" else rlFail "Compose UUID is empty!" fi