aboutsummaryrefslogtreecommitdiffstats
path: root/functest/opnfv_tests/features
diff options
context:
space:
mode:
Diffstat (limited to 'functest/opnfv_tests/features')
-rw-r--r--functest/opnfv_tests/features/sfc/ovs_utils.py20
-rwxr-xr-xfunctest/opnfv_tests/features/sfc/sfc.py40
2 files changed, 60 insertions, 0 deletions
diff --git a/functest/opnfv_tests/features/sfc/ovs_utils.py b/functest/opnfv_tests/features/sfc/ovs_utils.py
index 20ab5a7e..af1f232c 100644
--- a/functest/opnfv_tests/features/sfc/ovs_utils.py
+++ b/functest/opnfv_tests/features/sfc/ovs_utils.py
@@ -11,6 +11,7 @@ import functest.utils.functest_logger as rl
import os
import time
import shutil
+import re
logger = rl.Logger('ovs_utils').getLogger()
@@ -115,3 +116,22 @@ class OVSLogger(object):
dumpdir = os.path.join(self.ovs_dir, timestamp)
with open(os.path.join(dumpdir, 'error'), 'w') as f:
f.write(related_error)
+
+ def ofctl_time_counter(self, ssh_conn):
+ try:
+ # We get the flows from table 11
+ table = 11
+ br = "br-int"
+ output = self.ofctl_dump_flows(ssh_conn, br, table)
+ pattern = "NXM_NX_NSP"
+ rsps = []
+ lines = output.split(",")
+ for line in lines:
+ is_there = re.findall(pattern, line)
+ if is_there:
+ value = line.split(":")[1].split("-")[0]
+ rsps.append(value)
+ return rsps
+ except Exception, e:
+ logger.error('Error when countering %s' % e)
+ return None
diff --git a/functest/opnfv_tests/features/sfc/sfc.py b/functest/opnfv_tests/features/sfc/sfc.py
index e5ae7dcb..5e3e37d7 100755
--- a/functest/opnfv_tests/features/sfc/sfc.py
+++ b/functest/opnfv_tests/features/sfc/sfc.py
@@ -10,6 +10,7 @@ import re
import json
import SSHUtils as ssh_utils
import ovs_utils
+import thread
parser = argparse.ArgumentParser()
@@ -400,6 +401,31 @@ def check_ssh(ips, retries=100):
return False
+# Measure the time it takes to update the classification rules
+
+
+def capture_time_log(compute_clients):
+ ovs_logger = ovs_utils.OVSLogger(
+ os.path.join(os.getcwd(), 'ovs-logs'),
+ "test")
+ i = 0
+ first_RSP = ""
+ start_time = time.time()
+ while True:
+ rsps = ovs_logger.ofctl_time_counter(compute_clients[0])
+ if not i:
+ first_RSP = rsps[0]
+ i = i + 1
+ if(first_RSP != rsps[0]):
+ if (rsps[0] == rsps[1]):
+ stop_time = time.time()
+ logger.info("classification rules updated")
+ difference = stop_time - start_time
+ logger.info("It took %s seconds" % difference)
+ break
+ time.sleep(1)
+ return
+
def main():
installer_type = os.environ.get("INSTALLER_TYPE")
@@ -453,6 +479,13 @@ def main():
nova_client, SERVER, FLAVOR, image_id, network_id, sg_id)
subprocess.call(TACKER_SCRIPT, shell=True)
+
+ # Start measuring the time it takes to implement the classification rules
+ try:
+ thread.start_new_thread(capture_time_log, (compute_clients,))
+ except Exception, e:
+ logger.error("Unable to start the thread that counts time %s" % e)
+
server_ip, client_ip, sf1, sf2 = get_floating_ips(
nova_client, neutron_client)
@@ -496,6 +529,13 @@ def main():
logger.info("Changing the classification")
subprocess.call(TACKER_CHANGECLASSI, shell=True)
+
+ # Start measuring the time it takes to implement the classification rules
+ try:
+ thread.start_new_thread(capture_time_log, (compute_clients,))
+ except Exception, e:
+ logger.error("Unable to start the thread that counts time %s" % e)
+
logger.info("Wait for ODL to update the classification rules in OVS")
time.sleep(100)