Run background iperf3 tests with --json-stream option always
Either iperf3 is run from a pod (we recommend to use a certain centos10 pod) or from the supported Fedora 41 Advanced VM instances, iperf3 supports the --json-stream option on those environments (iperf version greater or equal to 3.17). This option can be used with --logfile (the output is written for every iperf3 interval on a file) or without it (the output is written to stdout). This option should not be used when iperf3 is run from the test machine/container: undercloud, devstack, tobiko pod (in case of podified envs). Change-Id: I0491dbff33619ca3096a9eeac70ae4a46c68b62d
This commit is contained in:
parent
8e2c18bf3f
commit
0d08449b2a
@ -502,7 +502,7 @@ def start_iperf3(
|
||||
parameters = iperf3.iperf3_client_parameters(
|
||||
address=address, bitrate=bitrate,
|
||||
download=download, port=port, protocol=protocol,
|
||||
timeout=0, logfile=iperf3.JSON_STREAM)
|
||||
timeout=0, json_stream=True)
|
||||
|
||||
cmd_args = iperf3.get_iperf3_client_command(
|
||||
parameters).as_list()[1:]
|
||||
|
@ -20,7 +20,6 @@ from tobiko.shell.iperf3 import _execute
|
||||
from tobiko.shell.iperf3 import _interface
|
||||
from tobiko.shell.iperf3 import _parameters
|
||||
|
||||
JSON_STREAM = _interface.JSON_STREAM
|
||||
|
||||
assert_has_bandwith_limits = _assert.assert_has_bandwith_limits
|
||||
execute_iperf3_client_in_background = \
|
||||
|
@ -89,10 +89,19 @@ def execute_iperf3_client(address: typing.Union[str, netaddr.IPAddress],
|
||||
params_timeout = 0
|
||||
elif timeout is not None:
|
||||
params_timeout = int(timeout - 0.5)
|
||||
|
||||
# json_stream option should be set when:
|
||||
# - tests are run_in_background
|
||||
# - tests are executed from a VM instance
|
||||
# This way we avoid using that option from the test machine (undercloud,
|
||||
# test pod, devstack, ...) where it is not supported
|
||||
# iperf3 support this option from version 3.17
|
||||
json_stream = run_in_background and (ssh_client is not None)
|
||||
|
||||
parameters = _parameters.iperf3_client_parameters(
|
||||
address=address, bitrate=bitrate,
|
||||
download=download, port=port, protocol=protocol,
|
||||
timeout=params_timeout, logfile=logfile)
|
||||
timeout=params_timeout, json_stream=json_stream, logfile=logfile)
|
||||
command = _interface.get_iperf3_client_command(parameters)
|
||||
|
||||
# output is a dictionary
|
||||
|
@ -23,8 +23,6 @@ from tobiko.shell import sh
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
|
||||
JSON_STREAM = "json-stream"
|
||||
|
||||
|
||||
def get_iperf3_client_command(parameters: _parameters.Iperf3ClientParameters):
|
||||
interface = Iperf3Interface()
|
||||
@ -68,6 +66,8 @@ class Iperf3Interface:
|
||||
options += self.get_download_option(parameters.download)
|
||||
if parameters.protocol is not None:
|
||||
options += self.get_protocol_option(parameters.protocol)
|
||||
if parameters.json_stream is not None:
|
||||
options += self.get_json_stream_option(parameters.json_stream)
|
||||
if parameters.logfile is not None:
|
||||
options += self.get_logfile_option(parameters.logfile)
|
||||
return options
|
||||
@ -124,7 +124,15 @@ class Iperf3Interface:
|
||||
return ['-p', port]
|
||||
|
||||
@staticmethod
|
||||
def get_logfile_option(logfile):
|
||||
if logfile == JSON_STREAM:
|
||||
def get_json_stream_option(json_stream: bool):
|
||||
# NOTE: when iperf3 is run with --json-stream, new json
|
||||
# entries are written for every interval
|
||||
# This option is supported from iperf3 version 3.17:
|
||||
if json_stream:
|
||||
return ['--json-stream']
|
||||
else:
|
||||
return []
|
||||
|
||||
@staticmethod
|
||||
def get_logfile_option(logfile):
|
||||
return ['--logfile', logfile]
|
||||
|
@ -29,6 +29,7 @@ class Iperf3ClientParameters(typing.NamedTuple):
|
||||
port: typing.Optional[int] = None
|
||||
protocol: typing.Optional[str] = None
|
||||
timeout: typing.Optional[int] = None
|
||||
json_stream: typing.Optional[bool] = None
|
||||
logfile: typing.Optional[str] = None
|
||||
|
||||
|
||||
@ -44,6 +45,7 @@ def iperf3_client_parameters(
|
||||
port: int = None,
|
||||
protocol: str = None,
|
||||
timeout: int = None,
|
||||
json_stream: bool = None,
|
||||
logfile: str = None):
|
||||
"""Get iperf3 client parameters
|
||||
mode allowed values: client or server
|
||||
@ -68,6 +70,7 @@ def iperf3_client_parameters(
|
||||
port=port,
|
||||
protocol=protocol,
|
||||
timeout=timeout,
|
||||
json_stream=json_stream,
|
||||
logfile=logfile)
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user