iperf3: add config to adjust the duration of the iperf run

the time is passed as a string param and is then converted
into seconds when literals "h" or "m" are found.
So it would accept 2m and would convert it to 120s, for example.

Example:

+cfg-iperf3-time@15+

Change-Id: Iff28816f83670751e9e91de31ec59b1b0ad8fc0d
This commit is contained in:
Andre Puschmann 2020-03-28 15:34:00 +01:00 committed by Pau Espin Pedrol
parent c04528cb1f
commit 2dcc4312a0
7 changed files with 34 additions and 5 deletions

View File

@ -123,3 +123,6 @@ srsue:
airplane_t_on_ms: -1
airplane_t_off_ms: -1
num_carriers: 1
iperf3cli:
time: 60

View File

@ -0,0 +1,3 @@
config:
iperf3cli:
time: ${param1}

View File

@ -20,7 +20,7 @@
import os
import json
from . import log, util, process, pcap_recorder, run_node, remote
from . import log, util, config, process, pcap_recorder, run_node, remote
def iperf3_result_to_json(file):
with open(file) as f:
@ -154,8 +154,23 @@ class IPerf3Client(log.Origin):
locally = not self._run_node or self._run_node.is_local()
return locally
def prepare_test_proc(self, downlink=False, netns=None, time_sec=10):
self.log('Starting iperf3-client connecting to %s:%d' % (self.server.addr(), self.server.port()))
def prepare_test_proc(self, downlink=False, netns=None, time_sec=None):
if time_sec is None:
values = config.get_defaults('iperf3cli')
config.overlay(values, self.suite_run.config().get('iperf3cli', {}))
time_sec_str = values.get('time', time_sec)
# Convert duration to seconds
if isinstance(time_sec_str, str) and time_sec_str.endswith('h'):
time_sec = int(time_sec_str[:-1]) * 3600
elif isinstance(time_sec_str, str) and time_sec_str.endswith('m'):
time_sec = int(time_sec_str[:-1]) * 60
else:
time_sec = int(time_sec_str)
assert(time_sec)
self.log('Preparing iperf3-client connecting to %s:%d (time=%ds)' % (self.server.addr(), self.server.port(), time_sec))
self.log_copied = False
self.run_dir = util.Dir(self.suite_run.get_test_run_dir().new_dir(self.name()))
self.log_file = self.run_dir.new_file(IPerf3Client.LOGFILE)

View File

@ -127,6 +127,7 @@ CONF_SCHEMA = util.dict_add(
'config.epc.enable_pcap': schema.BOOL_STR,
'config.modem.enable_pcap': schema.BOOL_STR,
'config.amarisoft.license_server_addr': schema.IPV4,
'config.iperf3cli.time': schema.DURATION,
},
dict([('resources.%s' % key, val) for key, val in WANT_SCHEMA.items()]),
dict([('modifiers.%s' % key, val) for key, val in WANT_SCHEMA.items()]))

View File

@ -136,6 +136,11 @@ def lte_rlc_drb_mode(val):
return
raise ValueError('Unknown LTE RLC DRB Mode value: %r' % val)
def duration(val):
if val.isdecimal() or val.endswith('m') or val.endswith('h'):
return
raise ValueError('Invalid duration value: %r' % val)
INT = 'int'
STR = 'str'
UINT = 'uint'
@ -157,6 +162,7 @@ CODEC = 'codec'
OSMO_TRX_CLOCK_REF = 'osmo_trx_clock_ref'
LTE_TRANSMISSION_MODE = 'lte_transmission_mode'
LTE_RLC_DRB_MODE = 'lte_rlc_drb_mode'
DURATION = 'duration'
SCHEMA_TYPES = {
INT: int,
@ -180,6 +186,7 @@ SCHEMA_TYPES = {
OSMO_TRX_CLOCK_REF: osmo_trx_clock_ref,
LTE_TRANSMISSION_MODE: lte_transmission_mode,
LTE_RLC_DRB_MODE: lte_rlc_drb_mode,
DURATION: duration,
}
def validate(config, schema):

View File

@ -32,7 +32,7 @@ print('ENB is connected to EPC')
ue.connect(enb)
iperf3srv.start()
proc = iperf3cli.prepare_test_proc(True, ue.netns(), time_sec=60)
proc = iperf3cli.prepare_test_proc(True, ue.netns())
print('waiting for UE to attach...')
wait(ue.is_connected, None)

View File

@ -32,7 +32,7 @@ print('ENB is connected to EPC')
ue.connect(enb)
iperf3srv.start()
proc = iperf3cli.prepare_test_proc(False, ue.netns(), time_sec=60)
proc = iperf3cli.prepare_test_proc(False, ue.netns())
print('waiting for UE to attach...')
wait(ue.is_connected, None)