From 12663cf4bca0d075c293df25e0c64ef02761ea03 Mon Sep 17 00:00:00 2001 From: Roman Safronov Date: Mon, 27 Jul 2020 13:11:07 +0300 Subject: [PATCH] Add flag to forbid packet loss during remote ping test By default ping returns success in case target host responded only on a part of requests. For some tests this may be not suitable. This patch adds a flag which will allow to configure check_remote_connectivity function to fail in case packet loss differs from 0%. Change-Id: I28bd5c086c3b47b25725efa73577fcc1cf965141 --- neutron_tempest_plugin/scenario/base.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/neutron_tempest_plugin/scenario/base.py b/neutron_tempest_plugin/scenario/base.py index 9223893f..78b766bc 100644 --- a/neutron_tempest_plugin/scenario/base.py +++ b/neutron_tempest_plugin/scenario/base.py @@ -302,7 +302,8 @@ class BaseTempestTestCase(base_api.BaseNetworkTest): def _check_remote_connectivity(self, source, dest, count, should_succeed=True, nic=None, mtu=None, fragmentation=True, - timeout=None, pattern=None): + timeout=None, pattern=None, + forbid_packet_loss=False): """check ping server via source ssh connection :param source: RemoteClient: an ssh connection from which to ping @@ -314,6 +315,7 @@ class BaseTempestTestCase(base_api.BaseNetworkTest): :param fragmentation: Flag for packet fragmentation :param timeout: Timeout for all ping packet(s) to succeed :param pattern: hex digits included in ICMP messages + :param forbid_packet_loss: forbid or allow some lost packets :returns: boolean -- should_succeed == ping :returns: ping is false if ping failed """ @@ -352,6 +354,10 @@ class BaseTempestTestCase(base_api.BaseNetworkTest): return not should_succeed LOG.debug('ping result: %s', result) + if forbid_packet_loss and ' 0% packet loss' not in result: + LOG.debug('Packet loss detected') + return not should_succeed + if validators.validate_ip_address(dest) is None: # Assert that the return traffic was from the correct # source address. @@ -366,12 +372,13 @@ class BaseTempestTestCase(base_api.BaseNetworkTest): nic=None, mtu=None, fragmentation=True, servers=None, timeout=None, ping_count=CONF.validation.ping_count, - pattern=None): + pattern=None, forbid_packet_loss=False): try: self.assertTrue(self._check_remote_connectivity( source, dest, ping_count, should_succeed, nic, mtu, fragmentation, - timeout=timeout, pattern=pattern)) + timeout=timeout, pattern=pattern, + forbid_packet_loss=forbid_packet_loss)) except lib_exc.SSHTimeout as ssh_e: LOG.debug(ssh_e) self._log_console_output(servers)