Skip to content

Commit

Permalink
Merge pull request #13181 from stevekuznetsov/skuznets/extended-edit
Browse files Browse the repository at this point in the history
Merged by openshift-bot
  • Loading branch information
OpenShift Bot authored Mar 7, 2017
2 parents 7902c39 + ec35afb commit da719a3
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 146 deletions.
36 changes: 36 additions & 0 deletions hack/lib/test/junit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,39 @@ function os::test::junit::reconcile_output() {
done
}
readonly -f os::test::junit::reconcile_output

# os::test::junit::generate_oscmd_report generats an XML jUnit report
# for the `os::cmd` suite from the raw test output. This function should
# be trapped on EXIT.
#
# Globals:
# - JUNIT_REPORT_OUTPUT
# - ARTIFACT_DIR
# Arguments:
# None
# Returns:
# None
function os::test::junit::generate_oscmd_report() {
if [[ -z "${JUNIT_REPORT_OUTPUT:-}" ||
-n "${JUNIT_REPORT_OUTPUT:-}" && ! -s "${JUNIT_REPORT_OUTPUT:-}" ]]; then
# we can't generate a report
return
fi

# get the jUnit output file into a workable state in case we
# crashed in the middle of testing something
os::test::junit::reconcile_output

# check that we didn't mangle jUnit output
os::test::junit::check_test_counters

# use the junitreport tool to generate us a report
os::util::ensure::built_binary_exists 'junitreport'

junitreport --type oscmd \
--suites nested \
--roots github.com/openshift/origin \
--output "${ARTIFACT_DIR}/report.xml" \
<"${JUNIT_REPORT_OUTPUT}"
junitreport summarize <"${ARTIFACT_DIR}/report.xml"
}
19 changes: 1 addition & 18 deletions hack/test-cmd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,7 @@ function cleanup()
go tool pprof -text "./_output/local/bin/$(os::util::host_platform)/openshift" cpu.pprof >"${LOG_DIR}/pprof.out" 2>&1
fi

# TODO(skuznets): un-hack this nonsense once traps are in a better state
if [[ -n "${JUNIT_REPORT_OUTPUT:-}" ]]; then
# get the jUnit output file into a workable state in case we crashed in the middle of testing something
os::test::junit::reconcile_output

# check that we didn't mangle jUnit output
os::test::junit::check_test_counters

# use the junitreport tool to generate us a report
os::util::ensure::built_binary_exists 'junitreport'

cat "${JUNIT_REPORT_OUTPUT}" \
| junitreport --type oscmd \
--suites nested \
--roots github.com/openshift/origin \
--output "${ARTIFACT_DIR}/report.xml"
cat "${ARTIFACT_DIR}/report.xml" | junitreport summarize
fi
os::test::junit::generate_oscmd_report

ENDTIME=$(date +%s); echo "$0 took $(($ENDTIME - $STARTTIME)) seconds"
os::log::info "Exiting with ${out}"
Expand Down
20 changes: 1 addition & 19 deletions test/extended/alternate_certs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,7 @@ function cleanup()
out=$?
kill $OS_PID

# TODO(skuznets): un-hack this nonsense once traps are in a better state
if [[ -n "${JUNIT_REPORT_OUTPUT:-}" ]]; then
# get the jUnit output file into a workable state in case we crashed in
# the middle of testing something
os::test::junit::reconcile_output

# check that we didn't mangle jUnit output
os::test::junit::check_test_counters

# use the junitreport tool to generate us a report
os::util::ensure::built_binary_exists 'junitreport'

cat "${JUNIT_REPORT_OUTPUT}" \
| junitreport --type oscmd \
--suites nested \
--roots github.com/openshift/origin \
--output "${ARTIFACT_DIR}/report.xml"
cat "${ARTIFACT_DIR}/report.xml" | junitreport summarize
fi
os::test::junit::generate_oscmd_report

os::log::info "Exiting"
exit $out
Expand Down
20 changes: 1 addition & 19 deletions test/extended/alternate_launches.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,7 @@ function cleanup()
out=$?
cleanup_openshift

# TODO(skuznets): un-hack this nonsense once traps are in a better state
if [[ -n "${JUNIT_REPORT_OUTPUT:-}" ]]; then
# get the jUnit output file into a workable state in case we crashed in
# the middle of testing something
os::test::junit::reconcile_output

# check that we didn't mangle jUnit output
os::test::junit::check_test_counters

# use the junitreport tool to generate us a report
os::util::ensure::built_binary_exists 'junitreport'

cat "${JUNIT_REPORT_OUTPUT}" \
| junitreport --type oscmd \
--suites nested \
--roots github.com/openshift/origin \
--output "${ARTIFACT_DIR}/report.xml"
cat "${ARTIFACT_DIR}/report.xml" | junitreport summarize
fi
os::test::junit::generate_oscmd_report

os::log::info "Exiting"
exit $out
Expand Down
20 changes: 1 addition & 19 deletions test/extended/cmd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,7 @@ function cleanup()
docker rmi test/scratchimage
cleanup_openshift

# TODO(skuznets): un-hack this nonsense once traps are in a better state
if [[ -n "${JUNIT_REPORT_OUTPUT:-}" ]]; then
# get the jUnit output file into a workable state in case we crashed in
# the middle of testing something
os::test::junit::reconcile_output

# check that we didn't mangle jUnit output
os::test::junit::check_test_counters

# use the junitreport tool to generate us a report
os::util::ensure::built_binary_exists 'junitreport'

