aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sfc/lib/topology_shuffler.py99
-rw-r--r--sfc/lib/utils.py2
-rw-r--r--sfc/tests/functest/sfc_two_chains_SSH_and_HTTP.py27
3 files changed, 70 insertions, 58 deletions
diff --git a/sfc/lib/topology_shuffler.py b/sfc/lib/topology_shuffler.py
index bfa86420..4524b879 100644
--- a/sfc/lib/topology_shuffler.py
+++ b/sfc/lib/topology_shuffler.py
@@ -53,7 +53,7 @@ DEFAULT_TOPO = {
}
-def _get_seed():
+def get_seed():
'''
Get a seed based on the day of the week to choose which topology to test
@@ -67,36 +67,16 @@ def _get_seed():
return seed
-def _split_host_aggregates():
+def _get_av_zones():
'''
- Gets all the compute hosts and creates an aggregate for each.
- Aggregates are named based on the convention compute1, compute2, ...
+ Return the availability zone each host belongs to
'''
nova_client = os_utils.get_nova_client()
hosts = os_utils.get_hypervisors(nova_client)
- aggregates = []
- for idx, host in enumerate(hosts):
- az_name = 'compute{0}'.format(idx)
- # aggregate name is the same as availability zone name
- os_utils.create_aggregate_with_host(
- nova_client, az_name, az_name, host)
- aggregates.append(az_name)
- # aggregates and av zones abstractions are tightly coupled in nova
- return aggregates
+ return ['nova::{0}'.format(host) for host in hosts]
-def clean_host_aggregates(aggregates):
- '''
- Clean all the created host aggregates
- '''
- nova_client = os_utils.get_nova_client()
- for aggregate in aggregates:
- if not os_utils.delete_aggregate(nova_client, aggregate):
- logger.error('Could not delete aggregate {0}'
- .format(aggregate))
-
-
-def topology(vnf_names, host_aggregates=None, seed=None):
+def topology(vnf_names, av_zones=None, seed=None):
'''
Get the topology for client, server and vnfs.
The topology is returned as a dict in the form
@@ -107,45 +87,58 @@ def topology(vnf_names, host_aggregates=None, seed=None):
'vnf2': <availability_zone>
...
}
- Use seed=-1 to get the default topology created by nova-scheduler
+ Use seed=None to get the default topology created by nova-scheduler
'''
- if host_aggregates is None:
- host_aggregates = _split_host_aggregates()
- if len(host_aggregates) < 2 or seed is None:
- return None
+ if av_zones is None:
+ av_zones = _get_av_zones()
+
+ if len(av_zones) < 2 or seed is None:
+ # fall back to nova availability zone
+ topology_assignment = {
+ 'id': DEFAULT_TOPO['id'],
+ 'description': DEFAULT_TOPO['description'],
+ 'client': 'nova',
+ 'server': 'nova'
+ }
+ for vnf in vnf_names:
+ topology_assignment[vnf] = 'nova'
+ return topology_assignment
- topology = TOPOLOGIES[seed]
- topology_assigment = {}
- if topology['id'] == 'CLIENT_VNF_SAME_HOST':
- topology_assigment['client'] = host_aggregates[0]
- topology_assigment['server'] = host_aggregates[1]
+ topo = TOPOLOGIES[seed]
+ topology_assigment = {
+ 'id': topo['id'],
+ 'description': topo['description']
+ }
+ if topo['id'] == 'CLIENT_VNF_SAME_HOST':
+ topology_assigment['client'] = av_zones[0]
+ topology_assigment['server'] = av_zones[1]
for vnf in vnf_names:
- topology_assigment[vnf] = host_aggregates[0]
- elif topology['id'] == 'CLIENT_SERVER_SAME_HOST':
- topology_assigment['client'] = host_aggregates[0]
- topology_assigment['server'] = host_aggregates[0]
+ topology_assigment[vnf] = av_zones[0]
+ elif topo['id'] == 'CLIENT_SERVER_SAME_HOST':
+ topology_assigment['client'] = av_zones[0]
+ topology_assigment['server'] = av_zones[0]
for vnf in vnf_names:
- topology_assigment[vnf] = host_aggregates[1]
- elif topology['id'] == 'SERVER_VNF_SAME_HOST':
- topology_assigment['client'] = host_aggregates[1]
- topology_assigment['server'] = host_aggregates[0]
+ topology_assigment[vnf] = av_zones[1]
+ elif topo['id'] == 'SERVER_VNF_SAME_HOST':
+ topology_assigment['client'] = av_zones[1]
+ topology_assigment['server'] = av_zones[0]
for vnf in vnf_names:
- topology_assigment[vnf] = host_aggregates[0]
- elif topology['id'] == 'CLIENT_SERVER_SAME_HOST_SPLIT_VNF':
- topology_assigment['client'] = host_aggregates[0]
- topology_assigment['server'] = host_aggregates[0]
+ topology_assigment[vnf] = av_zones[0]
+ elif topo['id'] == 'CLIENT_SERVER_SAME_HOST_SPLIT_VNF':
+ topology_assigment['client'] = av_zones[0]
+ topology_assigment['server'] = av_zones[0]
idx = 0
for vnf in vnf_names:
- topology_assigment[vnf] = host_aggregates[idx % 2]
+ topology_assigment[vnf] = av_zones[idx % 2]
idx += 1
- elif topology['id'] == 'CLIENT_SERVER_DIFFERENT_HOST_SPLIT_VNF':
- topology_assigment['client'] = host_aggregates[0]
- topology_assigment['server'] = host_aggregates[1]
+ elif topo['id'] == 'CLIENT_SERVER_DIFFERENT_HOST_SPLIT_VNF':
+ topology_assigment['client'] = av_zones[0]
+ topology_assigment['server'] = av_zones[1]
idx = 0
for vnf in vnf_names:
- topology_assigment[vnf] = host_aggregates[idx % 2]
+ topology_assigment[vnf] = av_zones[idx % 2]
idx += 1
logger.info("Creating enpoint and VNF topology on the compute hosts")
- logger.info(topology['description'])
+ logger.info(topo['description'])
return topology_assigment
diff --git a/sfc/lib/utils.py b/sfc/lib/utils.py
index 60f6776a..b1576803 100644
--- a/sfc/lib/utils.py
+++ b/sfc/lib/utils.py
@@ -82,7 +82,7 @@ def create_vnf_in_av_zone(tacker_client, vnf_name, vnfd_name, av_zone=None):
param_file = os.path.join(os.getcwd(),
'vnfd-templates',
'test-vnfd-default-params.yaml')
- if av_zone is not None:
+ if av_zone is not None or av_zone != 'nova':
param_file = os.path.join(
'/tmp',
'param_{0}.yaml'.format(av_zone.replace('::', '_')))
diff --git a/sfc/tests/functest/sfc_two_chains_SSH_and_HTTP.py b/sfc/tests/functest/sfc_two_chains_SSH_and_HTTP.py
index e02fa475..123b1cad 100644
--- a/sfc/tests/functest/sfc_two_chains_SSH_and_HTTP.py
+++ b/sfc/tests/functest/sfc_two_chains_SSH_and_HTTP.py
@@ -21,6 +21,7 @@ import sfc.lib.config as sfc_config
import sfc.lib.utils as test_utils
from sfc.lib.results import Results
from opnfv.deployment.factory import Factory as DeploymentFactory
+import sfc.lib.topology_shuffler as topo_shuffler
""" logging configuration """
@@ -110,12 +111,23 @@ def main():
TESTCASE_CONFIG.secgroup_name,
TESTCASE_CONFIG.secgroup_descr)
+ vnfs = ['testVNF1', 'testVNF2']
+
+ topo_seed = topo_shuffler.get_seed() # change to None for nova av zone
+ testTopology = topo_shuffler.topology(vnfs, seed=topo_seed)
+
+ logger.info('This test is run with the topology {0}'
+ .format(testTopology['id']))
+ logger.info('Topology description: {0}'
+ .format(testTopology['description']))
+
test_utils.create_instance(
nova_client, CLIENT, COMMON_CONFIG.flavor, image_id,
- network_id, sg_id)
+ network_id, sg_id, av_zone=testTopology['client'])
+
srv_instance = test_utils.create_instance(
nova_client, SERVER, COMMON_CONFIG.flavor, image_id,
- network_id, sg_id)
+ network_id, sg_id, av_zone=testTopology['server'])
srv_prv_ip = srv_instance.networks.get(TESTCASE_CONFIG.net_name)[0]
@@ -128,8 +140,10 @@ def main():
COMMON_CONFIG.vnfd_dir,
TESTCASE_CONFIG.test_vnfd_blue)
os_tacker.create_vnfd(tacker_client, tosca_file=tosca_blue)
- test_utils.create_vnf_in_av_zone(tacker_client, 'testVNF1', 'test-vnfd1')
- test_utils.create_vnf_in_av_zone(tacker_client, 'testVNF2', 'test-vnfd2')
+ test_utils.create_vnf_in_av_zone(
+ tacker_client, vnfs[0], 'test-vnfd1', testTopology[vnfs[0]])
+ test_utils.create_vnf_in_av_zone(
+ tacker_client, vnfs[1], 'test-vnfd2', testTopology[vnfs[1]])
vnf1_id = os_tacker.wait_for_vnf(tacker_client, vnf_name='testVNF1')
vnf2_id = os_tacker.wait_for_vnf(tacker_client, vnf_name='testVNF2')
@@ -261,6 +275,11 @@ def main():
ovs_logger, controller_clients, compute_clients, error)
results.add_to_summary(2, "FAIL", "SSH works")
+ logger.info('This test is run with the topology {0}'
+ .format(testTopology['id']))
+ logger.info('Topology description: {0}'
+ .format(testTopology['description']))
+
return results.compile_summary()