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
21 import functest.utils.functest_logger as ft_logger
22 import functest.utils.functest_utils as functest_utils
24 with open(os.environ["CONFIG_FUNCTEST_YAML"]) as f:
25 functest_yaml = yaml.safe_load(f)
27 dirs = functest_yaml.get('general').get('directories')
28 FUNCTEST_REPO = dirs.get('dir_repo_functest')
29 DOCTOR_REPO = dirs.get('dir_repo_doctor')
30 TEST_DB_URL = functest_yaml.get('results').get('test_db_url')
32 logger = ft_logger.Logger("doctor").getLogger()
37 cmd = 'cd %s/tests && ./run.sh' % DOCTOR_REPO
38 start_time = time.time()
40 ret = functest_utils.execute_command(cmd, logger, exit_on_error=False)
42 stop_time = time.time()
43 duration = round(stop_time - start_time, 1)
45 logger.info("doctor OK")
49 logger.info("doctor FAILED")
53 'timestart': start_time,
55 'status': test_status,
57 pod_name = functest_utils.get_pod_name(logger)
58 scenario = functest_utils.get_scenario(logger)
59 version = functest_utils.get_version(logger)
60 build_tag = functest_utils.get_build_tag(logger)
63 if details['status'] == "OK":
66 logger.info("Pushing Doctor results: TEST_DB_URL=%(db)s pod_name=%(pod)s "
67 "version=%(v)s scenario=%(s)s criteria=%(c)s details=%(d)s" % {
76 functest_utils.push_results_to_db("doctor",
77 "doctor-notification",
86 if __name__ == '__main__':