From da6d1d2e018e358f71ad734766580a7343829c29 Mon Sep 17 00:00:00 2001 From: “Manuel Buil” Date: Tue, 14 Mar 2017 14:14:38 +0100 Subject: Bug fix: Classification check failing If both SFs are in one host, the classification rules are not implemented in all the hosts Change-Id: Ifea131a86f49d33fdc6110a13d5fdc6c2796f7fa Signed-off-by: Manuel Buil --- sfc/lib/utils.py | 19 +++++++++++++++++-- ..._chain_two_service_functions_different_computes.py | 5 ++++- sfc/tests/functest/sfc_two_chains_SSH_and_HTTP.py | 8 ++++++-- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/sfc/lib/utils.py b/sfc/lib/utils.py index 4b5e91f5..26789868 100644 --- a/sfc/lib/utils.py +++ b/sfc/lib/utils.py @@ -370,11 +370,11 @@ def wait_for_classification_rules(ovs_logger, compute_clients, # ODL may take quite some time to implement the new flow # and an old flow may be there first_RSP = rsps[0] if len(rsps) > 0 else '' - logger.info("This is the first_RSP: %s" % first_RSP) + logger.debug("This is the first_RSP: %s" % first_RSP) if num_chains == 1: while not ((len(rsps) == 1) and (first_RSP != rsps[0])): rsps = ofctl_time_counter(ovs_logger, compute_client) - logger.info("These are the rsps: %s" % rsps) + logger.debug("These are the rsps: %s" % rsps) timeout -= 1 if timeout == 0: logger.error( @@ -420,3 +420,18 @@ def get_nova_id(tacker_client, resource, vnf_id=None, vnf_name=None): logger.error("Cannot get nova ID for VNF (id='%s', name='%s')" % (vnf_id, vnf_name)) return None + + +def filter_sffs(compute_nodes, testTopology, vnfs): + if 'nova' in testTopology.values(): + computes_to_check = [node.id for node in compute_nodes] + else: + # Get the number of the compute (e.g.node-7.domain.tld ==> 7) + computes_to_check = [ + testTopology[vnf].split('.')[0].split('-')[1] for vnf in vnfs] + + computes_sff = [ + node.ssh_client for node in compute_nodes + if node.id in computes_to_check] + + return computes_sff diff --git a/sfc/tests/functest/sfc_one_chain_two_service_functions_different_computes.py b/sfc/tests/functest/sfc_one_chain_two_service_functions_different_computes.py index 77c3a4e5..69d86f3f 100644 --- a/sfc/tests/functest/sfc_one_chain_two_service_functions_different_computes.py +++ b/sfc/tests/functest/sfc_one_chain_two_service_functions_different_computes.py @@ -167,9 +167,12 @@ def main(): num_chains = 1 + # We want to check the classif. only in the SFFs (computes with a SF) + compute_sffs = test_utils.filter_sffs(compute_nodes, testTopology, vnfs) + # Start measuring the time it takes to implement the classification rules t1 = threading.Thread(target=test_utils.wait_for_classification_rules, - args=(ovs_logger, compute_clients, num_chains,)) + args=(ovs_logger, compute_sffs, num_chains,)) try: t1.start() except Exception, e: 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 d96b9d83..f7527d48 100644 --- a/sfc/tests/functest/sfc_two_chains_SSH_and_HTTP.py +++ b/sfc/tests/functest/sfc_two_chains_SSH_and_HTTP.py @@ -181,9 +181,13 @@ def main(): logger.info(test_utils.run_cmd('tacker sfc-classifier-list')[1]) num_chains = 2 + # We want to check the classif. only in the SFFs (computes with a SF) + compute_sffs = test_utils.filter_sffs(compute_nodes, testTopology, vnfs) + # Start measuring the time it takes to implement the classification rules t1 = threading.Thread(target=test_utils.wait_for_classification_rules, - args=(ovs_logger, compute_clients, num_chains,)) + args=(ovs_logger, compute_sffs, num_chains,)) + try: t1.start() except Exception, e: @@ -254,7 +258,7 @@ def main(): # Start measuring the time it takes to implement the classification rules t2 = threading.Thread(target=test_utils.wait_for_classification_rules, - args=(ovs_logger, compute_clients,)) + args=(ovs_logger, compute_sffs, num_chains,)) try: t2.start() except Exception, e: -- cgit 1.2.3-korg