mirror of
https://github.com/apache/impala.git
synced 2025-12-19 09:58:28 -05:00
Fix generate_junitxml for python2.6.
With python 2.6, the syntax "{}".format(1) doesn't work:
$docker run centos:6 python -c 'print "{}".format(1)'
Traceback (most recent call last):
File "<string>", line 1, in <module>
ValueError: zero length field name in format
generate_junitxml was using this incantation and failing.
I've updated the syntax to be py2.6-friendly, and tested
it like so:
$docker run -v $(pwd):/mnt centos:6 bash -c "yum install -y python-argparse; /mnt/lib/python/impala_py_lib/jenkins/generate_junitxml.py --phase phase --step step --stdout out --stderr err; cat /extra_junit_xml_logs/*.xml"
[output from yum...]
Installed:
python-argparse.noarch 0:1.2.1-2.1.el6
Complete!
Generated: ./extra_junit_xml_logs/generate_junitxml.phase.step.20180904_18_04_56.xml
<?xml version="1.0" ?>
<testsuites errors="0" failures="0" tests="1" time="0.0">
<testsuite disabled="0" errors="0" failures="0" file="None" log="None" name="generate_junitxml.phase.step" skipped="0" tests="1" time="0" timestamp="2018-09-04 18:04:56+00:00" url="None">
<testcase classname="generate_junitxml.phase" name="step">
<system-out>
out
</system-out>
<system-err>
err
</system-err>
</testcase>
</testsuite>
</testsuites>
Change-Id: Ic0c1e837a9ed6c2d59906aed1d1098bde6f5d815
Reviewed-on: http://gerrit.cloudera.org:8080/11384
Reviewed-by: David Knupp <dknupp@cloudera.com>
Tested-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
This commit is contained in:
committed by
Impala Public Jenkins
parent
5f5c8612f6
commit
304e02cf62
@@ -97,10 +97,10 @@ class JunitReport(object):
|
||||
def add_testsuite_element(self):
|
||||
"""Create the testsuite element."""
|
||||
self.testsuite_element = ET.SubElement(self.root_element, "testsuite")
|
||||
self.testsuite_element.set("name", "{name}.{phase}.{step}".format(
|
||||
name=SCRIPT_NAME, phase=self.phase, step=self.step))
|
||||
self.testsuite_element.set(
|
||||
"name", "{}.{}.{}".format(SCRIPT_NAME, self.phase, self.step))
|
||||
self.testsuite_element.set(
|
||||
"timestamp", "{}+00:00".format(self.utc_time.strftime('%Y-%m-%d %H:%M:%S')))
|
||||
"timestamp", "{ts}+00:00".format(ts=self.utc_time.strftime('%Y-%m-%d %H:%M:%S')))
|
||||
self.testsuite_element.set("disabled", "0")
|
||||
self.testsuite_element.set("errors", "0")
|
||||
self.testsuite_element.set("failures", "0")
|
||||
@@ -114,7 +114,8 @@ class JunitReport(object):
|
||||
def add_testcase_element(self):
|
||||
"""Create the testcase element."""
|
||||
self.testcase_element = ET.SubElement(self.testsuite_element, "testcase")
|
||||
self.testcase_element.set("classname", "{}.{}".format(SCRIPT_NAME, self.phase))
|
||||
self.testcase_element.set("classname", "{name}.{phase}".format(
|
||||
name=SCRIPT_NAME, phase=self.phase))
|
||||
self.testcase_element.set("name", self.step)
|
||||
|
||||
def set_error(self):
|
||||
@@ -133,7 +134,8 @@ class JunitReport(object):
|
||||
output_type: [string] either out or err
|
||||
file_or_string: a path to a file containing the content, or a plain string
|
||||
"""
|
||||
output = ET.SubElement(self.testcase_element, "system-{}".format(output_type))
|
||||
output = ET.SubElement(self.testcase_element,
|
||||
"system-{output_type}".format(output_type=output_type))
|
||||
output.text = JunitReport.get_xml_content(file_or_string)
|
||||
|
||||
def to_file(self, junitxml_logdir=JUNITXML_LOGDIR):
|
||||
@@ -155,9 +157,9 @@ class JunitReport(object):
|
||||
else:
|
||||
raise
|
||||
|
||||
filename = '{}.{}.xml'.format(
|
||||
self.testsuite_element.attrib['name'],
|
||||
self.utc_time.strftime('%Y%m%d_%H_%M_%S')
|
||||
filename = '{name}.{ts}.xml'.format(
|
||||
name=self.testsuite_element.attrib['name'],
|
||||
ts=self.utc_time.strftime('%Y%m%d_%H_%M_%S')
|
||||
)
|
||||
junit_log_file = os.path.join(junitxml_logdir, filename)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user