Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Break up os::cleanup::all #14982

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions hack/lib/cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,23 @@
#
# Globals:
# - ARTIFACT_DIR
# - SKIP_CLEANUP
# - SKIP_TEARDOWN
# - SKIP_IMAGE_CLEANUP
# Arguments:
# 1 - return code of the script
# None
# Returns:
# None
function os::cleanup::all() {
local return_code="$1"
if [[ -n "${SKIP_CLEANUP:-}" ]]; then
os::log::warning "[CLEANUP] Skipping cleanup routines..."
return 0
fi

# All of our cleanup is best-effort, so we do not care
# if any specific step fails.
set +o errexit

os::test::junit::generate_report

os::log::info "[CLEANUP] Beginning cleanup routines..."
os::cleanup::dump_events
os::cleanup::dump_etcd
Expand All @@ -38,7 +40,6 @@ function os::cleanup::all() {
os::cleanup::processes
os::cleanup::prune_etcd
fi
os::util::describe_return_code "${return_code}"
}
readonly -f os::cleanup::all

Expand Down
4 changes: 3 additions & 1 deletion hack/test-cmd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ os::util::environment::setup_time_vars

function cleanup() {
return_code=$?
os::cleanup::all "${return_code}"
os::test::junit::generate_report
os::cleanup::all
os::util::describe_return_code "${return_code}"
exit "${return_code}"
}
trap "cleanup" EXIT
Expand Down
5 changes: 4 additions & 1 deletion hack/test-end-to-end-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ fi

function cleanup() {
return_code=$?
os::cleanup::all "${return_code}"

os::test::junit::generate_report
os::cleanup::all

# restore journald to previous form
if os::util::ensure::system_binary_exists 'systemctl'; then
Expand All @@ -33,6 +35,7 @@ function cleanup() {
${USE_SUDO:+sudo} systemctl restart docker.service
fi

os::util::describe_return_code "${return_code}"
exit "${return_code}"
}
trap "cleanup" EXIT
Expand Down
8 changes: 5 additions & 3 deletions hack/test-end-to-end.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ os::util::ensure::iptables_privileges_exist
os::log::info "Starting end-to-end test"

function cleanup() {
return_code=$?
os::cleanup::all "${return_code}"
exit "${return_code}"
return_code=$?
os::test::junit::generate_report
os::cleanup::all
os::util::describe_return_code "${return_code}"
exit "${return_code}"
}
trap "cleanup" EXIT

Expand Down
3 changes: 2 additions & 1 deletion hack/test-go.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@
# - DLV_DEBUG toggles running tests using delve debugger
function cleanup() {
return_code=$?
os::cleanup::all "${return_code}"

os::test::junit::generate_report
if [[ "${JUNIT_REPORT_NUM_FAILED:-}" == "0 failed" ]]; then
if [[ "${return_code}" -ne "0" ]]; then
os::log::warning "While the jUnit report found no failed tests, the \`go test\` process failed."
os::log::warning "This usually means that the unit test suite failed to compile."
fi
fi

os::util::describe_return_code "${return_code}"
exit "${return_code}"
}
trap "cleanup" EXIT
Expand Down
5 changes: 4 additions & 1 deletion hack/test-integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ function cleanup() {
# this is a domain socket. CI falls over it.
rm -f "${BASETMPDIR}/dockershim.sock"

os::cleanup::all "${return_code}"
os::test::junit::generate_report
os::cleanup::all
os::util::describe_return_code "${return_code}"

exit "${return_code}"
}
trap "cleanup" EXIT
Expand Down
3 changes: 2 additions & 1 deletion hack/test-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ source "$(dirname "${BASH_SOURCE}")/lib/init.sh"

function cleanup() {
return_code=$?
os::cleanup::all "${return_code}"
os::test::junit::generate_report
os::util::describe_return_code "${return_code}"
exit "${return_code}"
}
trap "cleanup" EXIT
Expand Down
4 changes: 3 additions & 1 deletion hack/update-generated-swagger-spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ source "$(dirname "${BASH_SOURCE}")/lib/init.sh"

function cleanup() {
return_code=$?
os::cleanup::all "${return_code}"
os::test::junit::generate_report
os::cleanup::all
os::util::describe_return_code "${return_code}"
exit "${return_code}"
}
trap "cleanup" EXIT
Expand Down
5 changes: 3 additions & 2 deletions test/extended/alternate_certs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ os::util::environment::setup_all_server_vars

function cleanup() {
return_code=$?
os::cleanup::all "${return_code}"
os::test::junit::generate_report
os::cleanup::all
os::util::describe_return_code "${return_code}"
exit "${return_code}"
}
trap "cleanup" EXIT


os::log::info "Starting server as distinct processes"
os::log::info "`openshift version`"
os::log::info "Server logs will be at: ${LOG_DIR}/openshift.log"
Expand Down
4 changes: 3 additions & 1 deletion test/extended/alternate_launches.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ os::util::environment::setup_all_server_vars

function cleanup() {
return_code=$?
os::cleanup::all "${return_code}"
os::test::junit::generate_report
os::cleanup::all
os::util::describe_return_code "${return_code}"
exit "${return_code}"
}
trap "cleanup" EXIT
Expand Down
4 changes: 3 additions & 1 deletion test/extended/cmd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ function cleanup() {

docker rmi test/scratchimage

os::cleanup::all "${return_code}"
os::test::junit::generate_report
os::cleanup::all
os::util::describe_return_code "${return_code}"
exit "${return_code}"
}
trap "cleanup" EXIT
Expand Down
4 changes: 3 additions & 1 deletion test/extended/gssapi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ os::cmd::expect_success_and_text 'oc version' 'GSSAPI Kerberos SPNEGO'

function cleanup() {
return_code=$?
os::cleanup::all "${return_code}"
os::test::junit::generate_report
os::cleanup::all
os::util::describe_return_code "${return_code}"
exit "${return_code}"
}
trap "cleanup" EXIT
Expand Down
4 changes: 3 additions & 1 deletion test/extended/ldap_groups.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ os::build::setup_env

function cleanup() {
return_code=$?
os::cleanup::all "${return_code}"
os::test::junit::generate_report
os::cleanup::all
os::util::describe_return_code "${return_code}"
exit "${return_code}"
}
trap "cleanup" EXIT
Expand Down
4 changes: 3 additions & 1 deletion test/extended/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ function os::test::extended::setup () {

function cleanup() {
return_code=$?
os::cleanup::all "${return_code}"
os::test::junit::generate_report
os::cleanup::all
os::util::describe_return_code "${return_code}"
exit "${return_code}"
}
trap "cleanup" EXIT
Expand Down