From 8346170ebffc6407252513a39affa53fc1f45a81 Mon Sep 17 00:00:00 2001 From: Manuel Buil Date: Mon, 5 Feb 2018 13:08:23 +0100 Subject: 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 --- sfc/lib/odl_utils.py | 19 +++++++++++++++++-- 1 file 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): -- cgit 1.2.3-korg