3 # Copyright (c) 2015 All rights reserved
4 # This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # 0.1: This script boots the VM1 and allocates IP address from Nova
11 # Later, the VM2 boots then execute cloud-init to ping VM1.
12 # After successful ping, both the VMs are deleted.
13 # 0.2: measure test duration and publish results under json format
23 with open('/home/opnfv/functest/conf/config_functest.yaml') as f:
24 functest_yaml = yaml.safe_load(f)
26 dirs = functest_yaml.get('general').get('directories')
27 FUNCTEST_REPO = dirs.get('dir_repo_functest')
28 DOCTOR_REPO = dirs.get('dir_repo_doctor')
29 TEST_DB_URL = functest_yaml.get('results').get('test_db_url')
31 sys.path.append('%s/testcases' % FUNCTEST_REPO)
34 logger = logging.getLogger('doctor')
35 logger.setLevel(logging.DEBUG)
36 ch = logging.StreamHandler()
37 ch.setLevel(logging.DEBUG)
38 formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
39 ch.setFormatter(formatter)
44 cmd = 'cd %s/tests && ./run.sh' % DOCTOR_REPO
45 start_time_ts = time.time()
47 ret = functest_utils.execute_command(cmd, logger, exit_on_error=False)
49 end_time_ts = time.time()
50 duration = round(end_time_ts - start_time_ts, 1)
52 logger.info("doctor OK")
55 logger.info("doctor FAILED")
59 'timestart': start_time_ts,
61 'status': test_status,
63 pod_name = functest_utils.get_pod_name(logger)
64 scenario = functest_utils.get_scenario(logger)
66 build_tag = functest_utils.get_build_tag(logger)
69 if details['status'] == "OK":
72 logger.info("Pushing result: TEST_DB_URL=%(db)s pod_name=%(pod)s "
73 "version=%(v)s scenario=%(s)s criteria=%(c)s details=%(d)s" % {
82 functest_utils.push_results_to_db(TEST_DB_URL,
83 'doctor', 'doctor-notification',
84 logger, pod_name, version, scenario,
85 status, build_tag, details)
88 if __name__ == '__main__':