Update linux client to support basic MTU testing

BP MTU selection and adervertisement requires sending pkts of known
sizes to verify MTU.  This patch allows basic MTU testing via the
linux_client

Change-Id: Ia98ad49bad9ebbf783de599689b4684d31fadca6
This commit is contained in:
Richard Winters 2015-02-17 11:46:54 -05:00
parent 1370b7db6f
commit f87059b8da
4 changed files with 26 additions and 7 deletions

View File

@ -282,6 +282,14 @@
# Timeout in seconds to wait for ping to succeed. (integer value)
#ping_timeout = 120
# The packet size for ping packets originating from remote linux hosts
# (integer value)
#ping_size = 56
# The number of ping packets originating from remote linux hosts
# (integer value)
#ping_count = 1
# Timeout in seconds to wait for authentication to succeed. (integer
# value)
#ssh_timeout = 300

View File

@ -87,10 +87,11 @@ class RemoteClient(object):
cmd = 'sudo sh -c "echo \\"%s\\" >/dev/console"' % message
return self.exec_command(cmd)
def ping_host(self, host):
def ping_host(self, host, count=CONF.compute.ping_count,
size=CONF.compute.ping_size):
addr = netaddr.IPAddress(host)
cmd = 'ping6' if addr.version == 6 else 'ping'
cmd += ' -c1 -w1 {0}'.format(host)
cmd += ' -c{0} -w{0} -s{1} {2}'.format(count, size, host)
return self.exec_command(cmd)
def get_mac_address(self):

View File

@ -219,6 +219,14 @@ ComputeGroup = [
default=120,
help="Timeout in seconds to wait for ping to "
"succeed."),
cfg.IntOpt('ping_size',
default=56,
help="The packet size for ping packets originating "
"from remote linux hosts"),
cfg.IntOpt('ping_count',
default=1,
help="The number of ping packets originating from remote "
"linux hosts"),
cfg.IntOpt('ssh_timeout',
default=300,
help="Timeout in seconds to wait for authentication to "

View File

@ -100,15 +100,17 @@ class TestRemoteClient(base.TestCase):
self._assert_exec_called_with('cut -f1 -d. /proc/uptime')
def test_ping_host(self):
ping_response = """PING localhost (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_req=1 ttl=64 time=0.048 ms
ping_response = """PING localhost (127.0.0.1) 70(98) bytes of data.
78 bytes from localhost (127.0.0.1): icmp_req=1 ttl=64 time=0.048 ms
78 bytes from localhost (127.0.0.1): icmp_req=2 ttl=64 time=0.048 ms
--- localhost ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
2 packets transmitted, 2 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.048/0.048/0.048/0.000 ms"""
self.ssh_mock.mock.exec_command.return_value = ping_response
self.assertEqual(self.conn.ping_host('127.0.0.1'), ping_response)
self._assert_exec_called_with('ping -c1 -w1 127.0.0.1')
self.assertEqual(self.conn.ping_host('127.0.0.1', count=2, size=70),
ping_response)
self._assert_exec_called_with('ping -c2 -w2 -s70 127.0.0.1')
def test_get_mac_address(self):
macs = """0a:0b:0c:0d:0e:0f