about summary refs log tree commit diff
path: root/nixos/tests/tuptime.nix
blob: 93410de7bdf5228471afa22c3b3e7b066fe439f3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import ./make-test-python.nix ({ pkgs, ...} : {
  name = "tuptime";
  meta = with pkgs.lib.maintainers; {
    maintainers = [ evils ];
  };

  nodes.machine = { pkgs, ... }: {
    imports = [ ../modules/profiles/minimal.nix ];
    services.tuptime.enable = true;
  };

  testScript =
    ''
      # see if it starts
      start_all()
      machine.wait_for_unit("multi-user.target")
      machine.succeed("tuptime | grep 'System startups:[[:blank:]]*1'")
      machine.succeed("tuptime | grep 'System uptime:[[:blank:]]*100.0%'")
      machine.shutdown()

      # restart machine and see if it correctly reports the reboot
      machine.start()
      machine.wait_for_unit("multi-user.target")
      machine.succeed("tuptime | grep 'System startups:[[:blank:]]*2'")
      machine.succeed("tuptime | grep 'System shutdowns:[[:blank:]]*1 ok'")
      machine.shutdown()
    '';
})