From fc792bba0bfaaaeca8a9a1b6ca47c9cd9303d41f Mon Sep 17 00:00:00 2001 From: fmenguy Date: Thu, 11 Mar 2021 20:33:36 +0100 Subject: NFVBENCH-205 - Add behave tests for characterization and non-regression Change-Id: I708eee21a9fd11e7a276707fb0b43d8598381ce7 Signed-off-by: fmenguy --- nfvbench/nfvbench.py | 3 +-- nfvbench/utils.py | 18 +++++++++--------- 2 files changed, 10 insertions(+), 11 deletions(-) (limited to 'nfvbench') diff --git a/nfvbench/nfvbench.py b/nfvbench/nfvbench.py index 7acb783..bd86810 100644 --- a/nfvbench/nfvbench.py +++ b/nfvbench/nfvbench.py @@ -246,8 +246,7 @@ class NFVBench(object): config.cache_size = config.flow_count # The size must be capped to 10000 (where does this limit come from?) - if config.cache_size > 10000: - config.cache_size = 10000 + config.cache_size = min(config.cache_size, 10000) config.duration_sec = float(config.duration_sec) config.interval_sec = float(config.interval_sec) diff --git a/nfvbench/utils.py b/nfvbench/utils.py index 80a0817..512422d 100644 --- a/nfvbench/utils.py +++ b/nfvbench/utils.py @@ -127,11 +127,11 @@ def get_intel_pci(nic_slot=None, nic_ports=None): trex_base_dir = '/opt/trex' contents = os.listdir(trex_base_dir) trex_dir = os.path.join(trex_base_dir, contents[0]) - process = subprocess.Popen(['python', 'dpdk_setup_ports.py', '-s'], - cwd=trex_dir, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - devices, _ = process.communicate() + with subprocess.Popen(['python', 'dpdk_setup_ports.py', '-s'], + cwd=trex_dir, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) as process: + devices, _ = process.communicate() except Exception: devices = '' @@ -147,10 +147,10 @@ def get_intel_pci(nic_slot=None, nic_ports=None): intf_name = glob.glob("/sys/bus/pci/devices/%s/net/*" % port[0]) if intf_name: intf_name = intf_name[0][intf_name[0].rfind('/') + 1:] - process = subprocess.Popen(['ip', '-o', '-d', 'link', 'show', intf_name], - stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - intf_info, _ = process.communicate() + with subprocess.Popen(['ip', '-o', '-d', 'link', 'show', intf_name], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) as process: + intf_info, _ = process.communicate() if re.search('team_slave|bond_slave', intf_info.decode("utf-8")): device_ports_list[port[0].split('.')[0]]['busy'] = True for port in matches: -- cgit 1.2.3-korg