cat "${JUNIT_REPORT_OUTPUT}" \
| junitreport --type oscmd \
--suites nested \
--roots github.com/openshift/origin \
--output "${ARTIFACT_DIR}/report.xml"
cat "${ARTIFACT_DIR}/report.xml" | junitreport summarize
fi
os::test::junit::generate_oscmd_report

os::log::info "Exiting"
return "${out}"
Expand Down
19 changes: 1 addition & 18 deletions test/extended/gssapi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,7 @@ function cleanup() {
set +e
cleanup_openshift

# TODO(skuznets): un-hack this nonsense once traps are in a better state
if [[ -n "${JUNIT_REPORT_OUTPUT:-}" ]]; then
# get the jUnit output file into a workable state in case we crashed in the middle of testing something
os::test::junit::reconcile_output

# check that we didn't mangle jUnit output
os::test::junit::check_test_counters

# use the junitreport tool to generate us a report
os::util::ensure::built_binary_exists 'junitreport'

cat "${JUNIT_REPORT_OUTPUT}" "${junit_gssapi_output}" \
| junitreport --type oscmd \
--suites nested \
--roots github.com/openshift/origin \
--output "${ARTIFACT_DIR}/report.xml"
cat "${ARTIFACT_DIR}/report.xml" | junitreport summarize
fi
os::test::junit::generate_oscmd_report

endtime=$(date +%s); echo "$0 took $((endtime - starttime)) seconds"
exit $out
Expand Down
20 changes: 1 addition & 19 deletions test/extended/ldap_groups.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,7 @@ function cleanup()
out=$?
cleanup_openshift

# TODO(skuznets): un-hack this nonsense once traps are in a better state
if [[ -n "${JUNIT_REPORT_OUTPUT:-}" ]]; then
# get the jUnit output file into a workable state in case we crashed in
# the middle of testing something
os::test::junit::reconcile_output

# check that we didn't mangle jUnit output
os::test::junit::check_test_counters

# use the junitreport tool to generate us a report
os::util::ensure::built_binary_exists 'junitreport'

cat "${JUNIT_REPORT_OUTPUT}" \
| junitreport --type oscmd \
--suites nested \
--roots github.com/openshift/origin \
--output "${ARTIFACT_DIR}/report.xml"
cat "${ARTIFACT_DIR}/report.xml" | junitreport summarize
fi
os::test::junit::generate_oscmd_report

os::log::info "Exiting"
return $out
Expand Down
51 changes: 17 additions & 34 deletions test/extended/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,50 +33,40 @@ function os::test::extended::setup () {
export EXTENDED_TEST_PATH="${OS_ROOT}/test/extended"
export KUBE_REPO_ROOT="${OS_ROOT}/vendor/k8s.io/kubernetes"

# allow setup to be skipped
if [[ -n "${TEST_ONLY+x}" ]]; then
# be sure to set VOLUME_DIR if you are running with TEST_ONLY
os::log::info "Not starting server, VOLUME_DIR=${VOLUME_DIR:-}"
return 0
fi

os::util::environment::setup_time_vars
os::util::environment::use_sudo
os::util::environment::setup_all_server_vars "test-extended/core"

os::util::ensure::iptables_privileges_exist

# Allow setting $JUNIT_REPORT to toggle output behavior
if [[ -n "${JUNIT_REPORT:-}" ]]; then
export JUNIT_REPORT_OUTPUT="${LOG_DIR}/raw_test_output.log"
# the Ginkgo tests also generate jUnit but expect different envars
export TEST_REPORT_DIR="${ARTIFACT_DIR}"
fi

function cleanup() {
out=$?
cleanup_openshift

# TODO(skuznets): un-hack this nonsense once traps are in a better
# state
if [[ -n "${JUNIT_REPORT_OUTPUT:-}" ]]; then
# get the jUnit output file into a workable state in case we
# crashed in the middle of testing something
os::test::junit::reconcile_output

# check that we didn't mangle jUnit output
os::test::junit::check_test_counters

# use the junitreport tool to generate us a report
os::util::ensure::built_binary_exists 'junitreport'

cat "${JUNIT_REPORT_OUTPUT}" \
| junitreport --type oscmd \
--suites nested \
--roots github.com/openshift/origin \
--output "${ARTIFACT_DIR}/report.xml"
cat "${ARTIFACT_DIR}/report.xml" | junitreport summarize
fi
os::test::junit::generate_oscmd_report

os::log::info "Exiting"
return $out
}

trap "exit" INT TERM
trap "cleanup" EXIT

# allow setup to be skipped
if [[ -n "${TEST_ONLY+x}" ]]; then
export SKIP_TEARDOWN='true'
# be sure to set VOLUME_DIR if you are running with TEST_ONLY
os::log::info "Not starting server, VOLUME_DIR=${VOLUME_DIR:-}"
return 0
fi

os::log::info "Starting server"

os::util::environment::setup_images_vars
Expand All @@ -94,13 +84,6 @@ function os::test::extended::setup () {
os::log::warn "/mnt/openshift-xfs-vol-dir does not exist, local storage quota tests may fail."
fi

# Allow setting $JUNIT_REPORT to toggle output behavior
if [[ -n "${JUNIT_REPORT:-}" ]]; then
export JUNIT_REPORT_OUTPUT="${LOG_DIR}/raw_test_output.log"
# the Ginkgo tests also generate jUnit but expect different envars
export TEST_REPORT_DIR="${ARTIFACT_DIR}"
fi

os::log::system::start

if [[ -n "${SHOW_ALL:-}" ]]; then
Expand Down

0 comments on commit da719a3

Please sign in to comment.