summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Pitt <martin.pitt@ubuntu.com>2016-11-30 08:02:49 +0100
committerGitHub <noreply@github.com>2016-11-30 08:02:49 +0100
commit2926b130b69651539a90e866db43466b9b0ccfc5 (patch)
tree6e3e7c1225c39b555c23b0375d80d534d153a5f0
parent97506e85e2cf8c726939a872239698d5279a1cfc (diff)
test: retry checking for transient hostname in hostnamectl (#4769)
Sometimes setting the transient hostname does not happen synchronously, so retry up to five times. It is not yet clear whether this is legitimate behaviour or an underlying bug, but this will at least show whether the wrong transient hostname is just a race condition or permanently wrong. Fixes #4753
-rwxr-xr-xtest/networkd-test.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/test/networkd-test.py b/test/networkd-test.py
index f8914a7895..3023cac97d 100755
--- a/test/networkd-test.py
+++ b/test/networkd-test.py
@@ -452,8 +452,17 @@ Domains= ~company ~lab''')
# should have received the fixed IP above
out = subprocess.check_output(['ip', '-4', 'a', 'show', 'dev', self.iface])
self.assertRegex(out, b'inet 192.168.5.210/24 .* scope global dynamic')
- # should have set transient hostname in hostnamed
- self.assertIn(b'testgreen', subprocess.check_output(['hostnamectl']))
+ # should have set transient hostname in hostnamed; this is
+ # sometimes a bit lagging (issue #4753), so retry a few times
+ for retry in range(1, 6):
+ out = subprocess.check_output(['hostnamectl'])
+ if b'testgreen' in out:
+ break
+ time.sleep(5)
+ sys.stdout.write('[retry %i] ' % retry)
+ sys.stdout.flush()
+ else:
+ self.fail('Transient hostname not found in hostnamectl:\n%s' % out.decode())
# and also applied to the system
self.assertEqual(socket.gethostname(), 'testgreen')
except AssertionError: