Skip to content

Commit 8801811

Browse files
openstack-manifests: Export JUnit results
Expose test results as JUnit to let Prow parse them.
1 parent 34b53ca commit 8801811

File tree

9 files changed

+53
-9
lines changed

9 files changed

+53
-9
lines changed

hack/openstack/test-manifests.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,14 @@ while getopts a:c:e:f:i:t:pr:h o; do
8989
done
9090
readonly api_fip os_cloud external_network compute_flavor openshift_install tests_dir persist run
9191

92+
declare python_venv
93+
if [[ -w './bin' ]]; then
94+
python_venv="$(realpath './bin/venv')"
95+
else
96+
python_venv="$(mktemp -d)"
97+
fi
98+
readonly python_venv
99+
92100
declare -a temp_dirs
93101
cleanup() {
94102
if [[ "$persist" == 'NO' ]]; then
@@ -101,8 +109,16 @@ trap cleanup EXIT
101109

102110
validate_configuration
103111

112+
python -m venv "$python_venv"
113+
# shellcheck source=/dev/null
114+
source "${python_venv}/bin/activate"
115+
pip install unittest-xml-reporting pyyaml
116+
104117
>&2 echo "Running the tests from '${tests_dir}' against the Installer binary '${openshift_install}'."
105118

119+
export JUNIT_DIR="${ARTIFACT_DIR:-.}/junit"
120+
mkdir -p "$JUNIT_DIR"
121+
106122
declare result='PASS'
107123
for testcase in "${tests_dir}"/* ; do
108124
if [ -d "$testcase" ] && [[ "$testcase" =~ $run ]]; then
@@ -117,6 +133,12 @@ for testcase in "${tests_dir}"/* ; do
117133
fill_install_config "${testcase}/install-config.yaml" > "${assets_dir}/install-config.yaml"
118134
"$openshift_install" --log-level warn create manifests --dir "$assets_dir"
119135
for t in "${testcase}"/test_*; do
136+
declare JUNIT_FILE test_name
137+
test_name="$(basename -- "$t")"
138+
test_name="${test_name#test_}"
139+
test_name="${test_name%.*}"
140+
JUNIT_FILE="${JUNIT_DIR}/$(basename -- "${testcase}")_${test_name}.xml"
141+
export JUNIT_FILE
120142
if $t "$assets_dir"; then
121143
echo "PASS: '$t'"
122144
else

scripts/openstack/manifest-tests/cinder-availability-zones/test_machines.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
# -*- coding: utf-8 -*-
33

44
import unittest
5+
import xmlrunner
56

7+
import os
68
import sys
79
import glob
810
import yaml
@@ -98,4 +100,5 @@ def test_replica_distribution(self):
98100

99101
if __name__ == '__main__':
100102
ASSETS_DIR = sys.argv.pop()
101-
unittest.main(verbosity=2)
103+
with open(os.environ.get('JUNIT_FILE', '/dev/null'), 'wb') as output:
104+
unittest.main(testRunner=xmlrunner.XMLTestRunner(output=output), failfast=False, buffer=False, catchbreak=False, verbosity=2)

scripts/openstack/manifest-tests/failure-domains/test_machines.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# -*- coding: utf-8 -*-
33

44
import unittest
5+
import xmlrunner
56

67
import os
78
import sys
@@ -123,5 +124,5 @@ def test_storage_zone_names(self):
123124

124125
if __name__ == '__main__':
125126
ASSETS_DIR = sys.argv.pop()
126-
INSTALLCONFIG_PATH = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'install-config.yaml')
127-
unittest.main(verbosity=2)
127+
with open(os.environ.get('JUNIT_FILE', '/dev/null'), 'wb') as output:
128+
unittest.main(testRunner=xmlrunner.XMLTestRunner(output=output), failfast=False, buffer=False, catchbreak=False, verbosity=2)

scripts/openstack/manifest-tests/lb-default-stable/test_cluster-infra.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
# -*- coding: utf-8 -*-
33

44
import unittest
5+
import xmlrunner
56

7+
import os
68
import sys
79
import glob
810
import yaml
@@ -24,4 +26,5 @@ def test_load_balancer(self):
2426

2527
if __name__ == '__main__':
2628
ASSETS_DIR = sys.argv.pop()
27-
unittest.main(verbosity=2)
29+
with open(os.environ.get('JUNIT_FILE', '/dev/null'), 'wb') as output:
30+
unittest.main(testRunner=xmlrunner.XMLTestRunner(output=output), failfast=False, buffer=False, catchbreak=False, verbosity=2)

scripts/openstack/manifest-tests/lb-default-techpreview/test_cluster-infra.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
# -*- coding: utf-8 -*-
33

44
import unittest
5+
import xmlrunner
56

7+
import os
68
import sys
79
import glob
810
import yaml
@@ -24,4 +26,5 @@ def test_load_balancer(self):
2426

2527
if __name__ == '__main__':
2628
ASSETS_DIR = sys.argv.pop()
27-
unittest.main(verbosity=2)
29+
with open(os.environ.get('JUNIT_FILE', '/dev/null'), 'wb') as output:
30+
unittest.main(testRunner=xmlrunner.XMLTestRunner(output=output), failfast=False, buffer=False, catchbreak=False, verbosity=2)

scripts/openstack/manifest-tests/lb-managed/test_cluster-infra.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
# -*- coding: utf-8 -*-
33

44
import unittest
5+
import xmlrunner
56

7+
import os
68
import sys
79
import glob
810
import yaml
@@ -29,4 +31,5 @@ def test_cluster_infra_object(self):
2931

3032
if __name__ == '__main__':
3133
ASSETS_DIR = sys.argv.pop()
32-
unittest.main(verbosity=2)
34+
with open(os.environ.get('JUNIT_FILE', '/dev/null'), 'wb') as output:
35+
unittest.main(testRunner=xmlrunner.XMLTestRunner(output=output), failfast=False, buffer=False, catchbreak=False, verbosity=2)

scripts/openstack/manifest-tests/lb-unmanaged/test_cluster-infra.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
# -*- coding: utf-8 -*-
33

44
import unittest
5+
import xmlrunner
56

7+
import os
68
import sys
79
import glob
810
import yaml
@@ -29,4 +31,5 @@ def test_cluster_infra_object(self):
2931

3032
if __name__ == '__main__':
3133
ASSETS_DIR = sys.argv.pop()
32-
unittest.main(verbosity=2)
34+
with open(os.environ.get('JUNIT_FILE', '/dev/null'), 'wb') as output:
35+
unittest.main(testRunner=xmlrunner.XMLTestRunner(output=output), failfast=False, buffer=False, catchbreak=False, verbosity=2)

scripts/openstack/manifest-tests/nova-availability-zones/test_machines.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
# -*- coding: utf-8 -*-
33

44
import unittest
5+
import xmlrunner
56

7+
import os
68
import sys
79
import glob
810
import yaml
@@ -91,4 +93,5 @@ def test_replica_distribution(self):
9193

9294
if __name__ == '__main__':
9395
ASSETS_DIR = sys.argv.pop()
94-
unittest.main(verbosity=2)
96+
with open(os.environ.get('JUNIT_FILE', '/dev/null'), 'wb') as output:
97+
unittest.main(testRunner=xmlrunner.XMLTestRunner(output=output), failfast=False, buffer=False, catchbreak=False, verbosity=2)

scripts/openstack/manifest-tests/server-groups/test_machines.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
# -*- coding: utf-8 -*-
33

44
import unittest
5+
import xmlrunner
56

7+
import os
68
import sys
79
import glob
810
import yaml
@@ -53,4 +55,5 @@ def test_consistent_group_names(self):
5355

5456
if __name__ == '__main__':
5557
ASSETS_DIR = sys.argv.pop()
56-
unittest.main(verbosity=2)
58+
with open(os.environ.get('JUNIT_FILE', '/dev/null'), 'wb') as output:
59+
unittest.main(testRunner=xmlrunner.XMLTestRunner(output=output), failfast=False, buffer=False, catchbreak=False, verbosity=2)

0 commit comments

Comments
 (0)