Commit bf3c1360 authored by Richard Neill's avatar Richard Neill
Browse files

ewaol-tests: Ensure failing environment clean-up results in a failed test suite



Previously, if an environment clean-up failure occured it would only be reported
to the log, while the test suite might still PASS.

To avoid silent failures and therefore potentially hidden bugs, this patch
ensures the result of the environment clean-up is reflected in the result of the
test suite.

Issue-Id: SCM-4394
Signed-off-by: Richard Neill's avatarRichard Neill <richard.neill@arm.com>
Change-Id: I8a3eda61ae8bc82a7ea5f04a7bdd8f7bfda2133c
parent 4e06f23a
......@@ -25,13 +25,13 @@ clean_test_environment() {
_run base_cleanup
if [ "${status}" -ne 0 ]; then
log "FAIL"
exit 1
return 1
fi
_run extra_cleanup
if [ "${status}" -ne 0 ]; then
log "FAIL"
exit 1
return 1
fi
}
......
......@@ -42,18 +42,28 @@ clean_test_environment() {
_run base_cleanup
if [ "${status}" -ne 0 ]; then
log "FAIL"
exit 1
return 1
fi
}
# Runs once before the first test
setup_file() {
_run test_suite_setup clean_test_environment
if [ "${status}" -ne 0 ]; then
log "FAIL"
return 1
fi
}
# Runs after the final test
teardown_file() {
_run test_suite_teardown clean_test_environment
if [ "${status}" -ne 0 ]; then
log "FAIL"
return 1
fi
}
@test 'run container' {
......
......@@ -161,25 +161,39 @@ test_suite_setup() {
_run check_running_test_suite "${TEST_RUN_FILE}"
if [ "${status}" -ne 0 ]; then
exit 1
echo "${output}"
return "${status}"
fi
_run begin_test_suite "${TEST_RUN_FILE}"
if [ "${status}" -ne 0 ]; then
echo "${output}"
return "${status}"
fi
if [ "${TEST_CLEAN_ENV}" = "1" ] && [ -n "${1}" ]; then
_run "${1}"
if [ "${status}" -ne 0 ]; then
echo "${output}"
return "${status}"
fi
fi
}
test_suite_teardown() {
status=0
if [ "${TEST_CLEAN_ENV}" = "1" ] && [ -n "${1}" ]; then
_run "${1}"
fi
_run finish_test_suite "${TEST_RUN_FILE}"
# Always finish, even if the clean-up operations failed
finish_test_suite "${TEST_RUN_FILE}"
echo "${output}"
return "${status}"
}
# Helper function to wait for some condition until a given timeout, probing the
......
......@@ -28,18 +28,18 @@ clean_test_environment() {
_run base_cleanup
if [ "${status}" -ne 0 ]; then
log "FAIL"
exit 1
return 1
fi
_run cleanup_k3s_agent_on_guest_vm
if [ "${status}" -ne 0 ]; then
log "FAIL"
exit 1
return 1
fi
_run extra_cleanup
if [ "${status}" -ne 0 ]; then
log "FAIL"
exit 1
return 1
fi
}
......@@ -38,34 +38,44 @@ clean_test_environment() {
_run base_cleanup
if [ "${status}" -ne 0 ]; then
log "FAIL"
exit 1
return 1
fi
}
# Runs once before the first test
setup_file() {
_run test_suite_setup clean_test_environment
if [ "${status}" -ne 0 ]; then
log "FAIL"
return 1
fi
# If the environment clean option is disabled, we should still wait for K3s
# to be fully initialized (e.g. after booting) before running the tests
_run wait_for_k3s_to_be_running
if [ "${status}" -ne 0 ]; then
log "FAIL"
exit 1
return 1
fi
_run extra_setup
if [ "${status}" -ne 0 ]; then
log "FAIL"
exit 1
return 1
fi
}
# Runs after the final test
teardown_file() {
_run test_suite_teardown clean_test_environment
if [ "${status}" -ne 0 ]; then
log "FAIL"
return 1
fi
}
# shellcheck disable=SC2016
......
......@@ -19,7 +19,7 @@ clean_test_environment() {
_run extra_cleanup
if [ "${status}" -ne 0 ]; then
log "FAIL"
exit 1
return 1
fi
}
......
......@@ -37,12 +37,22 @@ clean_test_environment() {
# Runs once before the first test
setup_file() {
_run test_suite_setup clean_test_environment
if [ "${status}" -ne 0 ]; then
log "FAIL"
return 1
fi
}
# Runs after the final test
teardown_file() {
_run test_suite_teardown clean_test_environment
if [ "${status}" -ne 0 ]; then
log "FAIL"
return 1
fi
}
@test 'user accounts management tests' {
......
......@@ -16,6 +16,6 @@ clean_test_environment() {
_run guest_vm_reset_password
if [ "${status}" -ne 0 ]; then
log "FAIL"
exit 1
return 1
fi
}
......@@ -42,18 +42,28 @@ clean_test_environment() {
# Runs once before the first test
setup_file() {
_run test_suite_setup clean_test_environment
if [ "${status}" -ne 0 ]; then
log "FAIL"
return 1
fi
_run xendomains_and_guest_vm_is_initialized "${TEST_GUEST_VM_NAME}"
if [ "${status}" -ne 0 ]; then
log "FAIL"
exit 1
return 1
fi
}
# Runs after the final test
teardown_file() {
_run test_suite_teardown clean_test_environment
if [ "${status}" -ne 0 ]; then
log "FAIL"
return 1
fi
}
@test 'validate Guest VM is running' {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment