Fix ping error command handler when unknow host error is received

This is a fix for below CI error:

 https://storage.gra1.cloud.ovh.net/v1/AUTH_dcaab5e32b234d56b626f72581e3644c/zuul_opendev_logs_a8f/671234/24/check/tobiko-devstack-functional/a8fe837/testr_results.html.gz

Change-Id: I1d0f3a18b38191e60bb79c54d8787fd6d36a83e1
This commit is contained in:
Federico Ressi 2019-09-23 10:46:35 +02:00
parent 348644cf95
commit 668c9b69f6
2 changed files with 3 additions and 2 deletions

View File

@ -289,7 +289,7 @@ def handle_ping_command_error(error):
details = text[len(prefix):].strip()
raise _exception.SendToPingError(details=details)
prefix = 'unknown host '
prefix = 'unknown host'
if text.startswith(prefix):
details = text[len(prefix):].strip()
raise _exception.UnknowHostError(details=details)

View File

@ -51,7 +51,8 @@ class PingTest(testtools.TestCase):
def test_ping_unreachable_hostname(self):
ex = self.assertRaises(ping.UnknowHostError, ping.ping,
'unreachable-host', count=3)
self.assertEqual('unreachable-host', ex.details)
if ex.details:
self.assertEqual('unreachable-host', ex.details)
def test_ping_until_received(self):
result = ping.ping_until_received('127.0.0.1', count=3)