Skip to content

Commit 64f9ef7

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)
1 parent a960063 commit 64f9ef7

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
@@ -1040,13 +1040,16 @@ def get_tz():
10401040
self.create_iface(dhcpserver_opts='EmitTimezone=yes\nTimezone=Pacific/Honolulu')
10411041
self.do_test(coldplug=None, extra_opts='IPv6AcceptRA=false\n[DHCP]\nUseTimezone=true', dhcp_mode='ipv4')
10421042

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

10511054

10521055
class MatchClientTest(unittest.TestCase, NetworkdTestingUtilities):

0 commit comments

Comments
 (0)