From 8a7d5179d66cd43c3f49cec6a764f1073232e6f3 Mon Sep 17 00:00:00 2001 From: Hugh Saunders Date: Thu, 11 Jun 2015 11:35:39 +0100 Subject: [PATCH] Create Junit XML Report from tempest run Tempest results are currently written to stdout as part of a test run. This output is difficult to parse. This patch adds steps to generate an XML report, and make this report available in /tmp on a physical host. The report is copied to a physical host so that external systems that do not have knowledge of the container inventory can retrieve the report, for example Jenkins. * Add pip packages python-subunit and junitxml to tempest venv, needed to convert the subunit stream stored in testrepository to junit XML. * openstack_tempest_gate: After a tempest run completes, the subunit stream is extracted from the testrepository, converted to junit XML and written to /tmp in the utility container running the tests. * run-tempest.sh After running openstack_tempest_gate, retrieve XML results and write them to /tmp on the host. Change-Id: I897024f545dd2a90f80b0d5c0aa558f335dc963a Closes-Bug: #1464686 --- playbooks/roles/os_tempest/defaults/main.yml | 2 ++ .../os_tempest/templates/openstack_tempest_gate.sh.j2 | 8 ++++++++ scripts/run-tempest.sh | 4 ++++ 3 files changed, 14 insertions(+) diff --git a/playbooks/roles/os_tempest/defaults/main.yml b/playbooks/roles/os_tempest/defaults/main.yml index 450617c109..4367941fad 100644 --- a/playbooks/roles/os_tempest/defaults/main.yml +++ b/playbooks/roles/os_tempest/defaults/main.yml @@ -91,6 +91,8 @@ tempest_pip_packages: - testrepository - testscenarios - testtools + - python-subunit + - junitxml tempest_image_dir: "/opt/images" tempest_images: diff --git a/playbooks/roles/os_tempest/templates/openstack_tempest_gate.sh.j2 b/playbooks/roles/os_tempest/templates/openstack_tempest_gate.sh.j2 index 4d341b6896..1ac0db9145 100644 --- a/playbooks/roles/os_tempest/templates/openstack_tempest_gate.sh.j2 +++ b/playbooks/roles/os_tempest/templates/openstack_tempest_gate.sh.j2 @@ -185,6 +185,14 @@ echo "Using test list $test_list_summary" # execute chosen tests with pretty output ./run_tempest.sh --no-virtual-env ${RUN_TEMPEST_OPTS} -- --load-list test_list ${TESTR_OPTS}; result=$? + +# Create junit xml report from test results +subunit-1to2 < .testrepository/0 | subunit2junitxml > tempest_results.xml +cp tempest_results.xml /tmp +if [ -d "/var/log/utility" ];then + # Copy the log to the utility logging directory + cp tempest_results.xml /var/log/utility/tempest_results_$(date +%Y%d%m-%H%M%S).xml +fi popd if [[ $result == 0 ]]; then diff --git a/scripts/run-tempest.sh b/scripts/run-tempest.sh index 67dd11a564..cb36f42b95 100755 --- a/scripts/run-tempest.sh +++ b/scripts/run-tempest.sh @@ -50,4 +50,8 @@ pushd playbooks ansible 'utility[0]' -m shell -a "export RUN_TEMPEST_OPTS=${RUN_TEMPEST_OPTS}; \ export TESTR_OPTS=${TESTR_OPTS}; \ ${TEMPEST_SCRIPT_PATH} ${TEMPEST_SCRIPT_PARAMETERS}" + + # Retrieve tempest test results + ansible 'utility[0]' -m fetch -a 'src=/tmp/tempest_results.xml dest=/tmp/ flat=true' + popd