Skip to content
Snippets Groups Projects
Commit f8fb9353 authored by Dariusz Kędzierski's avatar Dariusz Kędzierski
Browse files

Initial commit

* added script to process xml reports
* script will parse xml reports and create html reports with api
  execution times
* if execution time is greater than treshold it will be marked on red
  and task will fail
parent 6ab1226e
No related branches found
No related tags found
2 merge requests!456Release candidate v1 24,!246API tests execution time reports
......@@ -8,6 +8,7 @@ stages:
- deploy
- e2e-test
- post-deploy
- reports
variables:
GIT_DEPTH: 1
......@@ -274,3 +275,123 @@ tags_api_smoketest_negative:
reports:
junit: api_smoketest_tags_api_negative.xml
.hivemind_reports: &common_api_reports
stage: reports
environment: hive-4.pl.syncad.com
needs:
- job: hivemind_start_api_smoketest
artifacts: true
variables:
GIT_STRATEGY: none
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: always
- if: '$CI_PIPELINE_SOURCE == "push"'
when: manual
- when: on_success
tags:
- hivemind
bridge_api_smoketest_report:
<<: *common_api_reports
script:
- scripts/xml_report_parser.py api_smoketest_bridge.xml
artifacts:
paths:
- api_smoketest_bridge.html
bridge_api_smoketest_negative_report:
<<: *common_api_reports
script:
- scripts/xml_report_parser.py api_smoketest_bridge_negative.xml
artifacts:
paths:
- api_smoketest_bridge_negative.html
condenser_api_smoketest_report:
<<: *common_api_reports
script:
- scripts/xml_report_parser.py api_smoketest_condenser_api.xml
artifacts:
paths:
- api_smoketest_condenser_api.html
condenser_api_smoketest_negative_report:
<<: *common_api_reports
script:
- scripts/xml_report_parser.py api_smoketest_condenser_api_negative.xml
artifacts:
paths:
- api_smoketest_condenser_api_negative.html
database_api_smoketest_report:
<<: *common_api_reports
script:
- scripts/xml_report_parser.py api_smoketest_database_api.xml
artifacts:
paths:
- api_smoketest_database_api.html
database_api_smoketest_negative_report:
<<: *common_api_reports
script:
- scripts/xml_report_parser.py api_smoketest_database_api_negative.xml
artifacts:
paths:
- api_smoketest_database_api_negative.html
follow_api_smoketest_report:
<<: *common_api_reports
script:
- scripts/xml_report_parser.py api_smoketest_follow_api.xml
artifacts:
paths:
- api_smoketest_follow_api.html
follow_api_smoketest_negative_report:
<<: *common_api_reports
script:
- scripts/xml_report_parser.py api_smoketest_follow_api_negative.xml
artifacts:
paths:
- api_smoketest_follow_api_negative.html
tags_api_smoketest_report:
<<: *common_api_reports
script:
- scripts/xml_report_parser.py api_smoketest_tags_api.xml
artifacts:
paths:
- api_smoketest_tags_api.html
tags_api_smoketest_negative_report:
<<: *common_api_reports
script:
- scripts/xml_report_parser.py api_smoketest_tags_api_negative.xml
artifacts:
paths:
- api_smoketest_tags_api_negative.html
#!/usr/bin/python3
import xml.dom.minidom
import os
from sys import exit
TIME_TRESHOLD = 1.
if __name__ == '__main__':
above_treshold = False
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("xml_file", type = str, help = "Path to report file in xml format")
args = parser.parse_args()
html_file, _ = os.path.splitext(args.xml_file)
html_file += ".html"
with open(html_file, "w") as ofile:
ofile.write("<html>\n")
ofile.write(" <head>\n")
ofile.write(" <style>\n")
ofile.write(" table, th, td {\n")
ofile.write(" border: 1px solid black;\n")
ofile.write(" border-collapse: collapse;\n")
ofile.write(" }\n")
ofile.write(" th, td {\n")
ofile.write(" padding: 15px;\n")
ofile.write(" }\n")
ofile.write(" </style>\n")
ofile.write(" </head>\n")
ofile.write(" <body>\n")
ofile.write(" <table>\n")
ofile.write(" <tr><th>Test name</th><th>Time [s]</th></tr>\n")
document = xml.dom.minidom.parse(args.xml_file)
tests_collection = document.documentElement
for test in tests_collection.getElementsByTagName("testcase"):
if test.hasAttribute("name") and test.hasAttribute("time"):
if float(test.getAttribute("time")) > TIME_TRESHOLD:
ofile.write(" <tr><td>{}</td><td bgcolor=\"red\">{}</td></tr>\n".format(test.getAttribute("name"), test.getAttribute("time")))
above_treshold = True
else:
ofile.write(" <tr><td>{}</td><td>{}</td></tr>\n".format(test.getAttribute("name"), test.getAttribute("time")))
ofile.write(" </table>\n")
ofile.write(" </body>\n")
ofile.write("</html>\n")
if above_treshold:
exit(1)
exit(0)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment