Comment 1 for bug 1818233

Revision history for this message
Antonio Ojea (aojea) wrote :

The ping command on that helper uses the options -c1 (count=1) and -w1 (deadline=1),

```
      If ping does not receive any reply packets at all it will exit with code 1. If a packet count and deadline are both specified, and fewer than count
       packets are received by the time the deadline has arrived, it will also exit with code 1. On other error it exits with code 2. Otherwise it exits
       with code 0. This makes it possible to use the exit code to see if a host is alive or not.
````

if the pings deson't receive 1 replay in 1 second the subprocess returns a returncode == 1 and makes the test fail

   def ping_ip_address(self, ip_address, should_succeed=True,
                        ping_timeout=None, mtu=None):
        # the code is taken from tempest/scenario/manager.py in tempest git
        timeout = ping_timeout or CONF.validation.ping_timeout
        cmd = ['ping', '-c1', '-w1']

        if mtu:
            cmd += [
                # don't fragment
                '-M', 'do',
                # ping receives just the size of ICMP payload
                '-s', str(net_utils.get_ping_payload_size(mtu, 4))
            ]
        cmd.append(ip_address)

        def ping():
            proc = subprocess.Popen(cmd,
                                    stdout=subprocess.PIPE,
                                    stderr=subprocess.PIPE)
            proc.communicate()

            return (proc.returncode == 0) == should_succeed