1 import ./make-test-python.nix ({ pkgs, ...} : {
3 meta.maintainers = with pkgs.lib.maintainers; [ lheckemann ];
6 node_eutz = { pkgs, ... }: {
7 time.timeZone = "Europe/Amsterdam";
10 node_nulltz = { pkgs, ... }: {
15 testScript = { nodes, ... }: ''
16 node_eutz.wait_for_unit("dbus.socket")
18 with subtest("static - Ensure timezone change gives the correct result"):
19 node_eutz.fail("timedatectl set-timezone Asia/Tokyo")
20 date_result = node_eutz.succeed('date -d @0 "+%Y-%m-%d %H:%M:%S"')
21 assert date_result == "1970-01-01 01:00:00\n", "Timezone seems to be wrong"
23 node_nulltz.wait_for_unit("dbus.socket")
25 with subtest("imperative - Ensure timezone defaults to UTC"):
26 date_result = node_nulltz.succeed('date -d @0 "+%Y-%m-%d %H:%M:%S"')
29 date_result == "1970-01-01 00:00:00\n"
30 ), "Timezone seems to be wrong (not UTC)"
32 with subtest("imperative - Ensure timezone adjustment produces expected result"):
33 node_nulltz.succeed("timedatectl set-timezone Asia/Tokyo")
35 # Adjustment should be taken into account
36 date_result = node_nulltz.succeed('date -d @0 "+%Y-%m-%d %H:%M:%S"')
38 assert date_result == "1970-01-01 09:00:00\n", "Timezone was not adjusted"
40 with subtest("imperative - Ensure timezone adjustment persists across reboot"):
41 # Adjustment should persist across a reboot
42 node_nulltz.shutdown()
43 node_nulltz.wait_for_unit("dbus.socket")
44 date_result = node_nulltz.succeed('date -d @0 "+%Y-%m-%d %H:%M:%S"')
47 date_result == "1970-01-01 09:00:00\n"
48 ), "Timezone adjustment was not persisted"