X-Git-Url: https://gerrit.fd.io/r/gitweb?p=csit.git;a=blobdiff_plain;f=resources%2Ftools%2Fpresentation%2Finput_data_parser.py;h=203a3bfd253e1ec1d7e0f0bfe02b729769d79707;hp=1b8c3ccb47fd80f16174e22f525831fe6ae4fa23;hb=a4cdbf05722f6e880f465121a416828278195bd7;hpb=eecad36d7d2275fa47fbcab40dbcf56108ab0a51 diff --git a/resources/tools/presentation/input_data_parser.py b/resources/tools/presentation/input_data_parser.py index 1b8c3ccb47..203a3bfd25 100644 --- a/resources/tools/presentation/input_data_parser.py +++ b/resources/tools/presentation/input_data_parser.py @@ -171,6 +171,8 @@ class ExecutionChecker(ResultVisitor): REGEX_VERSION = re.compile(r"(stdout: 'vat# vat# Version:)(\s*)(.*)") + REGEX_TCP = re.compile(r'Total\s(rps|cps|throughput):\s([0-9]*).*$') + def __init__(self, **metadata): """Initialisation. @@ -275,7 +277,7 @@ class ExecutionChecker(ResultVisitor): :type msg: Message :returns: Nothing. """ - if msg.message.count("vat# Thread "): + if msg.message.count("return STDOUT Thread "): self._show_run_lookup_nr += 1 if self._lookup_kw_nr == 1 and self._show_run_lookup_nr == 1: self._data["tests"][self._test_ID]["show-run"] = str() @@ -416,34 +418,46 @@ class ExecutionChecker(ResultVisitor): test_result["doc"] = replace(doc_str, ' |br| [', '[', maxreplace=1) test_result["msg"] = test.message.replace('\n', ' |br| '). \ replace('\r', '').replace('"', "'") - if test.status == "PASS" and "NDRPDRDISC" in tags: + if test.status == "PASS" and ("NDRPDRDISC" in tags or "TCP" in tags): if "NDRDISC" in tags: test_type = "NDR" elif "PDRDISC" in tags: test_type = "PDR" + elif "TCP" in tags: # Change to wrk? + test_type = "TCP" else: return - try: - rate_value = str(re.search( - self.REGEX_RATE, test.message).group(1)) - except AttributeError: - rate_value = "-1" - try: - rate_unit = str(re.search( - self.REGEX_RATE, test.message).group(2)) - except AttributeError: - rate_unit = "-1" - test_result["type"] = test_type - test_result["throughput"] = dict() - test_result["throughput"]["value"] = int(rate_value.split('.')[0]) - test_result["throughput"]["unit"] = rate_unit - test_result["latency"] = self._get_latency(test.message, test_type) - if test_type == "PDR": - test_result["lossTolerance"] = str(re.search( - self.REGEX_TOLERANCE, test.message).group(1)) + + if test_type in ("NDR", "PDR"): + try: + rate_value = str(re.search( + self.REGEX_RATE, test.message).group(1)) + except AttributeError: + rate_value = "-1" + try: + rate_unit = str(re.search( + self.REGEX_RATE, test.message).group(2)) + except AttributeError: + rate_unit = "-1" + + test_result["throughput"] = dict() + test_result["throughput"]["value"] = \ + int(rate_value.split('.')[0]) + test_result["throughput"]["unit"] = rate_unit + test_result["latency"] = \ + self._get_latency(test.message, test_type) + if test_type == "PDR": + test_result["lossTolerance"] = str(re.search( + self.REGEX_TOLERANCE, test.message).group(1)) + + elif test_type in ("TCP", ): + groups = re.search(self.REGEX_TCP, test.message) + test_result["result"] = dict() + test_result["result"]["value"] = int(groups.group(2)) + test_result["result"]["unit"] = groups.group(1) else: test_result["status"] = test.status @@ -554,7 +568,7 @@ class ExecutionChecker(ResultVisitor): if teardown_kw.name.count("Show Vat History On All Duts"): self._vat_history_lookup_nr = 0 self._msg_type = "teardown-vat-history" - elif teardown_kw.name.count("Vpp Show Runtime"): + elif teardown_kw.name.count("Show Statistics On All Duts"): self._lookup_kw_nr += 1 self._show_run_lookup_nr = 0 self._msg_type = "teardown-show-runtime" @@ -852,9 +866,42 @@ class InputData(object): except (KeyError, IndexError, ValueError) as err: logging.error(" Missing mandatory parameter in the element " - "specification.", err) + "specification: {0}".format(err)) + return None + except AttributeError: return None except SyntaxError: logging.error(" The filter '{0}' is not correct. Check if all " "tags are enclosed by apostrophes.".format(cond)) return None + + @staticmethod + def merge_data(data): + """Merge data from more jobs and builds to a simple data structure. + + The output data structure is: + + - test (suite) 1 ID: + - param 1 + - param 2 + ... + - param n + ... + - test (suite) n ID: + ... + + :param data: Data to merge. + :type data: pandas.Series + :returns: Merged data. + :rtype: pandas.Series + """ + + logging.info(" Merging data ...") + + merged_data = pd.Series() + for _, builds in data.iteritems(): + for _, item in builds.iteritems(): + for ID, item_data in item.iteritems(): + merged_data[ID] = item_data + + return merged_data