aboutsummaryrefslogtreecommitdiff
path: root/nixos/tests
diff options
context:
space:
mode:
authorFrederik Rietdijk <fridh@fridh.nl>2020-11-29 13:51:10 +0100
committerFrederik Rietdijk <fridh@fridh.nl>2020-11-29 13:51:10 +0100
commit0d8491cb2b045e8a0b52bde121929b15a1d20196 (patch)
treed3740bc4c45a54ff299cb9a9bb0bc7cb8fa1e02d /nixos/tests
parent9e062723b2d60d2be85268fb7eebb28abce0b5af (diff)
parent3a477cf32417b4c81c9fe42fbfb52c40b69fc110 (diff)
Merge master into staging-next
Diffstat (limited to 'nixos/tests')
-rw-r--r--nixos/tests/all-tests.nix5
-rw-r--r--nixos/tests/bat.nix12
-rw-r--r--nixos/tests/jq.nix10
-rw-r--r--nixos/tests/lsd.nix12
-rw-r--r--nixos/tests/minecraft-server.nix37
-rw-r--r--nixos/tests/minecraft.nix28
6 files changed, 104 insertions, 0 deletions
diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix
index 771ee9bdbd33..d746105ea643 100644
--- a/nixos/tests/all-tests.nix
+++ b/nixos/tests/all-tests.nix
@@ -30,6 +30,7 @@ in
avahi-with-resolved = handleTest ./avahi.nix { networkd = true; };
awscli = handleTest ./awscli.nix { };
babeld = handleTest ./babeld.nix {};
+ bat = handleTest ./bat.nix {};
bazarr = handleTest ./bazarr.nix {};
bcachefs = handleTestOn ["x86_64-linux"] ./bcachefs.nix {}; # linux-4.18.2018.10.12 is unsupported on aarch64
beanstalkd = handleTest ./beanstalkd.nix {};
@@ -171,6 +172,7 @@ in
jenkins = handleTest ./jenkins.nix {};
jirafeau = handleTest ./jirafeau.nix {};
jitsi-meet = handleTest ./jitsi-meet.nix {};
+ jq = handleTest ./jq.nix {};
k3s = handleTest ./k3s.nix {};
kafka = handleTest ./kafka.nix {};
keepalived = handleTest ./keepalived.nix {};
@@ -194,6 +196,7 @@ in
limesurvey = handleTest ./limesurvey.nix {};
login = handleTest ./login.nix {};
loki = handleTest ./loki.nix {};
+ lsd = handleTest ./lsd.nix {};
lxd = handleTest ./lxd.nix {};
lxd-nftables = handleTest ./lxd-nftables.nix {};
#logstash = handleTest ./logstash.nix {};
@@ -208,6 +211,8 @@ in
mediawiki = handleTest ./mediawiki.nix {};
memcached = handleTest ./memcached.nix {};
metabase = handleTest ./metabase.nix {};
+ minecraft = handleTest ./minecraft.nix {};
+ minecraft-server = handleTest ./minecraft-server.nix {};
miniflux = handleTest ./miniflux.nix {};
minio = handleTest ./minio.nix {};
minidlna = handleTest ./minidlna.nix {};
diff --git a/nixos/tests/bat.nix b/nixos/tests/bat.nix
new file mode 100644
index 000000000000..8e65e235d94f
--- /dev/null
+++ b/nixos/tests/bat.nix
@@ -0,0 +1,12 @@
+import ./make-test-python.nix ({ pkgs, ... }: {
+ name = "bat";
+ meta = with pkgs.stdenv.lib.maintainers; { maintainers = [ nequissimus ]; };
+
+ machine = { pkgs, ... }: { environment.systemPackages = [ pkgs.bat ]; };
+
+ testScript = ''
+ machine.succeed("echo 'Foobar\n\n\n42' > /tmp/foo")
+ assert "Foobar" in machine.succeed("bat -p /tmp/foo")
+ assert "42" in machine.succeed("bat -p /tmp/foo -r 4:4")
+ '';
+})
diff --git a/nixos/tests/jq.nix b/nixos/tests/jq.nix
new file mode 100644
index 000000000000..20b67522ee6e
--- /dev/null
+++ b/nixos/tests/jq.nix
@@ -0,0 +1,10 @@
+import ./make-test-python.nix ({ pkgs, ... }: {
+ name = "jq";
+ meta = with pkgs.stdenv.lib.maintainers; { maintainers = [ nequissimus ]; };
+
+ nodes.jq = { pkgs, ... }: { environment.systemPackages = [ pkgs.jq ]; };
+
+ testScript = ''
+ assert "world" in jq.succeed('echo \'{"values":["hello","world"]}\'| jq \'.values[1]\''')
+ '';
+})
diff --git a/nixos/tests/lsd.nix b/nixos/tests/lsd.nix
new file mode 100644
index 000000000000..fee8e95e14ff
--- /dev/null
+++ b/nixos/tests/lsd.nix
@@ -0,0 +1,12 @@
+import ./make-test-python.nix ({ pkgs, ... }: {
+ name = "lsd";
+ meta = with pkgs.stdenv.lib.maintainers; { maintainers = [ nequissimus ]; };
+
+ nodes.lsd = { pkgs, ... }: { environment.systemPackages = [ pkgs.lsd ]; };
+
+ testScript = ''
+ lsd.succeed('echo "abc" > /tmp/foo')
+ assert "4 B /tmp/foo" in lsd.succeed('lsd --classic --blocks "size,name" /tmp/foo')
+ assert "lsd ${pkgs.lsd.version}" in lsd.succeed("lsd --version")
+ '';
+})
diff --git a/nixos/tests/minecraft-server.nix b/nixos/tests/minecraft-server.nix
new file mode 100644
index 000000000000..53780e4636ca
--- /dev/null
+++ b/nixos/tests/minecraft-server.nix
@@ -0,0 +1,37 @@
+let
+ seed = "2151901553968352745";
+ rcon-pass = "foobar";
+ rcon-port = 43000;
+in import ./make-test-python.nix ({ pkgs, ... }: {
+ name = "minecraft-server";
+ meta = with pkgs.stdenv.lib.maintainers; { maintainers = [ nequissimus ]; };
+
+ nodes.server = { ... }: {
+ environment.systemPackages = [ pkgs.mcrcon ];
+
+ nixpkgs.config.allowUnfree = true;
+
+ services.minecraft-server = {
+ declarative = true;
+ enable = true;
+ eula = true;
+ serverProperties = {
+ enable-rcon = true;
+ level-seed = seed;
+ online-mode = false;
+ "rcon.password" = rcon-pass;
+ "rcon.port" = rcon-port;
+ };
+ };
+
+ virtualisation.memorySize = 2048;
+ };
+
+ testScript = ''
+ server.wait_for_unit("minecraft-server")
+ server.wait_for_open_port(${toString rcon-port})
+ assert "${seed}" in server.succeed(
+ "mcrcon -H localhost -P ${toString rcon-port} -p '${rcon-pass}' -c 'seed'"
+ )
+ '';
+})
diff --git a/nixos/tests/minecraft.nix b/nixos/tests/minecraft.nix
new file mode 100644
index 000000000000..e0c35f2d2769
--- /dev/null
+++ b/nixos/tests/minecraft.nix
@@ -0,0 +1,28 @@
+import ./make-test-python.nix ({ pkgs, lib, ... }: {
+ name = "minecraft";
+ meta = with lib.maintainers; { maintainers = [ nequissimus ]; };
+
+ nodes.client = { nodes, ... }:
+ let user = nodes.client.config.users.users.alice;
+ in {
+ imports = [ ./common/user-account.nix ./common/x11.nix ];
+
+ environment.systemPackages = [ pkgs.minecraft ];
+
+ nixpkgs.config.allowUnfree = true;
+
+ test-support.displayManager.auto.user = user.name;
+ };
+
+ enableOCR = true;
+
+ testScript = { nodes, ... }:
+ let user = nodes.client.config.users.users.alice;
+ in ''
+ client.wait_for_x()
+ client.execute("su - alice -c minecraft-launcher &")
+ client.wait_for_text("CONTINUE WITHOUT LOGIN")
+ client.sleep(10)
+ client.screenshot("launcher")
+ '';
+})