summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVijayendra Radhakrishna <vradhakrishna@mvista.com>2016-12-02 23:08:46 +0530
committerVijayendra Radhakrishna <vradhakrishna@mvista.com>2016-12-02 23:21:29 +0530
commitb5f07669753b2b4383c7c10d133a2b803311cb8d (patch)
tree49e54645a5a87abbe0a03ded0e979205dd2a899b
parentf0791ea32270bcf9a3e1b5d3451053f6cf434e66 (diff)
odl-sfc refactor:Enable config options for tests
- JIRA:SFC-54 - Add config.py and config.yaml for test configurations Signed-off-by: Vijayendra Radhakrishna <vradhakrishna@mvista.com> Change-Id: Ib1ac65a154d691d70658723a03e2508ebfa9d04b Signed-off-by: Vijayendra Radhakrishna <vradhakrishna@mvista.com>
-rw-r--r--tests/functest/odl-sfc/config.py63
-rw-r--r--tests/functest/odl-sfc/config.yaml23
-rwxr-xr-xtests/functest/odl-sfc/sfc.py70
3 files changed, 116 insertions, 40 deletions
diff --git a/tests/functest/odl-sfc/config.py b/tests/functest/odl-sfc/config.py
new file mode 100644
index 00000000..556302e6
--- /dev/null
+++ b/tests/functest/odl-sfc/config.py
@@ -0,0 +1,63 @@
+import yaml
+import os
+
+import functest.utils.functest_logger as ft_logger
+import functest.utils.functest_utils as ft_utils
+import functest.utils.functest_constants as ft_constants
+
+logger = ft_logger.Logger("sfc_test_config").getLogger()
+
+
+class CommonConfig(object):
+ """
+ Common configuration parameters across testcases
+ """
+
+ def __init__(self):
+ self.line_length = 30
+ self.test_db = ft_utils.get_functest_config("results.test_db_url")
+ self.repo_path = ft_constants.SFC_REPO_DIR
+ self.sfc_test_dir = os.path.join(self.repo_path, "tests",
+ "functest", "odl-sfc")
+ self.functest_results_dir = os.path.join(
+ ft_constants.FUNCTEST_RESULTS_DIR, "odl-sfc")
+ self.config_file = os.path.join(self.sfc_test_dir, "config.yaml")
+ self.fuel_master_ip = ft_utils.get_parameter_from_yaml(
+ "defaults.fuel_master_ip", self.config_file)
+ self.fuel_master_uname = ft_utils.get_parameter_from_yaml(
+ "defaults.fuel_master_uname", self.config_file)
+ self.fuel_master_passwd = ft_utils.get_parameter_from_yaml(
+ "defaults.fuel_master_passwd", self.config_file)
+ self.flavor = ft_utils.get_parameter_from_yaml(
+ "defaults.flavor", self.config_file)
+ self.image_name = ft_utils.get_parameter_from_yaml(
+ "defaults.image_name", self.config_file)
+ self.image_file_name = ft_utils.get_parameter_from_yaml(
+ "defaults.image_file_name", self.config_file)
+ self.image_format = ft_utils.get_parameter_from_yaml(
+ "defaults.image_format", self.config_file)
+ self.url = ft_utils.get_parameter_from_yaml(
+ "defaults.url", self.config_file)
+ self.dir_functest_data = ft_utils.get_functest_config(
+ "general.directories.dir_functest_data")
+ self.image_path = os.path.join(
+ self.dir_functest_data, self.image_file_name)
+
+
+class TestcaseConfig(object):
+ """
+ Configuration for a testcase.
+ Parse config.yaml into a dict and create an object out of it.
+ """
+
+ def __init__(self, testcase):
+ common_config = CommonConfig()
+ test_config = None
+ with open(common_config.config_file) as f:
+ testcases_yaml = yaml.safe_load(f)
+ test_config = testcases_yaml['testcases'].get(testcase, None)
+ if test_config is None:
+ logger.error('Test {0} configuration is not present in {1}'
+ .format(testcase, common_config.config_file))
+ # Update class fields with configuration variables dynamically
+ self.__dict__.update(**test_config)
diff --git a/tests/functest/odl-sfc/config.yaml b/tests/functest/odl-sfc/config.yaml
new file mode 100644
index 00000000..c6624af6
--- /dev/null
+++ b/tests/functest/odl-sfc/config.yaml
@@ -0,0 +1,23 @@
+defaults:
+ flavor: custom #odl-sfc uses custom flavor
+ image_name: sf_nsh_colorado
+ image_file_name: sf_nsh_colorado.qcow2
+ fuel_master_ip: 10.20.0.2
+ fuel_master_uname: root
+ fuel_master_passwd: r00tme
+ image_format: qcow2
+ url: "http://artifacts.opnfv.org/sfc/demo"
+
+testcases:
+ sfc_two_chains_SSH_and_HTTP:
+ enabled: true
+ description: "ODL-SFC tests"
+ testname_db: "sfc_two_chains_SSH_and_HTTP"
+ net_name: example-net
+ subnet_name: example-subnet
+ router_name: example-router
+ subnet_cidr: "11.0.0.0/24"
+ secgroup_name: "example-sg"
+ secgroup_descr: "Example Security group"
+ test_vnfd_red: "test-vnfd1.yaml"
+ test_vnfd_blue: "test-vnfd2.yaml"
diff --git a/tests/functest/odl-sfc/sfc.py b/tests/functest/odl-sfc/sfc.py
index fe9d3e5f..12227698 100755
--- a/tests/functest/odl-sfc/sfc.py
+++ b/tests/functest/odl-sfc/sfc.py
@@ -9,6 +9,7 @@ import functest.utils.openstack_tacker as os_tacker
import threading
import ovs_utils
import utils as test_utils
+import config as sfc_config
parser = argparse.ArgumentParser()
@@ -22,33 +23,16 @@ args = parser.parse_args()
""" logging configuration """
logger = ft_logger.Logger("ODL_SFC").getLogger()
-FUNCTEST_RESULTS_DIR = '/home/opnfv/functest/results/odl-sfc'
-REPO_PATH = os.path.join(os.environ['REPOS_DIR'], 'sfc/')
CLIENT = "client"
SERVER = "server"
-FLAVOR = "custom"
-IMAGE_NAME = "sf_nsh_colorado"
-IMAGE_FILENAME = "sf_nsh_colorado.qcow2"
-IMAGE_FORMAT = "qcow2"
-IMAGE_DIR = "/home/opnfv/functest/data"
-IMAGE_PATH = os.path.join(IMAGE_DIR, IMAGE_FILENAME)
-URL = "http://artifacts.opnfv.org/sfc/demo"
-
-# NEUTRON Private Network parameters
-NET_NAME = "example-net"
-SUBNET_NAME = "example-subnet"
-SUBNET_CIDR = "11.0.0.0/24"
-ROUTER_NAME = "example-router"
-SECGROUP_NAME = "example-sg"
-SECGROUP_DESCR = "Example Security group"
-SFC_TEST_DIR = os.path.join(REPO_PATH, "tests/functest/odl-sfc/")
-ssh_options = '-q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
json_results = {"tests": 4, "failures": 0}
+COMMON_CONFIG = sfc_config.CommonConfig()
+TESTCASE_CONFIG = sfc_config.TestcaseConfig('sfc_two_chains_SSH_and_HTTP')
PROXY = {
- 'ip': '10.20.0.2',
- 'username': 'root',
- 'password': 'r00tme'
+ 'ip': COMMON_CONFIG.fuel_master_ip,
+ 'username': COMMON_CONFIG.fuel_master_uname,
+ 'password': COMMON_CONFIG.fuel_master_passwd
}
@@ -78,9 +62,10 @@ def main():
start_time = time.time()
status = "PASS"
test_utils.configure_iptables()
- test_utils.download_image(URL, IMAGE_PATH)
+ test_utils.download_image(COMMON_CONFIG.url,
+ COMMON_CONFIG.image_path)
_, custom_flv_id = os_utils.get_or_create_flavor(
- FLAVOR, 1500, 10, 1, public=True)
+ COMMON_CONFIG.flavor, 1500, 10, 1, public=True)
if not custom_flv_id:
logger.error("Failed to create custom flavor")
sys.exit(1)
@@ -94,40 +79,45 @@ def main():
compute_clients = test_utils.get_ssh_clients("compute", PROXY)
ovs_logger = ovs_utils.OVSLogger(
- os.path.join(SFC_TEST_DIR, 'ovs-logs'),
- FUNCTEST_RESULTS_DIR)
+ os.path.join(COMMON_CONFIG.sfc_test_dir, 'ovs-logs'),
+ COMMON_CONFIG.functest_results_dir)
image_id = os_utils.create_glance_image(glance_client,
- IMAGE_NAME,
- IMAGE_PATH,
- IMAGE_FORMAT,
+ COMMON_CONFIG.image_name,
+ COMMON_CONFIG.image_path,
+ COMMON_CONFIG.image_format,
public=True)
network_id = test_utils.setup_neutron(neutron_client,
- NET_NAME,
- SUBNET_NAME,
- ROUTER_NAME,
- SUBNET_CIDR)
+ TESTCASE_CONFIG.net_name,
+ TESTCASE_CONFIG.subnet_name,
+ TESTCASE_CONFIG.router_name,
+ TESTCASE_CONFIG.subnet_cidr)
sg_id = test_utils.create_security_groups(neutron_client,
- SECGROUP_NAME,
- SECGROUP_DESCR)
+ TESTCASE_CONFIG.secgroup_name,
+ TESTCASE_CONFIG.secgroup_descr)
test_utils.create_instance(
- nova_client, CLIENT, FLAVOR, image_id,
+ nova_client, CLIENT, COMMON_CONFIG.flavor, image_id,
network_id, sg_id)
srv_instance = test_utils.create_instance(
- nova_client, SERVER, FLAVOR, image_id,
+ nova_client, SERVER, COMMON_CONFIG.flavor, image_id,
network_id, sg_id)
- srv_prv_ip = srv_instance.networks.get(NET_NAME)[0]
+ srv_prv_ip = srv_instance.networks.get(TESTCASE_CONFIG.net_name)[0]
+ tosca_file = os.path.join(COMMON_CONFIG.sfc_test_dir,
+ TESTCASE_CONFIG.test_vnfd_red)
os_tacker.create_vnfd(
tacker_client,
- tosca_file=os.path.join(SFC_TEST_DIR, 'test-vnfd1.yaml'))
+ tosca_file=tosca_file)
+
+ tosca_file = os.path.join(COMMON_CONFIG.sfc_test_dir,
+ TESTCASE_CONFIG.test_vnfd_blue)
os_tacker.create_vnfd(
tacker_client,
- tosca_file=os.path.join(SFC_TEST_DIR, 'test-vnfd2.yaml'))
+ tosca_file=tosca_file)
os_tacker.create_vnf(
tacker_client, 'testVNF1', vnfd_name='test-vnfd1')