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
14 from functest.utils.constants import CONST
15 import functest.utils.functest_utils as ft_utils
17 logger = logging.getLogger('sdnvpn_test_config')
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_images,
49 "ubuntu-16.04-server-cloudimg-amd64-disk1.img")
50 self.custom_flavor_name = 'm1.custom'
51 self.custom_flavor_ram = 1024
52 self.custom_flavor_disk = 10
53 self.custom_flavor_vcpus = 1
56 class TestcaseConfig(object):
58 Configuration for a testcase.
59 Parse config.yaml into a dict and create an object out of it.
62 def __init__(self, testcase):
63 common_config = CommonConfig()
65 with open(common_config.config_file) as f:
66 testcases_yaml = yaml.safe_load(f)
67 test_config = testcases_yaml['testcases'].get(testcase, None)
68 if test_config is None:
69 logger.error('Test {0} configuration is not present in {1}'
70 .format(testcase, common_config.config_file))
71 # Update class fields with configuration variables dynamically
72 self.__dict__.update(**test_config)