Revert "Add support for JUnitXML output (optional)"

Requirements are not fulfilled and there are no unit tests.

This reverts commit efca0653aa.

Change-Id: I503740f2bdb50cac9fd0daea263c5d2c787ff157
This commit is contained in:
Jiri Podivin 2021-05-27 17:13:57 +02:00
parent b14fb3765b
commit e0150a260e
2 changed files with 0 additions and 47 deletions

View File

@ -15,14 +15,7 @@
# under the License.
import json
import logging
from prettytable import PrettyTable
import re
try:
from junit_xml import TestSuite, TestCase, to_xml_report_string
JUNIT_XML_FOUND = True
except ImportError:
JUNIT_XML_FOUND = False
from validations_libs import constants
from validations_libs import utils as v_utils
@ -65,36 +58,3 @@ def write_output(output_log, results):
with open(output_log, 'w') as output:
output.write(json.dumps({'results': results}, indent=4,
sort_keys=True))
def write_junitxml(output_junitxml, results):
"""Write output file as JUnitXML format"""
if not JUNIT_XML_FOUND:
log = logging.getLogger(__name__ + ".write_junitxml")
log.warning('junitxml output disabled: the `junit_xml` python module '
'is missing.')
return
test_cases = []
duration_re = re.compile('([0-9]+):([0-9]+):([0-9]+).([0-9]+)')
for vitem in results:
if vitem.get('Validations'):
parsed_duration = 0
test_duration = vitem.get('Duration', '')
matched_duration = duration_re.match(test_duration)
if matched_duration:
parsed_duration = (int(matched_duration[1])*3600
+ int(matched_duration[2])*60
+ int(matched_duration[3])
+ float('0.{}'.format(matched_duration[4])))
test_stdout = vitem.get('Status_by_Host', '')
test_case = TestCase('validations', vitem['Validations'],
parsed_duration, test_stdout)
if vitem['Status'] == 'FAILED':
test_case.add_failure_info('FAILED')
test_cases.append(test_case)
ts = TestSuite("Validations", test_cases)
with open(output_junitxml, 'w') as output:
output.write(to_xml_report_string([ts]))

View File

@ -66,11 +66,6 @@ class Run(Command):
default=None,
help=("Path where the run result will be stored."))
parser.add_argument('--junitxml', dest='junitxml',
default=None,
help=("Path where the run result in JUnitXML "
"format will be stored."))
parser.add_argument(
'--python-interpreter',
metavar="--python-interpreter <PYTHON_INTERPRETER_PATH>",
@ -192,8 +187,6 @@ class Run(Command):
_rc = any([r for r in results if r['Status'] == 'FAILED'])
if parsed_args.output_log:
common.write_output(parsed_args.output_log, results)
if parsed_args.junitxml:
common.write_junitxml(parsed_args.junitxml, results)
common.print_dict(results)
if _rc:
raise RuntimeError("One or more validations have failed.")