diff options
author | Tibor Frank <tifrank@cisco.com> | 2018-03-01 14:52:47 +0100 |
---|---|---|
committer | Tibor Frank <tifrank@cisco.com> | 2018-03-21 15:43:10 +0000 |
commit | efdcf6470f6e15dcc918c70e5a61d10e10653f1e (patch) | |
tree | b2d5a5a2163b56d12f300c06119e925377674187 /resources/tools/presentation/specification_parser.py | |
parent | 70068307d35abcd40abbcd9275bcb836d2cdbae6 (diff) |
CSIT-913: Continuous Trending, Analysis and Change Detection
- CSIT-915: LLD
- CSIT-917: Functions to evaluate the results according to the PASS / FAIL criteria
- CSIT-918: Sphinx configuration
- CSIT-948: Statistical functions
- CSIT-949: Data models for trending plots
- CSIT-950: Code trending plots
- CSIT-951: Static content
- CSIT-984: PAL Specification file
- CSIT-996: Download data from nexus
Change-Id: Icb9305945bb0f142135bb177cb8781ba0096280e
Signed-off-by: Tibor Frank <tifrank@cisco.com>
Diffstat (limited to 'resources/tools/presentation/specification_parser.py')
-rw-r--r-- | resources/tools/presentation/specification_parser.py | 87 |
1 files changed, 84 insertions, 3 deletions
diff --git a/resources/tools/presentation/specification_parser.py b/resources/tools/presentation/specification_parser.py index 501f9f191a..2659c29ca5 100644 --- a/resources/tools/presentation/specification_parser.py +++ b/resources/tools/presentation/specification_parser.py @@ -22,6 +22,7 @@ from yaml import load, YAMLError from pprint import pformat from errors import PresentationError +from utils import get_last_build_number class Specification(object): @@ -53,7 +54,8 @@ class Specification(object): "output": dict(), "tables": list(), "plots": list(), - "files": list()} + "files": list(), + "cpta": dict()} @property def specification(self): @@ -173,6 +175,17 @@ class Specification(object): """ return self._specification["files"] + @property + def cpta(self): + """Getter - Continuous Performance Trending and Analysis to be + generated. + + :returns: List of specifications of Continuous Performance Trending and + Analysis to be generated. + :rtype: list + """ + return self._specification["cpta"] + def set_input_state(self, job, build_nr, state): """Set the state of input @@ -354,9 +367,31 @@ class Specification(object): try: self._specification["configuration"] = self._cfg_yaml[idx] + except KeyError: raise PresentationError("No configuration defined.") + # Data sets: Replace ranges by lists + for set_name, data_set in self.configuration["data-sets"].items(): + for job, builds in data_set.items(): + if builds: + if isinstance(builds, dict): + # defined as a range <start, end> + if builds.get("end", None) == "lastSuccessfulBuild": + # defined as a range <start, lastSuccessfulBuild> + ret_code, build_nr, _ = get_last_build_number( + self.environment["urls"]["URL[JENKINS,CSIT]"], + job) + if ret_code != 0: + raise PresentationError( + "Not possible to get the number of the " + "last successful build.") + else: + # defined as a range <start, end (build number)> + build_nr = builds.get("end", None) + builds = [x for x in range(1, int(build_nr)+1)] + self.configuration["data-sets"][set_name][job] = builds + logging.info("Done.") def _parse_debug(self): @@ -412,8 +447,25 @@ class Specification(object): for key, value in self._cfg_yaml[idx]["general"].items(): self._specification["input"][key] = value self._specification["input"]["builds"] = dict() + for job, builds in self._cfg_yaml[idx]["builds"].items(): if builds: + if isinstance(builds, dict): + # defined as a range <start, end> + if builds.get("end", None) == "lastSuccessfulBuild": + # defined as a range <start, lastSuccessfulBuild> + ret_code, build_nr, _ = get_last_build_number( + self.environment["urls"]["URL[JENKINS,CSIT]"], + job) + if ret_code != 0: + raise PresentationError( + "Not possible to get the number of the " + "last successful build.") + else: + # defined as a range <start, end (build number)> + build_nr = builds.get("end", None) + builds = [x for x in range(builds["start"], + int(build_nr) + 1)] self._specification["input"]["builds"][job] = list() for build in builds: self._specification["input"]["builds"][job].\ @@ -440,8 +492,8 @@ class Specification(object): raise PresentationError("No output defined.") try: - self._specification["output"] = self._cfg_yaml[idx]["format"] - except KeyError: + self._specification["output"] = self._cfg_yaml[idx] + except (KeyError, IndexError): raise PresentationError("No output defined.") logging.info("Done.") @@ -535,6 +587,35 @@ class Specification(object): self._specification["files"].append(element) count += 1 + elif element["type"] == "cpta": + logging.info(" {:3d} Processing Continuous Performance " + "Trending and Analysis ...".format(count)) + + for plot in element["plots"]: + # Add layout to the plots: + layout = plot.get("layout", None) + if layout is not None: + try: + plot["layout"] = \ + self.configuration["plot-layouts"][layout] + except KeyError: + raise PresentationError( + "Layout {0} is not defined in the " + "configuration section.".format(layout)) + # Add data sets: + if isinstance(plot.get("data", None), str): + data_set = plot["data"] + try: + plot["data"] = \ + self.configuration["data-sets"][data_set] + except KeyError: + raise PresentationError( + "Data set {0} is not defined in " + "the configuration section.". + format(data_set)) + self._specification["cpta"] = element + count += 1 + logging.info("Done.") def read_specification(self): |