Skip to content

Commit

Permalink
test: applying timezone is asynchronous
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
yuwata authored and bluca committed May 26, 2024
1 parent f68af32 commit 196065e
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions test/networkd-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1046,13 +1046,16 @@ def get_tz():
self.create_iface(dhcpserver_opts='EmitTimezone=yes\nTimezone=Pacific/Honolulu')
self.do_test(coldplug=None, extra_opts='IPv6AcceptRA=false\n[DHCP]\nUseTimezone=true', dhcp_mode='ipv4')

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


class MatchClientTest(unittest.TestCase, NetworkdTestingUtilities):
Expand Down

0 comments on commit 196065e

Please sign in to comment.