4 import functest.utils.functest_logger as ft_logger
5 import functest.utils.functest_utils as ft_utils
7 logger = ft_logger.Logger("sndvpn_test_config").getLogger()
10 class CommonConfig(object):
12 Common configuration parameters across testcases
15 self.repo_path = os.path.join(os.environ['repos_dir'], 'sdnvpn')
16 self.config_file = os.path.join(self.repo_path,
17 'test/functest/config.yaml')
18 self.keyfile_path = os.path.join(self.repo_path,
19 'test/functest/id_rsa')
20 self.test_db = ft_utils.get_functest_config("results.test_db_url")
21 self.line_length = 90 # length for the summary table
22 self.vm_boot_timeout = 180
23 self.default_flavor = ft_utils.get_parameter_from_yaml(
24 "defaults.flavor", self.config_file)
25 self.image_filename = ft_utils.get_functest_config(
26 "general.openstack.image_file_name")
27 self.image_format = ft_utils.get_functest_config(
28 "general.openstack.image_disk_format")
29 self.image_path = '{0}/{1}'.format(
30 ft_utils.get_functest_config(
31 "general.directories.dir_functest_data"),
35 class TestcaseConfig(object):
37 Configuration for a testcase.
38 Parse config.yaml into a dict and create an object out of it.
40 def __init__(self, testcase):
41 common_config = CommonConfig()
43 with open(common_config.config_file) as f:
44 testcases_yaml = yaml.safe_load(f)
45 test_config = testcases_yaml['testcases'].get(testcase, None)
46 if test_config is None:
47 logger.error('Test {0} configuration is not present in {1}'
48 .format(testcase, common_config.config_file))
49 # Update class fields with configuration variables dynamically
50 self.__dict__.update(**test_config)