diff --git a/releasenotes/notes/run-iperf3-in-backgroung-693e3125b31f1897.yaml b/releasenotes/notes/run-iperf3-in-backgroung-693e3125b31f1897.yaml new file mode 100644 index 000000000..5f888f331 --- /dev/null +++ b/releasenotes/notes/run-iperf3-in-backgroung-693e3125b31f1897.yaml @@ -0,0 +1,12 @@ +--- +features: + - | + Added support for running ``iperf3`` client and server in background. Iperf3 + client can be run in guest VM is ``ssh_client`` object is provided or + locally on the machine where Tobiko is run. + Added two new config options for the RHOSO topologies: + + * ``max_traffic_break_allowed`` - to specify longest allowed single break + in the traffic tested with iperf3, + * ``max_total_breaks_allowed`` - to specify total allowed breaks time + in the traffic tested with iperf3. diff --git a/tobiko/openstack/topology/_topology.py b/tobiko/openstack/topology/_topology.py index 16daec0a7..71aaa6ee6 100644 --- a/tobiko/openstack/topology/_topology.py +++ b/tobiko/openstack/topology/_topology.py @@ -654,6 +654,16 @@ class OpenStackTopology(tobiko.SharedFixture): tobiko.skip_test("Background ping not supported by " "this topology class.") + def check_or_start_background_iperf_connection( + self, + server_ip: typing.Union[str, netaddr.IPAddress], # noqa; pylint: disable=W0613 + port: int, # noqa; pylint: disable=W0613 + protocol: str, # noqa; pylint: disable=W0613 + ssh_client: ssh.SSHClientType = None, # noqa; pylint: disable=W0613 + iperf3_server_ssh_client: ssh.SSHClientType = None): # noqa; pylint: disable=W0613 + tobiko.skip_test("Background iperf not supported by " + "this topology class.") + def get_openstack_topology(topology_class: typing.Type = None) -> \ OpenStackTopology: diff --git a/tobiko/podified/_topology.py b/tobiko/podified/_topology.py index 8184ebe1b..f9862f989 100644 --- a/tobiko/podified/_topology.py +++ b/tobiko/podified/_topology.py @@ -15,6 +15,7 @@ from __future__ import absolute_import import typing +import netaddr from oslo_log import log import tobiko @@ -24,6 +25,7 @@ from tobiko.podified import _edpm from tobiko.podified import _openshift from tobiko.podified import containers from tobiko import rhosp +from tobiko.shell import iperf3 from tobiko.shell import sh from tobiko.shell import ssh @@ -179,6 +181,29 @@ class PodifiedTopology(rhosp.RhospTopology): server_ip=server_ip ) + def check_or_start_background_iperf_connection( + self, + server_ip: typing.Union[str, netaddr.IPAddress], + port: int, + protocol: str, + ssh_client: ssh.SSHClientType = None, + iperf3_server_ssh_client: ssh.SSHClientType = None): + + if not ssh_client: + LOG.debug("Running iperf3 client in the POD is " + "implemented yet.") + else: + sh.check_or_start_external_process( + start_function=iperf3.execute_iperf3_client_in_background, + check_function=iperf3.check_iperf3_client_results, + liveness_function=iperf3.iperf3_client_alive, + stop_function=iperf3.stop_iperf3_client, + address=server_ip, + port=port, + protocol=protocol, + ssh_client=ssh_client, + iperf3_server_ssh_client=iperf3_server_ssh_client) + class EdpmNode(rhosp.RhospNode): diff --git a/tobiko/tripleo/_topology.py b/tobiko/tripleo/_topology.py index 7b6e6603d..b5968f256 100644 --- a/tobiko/tripleo/_topology.py +++ b/tobiko/tripleo/_topology.py @@ -198,6 +198,30 @@ class TripleoTopology(rhosp.RhospTopology): else: tripleo_nova.check_or_start_background_vm_ping(server_ip) + def check_or_start_background_iperf_connection( + self, + server_ip: typing.Union[str, netaddr.IPAddress], + port: int, + protocol: str, + ssh_client: ssh.SSHClientType = None, + iperf3_server_ssh_client: ssh.SSHClientType = None): + + if (not ssh_client and + CONF.tobiko.tripleo.run_background_services_in_pod): + # this fails if `oc` (openshift client) is not available + # so, if `run_background_services_in_pod` is true, make sure `oc` + # is available + # _openshift.check_or_start_tobiko_iperf_command(server_ip) + LOG.debug("Running iperf3 client in the POD is not " + "implemented yet") + else: + tripleo_nova.check_or_start_background_iperf_connection( + server_ip=server_ip, + port=port, + protocol=protocol, + ssh_client=ssh_client, + iperf3_server_ssh_client=iperf3_server_ssh_client) + class TripleoTopologyNode(rhosp.RhospNode): diff --git a/tobiko/tripleo/nova.py b/tobiko/tripleo/nova.py index 1acc7075f..e25d278c3 100644 --- a/tobiko/tripleo/nova.py +++ b/tobiko/tripleo/nova.py @@ -5,13 +5,16 @@ import typing # noqa from functools import wraps +import netaddr from oslo_log import log import pandas import tobiko from tobiko.tripleo import overcloud +from tobiko.shell import iperf3 from tobiko.shell import ping from tobiko.shell import sh +from tobiko.shell import ssh from tobiko.openstack import nova from tobiko.openstack import topology from tobiko.tripleo import containers @@ -281,3 +284,30 @@ def skip_background_vm_ping_checks_when_nondvr(server_ip): func(*args, **kwargs) return wrapper return decor + + +# Test is inteded for D/S env +@overcloud.skip_if_missing_overcloud +def check_or_start_background_iperf_connection( + server_ip: typing.Union[str, netaddr.IPAddress], + port: int, + protocol: str, + ssh_client: ssh.SSHClientType = None, + iperf3_server_ssh_client: ssh.SSHClientType = None): + """Check if process exists, if so stop and check ping health + if not : start a new separate iperf client process. + Iperf server runs on the vm which is behind IP address given + as the 'server_ip'. + If `iperf3_server_ssh_client` is given, Tobiko will make sure + that iperf3 server is running on the server behind this ssh_client + """ + sh.check_or_start_external_process( + start_function=iperf3.execute_iperf3_client_in_background, + check_function=iperf3.check_iperf3_client_results, + liveness_function=iperf3.iperf3_client_alive, + stop_function=iperf3.stop_iperf3_client, + address=server_ip, + port=port, + protocol=protocol, + ssh_client=ssh_client, + iperf3_server_ssh_client=iperf3_server_ssh_client)