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
16 import functest.utils.functest_logger as ft_logger
17 import functest.opnfv_tests.openstack.tempest.conf_utils as tempest_utils
19 logger = ft_logger.Logger("sdnvpn-tempest").getLogger()
23 verifier_repo_dir = tempest_utils.get_verifier_repo_dir(None)
24 src_tempest_dir = tempest_utils.get_verifier_deployment_dir(None, None)
26 if not src_tempest_dir:
27 logger.error("Rally deployment not found.")
30 tempest_utils.configure_verifier(src_tempest_dir)
32 src_tempest_conf = os.path.join(src_tempest_dir, 'tempest.conf')
33 bgpvpn_tempest_conf = src_tempest_dir + '/bgpvpn_tempest.conf'
35 if not os.path.isfile(src_tempest_conf):
36 logger.error("tempest.conf not found in %s." % src_tempest_conf)
38 shutil.copy(src_tempest_conf, bgpvpn_tempest_conf)
40 logger.info("Copying tempest.conf to %s." % bgpvpn_tempest_conf)
41 config = ConfigParser.RawConfigParser()
42 config.read(bgpvpn_tempest_conf)
43 config.set('service_available', 'bgpvpn', 'True')
44 logger.debug("Updating %s with bgpvpn=True" % bgpvpn_tempest_conf)
45 with open(bgpvpn_tempest_conf, 'wb') as tempest_conf:
46 config.write(tempest_conf)
48 cmd_line = (verifier_repo_dir +
49 "/run_tempest.sh -C %s -t -N -- "
50 "networking_bgpvpn_tempest" % bgpvpn_tempest_conf)
51 logger.info("Executing: %s" % cmd_line)
52 cmd = os.popen(cmd_line)
63 for match in re.findall('(.*?)[. ]*FAILED', output):
66 m = re.search('tests in(.*)sec', output)
68 # Look for num tests run
69 m = re.search('Ran:(.*)tests', output)
70 num_tests = m.group(1)
71 # Look for tests failed
72 m = re.search('Failed:(.*)', output)
74 # Look for name of the tests
75 testcases = re.findall("\{0\} (.*)", output)
77 results = {"duration": duration,
78 "num_tests": num_tests, "failed": failed,
85 return {"status": status, "details": results}
87 logger.error("Problem when parsing the results.")
90 if __name__ == '__main__':