Skip to content

Commit cb40719

Browse files
yuwatabluca
authored andcommitted
test: applying timezone is asynchronous
So, we need to try to read timezone several times. Also, on failure, show journal of timedated instead of hostnamed, as the timezone is handled by timedated. Hopefully fixes #33007. (cherry picked from commit 1ef586a) (cherry picked from commit 91d31ca) (cherry picked from commit 8b86ada) (cherry picked from commit 64f9ef7)
1 parent 00f772f commit cb40719

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

test/networkd-test.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,13 +1037,16 @@ def get_tz():
10371037
self.create_iface(dhcpserver_opts='EmitTimezone=yes\nTimezone=Pacific/Honolulu')
10381038
self.do_test(coldplug=None, extra_opts='IPv6AcceptRA=false\n[DHCP]\nUseTimezone=true', dhcp_mode='ipv4')
10391039

1040-
# should have applied the received timezone
1041-
try:
1042-
self.assertEqual(get_tz(), 'Pacific/Honolulu')
1043-
except AssertionError:
1040+
# Should have applied the received timezone. This is asynchronous, so we need to wait for a while:
1041+
for _ in range(20):
1042+
tz = get_tz()
1043+
if tz == 'Pacific/Honolulu':
1044+
break
1045+
time.sleep(0.5)
1046+
else:
10441047
self.show_journal('systemd-networkd.service')
1045-
self.show_journal('systemd-hostnamed.service')
1046-
raise
1048+
self.show_journal('systemd-timedated.service')
1049+
self.fail(f'Timezone: {tz}, expected: Pacific/Honolulu')
10471050

10481051

10491052
class MatchClientTest(unittest.TestCase, NetworkdTestingUtilities):

0 commit comments

Comments
 (0)