3 # Copyright (c) 2017 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
13 from functest.utils.constants import CONST
14 import functest.utils.functest_logger as ft_logger
15 import functest.utils.functest_utils as ft_utils
17 logger = ft_logger.Logger("sndvpn_test_config").getLogger()
20 class CommonConfig(object):
22 Common configuration parameters across testcases
25 self.repo_path = CONST.dir_repo_sdnvpn
26 self.config_file = os.path.join(self.repo_path,
27 'sdnvpn/test/functest/config.yaml')
28 self.keyfile_path = os.path.join(self.repo_path,
29 'sdnvpn/artifacts/id_rsa')
30 self.test_db = CONST.results_test_db_url
31 self.quagga_setup_script_path = os.path.join(
33 "sdnvpn/artifacts/quagga_setup.sh")
34 self.line_length = 90 # length for the summary table
35 self.vm_boot_timeout = 180
36 self.default_flavor = ft_utils.get_parameter_from_yaml(
37 "defaults.flavor", self.config_file)
38 self.image_filename = CONST.openstack_image_file_name
39 self.image_format = CONST.openstack_image_disk_format
40 self.image_path = '{0}/{1}'.format(CONST.dir_functest_data,
42 # This is the ubuntu image used by sfc
43 # Basically vanilla ubuntu + some scripts in there
44 # We can use it to setup a quagga instance
45 # TODO does functest have an ubuntu image somewhere?
46 self.ubuntu_image_name = "sdnvpn-ubuntu"
47 self.ubuntu_image_path = '{0}/{1}'.format(
48 CONST.dir_functest_data,
49 "ubuntu-16.04-server-cloudimg-amd64-disk1.img")
52 class TestcaseConfig(object):
54 Configuration for a testcase.
55 Parse config.yaml into a dict and create an object out of it.
58 def __init__(self, testcase):
59 common_config = CommonConfig()
61 with open(common_config.config_file) as f:
62 testcases_yaml = yaml.safe_load(f)
63 test_config = testcases_yaml['testcases'].get(testcase, None)
64 if test_config is None:
65 logger.error('Test {0} configuration is not present in {1}'
66 .format(testcase, common_config.config_file))
67 # Update class fields with configuration variables dynamically
68 self.__dict__.update(**test_config)