aboutsummaryrefslogtreecommitdiffstats
path: root/sfc/tests/functest/sfc_parent_function.py
diff options
context:
space:
mode:
Diffstat (limited to 'sfc/tests/functest/sfc_parent_function.py')
-rw-r--r--sfc/tests/functest/sfc_parent_function.py236
1 files changed, 181 insertions, 55 deletions
diff --git a/sfc/tests/functest/sfc_parent_function.py b/sfc/tests/functest/sfc_parent_function.py
index 6af8e8ec..d93b2fbf 100644
--- a/sfc/tests/functest/sfc_parent_function.py
+++ b/sfc/tests/functest/sfc_parent_function.py
@@ -51,11 +51,15 @@ class SfcCommonTestCase(object):
self.vnf_id = None
self.client_floating_ip = None
self.server_floating_ip = None
- self.fips_sfs = None
+ self.fips_sfs = []
self.neutron_port = None
+ self.vnf_objects = dict()
self.testcase_config = testcase_config
self.vnfs = vnfs
+ # n-sfc variables
+ self.port_groups = []
+
self.prepare_env(testcase_config, supported_installers, vnfs)
def prepare_env(self, testcase_config, supported_installers, vnfs):
@@ -117,9 +121,10 @@ class SfcCommonTestCase(object):
self.controller_clients = test_utils.get_ssh_clients(controller_nodes)
self.compute_clients = test_utils.get_ssh_clients(self.compute_nodes)
- self.tacker_client = os_sfc_utils.get_tacker_client()
- os_sfc_utils.register_vim(self.tacker_client,
- vim_file=COMMON_CONFIG.vim_file)
+ if COMMON_CONFIG.mano_component == 'tacker':
+ self.tacker_client = os_sfc_utils.get_tacker_client()
+ os_sfc_utils.register_vim(self.tacker_client,
+ vim_file=COMMON_CONFIG.vim_file)
self.ovs_logger = ovs_log.OVSLogger(
os.path.join(COMMON_CONFIG.sfc_test_dir, 'ovs-logs'),
@@ -170,13 +175,15 @@ class SfcCommonTestCase(object):
openstack_sfc.create_instance(SERVER, COMMON_CONFIG.flavor,
self.image_creator, self.network,
self.sg,
- self.test_topology['server'])
+ self.test_topology['server'],
+ [SERVER + '-port'])
self.client_instance, self.client_creator = \
openstack_sfc.create_instance(CLIENT, COMMON_CONFIG.flavor,
self.image_creator, self.network,
self.sg,
- self.test_topology['client'])
+ self.test_topology['client'],
+ [CLIENT + '-port'])
logger.info('This test is run with the topology {0}'.format(
self.test_topology['id']))
logger.info('Topology description: {0}'.format(
@@ -186,6 +193,20 @@ class SfcCommonTestCase(object):
logger.info("Server instance received private ip [{}]".format(
self.server_ip))
+ def register_vnf_template(self, test_case_name, template_name):
+ """ Register the template which defines the VNF
+
+ :param test_case_name: the name of the test case
+ :param template_name: name of the template
+ """
+
+ if COMMON_CONFIG.mano_component == 'tacker':
+ self.create_custom_vnfd(test_case_name, template_name)
+
+ elif COMMON_CONFIG.mano_component == 'no-mano':
+ # networking-sfc does not have the template concept
+ pass
+
def create_custom_vnfd(self, test_case_name, vnfd_name):
"""Create VNF Descriptor (VNFD)
@@ -201,12 +222,14 @@ class SfcCommonTestCase(object):
tosca_file=tosca_file,
vnfd_name=vnfd_name)
- def create_vnf(self, vnf_names, vnfd_name, vim_name):
- """Create vnf
+ def create_vnf(self, vnf_name, vnfd_name=None, vim_name=None,
+ symmetric=False):
+ """Create custom vnf
- :param vnf_names: names of available vnf(s)
+ :param vnf_name: name of the vnf
:param vnfd_name: name of the vnfd template (tacker)
:param vim_name: name of the vim (tacker)
+ :param symmetric: specifies whether this is part of the symmetric test
:return: av zone
"""
@@ -215,14 +238,35 @@ class SfcCommonTestCase(object):
logger.info('Topology description: {0}'
.format(self.test_topology['description']))
- os_sfc_utils.create_vnf_in_av_zone(
- self.tacker_client, vnf_names, vnfd_name, vim_name,
- self.default_param_file, self.test_topology[vnf_names])
-
- self.vnf_id = os_sfc_utils.wait_for_vnf(self.tacker_client,
- vnf_name=vnf_names)
- if self.vnf_id is None:
- raise Exception('ERROR while booting vnfs')
+ if COMMON_CONFIG.mano_component == 'tacker':
+ os_sfc_utils.create_vnf_in_av_zone(
+ self.tacker_client, vnf_name, vnfd_name, vim_name,
+ self.default_param_file, self.test_topology[vnf_name])
+
+ self.vnf_id = os_sfc_utils.wait_for_vnf(self.tacker_client,
+ vnf_name=vnf_name)
+ if self.vnf_id is None:
+ raise Exception('ERROR while booting vnfs')
+
+ elif COMMON_CONFIG.mano_component == 'no-mano':
+ av_zone = self.test_topology[vnf_name]
+ if symmetric:
+ ports = [vnf_name + '-port1', vnf_name + '-port2']
+ else:
+ ports = [vnf_name + '-port']
+ vnf_instance, vnf_creator = \
+ openstack_sfc.create_instance(vnf_name, COMMON_CONFIG.flavor,
+ self.vnf_image_creator,
+ self.network,
+ self.sg,
+ av_zone,
+ ports)
+
+ if not openstack_sfc.wait_for_vnf(vnf_creator):
+ raise Exception('ERROR while booting vnf %s' % vnf_name)
+
+ self.creators.append(vnf_creator)
+ self.vnf_objects[vnf_name] = [vnf_creator, vnf_instance]
def assign_floating_ip_client_server(self):
"""Assign floating IPs on the router about server and the client
@@ -238,18 +282,28 @@ class SfcCommonTestCase(object):
self.server_floating_ip = openstack_sfc.assign_floating_ip(
self.router, self.server_instance, self.server_creator)
- def assign_floating_ip_sfs(self, vnf_ip=None):
+ def assign_floating_ip_sfs(self):
"""Assign floating IPs to service function
- :param vnf_ip: IP of vnf - optional
:return: The list fips_sfs consist of the available IPs for service
functions
"""
logger.info("Assigning floating IPs to service functions")
- self.fips_sfs = openstack_sfc.assign_floating_ip_vnfs(self.router,
- vnf_ip)
+ if COMMON_CONFIG.mano_component == 'tacker':
+ vnf_ip = os_sfc_utils.get_vnf_ip(self.tacker_client,
+ vnf_id=self.vnf_id)
+ self.fips_sfs = openstack_sfc.assign_floating_ip_vnfs(self.router,
+ vnf_ip)
+ elif COMMON_CONFIG.mano_component == 'no-mano':
+ for vnf in self.vnfs:
+ # creator object is in [0] and instance in [1]
+ vnf_instance = self.vnf_objects[vnf][1]
+ vnf_creator = self.vnf_objects[vnf][0]
+ sf_floating_ip = openstack_sfc.assign_floating_ip(
+ self.router, vnf_instance, vnf_creator)
+ self.fips_sfs.append(sf_floating_ip)
def check_floating_ips(self):
"""Check the responsivness of the floating IPs
@@ -338,37 +392,122 @@ class SfcCommonTestCase(object):
:param par_vnffgd_name: The vnffgd name of network components
:return: Remove the vnffg and vnffgd components
"""
+ if COMMON_CONFIG.mano_component == 'tacker':
+ os_sfc_utils.delete_vnffg(self.tacker_client,
+ vnffg_name=par_vnffg_name)
- os_sfc_utils.delete_vnffg(self.tacker_client,
- vnffg_name=par_vnffg_name)
+ os_sfc_utils.delete_vnffgd(self.tacker_client,
+ vnffgd_name=par_vnffgd_name)
- os_sfc_utils.delete_vnffgd(self.tacker_client,
- vnffgd_name=par_vnffgd_name)
+ elif COMMON_CONFIG.mano_component == 'no-mano':
+ # TODO: If we had a testcase where only one chains must be removed
+ # we would need to add the logic. Now it removes all of them
+ openstack_sfc.delete_chain()
- def create_vnffg(self, testcase_config_name, vnf_name, conn_name):
+ def create_vnffg(self, testcase_config_name, vnffgd_name, vnffg_name,
+ port=80, protocol='tcp', symmetric=False,
+ only_chain=False):
"""Create the vnffg components following the instructions from
relevant templates.
:param testcase_config_name: The config input of the test case
- :param vnf_name: The name of the vnf
- :param conn_name: Protocol type / name of the component
+ :param vnffgd_name: The name of the vnffgd template
+ :param vnffg_name: The name for the vnffg
:return: Create the vnffg component
"""
- tosca_file = os.path.join(COMMON_CONFIG.sfc_test_dir,
- COMMON_CONFIG.vnffgd_dir,
- testcase_config_name)
-
- os_sfc_utils.create_vnffgd(self.tacker_client,
- tosca_file=tosca_file,
- vnffgd_name=vnf_name)
-
- self.neutron_port = openstack_sfc.get_client_port(self.client_instance,
- self.client_creator)
- os_sfc_utils.create_vnffg_with_param_file(self.tacker_client, vnf_name,
- conn_name,
- self.default_param_file,
- self.neutron_port.id)
+ logger.info("Creating the vnffg...")
+
+ if COMMON_CONFIG.mano_component == 'tacker':
+ tosca_file = os.path.join(COMMON_CONFIG.sfc_test_dir,
+ COMMON_CONFIG.vnffgd_dir,
+ testcase_config_name)
+
+ os_sfc_utils.create_vnffgd(self.tacker_client,
+ tosca_file=tosca_file,
+ vnffgd_name=vnffgd_name)
+
+ self.neutron_port = \
+ openstack_sfc.get_instance_port(self.client_instance,
+ self.client_creator)
+
+ if symmetric:
+ server_port = openstack_sfc.get_instance_port(
+ self.server_instance,
+ self.server_creator)
+ server_ip_prefix = self.server_ip + '/32'
+
+ os_sfc_utils.create_vnffg_with_param_file(
+ self.tacker_client,
+ vnffgd_name,
+ vnffg_name,
+ self.default_param_file,
+ self.neutron_port.id,
+ server_port=server_port.id,
+ server_ip=server_ip_prefix)
+
+ else:
+ os_sfc_utils.create_vnffg_with_param_file(
+ self.tacker_client,
+ vnffgd_name,
+ vnffg_name,
+ self.default_param_file,
+ self.neutron_port.id)
+
+ elif COMMON_CONFIG.mano_component == 'no-mano':
+ if not only_chain:
+ for vnf in self.vnfs:
+ # creator object is in [0] and instance in [1]
+ vnf_instance = self.vnf_objects[vnf][1]
+ vnf_creator = self.vnf_objects[vnf][0]
+ if symmetric:
+ # VNFs have two ports
+ p1 = vnf_instance.name + '-port1'
+ neutron_port1 = \
+ openstack_sfc.get_instance_port(vnf_instance,
+ vnf_creator,
+ port_name=p1)
+ p2 = vnf_instance.name + '-port2'
+ neutron_port2 = \
+ openstack_sfc.get_instance_port(vnf_instance,
+ vnf_creator,
+ port_name=p2)
+ neutron_ports = [neutron_port1, neutron_port2]
+
+ else:
+ neutron_port1 = \
+ openstack_sfc.get_instance_port(vnf_instance,
+ vnf_creator)
+ neutron_ports = [neutron_port1]
+
+ port_group = \
+ openstack_sfc.create_port_groups(neutron_ports,
+ vnf_instance)
+
+ self.port_groups.append(port_group)
+ self.neutron_port = \
+ openstack_sfc.get_instance_port(self.client_instance,
+ self.client_creator)
+
+ if symmetric:
+ # We must pass the server_port and server_ip in the symmetric
+ # case. Otherwise ODL does not work well
+ server_port = openstack_sfc.get_instance_port(
+ self.server_instance,
+ self.server_creator)
+ server_ip_prefix = self.server_ip + '/32'
+ openstack_sfc.create_chain(self.port_groups,
+ self.neutron_port.id,
+ port, protocol, vnffg_name,
+ symmetric,
+ server_port=server_port.id,
+ server_ip=server_ip_prefix)
+
+ else:
+ openstack_sfc.create_chain(self.port_groups,
+ self.neutron_port.id,
+ port, protocol, vnffg_name,
+ symmetric)
def present_results_http(self):
"""Check whether the connection between server and client using
@@ -438,19 +577,6 @@ class SfcCommonTestCase(object):
return results
- def create_chain(self, testcase_config):
- """Create a connection chain for the test scenario purposes
-
- :param testcase_config: The config input of the test case
- :return: Create the proper chain for the specific test scenario
- """
-
- self.neutron_port = openstack_sfc.get_client_port(self.client_instance,
- self.client_creator)
- odl_utils.create_chain(self.tacker_client, self.default_param_file,
- self.neutron_port, COMMON_CONFIG,
- testcase_config)
-
def check_deletion(self):
"""Check that the deletion of the chain has been completed sucessfully.