summaryrefslogtreecommitdiffstats
path: root/nixos/tests/tuned.nix
blob: ad5aacbe0fb3f54d643ba067441dccbbb43883e4 (plain)
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
{ pkgs, ... }:

{
  name = "tuned";
  meta = { inherit (pkgs.tuned.meta) maintainers; };

  nodes.machine = {
    imports = [ ./common/x11.nix ];

    services.tuned = {
      enable = true;

      profiles = {
        test-profile = {
          sysctls = {
            type = "sysctl";
            replace = true;

            "net.core.rmem_default" = 262144;
            "net.core.wmem_default" = 262144;
          };
        };
      };
    };
  };

  enableOCR = true;

  testScript = ''
    with subtest("Wait for service startup"):
      machine.wait_for_x()
      machine.wait_for_unit("tuned.service")
      machine.wait_for_unit("tuned-ppd.service")

    with subtest("Get service status"):
      machine.succeed("systemctl status tuned.service")

    # NOTE(@getchoo): `pkgs.tuned` provides its own `tuned.conf` for tmpfiles.d
    # A naming conflict with it and a `systemd.tmpfiles.settings` entry appeared in the initial PR for this module
    # This breaks the GUI in some cases, and it was annoying to figure out. Make sure it doesn't happen again!
    with subtest("Ensure systemd-tmpfiles paths are configured"):
      machine.succeed("systemd-tmpfiles --cat-config | grep '/etc/tuned/profiles'")
      machine.succeed("systemd-tmpfiles --cat-config | grep '/run/tuned'")

    with subtest("Test GUI"):
      machine.execute("tuned-gui >&2 &")
      machine.wait_for_window("tuned")
      machine.wait_for_text("Start TuneD Daemon")
      machine.screenshot("gui")
  '';
}