X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=resources%2Ftools%2Fpresentation%2Finput_data_parser.py;h=94f8e96ec839bd6ea7ad9fcbd29b5129adef1bb5;hb=refs%2Fchanges%2F17%2F32817%2F5;hp=d108d09e84774a5f17a9c6c1d6882651323aa741;hpb=c763cfcb064e4f4acf6b8309b08d3800b9bd5331;p=csit.git diff --git a/resources/tools/presentation/input_data_parser.py b/resources/tools/presentation/input_data_parser.py index d108d09e84..94f8e96ec8 100644 --- a/resources/tools/presentation/input_data_parser.py +++ b/resources/tools/presentation/input_data_parser.py @@ -239,6 +239,15 @@ class ExecutionChecker(ResultVisitor): ) REGEX_MRR_MSG_INFO = re.compile(r'.*\[(.*)\]') + REGEX_VSAP_MSG_INFO = re.compile( + r'Transfer Rate: (\d*.\d*).*\n' + r'Latency: (\d*.\d*).*\n' + r'Completed requests: (\d*).*\n' + r'Failed requests: (\d*).*\n' + r'Total data transferred: (\d*).*\n' + r'Connection [cr]ps rate:\s*(\d*.\d*)' + ) + # Needed for CPS and PPS tests REGEX_NDRPDR_LAT_BASE = re.compile( r'LATENCY.*\[\'(.*)\', \'(.*)\'\]\s\n.*\n.*\n' @@ -664,49 +673,17 @@ class ExecutionChecker(ResultVisitor): replace(u"'", u'"').replace(u'b"', u'"'). replace(u'u"', u'"').split(u":", 1)[1]) - try: - threads_nr = len(runtime[0][u"clocks"]) - except (IndexError, KeyError): - return - dut = u"dut{nr}".format( nr=len(self._data[u'tests'][self._test_id][u'show-run'].keys()) + 1) - oper = { - u"host": host, - u"socket": sock, - u"runtime": runtime, - u"threads": OrderedDict({idx: list() for idx in range(threads_nr)}) - } - - for item in runtime: - for idx in range(threads_nr): - if item[u"vectors"][idx] > 0: - clocks = item[u"clocks"][idx] / item[u"vectors"][idx] - elif item[u"calls"][idx] > 0: - clocks = item[u"clocks"][idx] / item[u"calls"][idx] - elif item[u"suspends"][idx] > 0: - clocks = item[u"clocks"][idx] / item[u"suspends"][idx] - else: - clocks = 0.0 - - if item[u"calls"][idx] > 0: - vectors_call = item[u"vectors"][idx] / item[u"calls"][idx] - else: - vectors_call = 0.0 - - if int(item[u"calls"][idx]) + int(item[u"vectors"][idx]) + \ - int(item[u"suspends"][idx]): - oper[u"threads"][idx].append([ - item[u"name"], - item[u"calls"][idx], - item[u"vectors"][idx], - item[u"suspends"][idx], - clocks, - vectors_call - ]) - - self._data[u'tests'][self._test_id][u'show-run'][dut] = copy.copy(oper) + self._data[u'tests'][self._test_id][u'show-run'][dut] = \ + copy.copy( + { + u"host": host, + u"socket": sock, + u"runtime": runtime, + } + ) def _get_ndrpdr_throughput(self, msg): """Get NDR_LOWER, NDR_UPPER, PDR_LOWER and PDR_UPPER from the test @@ -926,6 +903,39 @@ class ExecutionChecker(ResultVisitor): return result, status + def _get_vsap_data(self, msg, tags): + """Get data from the vsap test message. + + :param msg: The test message to be parsed. + :param tags: Test tags. + :type msg: str + :type tags: list + :returns: Parsed data as a JSON dict and the status (PASS/FAIL). + :rtype: tuple(dict, str) + """ + result = dict() + status = u"FAIL" + + groups = re.search(self.REGEX_VSAP_MSG_INFO, msg) + if groups is not None: + try: + result[u"transfer-rate"] = float(groups.group(1)) * 1e3 + result[u"latency"] = float(groups.group(2)) + result[u"completed-requests"] = int(groups.group(3)) + result[u"failed-requests"] = int(groups.group(4)) + result[u"bytes-transferred"] = int(groups.group(5)) + if u"TCP_CPS"in tags: + result[u"cps"] = float(groups.group(6)) + elif u"TCP_RPS" in tags: + result[u"rps"] = float(groups.group(6)) + else: + return result, status + status = u"PASS" + except (IndexError, ValueError): + pass + + return result, status + def visit_suite(self, suite): """Implements traversing through the suite and its direct children. @@ -1124,6 +1134,10 @@ class ExecutionChecker(ResultVisitor): if test.status == u"PASS": test_result[u"result"], test_result[u"status"] = \ self._get_hoststack_data(test.message, tags) + elif u"LDP_NGINX" in tags: + test_result[u"type"] = u"LDP_NGINX" + test_result[u"result"], test_result[u"status"] = \ + self._get_vsap_data(test.message, tags) # elif u"TCP" in tags: # This might be not used # test_result[u"type"] = u"TCP" # if test.status == u"PASS": @@ -1975,15 +1989,6 @@ class InputData: """Print all operational data to console. """ - tbl_hdr = ( - u"Name", - u"Nr of Vectors", - u"Nr of Packets", - u"Suspends", - u"Cycles per Packet", - u"Average Vector Size" - ) - for job in self._input_data.values: for build in job.values: for test_id, test_data in build[u"tests"].items(): @@ -1991,12 +1996,59 @@ class InputData: if test_data.get(u"show-run", None) is None: continue for dut_name, data in test_data[u"show-run"].items(): - if data.get(u"threads", None) is None: + if data.get(u"runtime", None) is None: + continue + try: + threads_nr = len(data[u"runtime"][0][u"clocks"]) + except (IndexError, KeyError): continue + threads = OrderedDict( + {idx: list() for idx in range(threads_nr)}) + for item in data[u"runtime"]: + for idx in range(threads_nr): + if item[u"vectors"][idx] > 0: + clocks = item[u"clocks"][idx] / \ + item[u"vectors"][idx] + elif item[u"calls"][idx] > 0: + clocks = item[u"clocks"][idx] / \ + item[u"calls"][idx] + elif item[u"suspends"][idx] > 0: + clocks = item[u"clocks"][idx] / \ + item[u"suspends"][idx] + else: + clocks = 0.0 + + if item[u"calls"][idx] > 0: + vectors_call = item[u"vectors"][idx] / \ + item[u"calls"][idx] + else: + vectors_call = 0.0 + + if int(item[u"calls"][idx]) + int( + item[u"vectors"][idx]) + \ + int(item[u"suspends"][idx]): + threads[idx].append([ + item[u"name"], + item[u"calls"][idx], + item[u"vectors"][idx], + item[u"suspends"][idx], + clocks, + vectors_call + ]) + print(f"Host IP: {data.get(u'host', '')}, " f"Socket: {data.get(u'socket', '')}") - for thread_nr, thread in data[u"threads"].items(): - txt_table = prettytable.PrettyTable(tbl_hdr) + for thread_nr, thread in threads.items(): + txt_table = prettytable.PrettyTable( + ( + u"Name", + u"Nr of Vectors", + u"Nr of Packets", + u"Suspends", + u"Cycles per Packet", + u"Average Vector Size" + ) + ) avg = 0.0 for row in thread: txt_table.add_row(row)