- # TODO: Remove when definitely no NDRPDRDISC tests are used:
- def _get_latency(self, msg, test_type):
- """Get the latency data from the test message.
-
- :param msg: Message to be parsed.
- :param test_type: Type of the test - NDR or PDR.
- :type msg: str
- :type test_type: str
- :returns: Latencies parsed from the message.
- :rtype: dict
- """
-
- if test_type == "NDR":
- groups = re.search(self.REGEX_LAT_NDR, msg)
- groups_range = range(1, 7)
- elif test_type == "PDR":
- groups = re.search(self.REGEX_LAT_PDR, msg)
- groups_range = range(1, 3)
- else:
- return {}
-
- latencies = list()
- for idx in groups_range:
- try:
- lat = [int(item) for item in str(groups.group(idx)).split('/')]
- except (AttributeError, ValueError):
- lat = [-1, -1, -1]
- latencies.append(lat)
-
- keys = ("min", "avg", "max")
- latency = {
- "direction1": {
- },
- "direction2": {
- }
- }
-
- latency["direction1"]["100"] = dict(zip(keys, latencies[0]))
- latency["direction2"]["100"] = dict(zip(keys, latencies[1]))
- if test_type == "NDR":
- latency["direction1"]["50"] = dict(zip(keys, latencies[2]))
- latency["direction2"]["50"] = dict(zip(keys, latencies[3]))
- latency["direction1"]["10"] = dict(zip(keys, latencies[4]))
- latency["direction2"]["10"] = dict(zip(keys, latencies[5]))
-
- return latency
-