from datetime import datetime as dt
from datetime import timedelta
from json import loads
-from jumpavg.AvgStdevMetadataFactory import AvgStdevMetadataFactory
+from resources.libraries.python import jumpavg
from input_data_files import download_and_unzip_data_file
"type": "MRR" | "BMRR",
"status": "PASS" | "FAIL",
"result": {
- "receive-rate": AvgStdevMetadata,
+ "receive-rate": float,
+ # Average of a list, computed using AvgStdevStats.
+ # In CSIT-1180, replace with List[float].
}
}
REGEX_VERSION_DPDK = re.compile(r"(DPDK version:\s*|DPDK Version:\s*)(.*)")
- REGEX_TCP = re.compile(r'Total\s(rps|cps|throughput):\s([0-9]*).*$')
+ REGEX_TCP = re.compile(r'Total\s(rps|cps|throughput):\s(\d*).*$')
REGEX_MRR = re.compile(r'MaxReceivedRate_Results\s\[pkts/(\d*)sec\]:\s'
r'tx\s(\d*),\srx\s(\d*)')
r' in packets per second: \[(.*)\]')
REGEX_RECONF_LOSS = re.compile(r'Packets lost due to reconfig: (\d*)')
- REGEX_RECONF_TIME = re.compile(r'Implied time lost: (\d*.\d*)')
+ REGEX_RECONF_TIME = re.compile(r'Implied time lost: (\d*.[\de-]*)')
REGEX_TC_TAG = re.compile(r'\d+[tT]\d+[cC]')
REGEX_TC_NAME_NEW = re.compile(r'-\d+[cC]-')
- REGEX_TC_NUMBER = re.compile(r'tc[0-9]{2}-')
+ REGEX_TC_NUMBER = re.compile(r'tc\d{2}-')
+
+ REGEX_TC_PAPI_CLI = re.compile(r'.*\((\d+.\d+.\d+.\d+.) - (.*)\)')
def __init__(self, metadata, mapping, ignore):
"""Initialisation.
self._data["tests"][self._test_ID]["conf-history"] = str()
else:
self._msg_type = None
- text = re.sub("[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3} "
+ text = re.sub("\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3} "
"VAT command history:", "", msg.message, count=1). \
replace("\n\n", "\n").replace('\n', ' |br| ').\
replace('\r', '').replace('"', "'")
self._data["tests"][self._test_ID]["conf-history"] = str()
else:
self._msg_type = None
- text = re.sub("[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3} "
+ text = re.sub("\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3} "
"PAPI command history:", "", msg.message, count=1). \
replace("\n\n", "\n").replace('\n', ' |br| ').\
replace('\r', '').replace('"', "'")
:type msg: Message
:returns: Nothing.
"""
- if msg.message.count("Runtime:"):
- 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()
- if self._lookup_kw_nr > 1:
- self._msg_type = None
- if self._show_run_lookup_nr > 0:
- message = str(msg.message).replace(' ', '').replace('\n', '').\
- replace("'", '"').replace('b"', '"').replace('u"', '"')[8:]
- runtime = loads(message)
- try:
- threads_nr = len(runtime[0]["clocks"])
- except (IndexError, KeyError):
- return
- tbl_hdr = ["Name", "Calls", "Vectors", "Suspends", "Clocks"]
- table = [[tbl_hdr, ] for _ in range(threads_nr)]
- for item in runtime:
- for idx in range(threads_nr):
+ if not "show-run" in self._data["tests"][self._test_ID].keys():
+ self._data["tests"][self._test_ID]["show-run"] = str()
+
+ if msg.message.count("stats runtime"):
+ host = str(re.search(self.REGEX_TC_PAPI_CLI, msg.message).\
+ group(1))
+ socket = str(re.search(self.REGEX_TC_PAPI_CLI, msg.message).\
+ group(2))
+ message = str(msg.message).replace(' ', '').replace('\n', '').\
+ replace("'", '"').replace('b"', '"').replace('u"', '"').\
+ split(":",1)[1]
+ runtime = loads(message)
+ try:
+ threads_nr = len(runtime[0]["clocks"])
+ except (IndexError, KeyError):
+ return
+ tbl_hdr = ["Name", "Calls", "Vectors", "Suspends", "Clocks",
+ "Vectors/Calls"]
+ table = [[tbl_hdr, ] for _ in range(threads_nr)]
+ for item in runtime:
+ for idx in range(threads_nr):
+ name = format(item["name"])
+ calls = format(item["calls"][idx])
+ vectors = format(item["vectors"][idx])
+ suspends = format(item["suspends"][idx])
+ if item["vectors"][idx] > 0:
+ clocks = format(
+ item["clocks"][idx]/item["vectors"][idx], ".2e")
+ elif item["calls"][idx] > 0:
+ clocks = format(
+ item["clocks"][idx]/item["calls"][idx], ".2e")
+ elif item["suspends"][idx] > 0:
+ clocks = format(
+ item["clocks"][idx]/item["suspends"][idx], ".2e")
+ else:
+ clocks = 0
+ if item["calls"][idx] > 0:
+ vectors_call = format(
+ item["vectors"][idx]/item["calls"][idx], ".2f")
+ else:
+ vectors_call = format(0, ".2f")
+ if int(calls) + int(vectors) + int(suspends):
table[idx].append([
- item["name"],
- item["calls"][idx],
- item["vectors"][idx],
- item["suspends"][idx],
- item["clocks"][idx]
+ name, calls, vectors, suspends, clocks, vectors_call
])
- text = ""
- for idx in range(threads_nr):
- text += "Thread {idx} ".format(idx=idx)
- text += "vpp_main\n" if idx == 0 else \
- "vpp_wk_{idx}\n".format(idx=idx-1)
- txt_table = None
- for row in table[idx]:
- if txt_table is None:
- txt_table = prettytable.PrettyTable(row)
- else:
- if any(row[1:]):
- txt_table.add_row(row)
- txt_table.set_style(prettytable.MSWORD_FRIENDLY)
- txt_table.align["Name"] = "l"
- txt_table.align["Calls"] = "r"
- txt_table.align["Vectors"] = "r"
- txt_table.align["Suspends"] = "r"
- txt_table.align["Clocks"] = "r"
-
- text += txt_table.get_string(sortby="Name") + '\n'
-
- text = text.replace('\n', ' |br| ').replace('\r', '').\
- replace('"', "'")
- try:
- self._data["tests"][self._test_ID]["show-run"] += " |br| "
- self._data["tests"][self._test_ID]["show-run"] += \
- "**DUT" + str(self._show_run_lookup_nr) + ":** |br| " \
- + text
- except KeyError:
- pass
+ text = ""
+ for idx in range(threads_nr):
+ text += "Thread {idx} ".format(idx=idx)
+ text += "vpp_main\n" if idx == 0 else \
+ "vpp_wk_{idx}\n".format(idx=idx-1)
+ txt_table = None
+ for row in table[idx]:
+ if txt_table is None:
+ txt_table = prettytable.PrettyTable(row)
+ else:
+ if any(row[1:]):
+ txt_table.add_row(row)
+ txt_table.set_style(prettytable.MSWORD_FRIENDLY)
+ txt_table.align["Name"] = "l"
+ txt_table.align["Calls"] = "r"
+ txt_table.align["Vectors"] = "r"
+ txt_table.align["Suspends"] = "r"
+ txt_table.align["Clocks"] = "r"
+ txt_table.align["Vectors/Calls"] = "r"
+
+ text += txt_table.get_string(sortby="Name") + '\n'
+ text = (" \n **DUT: {host}/{socket}** \n {text}".
+ format(host=host, socket=socket, text=text))
+ text = text.replace('\n', ' |br| ').replace('\r', '').\
+ replace('"', "'")
+ self._data["tests"][self._test_ID]["show-run"] += text
def _get_ndrpdr_throughput(self, msg):
"""Get NDR_LOWER, NDR_UPPER, PDR_LOWER and PDR_UPPER from the test
items_str = groups.group(1)
items_float = [float(item.strip()) for item
in items_str.split(",")]
- metadata = AvgStdevMetadataFactory.from_data(items_float)
- # Next two lines have been introduced in CSIT-1179,
- # to be removed in CSIT-1180.
- metadata.size = 1
- metadata.stdev = 0.0
- test_result["result"]["receive-rate"] = metadata
+ # Use whole list in CSIT-1180.
+ stats = jumpavg.AvgStdevStats.for_runs(items_float)
+ test_result["result"]["receive-rate"] = stats.avg
else:
groups = re.search(self.REGEX_MRR, test.message)
test_result["result"]["receive-rate"] = \
- AvgStdevMetadataFactory.from_data([
- float(groups.group(3)) / float(groups.group(1)), ])
+ float(groups.group(3)) / float(groups.group(1))
elif test_result["type"] == "RECONF":
test_result["result"] = None
pass
-class InputData(object):
+class InputData:
"""Input data
The data is extracted from output.xml files generated by Jenkins jobs and