X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=resources%2Ftools%2Fpresentation%2Finput_data_parser.py;h=f47f1bc6df62cc8e4ffee078f8506d7043e0746b;hb=144ebec26ff0a32000283eddfac393e497e01164;hp=25e258f75aedf875e884405abf2fa26446868000;hpb=859a3f724c077f9db9a2f40f76b6dad27f199003;p=csit.git diff --git a/resources/tools/presentation/input_data_parser.py b/resources/tools/presentation/input_data_parser.py index 25e258f75a..f47f1bc6df 100644 --- a/resources/tools/presentation/input_data_parser.py +++ b/resources/tools/presentation/input_data_parser.py @@ -281,7 +281,7 @@ class ExecutionChecker(ResultVisitor): REGEX_VERSION_VPP = re.compile(r"(return STDOUT Version:\s*|" r"VPP Version:\s*|VPP version:\s*)(.*)") - REGEX_VERSION_DPDK = re.compile(r"DPDK Version: (\d*.\d*)") + 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]*).*$') @@ -425,7 +425,7 @@ class ExecutionChecker(ResultVisitor): if msg.message.count("DPDK Version:"): try: self._version = str(re.search( - self.REGEX_VERSION_DPDK, msg.message). group(1)) + self.REGEX_VERSION_DPDK, msg.message). group(2)) self._data["metadata"]["version"] = self._version except IndexError: pass @@ -1497,6 +1497,96 @@ class InputData(object): "tags are enclosed by apostrophes.".format(cond)) return None + def filter_tests_by_name(self, element, params=None, data_set="tests", + continue_on_error=False): + """Filter required data from the given jobs and builds. + + The output data structure is: + + - job 1 + - build 1 + - test (or suite) 1 ID: + - param 1 + - param 2 + ... + - param n + ... + - test (or suite) n ID: + ... + ... + - build n + ... + - job n + + :param element: Element which will use the filtered data. + :param params: Parameters which will be included in the output. If None, + all parameters are included. + :param data_set: The set of data to be filtered: tests, suites, + metadata. + :param continue_on_error: Continue if there is error while reading the + data. The Item will be empty then + :type element: pandas.Series + :type params: list + :type data_set: str + :type continue_on_error: bool + :returns: Filtered data. + :rtype pandas.Series + """ + + include = element.get("include", None) + if not include: + logging.warning("No tests to include, skipping the element.") + return None + + if params is None: + params = element.get("parameters", None) + if params: + params.append("type") + + data = pd.Series() + try: + for job, builds in element["data"].items(): + data[job] = pd.Series() + for build in builds: + data[job][str(build)] = pd.Series() + for test in include: + try: + reg_ex = re.compile(str(test).lower()) + for test_ID in self.data[job][str(build)]\ + [data_set].keys(): + if re.match(reg_ex, str(test_ID).lower()): + test_data = self.data[job][str(build)]\ + [data_set][test_ID] + data[job][str(build)][test_ID] = pd.Series() + if params is None: + for param, val in test_data.items(): + data[job][str(build)][test_ID]\ + [param] = val + else: + for param in params: + try: + data[job][str(build)][test_ID]\ + [param] = test_data[param] + except KeyError: + data[job][str(build)][test_ID]\ + [param] = "No Data" + except KeyError as err: + logging.error("{err!r}".format(err=err)) + if continue_on_error: + continue + else: + return None + return data + + except (KeyError, IndexError, ValueError) as err: + logging.error("Missing mandatory parameter in the element " + "specification: {err!r}".format(err=err)) + return None + except AttributeError as err: + logging.error("{err!r}".format(err=err)) + return None + + @staticmethod def merge_data(data): """Merge data from more jobs and builds to a simple data structure.