Adding pattern to check_remote_connectivity function
Ping messages sent by this function will include a pattern of bytes
that are repeated until message size is completed.
Input format required is a string with hex digits.
This is useful when these messages are captured, in order to identify
and differentiate clearly messages from different tests.
It can be used to validate that traffic routing is not affected by
packet data as well.
Closes-Bug: #1861397
Change-Id: Ib94518597bdf3d9f3049643d3242db632769de6b
diff --git a/neutron_tempest_plugin/scenario/base.py b/neutron_tempest_plugin/scenario/base.py
index 9bdaa97..42bd33b 100644
--- a/neutron_tempest_plugin/scenario/base.py
+++ b/neutron_tempest_plugin/scenario/base.py
@@ -250,7 +250,7 @@
def _check_remote_connectivity(self, source, dest, count,
should_succeed=True,
nic=None, mtu=None, fragmentation=True,
- timeout=None):
+ timeout=None, pattern=None):
"""check ping server via source ssh connection
:param source: RemoteClient: an ssh connection from which to ping
@@ -261,12 +261,13 @@
:param mtu: mtu size for the packet to be sent
:param fragmentation: Flag for packet fragmentation
:param timeout: Timeout for all ping packet(s) to succeed
+ :param pattern: hex digits included in ICMP messages
:returns: boolean -- should_succeed == ping
:returns: ping is false if ping failed
"""
def ping_host(source, host, count,
size=CONF.validation.ping_size, nic=None, mtu=None,
- fragmentation=True):
+ fragmentation=True, pattern=None):
IP_VERSION_4 = neutron_lib_constants.IP_VERSION_4
IP_VERSION_6 = neutron_lib_constants.IP_VERSION_6
@@ -282,13 +283,16 @@
cmd += ' -M do'
size = str(net_utils.get_ping_payload_size(
mtu=mtu, ip_version=ip_version))
+ if pattern:
+ cmd += ' -p {pattern}'.format(pattern=pattern)
cmd += ' -c{0} -w{0} -s{1} {2}'.format(count, size, host)
return source.exec_command(cmd)
def ping_remote():
try:
result = ping_host(source, dest, count, nic=nic, mtu=mtu,
- fragmentation=fragmentation)
+ fragmentation=fragmentation,
+ pattern=pattern)
except lib_exc.SSHExecCommandFailed:
LOG.warning('Failed to ping IP: %s via a ssh connection '
@@ -309,12 +313,13 @@
def check_remote_connectivity(self, source, dest, should_succeed=True,
nic=None, mtu=None, fragmentation=True,
servers=None, timeout=None,
- ping_count=CONF.validation.ping_count):
+ ping_count=CONF.validation.ping_count,
+ pattern=None):
try:
self.assertTrue(self._check_remote_connectivity(
source, dest, ping_count, should_succeed, nic, mtu,
fragmentation,
- timeout=timeout))
+ timeout=timeout, pattern=pattern))
except lib_exc.SSHTimeout as ssh_e:
LOG.debug(ssh_e)
self._log_console_output(servers)