3 # Copyright (c) 2015 Orange
4 # morgan.richomme@orange.com
6 # This program and the accompanying materials
7 # are made available under the terms of the Apache License, Version 2.0
8 # which accompanies this distribution, and is available at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # This script is used to get data from test DB
13 # and format them into a json format adapted for a dashboard
20 import dashboard_utils
24 pp = pprint.PrettyPrinter(indent=4)
26 parser = argparse.ArgumentParser()
27 parser.add_argument("repo_path", help="Path to the repository")
28 parser.add_argument("-d", "--debug", help="Debug mode", action="store_true")
29 args = parser.parse_args()
31 """ logging configuration """
32 logger = logging.getLogger('config_functest')
33 logger.setLevel(logging.DEBUG)
35 ch = logging.StreamHandler()
37 ch.setLevel(logging.DEBUG)
39 ch.setLevel(logging.INFO)
41 formatter = logging.Formatter('%(asctime)s - %(name)s -\
42 %(levelname)s - %(message)s')
43 ch.setFormatter(formatter)
46 if not os.path.exists(args.repo_path):
47 logger.error("Repo directory not found '%s'" % args.repo_path)
50 with open(args.repo_path+"testcases/config_functest.yaml") as f:
51 functest_yaml = yaml.safe_load(f)
54 """ global variables """
56 HOME = os.environ['HOME']+"/"
57 REPO_PATH = args.repo_path
58 TEST_DB = functest_yaml.get("results").get("test_db_url")
63 logger.info("Functest test result generation for dashboard")
65 # TODO create the loop to provide all the json files
66 logger.debug("Retrieve all the testcases from DB")
67 test_cases = dashboard_utils.get_testcases(TEST_DB, "functest")
69 # TODO to be refactor once graph for Tempest, rally and ODL ready
70 # Do it only for vPing in first stage
71 for case in test_cases:
72 logger.debug("Generate " + case + " json files")
73 dashboard_utils.generateJson('functest', case, TEST_DB)
75 logger.info("Functest json files for dashboard successfully generated")
77 logger.error("Impossible to generate json files for dashboard")
80 if __name__ == '__main__':