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

Reports will include call parameters for api calls that are above treshold

parent 1f84c88e
No related branches found
No related tags found
2 merge requests!456Release candidate v1 24,!246API tests execution time reports
......@@ -301,7 +301,7 @@ bridge_api_smoketest_report:
<<: *common_api_reports
script:
- scripts/xml_report_parser.py api_smoketest_bridge.xml
- scripts/xml_report_parser.py tests/tests_api/hivemind/tavern/bridge_api_patterns/ api_smoketest_bridge.xml
artifacts:
when: always
......@@ -312,7 +312,7 @@ bridge_api_smoketest_negative_report:
<<: *common_api_reports
script:
- scripts/xml_report_parser.py api_smoketest_bridge_negative.xml
- scripts/xml_report_parser.py tests/tests_api/hivemind/tavern/bridge_api_negative/ api_smoketest_bridge_negative.xml
artifacts:
when: always
......@@ -323,7 +323,7 @@ condenser_api_smoketest_report:
<<: *common_api_reports
script:
- scripts/xml_report_parser.py api_smoketest_condenser_api.xml
- scripts/xml_report_parser.py tests/tests_api/hivemind/tavern/condenser_api_patterns/ api_smoketest_condenser_api.xml
artifacts:
when: always
......@@ -334,7 +334,7 @@ condenser_api_smoketest_negative_report:
<<: *common_api_reports
script:
- scripts/xml_report_parser.py api_smoketest_condenser_api_negative.xml
- scripts/xml_report_parser.py tests/tests_api/hivemind/tavern/condenser_api_negative/ api_smoketest_condenser_api_negative.xml
artifacts:
when: always
......@@ -345,7 +345,7 @@ database_api_smoketest_report:
<<: *common_api_reports
script:
- scripts/xml_report_parser.py api_smoketest_database_api.xml
- scripts/xml_report_parser.py tests/tests_api/hivemind/tavern/database_api_patterns/ api_smoketest_database_api.xml
artifacts:
when: always
......@@ -356,7 +356,7 @@ database_api_smoketest_negative_report:
<<: *common_api_reports
script:
- scripts/xml_report_parser.py api_smoketest_database_api_negative.xml
- scripts/xml_report_parser.py tests/tests_api/hivemind/tavern/database_api_negative/ api_smoketest_database_api_negative.xml
artifacts:
when: always
......@@ -367,7 +367,7 @@ follow_api_smoketest_report:
<<: *common_api_reports
script:
- scripts/xml_report_parser.py api_smoketest_follow_api.xml
- scripts/xml_report_parser.py tests/tests_api/hivemind/tavern/follow_api_patterns/ api_smoketest_follow_api.xml
artifacts:
when: always
......@@ -378,7 +378,7 @@ follow_api_smoketest_negative_report:
<<: *common_api_reports
script:
- scripts/xml_report_parser.py api_smoketest_follow_api_negative.xml
- scripts/xml_report_parser.py tests/tests_api/hivemind/tavern/follow_api_negative/ api_smoketest_follow_api_negative.xml
artifacts:
when: always
......@@ -389,7 +389,7 @@ tags_api_smoketest_report:
<<: *common_api_reports
script:
- scripts/xml_report_parser.py api_smoketest_tags_api.xml
- scripts/xml_report_parser.py tests/tests_api/hivemind/tavern/tags_api_patterns/ api_smoketest_tags_api.xml
artifacts:
when: always
......@@ -400,7 +400,7 @@ tags_api_smoketest_negative_report:
<<: *common_api_reports
script:
- scripts/xml_report_parser.py api_smoketest_tags_api_negative.xml
- scripts/xml_report_parser.py tests/tests_api/hivemind/tavern/tags_api_negative/ api_smoketest_tags_api_negative.xml
artifacts:
when: always
......
......@@ -3,17 +3,48 @@
import xml.dom.minidom
import os
from sys import exit
from json import dumps
TIME_TRESHOLD = 1.
def get_request_from_yaml(path_to_yaml):
import yaml
yaml_document = None
with open(path_to_yaml, "r") as yaml_file:
yaml_document = yaml.load(yaml_file, Loader=yaml.BaseLoader)
print(yaml_document)
if "stages" in yaml_document:
if "request" in yaml_document["stages"][0]:
json_parameters = yaml_document["stages"][0]["request"].get("json", None)
assert json_parameters is not None, "Unable to find json parameters in request"
return dumps(json_parameters)
return ""
def make_class_path_dict(root_dir):
import os
from fnmatch import fnmatch
pattern = "*.tavern.yaml"
ret = {}
for path, subdirs, files in os.walk(root_dir):
for name in files:
if fnmatch(name, pattern):
test_path = os.path.join(path, name)
ret[test_path.replace("/", ".")] = test_path
return ret
if __name__ == '__main__':
above_treshold = False
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("path_to_test_dir", type = str, help = "Path to test directory for given xml file")
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"
class_to_path = make_class_path_dict(args.path_to_test_dir)
with open(html_file, "w") as ofile:
ofile.write("<html>\n")
ofile.write(" <head>\n")
......@@ -35,7 +66,7 @@ if __name__ == '__main__':
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")))
ofile.write(" <tr><td>{}<br/>Parameters: {}</td><td bgcolor=\"red\">{}</td></tr>\n".format(test.getAttribute("name"), get_request_from_yaml(class_to_path[test.getAttribute("classname")]), test.getAttribute("time")))
above_treshold = True
else:
ofile.write(" <tr><td>{}</td><td>{}</td></tr>\n".format(test.getAttribute("name"), test.getAttribute("time")))
......
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