summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sfc/lib/utils.py35
-rw-r--r--sfc/tests/functest/config.yaml6
-rw-r--r--sfc/tests/functest/setup_scripts/delete.sh3
-rw-r--r--sfc/tests/functest/sfc_two_chains_SSH_and_HTTP.py33
4 files changed, 36 insertions, 41 deletions
diff --git a/sfc/lib/utils.py b/sfc/lib/utils.py
index 14a2cc2c..2f98f6ff 100644
--- a/sfc/lib/utils.py
+++ b/sfc/lib/utils.py
@@ -27,25 +27,19 @@ FUNCTEST_RESULTS_DIR = os.path.join("home", "opnfv",
"functest", "results", "odl-sfc")
-def run_cmd(cmd, wdir=None, ignore_stderr=False, ignore_no_output=True):
+def run_cmd(cmd):
"""run given command locally and return commands output if success"""
pipe = subprocess.Popen(cmd, shell=True,
- stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
- stderr=subprocess.PIPE, cwd=wdir)
+ stderr=subprocess.PIPE)
(output, errors) = pipe.communicate()
if output:
output = output.strip()
- if pipe.returncode < 0:
+ if pipe.returncode != 0 or len(errors) > 0:
+ logger.error('FAILED to execute {0}'.format(cmd))
logger.error(errors)
- return False
- if errors:
- logger.error(errors)
- return ignore_stderr
-
- if ignore_no_output and not output:
- return True
+ return None
return output
@@ -348,7 +342,7 @@ def check_ssh(ips, retries=100):
return False
-def ofctl_time_counter(ovs_logger, ssh_conn):
+def ofctl_time_counter(ovs_logger, ssh_conn, max_duration=None):
try:
# We get the flows from table 11
table = 11
@@ -358,6 +352,17 @@ def ofctl_time_counter(ovs_logger, ssh_conn):
rsps = []
lines = output.split(",")
for line in lines:
+ if max_duration is not None:
+ pattern2 = "duration"
+ is_there2 = re.findall(pattern2, line)
+ if is_there2:
+ value = line.split("=")[1].split(".")[0]
+ value_int = int(value)
+ if value_int < max_duration:
+ # The RSP is new, no need to store the RSP in first_RSP
+ return rsps
+ else:
+ continue
is_there = re.findall(pattern, line)
if is_there:
value = line.split(":")[1].split("-")[0]
@@ -370,7 +375,11 @@ def ofctl_time_counter(ovs_logger, ssh_conn):
@ft_utils.timethis
def wait_for_classification_rules(ovs_logger, compute_clients, timeout=200):
- rsps = ofctl_time_counter(ovs_logger, compute_clients[0])
+ # 10 sec. is the threshold to consider a flow from an old deployment
+ max_duration = 10
+ rsps = ofctl_time_counter(ovs_logger, compute_clients[0], max_duration)
+ # first_RSP saves a potential RSP from an old deployment. 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 ''
while not ((len(rsps) > 1) and
(first_RSP != rsps[0]) and
diff --git a/sfc/tests/functest/config.yaml b/sfc/tests/functest/config.yaml
index c198d957..512660a7 100644
--- a/sfc/tests/functest/config.yaml
+++ b/sfc/tests/functest/config.yaml
@@ -4,14 +4,14 @@ defaults:
ram_size_in_mb: 1500
disk_size_in_gb: 10
vcpu_count: 1
- image_name: sf_nsh_colorado
- image_file_name: sf_nsh_colorado.qcow2
+ image_name: sfc_cloud
+ image_file_name: sfc_cloud.qcow2
fuel_master_ip: 10.20.0.2
fuel_master_uname: root
fuel_master_passwd: r00tme
fuel_environment: # Change this to the id of the desired fuel env (1, 2, 3...)
image_format: qcow2
- url: "http://artifacts.opnfv.org/sfc/demo"
+ url: "http://artifacts.opnfv.org/sfc/random"
vnfd-dir: "vnfd-templates"
testcases:
diff --git a/sfc/tests/functest/setup_scripts/delete.sh b/sfc/tests/functest/setup_scripts/delete.sh
index 2c9de04b..908d81fc 100644
--- a/sfc/tests/functest/setup_scripts/delete.sh
+++ b/sfc/tests/functest/setup_scripts/delete.sh
@@ -1,4 +1,4 @@
-source ${repos_dir}/sfc/sfc/tests/functest/tackerc
+# Remember to source the env variables $creds before
tacker sfc-classifier-delete red_http
tacker sfc-classifier-delete blue_ssh
tacker sfc-classifier-delete red_ssh
@@ -14,3 +14,4 @@ openstack stack delete sfc_test1 --y
openstack stack delete sfc_test2 --y
nova delete client
nova delete server
+for line in $(neutron floatingip-list | cut -d" " -f2);do neutron floatingip-delete $line;done
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 2383bb3e..e112e07b 100644
--- a/sfc/tests/functest/sfc_two_chains_SSH_and_HTTP.py
+++ b/sfc/tests/functest/sfc_two_chains_SSH_and_HTTP.py
@@ -8,7 +8,6 @@
# http://www.apache.org/licenses/LICENSE-2.0
#
-import argparse
import os
import sys
import threading
@@ -17,19 +16,12 @@ import functest.utils.functest_logger as ft_logger
import functest.utils.openstack_tacker as os_tacker
import functest.utils.openstack_utils as os_utils
import opnfv.utils.ovs_logger as ovs_log
+
import sfc.lib.config as sfc_config
import sfc.lib.utils as test_utils
from sfc.lib.results import Results
-parser = argparse.ArgumentParser()
-
-parser.add_argument("-r", "--report",
- help="Create json result file",
- action="store_true")
-
-args = parser.parse_args()
-
""" logging configuration """
logger = ft_logger.Logger("ODL_SFC").getLogger()
@@ -111,24 +103,17 @@ def main():
srv_prv_ip = srv_instance.networks.get(TESTCASE_CONFIG.net_name)[0]
- tosca_file = os.path.join(COMMON_CONFIG.sfc_test_dir,
- COMMON_CONFIG.vnfd_dir,
- TESTCASE_CONFIG.test_vnfd_red)
- os_tacker.create_vnfd(
- tacker_client,
- tosca_file=tosca_file)
+ tosca_red = os.path.join(COMMON_CONFIG.sfc_test_dir,
+ COMMON_CONFIG.vnfd_dir,
+ TESTCASE_CONFIG.test_vnfd_red)
+ os_tacker.create_vnfd(tacker_client, tosca_file=tosca_red)
- tosca_file = os.path.join(COMMON_CONFIG.sfc_test_dir,
+ tosca_blue = os.path.join(COMMON_CONFIG.sfc_test_dir,
COMMON_CONFIG.vnfd_dir,
TESTCASE_CONFIG.test_vnfd_blue)
- os_tacker.create_vnfd(
- tacker_client,
- tosca_file=tosca_file)
-
- os_tacker.create_vnf(
- tacker_client, 'testVNF1', vnfd_name='test-vnfd1')
- os_tacker.create_vnf(
- tacker_client, 'testVNF2', vnfd_name='test-vnfd2')
+ os_tacker.create_vnfd(tacker_client, tosca_file=tosca_blue)
+ os_tacker.create_vnf(tacker_client, 'testVNF1', vnfd_name='test-vnfd1')
+ os_tacker.create_vnf(tacker_client, 'testVNF2', vnfd_name='test-vnfd2')
try:
os_tacker.wait_for_vnf(tacker_client, vnf_name='testVNF1')