Browse Source

nixos/tests: move sysctl test to misc

nsd-state-dir
Joachim Fasting 5 years ago
parent
commit
c85cf60c83
No known key found for this signature in database GPG Key ID: 66EAB6B14F6B6E0D
  1. 1
      nixos/release-combined.nix
  2. 1
      nixos/release.nix
  3. 9
      nixos/tests/misc.nix
  4. 25
      nixos/tests/sysctl.nix

1
nixos/release-combined.nix

@ -119,7 +119,6 @@ in rec {
(all nixos.tests.sddm.default)
(all nixos.tests.simple)
(all nixos.tests.slim)
nixos.tests.sysctl.x86_64-linux # i686 fails
(all nixos.tests.udisks2)
(all nixos.tests.xfce)

1
nixos/release.nix

@ -313,7 +313,6 @@ in rec {
tests.slim = callTest tests/slim.nix {};
tests.smokeping = callTest tests/smokeping.nix {};
tests.snapper = callTest tests/snapper.nix {};
tests.sysctl = callTest tests/sysctl.nix {};
tests.taskserver = callTest tests/taskserver.nix {};
tests.tomcat = callTest tests/tomcat.nix {};
tests.udisks2 = callTest tests/udisks2.nix {};

9
nixos/tests/misc.nix

@ -25,6 +25,7 @@ import ./make-test.nix ({ pkgs, ...} : {
};
users.users.sybil = { isNormalUser = true; group = "wheel"; };
security.sudo = { enable = true; wheelNeedsPassword = false; };
boot.kernel.sysctl."vm.swappiness" = 1;
};
testScript =
@ -117,5 +118,13 @@ import ./make-test.nix ({ pkgs, ...} : {
subtest "sudo", sub {
$machine->succeed("su - sybil -c 'sudo true'");
};
# Test sysctl
subtest "sysctl", sub {
$machine->waitForUnit("systemd-sysctl.service");
$machine->succeed('[ `sysctl -ne vm.swappiness` = 1 ]');
$machine->execute('sysctl vm.swappiness=60');
$machine->succeed('[ `sysctl -ne vm.swappiness` = 60 ]');
};
'';
})

25
nixos/tests/sysctl.nix

@ -1,25 +0,0 @@
import ./make-test.nix ({ pkgs, ...} : {
name = "sysctl";
meta = with pkgs.stdenv.lib.maintainers; {
maintainers = [ nequissimus ];
};
machine = { config, lib, pkgs, ... }:
{
boot.kernelPackages = pkgs.linuxPackages;
boot.kernel.sysctl = {
"kernel.dmesg_restrict" = true; # Restrict dmesg access
"net.core.bpf_jit_enable" = false; # Turn off bpf JIT
"user.max_user_namespaces" = 0; # Disable user namespaces
"vm.swappiness" = 2; # Low swap usage
};
};
testScript =
''
$machine->succeed("sysctl kernel.dmesg_restrict | grep 'kernel.dmesg_restrict = 1'");
$machine->succeed("sysctl net.core.bpf_jit_enable | grep 'net.core.bpf_jit_enable = 0'");
$machine->succeed("sysctl user.max_user_namespaces | grep 'user.max_user_namespaces = 0'");
$machine->succeed("sysctl vm.swappiness | grep 'vm.swappiness = 2'");
'';
})
Loading…
Cancel
Save