diff options
author | Manuel Buil <mbuil@suse.com> | 2018-02-05 13:08:23 +0100 |
---|---|---|
committer | Brady Johnson <bjohnson@inocybe.com> | 2018-02-06 14:32:07 +0000 |
commit | 8346170ebffc6407252513a39affa53fc1f45a81 (patch) | |
tree | ca5146342e63ef65016c6a08f147d922bfef7572 | |
parent | 242e25c987847aa01d4470e96500e085aacc5738 (diff) |
Define the timethis function in the sfc repo
Functest removed the function from their repo, so we need to define it in ours:
Change-Id: Ica122e57612c38751d8ff810f3ba61b749e867eb
Signed-off-by: Manuel Buil <mbuil@suse.com>
-rw-r--r-- | sfc/lib/odl_utils.py | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/sfc/lib/odl_utils.py b/sfc/lib/odl_utils.py index c8b0ebdd..edd52054 100644 --- a/sfc/lib/odl_utils.py +++ b/sfc/lib/odl_utils.py @@ -5,7 +5,7 @@ import time import json import re import logging -import functest.utils.functest_utils as ft_utils +import functools import sfc.lib.openstack_utils as os_sfc_utils @@ -100,7 +100,21 @@ def promised_rsps_in_computes(odl_ip, odl_port): return rsps_in_computes -@ft_utils.timethis +def timethis(func): + """Measure the time it takes for a function to complete""" + @functools.wraps(func) + def timed(*args, **kwargs): + ts = time.time() + result = func(*args, **kwargs) + te = time.time() + elapsed = '{0}'.format(te - ts) + logger.info('{f}(*{a}, **{kw}) took: {t} sec'.format( + f=func.__name__, a=args, kw=kwargs, t=elapsed)) + return result, elapsed + return timed + + +@timethis def wait_for_classification_rules(ovs_logger, compute_nodes, odl_ip, odl_port, compute_client_name, timeout=200): ''' @@ -334,6 +348,7 @@ def check_vnffg_deletion(odl_ip, odl_port, ovs_logger, compute_client_name, return True + def create_chain(tacker_client, default_param_file, neutron_port, COMMON_CONFIG, TESTCASE_CONFIG): |