From d8d1e397cb655e4f5f8064d7f5d9fe864528db14 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Fri, 14 Mar 2025 22:37:17 +0100 Subject: [PATCH 01/26] nixosTests.zwave-js-ui: migrate to runTest Part Of #386873 --- nixos/tests/all-tests.nix | 2 +- nixos/tests/zwave-js-ui.nix | 50 ++++++++++++++++++------------------- 2 files changed, 25 insertions(+), 27 deletions(-) diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 52d7e8fb618f..463baf6c22c0 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -1321,5 +1321,5 @@ in { zrepl = handleTest ./zrepl.nix {}; zsh-history = handleTest ./zsh-history.nix {}; zwave-js = handleTest ./zwave-js.nix {}; - zwave-js-ui = handleTest ./zwave-js-ui.nix {}; + zwave-js-ui = runTest ./zwave-js-ui.nix; } diff --git a/nixos/tests/zwave-js-ui.nix b/nixos/tests/zwave-js-ui.nix index ea468cdd1a5d..4f3ba972d9d9 100644 --- a/nixos/tests/zwave-js-ui.nix +++ b/nixos/tests/zwave-js-ui.nix @@ -1,31 +1,29 @@ -import ./make-test-python.nix ( - { lib, ... }: - { - name = "zwave-js-ui"; - meta.maintainers = with lib.maintainers; [ cdombroski ]; +{ lib, ... }: +{ + name = "zwave-js-ui"; + meta.maintainers = with lib.maintainers; [ cdombroski ]; - nodes = { - machine = - { ... }: - { - services.zwave-js-ui = { - enable = true; - serialPort = "/dev/null"; - settings = { - HOST = "::"; - PORT = "9999"; - }; + nodes = { + machine = + { ... }: + { + services.zwave-js-ui = { + enable = true; + serialPort = "/dev/null"; + settings = { + HOST = "::"; + PORT = "9999"; }; }; - }; + }; + }; - testScript = '' - start_all() + testScript = '' + start_all() - machine.wait_for_unit("zwave-js-ui.service") - machine.wait_for_open_port(9999) - machine.wait_until_succeeds("journalctl --since -1m --unit zwave-js-ui --grep 'Listening on port 9999host :: protocol HTTP'") - machine.wait_for_file("/var/lib/zwave-js-ui/users.json") - ''; - } -) + machine.wait_for_unit("zwave-js-ui.service") + machine.wait_for_open_port(9999) + machine.wait_until_succeeds("journalctl --since -1m --unit zwave-js-ui --grep 'Listening on port 9999host :: protocol HTTP'") + machine.wait_for_file("/var/lib/zwave-js-ui/users.json") + ''; +} From 16cf246490334b367034687c27de37f394d700e5 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Fri, 14 Mar 2025 22:39:30 +0100 Subject: [PATCH 02/26] nixosTests.zwave-js: migrate to runTest Part Of #386873 --- nixos/tests/all-tests.nix | 2 +- nixos/tests/zwave-js.nix | 62 ++++++++++++++++++--------------------- 2 files changed, 30 insertions(+), 34 deletions(-) diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 463baf6c22c0..50e2bd0c70b4 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -1320,6 +1320,6 @@ in { zram-generator = handleTest ./zram-generator.nix {}; zrepl = handleTest ./zrepl.nix {}; zsh-history = handleTest ./zsh-history.nix {}; - zwave-js = handleTest ./zwave-js.nix {}; + zwave-js = runTest ./zwave-js.nix; zwave-js-ui = runTest ./zwave-js-ui.nix; } diff --git a/nixos/tests/zwave-js.nix b/nixos/tests/zwave-js.nix index 3ce12780893e..2815508211f8 100644 --- a/nixos/tests/zwave-js.nix +++ b/nixos/tests/zwave-js.nix @@ -1,38 +1,34 @@ -import ./make-test-python.nix ( - { pkgs, lib, ... }: +{ pkgs, lib, ... }: - let - secretsConfigFile = pkgs.writeText "secrets.json" ( - builtins.toJSON { - securityKeys = { - "S0_Legacy" = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; - }; - } - ); - in - { - name = "zwave-js"; - meta.maintainers = with lib.maintainers; [ graham33 ]; +let + secretsConfigFile = pkgs.writeText "secrets.json" ( + builtins.toJSON { + securityKeys = { + "S0_Legacy" = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + }; + } + ); +in +{ + name = "zwave-js"; + meta.maintainers = with lib.maintainers; [ graham33 ]; - nodes = { - machine = - { config, ... }: - { - services.zwave-js = { - enable = true; - serialPort = "/dev/null"; - extraFlags = [ "--mock-driver" ]; - inherit secretsConfigFile; - }; - }; + nodes = { + machine = { + services.zwave-js = { + enable = true; + serialPort = "/dev/null"; + extraFlags = [ "--mock-driver" ]; + inherit secretsConfigFile; + }; }; + }; - testScript = '' - start_all() + testScript = '' + start_all() - machine.wait_for_unit("zwave-js.service") - machine.wait_for_open_port(3000) - machine.wait_until_succeeds("journalctl --since -1m --unit zwave-js --grep 'ZwaveJS server listening'") - ''; - } -) + machine.wait_for_unit("zwave-js.service") + machine.wait_for_open_port(3000) + machine.wait_until_succeeds("journalctl --since -1m --unit zwave-js --grep 'ZwaveJS server listening'") + ''; +} From 04bc28c6802cbf564f83708b7983f12fd39a9bfa Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Fri, 14 Mar 2025 22:41:04 +0100 Subject: [PATCH 03/26] nixosTests.zsh-history: migrate to runTest Part Of #386873 --- nixos/tests/all-tests.nix | 2 +- nixos/tests/zsh-history.nix | 68 ++++++++++++++++++------------------- 2 files changed, 34 insertions(+), 36 deletions(-) diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 50e2bd0c70b4..ea62bfbdc521 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -1319,7 +1319,7 @@ in { zookeeper = handleTest ./zookeeper.nix {}; zram-generator = handleTest ./zram-generator.nix {}; zrepl = handleTest ./zrepl.nix {}; - zsh-history = handleTest ./zsh-history.nix {}; + zsh-history = runTest ./zsh-history.nix; zwave-js = runTest ./zwave-js.nix; zwave-js-ui = runTest ./zwave-js-ui.nix; } diff --git a/nixos/tests/zsh-history.nix b/nixos/tests/zsh-history.nix index 539729e32039..fe3dd44a25e2 100644 --- a/nixos/tests/zsh-history.nix +++ b/nixos/tests/zsh-history.nix @@ -1,40 +1,38 @@ -import ./make-test-python.nix ( - { pkgs, ... }: - { - name = "zsh-history"; - meta = with pkgs.lib.maintainers; { - maintainers = [ ]; +{ pkgs, ... }: +{ + name = "zsh-history"; + meta = with pkgs.lib.maintainers; { + maintainers = [ ]; + }; + + nodes.default = + { ... }: + { + programs = { + zsh.enable = true; + }; + environment.systemPackages = [ pkgs.zsh-history ]; + programs.zsh.interactiveShellInit = '' + source ${pkgs.zsh-history.out}/share/zsh/init.zsh + ''; + users.users.root.shell = "${pkgs.zsh}/bin/zsh"; }; - nodes.default = - { ... }: - { - programs = { - zsh.enable = true; - }; - environment.systemPackages = [ pkgs.zsh-history ]; - programs.zsh.interactiveShellInit = '' - source ${pkgs.zsh-history.out}/share/zsh/init.zsh - ''; - users.users.root.shell = "${pkgs.zsh}/bin/zsh"; - }; + testScript = '' + start_all() + default.wait_for_unit("multi-user.target") + default.wait_until_succeeds("pgrep -f 'agetty.*tty1'") - testScript = '' - start_all() - default.wait_for_unit("multi-user.target") - default.wait_until_succeeds("pgrep -f 'agetty.*tty1'") + # Login + default.wait_until_tty_matches("1", "login: ") + default.send_chars("root\n") + default.wait_until_tty_matches("1", r"\nroot@default\b") - # Login - default.wait_until_tty_matches("1", "login: ") - default.send_chars("root\n") - default.wait_until_tty_matches("1", r"\nroot@default\b") + # Generate some history + default.send_chars("echo foobar\n") + default.wait_until_tty_matches("1", "foobar") - # Generate some history - default.send_chars("echo foobar\n") - default.wait_until_tty_matches("1", "foobar") - - # Ensure that command was recorded in history - default.succeed("/run/current-system/sw/bin/history list | grep -q foobar") - ''; - } -) + # Ensure that command was recorded in history + default.succeed("/run/current-system/sw/bin/history list | grep -q foobar") + ''; +} From 89bf1ebca0cfdd3a84f6ecaa2f72272a697fce80 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Fri, 14 Mar 2025 22:41:58 +0100 Subject: [PATCH 04/26] nixosTests.zrepl: migrate to runTest Part Of #386873 --- nixos/tests/all-tests.nix | 2 +- nixos/tests/zrepl.nix | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index ea62bfbdc521..51bf608c9605 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -1318,7 +1318,7 @@ in { zoneminder = handleTest ./zoneminder.nix {}; zookeeper = handleTest ./zookeeper.nix {}; zram-generator = handleTest ./zram-generator.nix {}; - zrepl = handleTest ./zrepl.nix {}; + zrepl = runTest ./zrepl.nix; zsh-history = runTest ./zsh-history.nix; zwave-js = runTest ./zwave-js.nix; zwave-js-ui = runTest ./zwave-js-ui.nix; diff --git a/nixos/tests/zrepl.nix b/nixos/tests/zrepl.nix index 095e03cb3344..3bc6ed9d342c 100644 --- a/nixos/tests/zrepl.nix +++ b/nixos/tests/zrepl.nix @@ -1,8 +1,8 @@ -import ./make-test-python.nix ({ +{ name = "zrepl"; nodes.host = - { config, pkgs, ... }: + { pkgs, ... }: { config = { # Prerequisites for ZFS and tests. @@ -73,4 +73,4 @@ import ./make-test-python.nix ({ "zrepl_zfs_snapshot_duration_count{filesystem=\"test\"}" in out ), "zrepl snapshot counter for test was not found in Prometheus output" ''; -}) +} From c0e830903472436c1455206d66e3eb09f051087a Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Fri, 14 Mar 2025 22:42:49 +0100 Subject: [PATCH 05/26] nixosTests.zram-generator: migrate to runTest Part Of #386873 --- nixos/tests/all-tests.nix | 2 +- nixos/tests/zram-generator.nix | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 51bf608c9605..7585bbcc90ee 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -1317,7 +1317,7 @@ in { zipline = handleTest ./zipline.nix {}; zoneminder = handleTest ./zoneminder.nix {}; zookeeper = handleTest ./zookeeper.nix {}; - zram-generator = handleTest ./zram-generator.nix {}; + zram-generator = runTest ./zram-generator.nix; zrepl = runTest ./zrepl.nix; zsh-history = runTest ./zsh-history.nix; zwave-js = runTest ./zwave-js.nix; diff --git a/nixos/tests/zram-generator.nix b/nixos/tests/zram-generator.nix index 14c988f94429..46414efee4b3 100644 --- a/nixos/tests/zram-generator.nix +++ b/nixos/tests/zram-generator.nix @@ -1,4 +1,4 @@ -import ./make-test-python.nix { +{ name = "zram-generator"; nodes = { From 1c825e3db490e1ed1eb2d921e51f4025173ae05a Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Fri, 14 Mar 2025 22:43:51 +0100 Subject: [PATCH 06/26] nixosTests.zookeeper: migrate to runTest Part Of #386873 --- nixos/tests/all-tests.nix | 2 +- nixos/tests/zookeeper.nix | 90 +++++++++++++++++++-------------------- 2 files changed, 45 insertions(+), 47 deletions(-) diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 7585bbcc90ee..99e80f0ec537 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -1316,7 +1316,7 @@ in { }; zipline = handleTest ./zipline.nix {}; zoneminder = handleTest ./zoneminder.nix {}; - zookeeper = handleTest ./zookeeper.nix {}; + zookeeper = runTest ./zookeeper.nix; zram-generator = runTest ./zram-generator.nix; zrepl = runTest ./zrepl.nix; zsh-history = runTest ./zsh-history.nix; diff --git a/nixos/tests/zookeeper.nix b/nixos/tests/zookeeper.nix index 8442f021e051..b1fc0d3a8604 100644 --- a/nixos/tests/zookeeper.nix +++ b/nixos/tests/zookeeper.nix @@ -1,54 +1,52 @@ -import ./make-test-python.nix ( - { pkgs, ... }: - let +{ pkgs, ... }: +let - perlEnv = pkgs.perl.withPackages (p: [ p.NetZooKeeper ]); + perlEnv = pkgs.perl.withPackages (p: [ p.NetZooKeeper ]); - in - { - name = "zookeeper"; - meta = with pkgs.lib.maintainers; { - maintainers = [ - nequissimus - ztzg - ]; - }; +in +{ + name = "zookeeper"; + meta = with pkgs.lib.maintainers; { + maintainers = [ + nequissimus + ztzg + ]; + }; - nodes = { - server = - { ... }: - { - services.zookeeper = { - enable = true; - }; - - networking.firewall.allowedTCPPorts = [ 2181 ]; + nodes = { + server = + { ... }: + { + services.zookeeper = { + enable = true; }; - }; - testScript = '' - start_all() + networking.firewall.allowedTCPPorts = [ 2181 ]; + }; + }; - server.wait_for_unit("zookeeper") - server.wait_for_unit("network.target") - server.wait_for_open_port(2181) + testScript = '' + start_all() - server.wait_until_succeeds( - "${pkgs.zookeeper}/bin/zkCli.sh -server localhost:2181 create /foo bar" - ) - server.wait_until_succeeds( - "${pkgs.zookeeper}/bin/zkCli.sh -server localhost:2181 set /foo hello" - ) - server.wait_until_succeeds( - "${pkgs.zookeeper}/bin/zkCli.sh -server localhost:2181 get /foo | grep hello" - ) + server.wait_for_unit("zookeeper") + server.wait_for_unit("network.target") + server.wait_for_open_port(2181) - server.wait_until_succeeds( - "${perlEnv}/bin/perl -E 'use Net::ZooKeeper qw(:acls); $z=Net::ZooKeeper->new(q(localhost:2181)); $z->create(qw(/perl foo acl), ZOO_OPEN_ACL_UNSAFE) || die $z->get_error()'" - ) - server.wait_until_succeeds( - "${perlEnv}/bin/perl -E 'use Net::ZooKeeper qw(:acls); $z=Net::ZooKeeper->new(q(localhost:2181)); $z->get(qw(/perl)) eq qw(foo) || die $z->get_error()'" - ) - ''; - } -) + server.wait_until_succeeds( + "${pkgs.zookeeper}/bin/zkCli.sh -server localhost:2181 create /foo bar" + ) + server.wait_until_succeeds( + "${pkgs.zookeeper}/bin/zkCli.sh -server localhost:2181 set /foo hello" + ) + server.wait_until_succeeds( + "${pkgs.zookeeper}/bin/zkCli.sh -server localhost:2181 get /foo | grep hello" + ) + + server.wait_until_succeeds( + "${perlEnv}/bin/perl -E 'use Net::ZooKeeper qw(:acls); $z=Net::ZooKeeper->new(q(localhost:2181)); $z->create(qw(/perl foo acl), ZOO_OPEN_ACL_UNSAFE) || die $z->get_error()'" + ) + server.wait_until_succeeds( + "${perlEnv}/bin/perl -E 'use Net::ZooKeeper qw(:acls); $z=Net::ZooKeeper->new(q(localhost:2181)); $z->get(qw(/perl)) eq qw(foo) || die $z->get_error()'" + ) + ''; +} From 7c443382b23edc25b999493d8062c5e98f202975 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Fri, 14 Mar 2025 22:45:38 +0100 Subject: [PATCH 07/26] nixosTests.zoneminder: migrate to runTest Part Of #386873 --- nixos/tests/all-tests.nix | 2 +- nixos/tests/zoneminder.nix | 42 ++++++++++++++++++-------------------- 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 99e80f0ec537..5bad50b737d0 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -1315,7 +1315,7 @@ in { _module.args.package = pkgs.zigbee2mqtt_2; }; zipline = handleTest ./zipline.nix {}; - zoneminder = handleTest ./zoneminder.nix {}; + zoneminder = runTest ./zoneminder.nix; zookeeper = runTest ./zookeeper.nix; zram-generator = runTest ./zram-generator.nix; zrepl = runTest ./zrepl.nix; diff --git a/nixos/tests/zoneminder.nix b/nixos/tests/zoneminder.nix index 7a32ff8bb8bb..da0484a6615b 100644 --- a/nixos/tests/zoneminder.nix +++ b/nixos/tests/zoneminder.nix @@ -1,26 +1,24 @@ -import ./make-test-python.nix ( - { lib, ... }: +{ lib, ... }: - { - name = "zoneminder"; - meta.maintainers = with lib.maintainers; [ danielfullmer ]; +{ + name = "zoneminder"; + meta.maintainers = with lib.maintainers; [ danielfullmer ]; - nodes.machine = - { ... }: - { - services.zoneminder = { - enable = true; - database.createLocally = true; - database.username = "zoneminder"; - }; - time.timeZone = "America/New_York"; + nodes.machine = + { ... }: + { + services.zoneminder = { + enable = true; + database.createLocally = true; + database.username = "zoneminder"; }; + time.timeZone = "America/New_York"; + }; - testScript = '' - machine.wait_for_unit("zoneminder.service") - machine.wait_for_unit("nginx.service") - machine.wait_for_open_port(8095) - machine.succeed("curl --fail http://localhost:8095/") - ''; - } -) + testScript = '' + machine.wait_for_unit("zoneminder.service") + machine.wait_for_unit("nginx.service") + machine.wait_for_open_port(8095) + machine.succeed("curl --fail http://localhost:8095/") + ''; +} From 75702914a71518ab6108e66484f9e1c5b99052ca Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Fri, 14 Mar 2025 22:46:10 +0100 Subject: [PATCH 08/26] nixosTests.zipline: migrate to runTest Part Of #386873 --- nixos/tests/all-tests.nix | 2 +- nixos/tests/zipline.nix | 70 +++++++++++++++++++-------------------- 2 files changed, 35 insertions(+), 37 deletions(-) diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 5bad50b737d0..829a5a645971 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -1314,7 +1314,7 @@ in { imports = [ ./zigbee2mqtt.nix ]; _module.args.package = pkgs.zigbee2mqtt_2; }; - zipline = handleTest ./zipline.nix {}; + zipline = runTest ./zipline.nix; zoneminder = runTest ./zoneminder.nix; zookeeper = runTest ./zookeeper.nix; zram-generator = runTest ./zram-generator.nix; diff --git a/nixos/tests/zipline.nix b/nixos/tests/zipline.nix index f72d6dcca7c7..dfda9230ea7c 100644 --- a/nixos/tests/zipline.nix +++ b/nixos/tests/zipline.nix @@ -1,44 +1,42 @@ -import ./make-test-python.nix ( - { lib, ... }: - { - name = "zipline"; - meta.maintainers = with lib.maintainers; [ defelo ]; +{ lib, ... }: +{ + name = "zipline"; + meta.maintainers = with lib.maintainers; [ defelo ]; - nodes.machine = { - services.zipline = { - enable = true; - settings = { - CORE_HOSTNAME = "127.0.0.1"; - CORE_PORT = 8000; - }; - environmentFiles = [ - (builtins.toFile "zipline.env" '' - CORE_SECRET=DMlouex3W0QLRbVwkUafNnNws5jpgRDX - '') - ]; + nodes.machine = { + services.zipline = { + enable = true; + settings = { + CORE_HOSTNAME = "127.0.0.1"; + CORE_PORT = 8000; }; - - networking.hosts."127.0.0.1" = [ "zipline.local" ]; + environmentFiles = [ + (builtins.toFile "zipline.env" '' + CORE_SECRET=DMlouex3W0QLRbVwkUafNnNws5jpgRDX + '') + ]; }; - testScript = '' - import json - import re + networking.hosts."127.0.0.1" = [ "zipline.local" ]; + }; - machine.wait_for_unit("zipline.service") - machine.wait_for_open_port(8000) + testScript = '' + import json + import re - resp = machine.succeed("curl zipline.local:8000/api/setup -v -X POST -H 'Content-Type: application/json' -d '{\"username\": \"administrator\", \"password\": \"password\"}' 2>&1") - data = json.loads(resp.splitlines()[-1]) - assert data["firstSetup"] is True - assert data["user"]["username"] == "administrator" - assert data["user"]["role"] == "SUPERADMIN" + machine.wait_for_unit("zipline.service") + machine.wait_for_open_port(8000) - resp = machine.succeed("curl zipline.local:8000/api/auth/login -v -X POST -H 'Content-Type: application/json' -d '{\"username\": \"administrator\", \"password\": \"password\"}' 2>&1") + resp = machine.succeed("curl zipline.local:8000/api/setup -v -X POST -H 'Content-Type: application/json' -d '{\"username\": \"administrator\", \"password\": \"password\"}' 2>&1") + data = json.loads(resp.splitlines()[-1]) + assert data["firstSetup"] is True + assert data["user"]["username"] == "administrator" + assert data["user"]["role"] == "SUPERADMIN" - assert (cookie := re.search(r"(?m)^< set-cookie: ([^;]*)", resp)) - resp = machine.succeed(f"curl zipline.local:8000/api/user -H 'Cookie: {cookie[1]}'") - assert json.loads(resp)["user"]["id"] == data["user"]["id"] - ''; - } -) + resp = machine.succeed("curl zipline.local:8000/api/auth/login -v -X POST -H 'Content-Type: application/json' -d '{\"username\": \"administrator\", \"password\": \"password\"}' 2>&1") + + assert (cookie := re.search(r"(?m)^< set-cookie: ([^;]*)", resp)) + resp = machine.succeed(f"curl zipline.local:8000/api/user -H 'Cookie: {cookie[1]}'") + assert json.loads(resp)["user"]["id"] == data["user"]["id"] + ''; +} From 052ef614f6900a6296df1162526b338d398dfa9c Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Fri, 14 Mar 2025 22:49:23 +0100 Subject: [PATCH 09/26] nixosTests.zeronet-conservancy: migrate to runTest Part Of #386873 --- nixos/tests/all-tests.nix | 2 +- nixos/tests/zeronet-conservancy.nix | 47 +++++++++++++++-------------- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 829a5a645971..b583e3b390c3 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -1304,7 +1304,7 @@ in { your_spotify = handleTest ./your_spotify.nix {}; zammad = handleTest ./zammad.nix {}; zenohd = handleTest ./zenohd.nix {}; - zeronet-conservancy = handleTest ./zeronet-conservancy.nix {}; + zeronet-conservancy = runTest ./zeronet-conservancy.nix; zfs = handleTest ./zfs.nix {}; zigbee2mqtt_1 = runTest { imports = [ ./zigbee2mqtt.nix ]; diff --git a/nixos/tests/zeronet-conservancy.nix b/nixos/tests/zeronet-conservancy.nix index 1c906d80a317..674712e3fe6a 100644 --- a/nixos/tests/zeronet-conservancy.nix +++ b/nixos/tests/zeronet-conservancy.nix @@ -1,30 +1,31 @@ +{ + lib, + ... +}: let port = 43110; in -import ./make-test-python.nix ( - { pkgs, ... }: - { - name = "zeronet-conservancy"; - meta = with pkgs.lib.maintainers; { - maintainers = [ fgaz ]; +{ + name = "zeronet-conservancy"; + meta = with lib.maintainers; { + maintainers = [ fgaz ]; + }; + + nodes.machine = + { pkgs, ... }: + { + services.zeronet = { + enable = true; + package = pkgs.zeronet-conservancy; + inherit port; + }; }; - nodes.machine = - { config, pkgs, ... }: - { - services.zeronet = { - enable = true; - package = pkgs.zeronet-conservancy; - inherit port; - }; - }; + testScript = '' + machine.wait_for_unit("zeronet.service") - testScript = '' - machine.wait_for_unit("zeronet.service") + machine.wait_for_open_port(${toString port}) - machine.wait_for_open_port(${toString port}) - - machine.succeed("curl --fail -H 'Accept: text/html, application/xml, */*' localhost:${toString port}/Stats") - ''; - } -) + machine.succeed("curl --fail -H 'Accept: text/html, application/xml, */*' localhost:${toString port}/Stats") + ''; +} From e3c80a49c8a397d8e8c14c5db0570fcd6573696b Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Fri, 14 Mar 2025 22:51:56 +0100 Subject: [PATCH 10/26] nixosTests.zenohd: migrate to runTest Part Of #386873 --- nixos/tests/all-tests.nix | 2 +- nixos/tests/zenohd.nix | 145 +++++++++++++++++++------------------- 2 files changed, 72 insertions(+), 75 deletions(-) diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index b583e3b390c3..05b83af64526 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -1303,7 +1303,7 @@ in { yggdrasil = handleTest ./yggdrasil.nix {}; your_spotify = handleTest ./your_spotify.nix {}; zammad = handleTest ./zammad.nix {}; - zenohd = handleTest ./zenohd.nix {}; + zenohd = runTest ./zenohd.nix; zeronet-conservancy = runTest ./zeronet-conservancy.nix; zfs = handleTest ./zfs.nix {}; zigbee2mqtt_1 = runTest { diff --git a/nixos/tests/zenohd.nix b/nixos/tests/zenohd.nix index 0aeca6b61818..ee1959e86c48 100644 --- a/nixos/tests/zenohd.nix +++ b/nixos/tests/zenohd.nix @@ -1,71 +1,68 @@ -import ./make-test-python.nix ( - { pkgs, lib, ... }: +{ pkgs, lib, ... }: - { - name = "zenohd"; - meta.maintainers = [ lib.maintainers.markuskowa ]; +{ + name = "zenohd"; + meta.maintainers = [ lib.maintainers.markuskowa ]; - nodes = { - router = - { - pkgs, - lib, - config, - ... - }: - { - networking.firewall.allowedTCPPorts = [ - 7447 # zenohd default port - config.services.zenohd.settings.plugins.mqtt.port - config.services.zenohd.settings.plugins.webserver.http_port + nodes = { + router = + { + pkgs, + config, + ... + }: + { + networking.firewall.allowedTCPPorts = [ + 7447 # zenohd default port + config.services.zenohd.settings.plugins.mqtt.port + config.services.zenohd.settings.plugins.webserver.http_port + ]; + + services.zenohd = { + enable = true; + + plugins = with pkgs; [ + zenoh-plugin-mqtt + zenoh-plugin-webserver ]; - services.zenohd = { - enable = true; + backends = with pkgs; [ + zenoh-backend-filesystem + zenoh-backend-rocksdb + ]; - plugins = with pkgs; [ - zenoh-plugin-mqtt - zenoh-plugin-webserver - ]; - - backends = with pkgs; [ - zenoh-backend-filesystem - zenoh-backend-rocksdb - ]; - - settings = { - plugins = { - mqtt = { - port = 1883; - allow = ".*"; + settings = { + plugins = { + mqtt = { + port = 1883; + allow = ".*"; + }; + webserver.http_port = 8000; + storage_manager = { + volumes = { + fs = { }; + rocksdb = { }; }; - webserver.http_port = 8000; - storage_manager = { - volumes = { - fs = { }; - rocksdb = { }; + storages = { + mem = { + key_expr = "mem/**"; + volume = "memory"; }; - storages = { - mem = { - key_expr = "mem/**"; - volume = "memory"; + fs = { + key_expr = "fs/**"; + volume = { + id = "fs"; + dir = "zenoh-fs"; + strip_prefix = "fs"; }; - fs = { - key_expr = "fs/**"; - volume = { - id = "fs"; - dir = "zenoh-fs"; - strip_prefix = "fs"; - }; - }; - rocksdb = { - key_expr = "rocksdb/**"; - volume = { - id = "rocksdb"; - dir = "zenoh-rocksdb"; - strip_prefix = "rocksdb"; - create_db = true; - }; + }; + rocksdb = { + key_expr = "rocksdb/**"; + volume = { + id = "rocksdb"; + dir = "zenoh-rocksdb"; + strip_prefix = "rocksdb"; + create_db = true; }; }; }; @@ -73,21 +70,21 @@ import ./make-test-python.nix ( }; }; }; - - client = { - environment.systemPackages = [ - pkgs.mosquitto - ]; }; + + client = { + environment.systemPackages = [ + pkgs.mosquitto + ]; }; + }; - testScript = '' - router.wait_for_unit("zenohd.service") - client.wait_for_unit("multi-user.target") + testScript = '' + router.wait_for_unit("zenohd.service") + client.wait_for_unit("multi-user.target") - for be in ["fs", "rocksdb", "mem" ]: - client.succeed(f"mosquitto_pub -h router -t {be}/test -m hello") - client.succeed(f"curl router:8000/{be}/test | grep hello") - ''; - } -) + for be in ["fs", "rocksdb", "mem" ]: + client.succeed(f"mosquitto_pub -h router -t {be}/test -m hello") + client.succeed(f"curl router:8000/{be}/test | grep hello") + ''; +} From 2a33e128e143e6fa37e9f7b3286a4ed39781202a Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Fri, 14 Mar 2025 22:52:10 +0100 Subject: [PATCH 11/26] nixosTests.zammad: migrate to runTest Part Of #386873 --- nixos/tests/all-tests.nix | 2 +- nixos/tests/zammad.nix | 70 ++++++++++++++++++--------------------- 2 files changed, 34 insertions(+), 38 deletions(-) diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 05b83af64526..091f1462ad17 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -1302,7 +1302,7 @@ in { ydotool = handleTest ./ydotool.nix {}; yggdrasil = handleTest ./yggdrasil.nix {}; your_spotify = handleTest ./your_spotify.nix {}; - zammad = handleTest ./zammad.nix {}; + zammad = runTest ./zammad.nix; zenohd = runTest ./zenohd.nix; zeronet-conservancy = runTest ./zeronet-conservancy.nix; zfs = handleTest ./zfs.nix {}; diff --git a/nixos/tests/zammad.nix b/nixos/tests/zammad.nix index cbdd94485e90..d5b668e1e878 100644 --- a/nixos/tests/zammad.nix +++ b/nixos/tests/zammad.nix @@ -1,42 +1,38 @@ -import ./make-test-python.nix ( - { lib, pkgs, ... }: +{ lib, pkgs, ... }: - { - name = "zammad"; +{ + name = "zammad"; - meta.maintainers = with lib.maintainers; [ - taeer - netali - ]; + meta.maintainers = with lib.maintainers; [ + taeer + netali + ]; - nodes.machine = - { config, ... }: - { - virtualisation = { - memorySize = 2048; - }; + nodes.machine = { + virtualisation = { + memorySize = 2048; + }; - services.zammad.enable = true; - services.zammad.secretKeyBaseFile = pkgs.writeText "secret" '' - 52882ef142066e09ab99ce816ba72522e789505caba224a52d750ec7dc872c2c371b2fd19f16b25dfbdd435a4dd46cb3df9f82eb63fafad715056bdfe25740d6 - ''; - }; - - testScript = '' - start_all() - machine.wait_for_unit("postgresql.service") - machine.wait_for_unit("redis-zammad.service") - machine.wait_for_unit("zammad-web.service") - machine.wait_for_unit("zammad-websocket.service") - machine.wait_for_unit("zammad-worker.service") - # wait for zammad to fully come up - machine.sleep(120) - - # without the grep the command does not produce valid utf-8 for some reason - with subtest("welcome screen loads"): - machine.succeed( - "curl -sSfL http://localhost:3000/ | grep 'Zammad Helpdesk'" - ) + services.zammad.enable = true; + services.zammad.secretKeyBaseFile = pkgs.writeText "secret" '' + 52882ef142066e09ab99ce816ba72522e789505caba224a52d750ec7dc872c2c371b2fd19f16b25dfbdd435a4dd46cb3df9f82eb63fafad715056bdfe25740d6 ''; - } -) + }; + + testScript = '' + start_all() + machine.wait_for_unit("postgresql.service") + machine.wait_for_unit("redis-zammad.service") + machine.wait_for_unit("zammad-web.service") + machine.wait_for_unit("zammad-websocket.service") + machine.wait_for_unit("zammad-worker.service") + # wait for zammad to fully come up + machine.sleep(120) + + # without the grep the command does not produce valid utf-8 for some reason + with subtest("welcome screen loads"): + machine.succeed( + "curl -sSfL http://localhost:3000/ | grep 'Zammad Helpdesk'" + ) + ''; +} From 86677773007181169bb4c9ecea9cbd5da6e30c31 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Fri, 14 Mar 2025 22:57:44 +0100 Subject: [PATCH 12/26] nixosTests.your_spotify: migrate to runTest Part Of #386873 --- nixos/tests/all-tests.nix | 2 +- nixos/tests/your_spotify.nix | 56 +++++++++++++++++------------------- 2 files changed, 28 insertions(+), 30 deletions(-) diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 091f1462ad17..12b9f11fb6eb 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -1301,7 +1301,7 @@ in { yabar = handleTest ./yabar.nix {}; ydotool = handleTest ./ydotool.nix {}; yggdrasil = handleTest ./yggdrasil.nix {}; - your_spotify = handleTest ./your_spotify.nix {}; + your_spotify = runTest ./your_spotify.nix; zammad = runTest ./zammad.nix; zenohd = runTest ./zenohd.nix; zeronet-conservancy = runTest ./zeronet-conservancy.nix; diff --git a/nixos/tests/your_spotify.nix b/nixos/tests/your_spotify.nix index 9fdc2dad8eb5..c4935face7df 100644 --- a/nixos/tests/your_spotify.nix +++ b/nixos/tests/your_spotify.nix @@ -1,36 +1,34 @@ -import ./make-test-python.nix ( - { pkgs, ... }: - { - name = "your_spotify"; - meta = with pkgs.lib.maintainers; { - maintainers = [ patrickdag ]; - }; +{ pkgs, ... }: +{ + name = "your_spotify"; + meta = with pkgs.lib.maintainers; { + maintainers = [ patrickdag ]; + }; - nodes.machine = { - services.your_spotify = { - enable = true; - spotifySecretFile = pkgs.writeText "spotifySecretFile" "deadbeef"; - settings = { - CLIENT_ENDPOINT = "http://localhost"; - API_ENDPOINT = "http://localhost:3000"; - SPOTIFY_PUBLIC = "beefdead"; - }; - enableLocalDB = true; - nginxVirtualHost = "localhost"; + nodes.machine = { + services.your_spotify = { + enable = true; + spotifySecretFile = pkgs.writeText "spotifySecretFile" "deadbeef"; + settings = { + CLIENT_ENDPOINT = "http://localhost"; + API_ENDPOINT = "http://localhost:3000"; + SPOTIFY_PUBLIC = "beefdead"; }; + enableLocalDB = true; + nginxVirtualHost = "localhost"; }; + }; - testScript = '' - machine.wait_for_unit("your_spotify.service") + testScript = '' + machine.wait_for_unit("your_spotify.service") - machine.wait_for_open_port(3000) - machine.wait_for_open_port(80) + machine.wait_for_open_port(3000) + machine.wait_for_open_port(80) - out = machine.succeed("curl --fail -X GET 'http://localhost:3000/'") - assert "Hello !" in out + out = machine.succeed("curl --fail -X GET 'http://localhost:3000/'") + assert "Hello !" in out - out = machine.succeed("curl --fail -X GET 'http://localhost:80/'") - assert "Your Spotify" in out - ''; - } -) + out = machine.succeed("curl --fail -X GET 'http://localhost:80/'") + assert "Your Spotify" in out + ''; +} From 04a03a5c8cd708749ad0fe3662efc2a2236f94d3 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Fri, 14 Mar 2025 22:59:07 +0100 Subject: [PATCH 13/26] nixosTests.yggdrasil: migrate to runTest Part Of #386873 --- nixos/tests/all-tests.nix | 2 +- nixos/tests/yggdrasil.nix | 284 +++++++++++++++++++------------------- 2 files changed, 141 insertions(+), 145 deletions(-) diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 12b9f11fb6eb..e7261f0595b5 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -1300,7 +1300,7 @@ in { xxh = handleTest ./xxh.nix {}; yabar = handleTest ./yabar.nix {}; ydotool = handleTest ./ydotool.nix {}; - yggdrasil = handleTest ./yggdrasil.nix {}; + yggdrasil = runTest ./yggdrasil.nix; your_spotify = runTest ./your_spotify.nix; zammad = runTest ./zammad.nix; zenohd = runTest ./zenohd.nix; diff --git a/nixos/tests/yggdrasil.nix b/nixos/tests/yggdrasil.nix index 0d47a599f94c..e4b15a841cf4 100644 --- a/nixos/tests/yggdrasil.nix +++ b/nixos/tests/yggdrasil.nix @@ -25,173 +25,169 @@ let danIp6 = bobPrefix + "::2"; in -import ./make-test-python.nix ( - { pkgs, ... }: - { - name = "yggdrasil"; - meta = with pkgs.lib.maintainers; { - maintainers = [ gazally ]; - }; +{ pkgs, ... }: +{ + name = "yggdrasil"; + meta = with pkgs.lib.maintainers; { + maintainers = [ gazally ]; + }; - nodes = rec { - # Alice is listening for peerings on a specified port, - # but has multicast peering disabled. Alice has part of her - # yggdrasil config in Nix and part of it in a file. - alice = - { ... }: - { - networking = { - interfaces.eth1.ipv4.addresses = [ - { - address = "192.168.1.200"; - prefixLength = 24; - } - ]; - firewall.allowedTCPPorts = [ - 80 - 12345 - ]; + nodes = { + # Alice is listening for peerings on a specified port, + # but has multicast peering disabled. Alice has part of her + # yggdrasil config in Nix and part of it in a file. + alice = + { ... }: + { + networking = { + interfaces.eth1.ipv4.addresses = [ + { + address = "192.168.1.200"; + prefixLength = 24; + } + ]; + firewall.allowedTCPPorts = [ + 80 + 12345 + ]; + }; + services.httpd.enable = true; + services.httpd.adminAddr = "foo@example.org"; + + services.yggdrasil = { + enable = true; + settings = { + Listen = [ "tcp://0.0.0.0:12345" ]; + MulticastInterfaces = [ ]; }; - services.httpd.enable = true; - services.httpd.adminAddr = "foo@example.org"; + configFile = toString ( + pkgs.writeTextFile { + name = "yggdrasil-alice-conf"; + text = builtins.toJSON aliceKeys; + } + ); + }; + }; - services.yggdrasil = { - enable = true; - settings = { - Listen = [ "tcp://0.0.0.0:12345" ]; - MulticastInterfaces = [ ]; - }; - configFile = toString ( - pkgs.writeTextFile { - name = "yggdrasil-alice-conf"; - text = builtins.toJSON aliceKeys; + # Bob is set up to peer with Alice, and also to do local multicast + # peering. Bob's yggdrasil config is in a file. + bob = + { ... }: + { + networking.firewall.allowedTCPPorts = [ 54321 ]; + services.yggdrasil = { + enable = true; + openMulticastPort = true; + configFile = toString ( + pkgs.writeTextFile { + name = "yggdrasil-bob-conf"; + text = builtins.toJSON bobConfig; + } + ); + }; + + boot.kernel.sysctl."net.ipv6.conf.all.forwarding" = 1; + + networking = { + bridges.br0.interfaces = [ ]; + interfaces.br0 = { + ipv6.addresses = [ + { + address = bobPrefix + "::1"; + prefixLength = 64; } - ); + ]; }; }; - # Bob is set up to peer with Alice, and also to do local multicast - # peering. Bob's yggdrasil config is in a file. - bob = - { ... }: - { - networking.firewall.allowedTCPPorts = [ 54321 ]; - services.yggdrasil = { - enable = true; - openMulticastPort = true; - configFile = toString ( - pkgs.writeTextFile { - name = "yggdrasil-bob-conf"; - text = builtins.toJSON bobConfig; - } - ); - }; - - boot.kernel.sysctl."net.ipv6.conf.all.forwarding" = 1; - - networking = { - bridges.br0.interfaces = [ ]; - interfaces.br0 = { - ipv6.addresses = [ + # dan is a node inside a container running on bob's host. + containers.dan = { + autoStart = true; + privateNetwork = true; + hostBridge = "br0"; + config = { + networking.interfaces.eth0.ipv6 = { + addresses = [ { - address = bobPrefix + "::1"; + address = bobPrefix + "::2"; prefixLength = 64; } ]; - }; - }; - - # dan is a node inside a container running on bob's host. - containers.dan = { - autoStart = true; - privateNetwork = true; - hostBridge = "br0"; - config = - { config, pkgs, ... }: - { - networking.interfaces.eth0.ipv6 = { - addresses = [ - { - address = bobPrefix + "::2"; - prefixLength = 64; - } - ]; - routes = [ - { - address = "200::"; - prefixLength = 7; - via = bobPrefix + "::1"; - } - ]; - }; - services.httpd.enable = true; - services.httpd.adminAddr = "foo@example.org"; - networking.firewall.allowedTCPPorts = [ 80 ]; - }; - }; - }; - - # Carol only does local peering. Carol's yggdrasil config is all Nix. - carol = - { ... }: - { - networking.firewall.allowedTCPPorts = [ 43210 ]; - services.yggdrasil = { - enable = true; - extraArgs = [ - "-loglevel" - "error" - ]; - denyDhcpcdInterfaces = [ "ygg0" ]; - settings = { - IfTAPMode = true; - IfName = "ygg0"; - MulticastInterfaces = [ + routes = [ { - Port = 43210; + address = "200::"; + prefixLength = 7; + via = bobPrefix + "::1"; } ]; - openMulticastPort = true; }; - persistentKeys = true; + services.httpd.enable = true; + services.httpd.adminAddr = "foo@example.org"; + networking.firewall.allowedTCPPorts = [ 80 ]; }; }; - }; + }; - testScript = '' - import re + # Carol only does local peering. Carol's yggdrasil config is all Nix. + carol = + { ... }: + { + networking.firewall.allowedTCPPorts = [ 43210 ]; + services.yggdrasil = { + enable = true; + extraArgs = [ + "-loglevel" + "error" + ]; + denyDhcpcdInterfaces = [ "ygg0" ]; + settings = { + IfTAPMode = true; + IfName = "ygg0"; + MulticastInterfaces = [ + { + Port = 43210; + } + ]; + openMulticastPort = true; + }; + persistentKeys = true; + }; + }; + }; - # Give Alice a head start so she is ready when Bob calls. - alice.start() - alice.wait_for_unit("yggdrasil.service") + testScript = '' + import re - bob.start() - carol.start() - bob.wait_for_unit("default.target") - carol.wait_for_unit("yggdrasil.service") + # Give Alice a head start so she is ready when Bob calls. + alice.start() + alice.wait_for_unit("yggdrasil.service") - ip_addr_show = "ip -o -6 addr show dev ygg0 scope global" - carol.wait_until_succeeds(f"[ `{ip_addr_show} | grep -v tentative | wc -l` -ge 1 ]") - carol_ip6 = re.split(" +|/", carol.succeed(ip_addr_show))[3] + bob.start() + carol.start() + bob.wait_for_unit("default.target") + carol.wait_for_unit("yggdrasil.service") - # If Alice can talk to Carol, then Bob's outbound peering and Carol's - # local peering have succeeded and everybody is connected. - alice.wait_until_succeeds(f"ping -c 1 {carol_ip6}") - alice.succeed("ping -c 1 ${bobIp6}") + ip_addr_show = "ip -o -6 addr show dev ygg0 scope global" + carol.wait_until_succeeds(f"[ `{ip_addr_show} | grep -v tentative | wc -l` -ge 1 ]") + carol_ip6 = re.split(" +|/", carol.succeed(ip_addr_show))[3] - bob.succeed("ping -c 1 ${aliceIp6}") - bob.succeed(f"ping -c 1 {carol_ip6}") + # If Alice can talk to Carol, then Bob's outbound peering and Carol's + # local peering have succeeded and everybody is connected. + alice.wait_until_succeeds(f"ping -c 1 {carol_ip6}") + alice.succeed("ping -c 1 ${bobIp6}") - carol.succeed("ping -c 1 ${aliceIp6}") - carol.succeed("ping -c 1 ${bobIp6}") - carol.succeed("ping -c 1 ${bobPrefix}::1") - carol.succeed("ping -c 8 ${danIp6}") + bob.succeed("ping -c 1 ${aliceIp6}") + bob.succeed(f"ping -c 1 {carol_ip6}") - carol.fail("journalctl -u dhcpcd | grep ygg0") + carol.succeed("ping -c 1 ${aliceIp6}") + carol.succeed("ping -c 1 ${bobIp6}") + carol.succeed("ping -c 1 ${bobPrefix}::1") + carol.succeed("ping -c 8 ${danIp6}") - alice.wait_for_unit("httpd.service") - carol.succeed("curl --fail -g http://[${aliceIp6}]") - carol.succeed("curl --fail -g http://[${danIp6}]") - ''; - } -) + carol.fail("journalctl -u dhcpcd | grep ygg0") + + alice.wait_for_unit("httpd.service") + carol.succeed("curl --fail -g http://[${aliceIp6}]") + carol.succeed("curl --fail -g http://[${danIp6}]") + ''; +} From 1fd9bc9a380bcaf1caa6b95e47129e67ccaea911 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Fri, 14 Mar 2025 23:01:01 +0100 Subject: [PATCH 14/26] nixosTests.yabar: migrate to runTest Part Of #386873 --- nixos/tests/all-tests.nix | 2 +- nixos/tests/yabar.nix | 49 ++++++++++++++++++--------------------- 2 files changed, 24 insertions(+), 27 deletions(-) diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index e7261f0595b5..97c45e60c42c 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -1298,7 +1298,7 @@ in { xss-lock = handleTest ./xss-lock.nix {}; xterm = handleTest ./xterm.nix {}; xxh = handleTest ./xxh.nix {}; - yabar = handleTest ./yabar.nix {}; + yabar = runTest ./yabar.nix; ydotool = handleTest ./ydotool.nix {}; yggdrasil = runTest ./yggdrasil.nix; your_spotify = runTest ./your_spotify.nix; diff --git a/nixos/tests/yabar.nix b/nixos/tests/yabar.nix index 1c844677abbd..13a207f74829 100644 --- a/nixos/tests/yabar.nix +++ b/nixos/tests/yabar.nix @@ -1,33 +1,30 @@ -import ./make-test-python.nix ( - { pkgs, lib, ... }: - { - name = "yabar"; - meta.maintainers = [ ]; +{ + name = "yabar"; + meta.maintainers = [ ]; - nodes.machine = { - imports = [ - ./common/x11.nix - ./common/user-account.nix - ]; + nodes.machine = { + imports = [ + ./common/x11.nix + ./common/user-account.nix + ]; - test-support.displayManager.auto.user = "bob"; + test-support.displayManager.auto.user = "bob"; - programs.yabar.enable = true; - programs.yabar.bars = { - top.indicators.date.exec = "YABAR_DATE"; - }; + programs.yabar.enable = true; + programs.yabar.bars = { + top.indicators.date.exec = "YABAR_DATE"; }; + }; - testScript = '' - machine.start() - machine.wait_for_x() + testScript = '' + machine.start() + machine.wait_for_x() - # confirm proper startup - machine.wait_for_unit("yabar.service", "bob") - machine.sleep(10) - machine.wait_for_unit("yabar.service", "bob") + # confirm proper startup + machine.wait_for_unit("yabar.service", "bob") + machine.sleep(10) + machine.wait_for_unit("yabar.service", "bob") - machine.screenshot("top_bar") - ''; - } -) + machine.screenshot("top_bar") + ''; +} From 7c1bc83f5646cded9dd683370a74f9d126e1abde Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Fri, 14 Mar 2025 23:02:38 +0100 Subject: [PATCH 15/26] nixosTests.xxh: migrate to runTest Part Of #386873 --- nixos/tests/all-tests.nix | 2 +- nixos/tests/xxh.nix | 134 +++++++++++++++++++------------------- 2 files changed, 67 insertions(+), 69 deletions(-) diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 97c45e60c42c..86e33ce5b3d6 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -1297,7 +1297,7 @@ in { xscreensaver = handleTest ./xscreensaver.nix {}; xss-lock = handleTest ./xss-lock.nix {}; xterm = handleTest ./xterm.nix {}; - xxh = handleTest ./xxh.nix {}; + xxh = runTest ./xxh.nix; yabar = runTest ./yabar.nix; ydotool = handleTest ./ydotool.nix {}; yggdrasil = runTest ./yggdrasil.nix; diff --git a/nixos/tests/xxh.nix b/nixos/tests/xxh.nix index 03273ad775b5..a3080bdaf4ef 100644 --- a/nixos/tests/xxh.nix +++ b/nixos/tests/xxh.nix @@ -1,76 +1,74 @@ -import ./make-test-python.nix ( - { pkgs, lib, ... }: +{ pkgs, lib, ... }: - let - inherit (import ./ssh-keys.nix pkgs) snakeOilPrivateKey snakeOilPublicKey; - xxh-shell-zsh = pkgs.stdenv.mkDerivation { - pname = "xxh-shell-zsh"; - version = ""; - src = pkgs.fetchFromGitHub { - owner = "xxh"; - repo = "xxh-shell-zsh"; - # gets rarely updated, we can then just replace the hash - rev = "91e1f84f8d6e0852c3235d4813f341230cac439f"; - sha256 = "sha256-Y1FrIRxTd0yooK+ZzKcCd6bLSy5E2fRXYAzrIsm7rIc="; +let + inherit (import ./ssh-keys.nix pkgs) snakeOilPrivateKey snakeOilPublicKey; + xxh-shell-zsh = pkgs.stdenv.mkDerivation { + pname = "xxh-shell-zsh"; + version = ""; + src = pkgs.fetchFromGitHub { + owner = "xxh"; + repo = "xxh-shell-zsh"; + # gets rarely updated, we can then just replace the hash + rev = "91e1f84f8d6e0852c3235d4813f341230cac439f"; + sha256 = "sha256-Y1FrIRxTd0yooK+ZzKcCd6bLSy5E2fRXYAzrIsm7rIc="; + }; + + postPatch = '' + substituteInPlace build.sh \ + --replace "echo Install wget or curl" "cp ${zsh-portable-binary} zsh-5.8-linux-x86_64.tar.gz" \ + --replace "command -v curl" "command -v this-should-not-trigger" + ''; + + installPhase = '' + mkdir -p $out + mv * $out/ + ''; + }; + + zsh-portable-binary = pkgs.fetchurl { + # kept in sync with https://github.com/xxh/xxh-shell-zsh/tree/master/build.sh#L27 + url = "https://github.com/romkatv/zsh-bin/releases/download/v3.0.1/zsh-5.8-linux-x86_64.tar.gz"; + sha256 = "sha256-i8flMd2Isc0uLoeYQNDnOGb/kK3oTFVqQgIx7aOAIIo="; + }; +in +{ + name = "xxh"; + meta = with lib.maintainers; { + maintainers = [ lom ]; + }; + + nodes = { + server = + { ... }: + { + services.openssh.enable = true; + users.users.root.openssh.authorizedKeys.keys = [ snakeOilPublicKey ]; }; - postPatch = '' - substituteInPlace build.sh \ - --replace "echo Install wget or curl" "cp ${zsh-portable-binary} zsh-5.8-linux-x86_64.tar.gz" \ - --replace "command -v curl" "command -v this-should-not-trigger" - ''; + client = + { ... }: + { + programs.zsh.enable = true; + users.users.root.shell = pkgs.zsh; + environment.systemPackages = with pkgs; [ + xxh + git + ]; + }; + }; - installPhase = '' - mkdir -p $out - mv * $out/ - ''; - }; + testScript = '' + start_all() - zsh-portable-binary = pkgs.fetchurl { - # kept in sync with https://github.com/xxh/xxh-shell-zsh/tree/master/build.sh#L27 - url = "https://github.com/romkatv/zsh-bin/releases/download/v3.0.1/zsh-5.8-linux-x86_64.tar.gz"; - sha256 = "sha256-i8flMd2Isc0uLoeYQNDnOGb/kK3oTFVqQgIx7aOAIIo="; - }; - in - { - name = "xxh"; - meta = with lib.maintainers; { - maintainers = [ lom ]; - }; + client.succeed("mkdir -m 700 /root/.ssh") - nodes = { - server = - { ... }: - { - services.openssh.enable = true; - users.users.root.openssh.authorizedKeys.keys = [ snakeOilPublicKey ]; - }; + client.succeed( + "cat ${snakeOilPrivateKey} > /root/.ssh/id_ecdsa" + ) + client.succeed("chmod 600 /root/.ssh/id_ecdsa") - client = - { ... }: - { - programs.zsh.enable = true; - users.users.root.shell = pkgs.zsh; - environment.systemPackages = with pkgs; [ - xxh - git - ]; - }; - }; + server.wait_for_unit("sshd") - testScript = '' - start_all() - - client.succeed("mkdir -m 700 /root/.ssh") - - client.succeed( - "cat ${snakeOilPrivateKey} > /root/.ssh/id_ecdsa" - ) - client.succeed("chmod 600 /root/.ssh/id_ecdsa") - - server.wait_for_unit("sshd") - - client.succeed("xxh server -i /root/.ssh/id_ecdsa +hc \'echo $0\' +i +s zsh +I xxh-shell-zsh+path+${xxh-shell-zsh} | grep -Fq '/root/.xxh/.xxh/shells/xxh-shell-zsh/build/zsh-bin/bin/zsh'") - ''; - } -) + client.succeed("xxh server -i /root/.ssh/id_ecdsa +hc \'echo $0\' +i +s zsh +I xxh-shell-zsh+path+${xxh-shell-zsh} | grep -Fq '/root/.xxh/.xxh/shells/xxh-shell-zsh/build/zsh-bin/bin/zsh'") + ''; +} From 20ad3329fe4305b15f9c3b8a01b75c43d83fbe74 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Fri, 14 Mar 2025 23:03:42 +0100 Subject: [PATCH 16/26] nixosTests.xterm: migrate to runTest Part Of #386873 --- nixos/tests/all-tests.nix | 2 +- nixos/tests/xterm.nix | 44 ++++++++++++++++++--------------------- 2 files changed, 21 insertions(+), 25 deletions(-) diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 86e33ce5b3d6..cb712b8e2aa6 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -1296,7 +1296,7 @@ in { xrdp-with-audio-pulseaudio = handleTest ./xrdp-with-audio-pulseaudio.nix {}; xscreensaver = handleTest ./xscreensaver.nix {}; xss-lock = handleTest ./xss-lock.nix {}; - xterm = handleTest ./xterm.nix {}; + xterm = runTest ./xterm.nix; xxh = runTest ./xxh.nix; yabar = runTest ./yabar.nix; ydotool = handleTest ./ydotool.nix {}; diff --git a/nixos/tests/xterm.nix b/nixos/tests/xterm.nix index 52a7b431a44e..caf1780d1565 100644 --- a/nixos/tests/xterm.nix +++ b/nixos/tests/xterm.nix @@ -1,26 +1,22 @@ -import ./make-test-python.nix ( - { pkgs, ... }: - { - name = "xterm"; - meta = with pkgs.lib.maintainers; { - maintainers = [ nequissimus ]; - }; +{ pkgs, ... }: +{ + name = "xterm"; + meta = with pkgs.lib.maintainers; { + maintainers = [ nequissimus ]; + }; - nodes.machine = - { pkgs, ... }: - { - imports = [ ./common/x11.nix ]; - services.xserver.desktopManager.xterm.enable = false; - }; + nodes.machine = { + imports = [ ./common/x11.nix ]; + services.xserver.desktopManager.xterm.enable = false; + }; - testScript = '' - machine.wait_for_x() - machine.succeed("DISPLAY=:0 xterm -title testterm -class testterm -fullscreen >&2 &") - machine.sleep(2) - machine.send_chars("echo $XTERM_VERSION >> /tmp/xterm_version\n") - machine.wait_for_file("/tmp/xterm_version") - assert "${pkgs.xterm.version}" in machine.succeed("cat /tmp/xterm_version") - machine.screenshot("window") - ''; - } -) + testScript = '' + machine.wait_for_x() + machine.succeed("DISPLAY=:0 xterm -title testterm -class testterm -fullscreen >&2 &") + machine.sleep(2) + machine.send_chars("echo $XTERM_VERSION >> /tmp/xterm_version\n") + machine.wait_for_file("/tmp/xterm_version") + assert "${pkgs.xterm.version}" in machine.succeed("cat /tmp/xterm_version") + machine.screenshot("window") + ''; +} From 650ab40c8146822cdb76f1b8eb72c60a9dcf825d Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Fri, 14 Mar 2025 23:07:18 +0100 Subject: [PATCH 17/26] nixosTests.xss-lock: migrate to runTest Part Of #386873 --- nixos/tests/all-tests.nix | 2 +- nixos/tests/xss-lock.nix | 79 +++++++++++++++++++-------------------- 2 files changed, 39 insertions(+), 42 deletions(-) diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index cb712b8e2aa6..5bc923268fae 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -1295,7 +1295,7 @@ in { xrdp = handleTest ./xrdp.nix {}; xrdp-with-audio-pulseaudio = handleTest ./xrdp-with-audio-pulseaudio.nix {}; xscreensaver = handleTest ./xscreensaver.nix {}; - xss-lock = handleTest ./xss-lock.nix {}; + xss-lock = runTest ./xss-lock.nix; xterm = runTest ./xterm.nix; xxh = runTest ./xxh.nix; yabar = runTest ./yabar.nix; diff --git a/nixos/tests/xss-lock.nix b/nixos/tests/xss-lock.nix index f46db1e49c28..fb09715fc166 100644 --- a/nixos/tests/xss-lock.nix +++ b/nixos/tests/xss-lock.nix @@ -1,54 +1,51 @@ -import ./make-test-python.nix ( - { pkgs, lib, ... }: - { - name = "xss-lock"; - meta.maintainers = [ ]; +{ + name = "xss-lock"; + meta.maintainers = [ ]; - nodes = { - simple = { + nodes = { + simple = { + imports = [ + ./common/x11.nix + ./common/user-account.nix + ]; + programs.xss-lock.enable = true; + test-support.displayManager.auto.user = "alice"; + }; + + custom_lockcmd = + { pkgs, ... }: + { imports = [ ./common/x11.nix ./common/user-account.nix ]; - programs.xss-lock.enable = true; test-support.displayManager.auto.user = "alice"; - }; - custom_lockcmd = - { pkgs, ... }: - { - imports = [ - ./common/x11.nix - ./common/user-account.nix + programs.xss-lock = { + enable = true; + extraOptions = [ + "-n" + "${pkgs.libnotify}/bin/notify-send 'About to sleep!'" ]; - test-support.displayManager.auto.user = "alice"; - - programs.xss-lock = { - enable = true; - extraOptions = [ - "-n" - "${pkgs.libnotify}/bin/notify-send 'About to sleep!'" - ]; - lockerCommand = "${pkgs.xlockmore}/bin/xlock -mode ant"; - }; + lockerCommand = "${pkgs.xlockmore}/bin/xlock -mode ant"; }; - }; + }; + }; - testScript = '' - def perform_xsslock_test(machine, lockCmd): - machine.start() - machine.wait_for_x() - machine.wait_for_unit("xss-lock.service", "alice") - machine.fail(f"pgrep {lockCmd}") - machine.succeed("su -l alice -c 'xset dpms force standby'") - machine.wait_until_succeeds(f"pgrep {lockCmd}") + testScript = '' + def perform_xsslock_test(machine, lockCmd): + machine.start() + machine.wait_for_x() + machine.wait_for_unit("xss-lock.service", "alice") + machine.fail(f"pgrep {lockCmd}") + machine.succeed("su -l alice -c 'xset dpms force standby'") + machine.wait_until_succeeds(f"pgrep {lockCmd}") - with subtest("simple"): - perform_xsslock_test(simple, "i3lock") + with subtest("simple"): + perform_xsslock_test(simple, "i3lock") - with subtest("custom_cmd"): - perform_xsslock_test(custom_lockcmd, "xlock") - ''; - } -) + with subtest("custom_cmd"): + perform_xsslock_test(custom_lockcmd, "xlock") + ''; +} From 2af95991abbfb7ca6dc0831cac3b105c13ef86a0 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Fri, 14 Mar 2025 23:09:47 +0100 Subject: [PATCH 18/26] nixosTests.xrdp-with-audio-pulseaudio: migrate to runTest Part Of #386873 --- nixos/tests/all-tests.nix | 2 +- nixos/tests/xrdp-with-audio-pulseaudio.nix | 170 ++++++++++----------- 2 files changed, 85 insertions(+), 87 deletions(-) diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 5bc923268fae..b96f805068d4 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -1293,7 +1293,7 @@ in { xmonad-xdg-autostart = handleTest ./xmonad-xdg-autostart.nix {}; xpadneo = handleTest ./xpadneo.nix {}; xrdp = handleTest ./xrdp.nix {}; - xrdp-with-audio-pulseaudio = handleTest ./xrdp-with-audio-pulseaudio.nix {}; + xrdp-with-audio-pulseaudio = runTest ./xrdp-with-audio-pulseaudio.nix; xscreensaver = handleTest ./xscreensaver.nix {}; xss-lock = runTest ./xss-lock.nix; xterm = runTest ./xterm.nix; diff --git a/nixos/tests/xrdp-with-audio-pulseaudio.nix b/nixos/tests/xrdp-with-audio-pulseaudio.nix index a10e6b85326c..cc630143b990 100644 --- a/nixos/tests/xrdp-with-audio-pulseaudio.nix +++ b/nixos/tests/xrdp-with-audio-pulseaudio.nix @@ -1,110 +1,108 @@ -import ./make-test-python.nix ( - { pkgs, ... }: - { - # How to interactively test this module if the audio actually works +{ pkgs, ... }: +{ + # How to interactively test this module if the audio actually works - # - nix run .#pulseaudio-module-xrdp.tests.xrdp-with-audio-pulseaudio.driverInteractive - # - test_script() # launches the terminal and the tests itself - # - server.send_monitor_command("hostfwd_add tcp::3389-:3389") # forward the RDP port to the host - # - Connect with the RDP client you like (ex: Remmina) - # - Don't forget to enable audio support. In remmina: Advanced -> Audio output mode to Local (default is Off) - # - Open a browser or something that plays sound. Ex: chromium + # - nix run .#pulseaudio-module-xrdp.tests.xrdp-with-audio-pulseaudio.driverInteractive + # - test_script() # launches the terminal and the tests itself + # - server.send_monitor_command("hostfwd_add tcp::3389-:3389") # forward the RDP port to the host + # - Connect with the RDP client you like (ex: Remmina) + # - Don't forget to enable audio support. In remmina: Advanced -> Audio output mode to Local (default is Off) + # - Open a browser or something that plays sound. Ex: chromium - name = "xrdp-with-audio-pulseaudio"; - meta = with pkgs.lib.maintainers; { - maintainers = [ lucasew ]; - }; + name = "xrdp-with-audio-pulseaudio"; + meta = with pkgs.lib.maintainers; { + maintainers = [ lucasew ]; + }; - nodes = { - server = - { pkgs, ... }: - { - imports = [ ./common/user-account.nix ]; + nodes = { + server = + { pkgs, ... }: + { + imports = [ ./common/user-account.nix ]; - environment.etc."xrdp/test.txt".text = "Shouldn't conflict"; + environment.etc."xrdp/test.txt".text = "Shouldn't conflict"; - services.xrdp.enable = true; - services.xrdp.audio.enable = true; - services.xrdp.defaultWindowManager = "${pkgs.xterm}/bin/xterm"; + services.xrdp.enable = true; + services.xrdp.audio.enable = true; + services.xrdp.defaultWindowManager = "${pkgs.xterm}/bin/xterm"; - services.pulseaudio = { - enable = true; - }; + services.pulseaudio = { + enable = true; + }; - systemd.user.services.pactl-list = { - script = '' - while [ ! -S /tmp/.xrdp/xrdp_chansrv_audio_in_socket_* ]; do - sleep 1 - done + systemd.user.services.pactl-list = { + script = '' + while [ ! -S /tmp/.xrdp/xrdp_chansrv_audio_in_socket_* ]; do sleep 1 - ${pkgs.pulseaudio}/bin/pactl list - echo Source: - ${pkgs.pulseaudio}/bin/pactl get-default-source | tee /tmp/pulseaudio-source - echo Sink: - ${pkgs.pulseaudio}/bin/pactl get-default-sink | tee /tmp/pulseaudio-sink + done + sleep 1 + ${pkgs.pulseaudio}/bin/pactl list + echo Source: + ${pkgs.pulseaudio}/bin/pactl get-default-source | tee /tmp/pulseaudio-source + echo Sink: + ${pkgs.pulseaudio}/bin/pactl get-default-sink | tee /tmp/pulseaudio-sink - ''; - wantedBy = [ "default.target" ]; - }; - - networking.firewall.allowedTCPPorts = [ 3389 ]; + ''; + wantedBy = [ "default.target" ]; }; - client = - { pkgs, ... }: - { - imports = [ - ./common/x11.nix - ./common/user-account.nix - ]; - test-support.displayManager.auto.user = "alice"; + networking.firewall.allowedTCPPorts = [ 3389 ]; + }; - environment.systemPackages = [ pkgs.freerdp ]; + client = + { pkgs, ... }: + { + imports = [ + ./common/x11.nix + ./common/user-account.nix + ]; + test-support.displayManager.auto.user = "alice"; - services.xrdp.enable = true; - services.xrdp.audio.enable = true; - services.xrdp.defaultWindowManager = "${pkgs.icewm}/bin/icewm"; + environment.systemPackages = [ pkgs.freerdp ]; - services.pulseaudio = { - enable = true; - }; + services.xrdp.enable = true; + services.xrdp.audio.enable = true; + services.xrdp.defaultWindowManager = "${pkgs.icewm}/bin/icewm"; + + services.pulseaudio = { + enable = true; }; - }; + }; + }; - testScript = - { nodes, ... }: - let - user = nodes.client.config.users.users.alice; - in - '' - start_all() + testScript = + { nodes, ... }: + let + user = nodes.client.config.users.users.alice; + in + '' + start_all() - client.wait_for_x() - client.wait_for_file("${user.home}/.Xauthority") - client.succeed("xauth merge ${user.home}/.Xauthority") + client.wait_for_x() + client.wait_for_file("${user.home}/.Xauthority") + client.succeed("xauth merge ${user.home}/.Xauthority") - client.sleep(5) + client.sleep(5) - client.execute("xterm >&2 &") - client.sleep(1) + client.execute("xterm >&2 &") + client.sleep(1) - client.send_chars("xfreerdp /cert-tofu /w:640 /h:480 /v:127.0.0.1 /u:${user.name} /p:${user.password} /sound\n") + client.send_chars("xfreerdp /cert-tofu /w:640 /h:480 /v:127.0.0.1 /u:${user.name} /p:${user.password} /sound\n") - client.sleep(10) + client.sleep(10) - client.succeed("[ -S /tmp/.xrdp/xrdp_chansrv_audio_in_socket_* ]") # checks if it's a socket - client.sleep(5) - client.screenshot("localrdp") + client.succeed("[ -S /tmp/.xrdp/xrdp_chansrv_audio_in_socket_* ]") # checks if it's a socket + client.sleep(5) + client.screenshot("localrdp") - client.execute("xterm >&2 &") - client.sleep(1) - client.send_chars("xfreerdp /cert-tofu /w:640 /h:480 /v:server /u:${user.name} /p:${user.password} /sound\n") - client.sleep(10) + client.execute("xterm >&2 &") + client.sleep(1) + client.send_chars("xfreerdp /cert-tofu /w:640 /h:480 /v:server /u:${user.name} /p:${user.password} /sound\n") + client.sleep(10) - server.succeed("[ -S /tmp/.xrdp/xrdp_chansrv_audio_in_socket_* ]") # checks if it's a socket - server.succeed('[ "$(cat /tmp/pulseaudio-source)" == "xrdp-source" ]') - server.succeed('[ "$(cat /tmp/pulseaudio-sink)" == "xrdp-sink" ]') - client.screenshot("remoterdp") - ''; - } -) + server.succeed("[ -S /tmp/.xrdp/xrdp_chansrv_audio_in_socket_* ]") # checks if it's a socket + server.succeed('[ "$(cat /tmp/pulseaudio-source)" == "xrdp-source" ]') + server.succeed('[ "$(cat /tmp/pulseaudio-sink)" == "xrdp-sink" ]') + client.screenshot("remoterdp") + ''; +} From 6d1946030c931e26b0d1431057249f60e49b34e6 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Fri, 14 Mar 2025 23:15:25 +0100 Subject: [PATCH 19/26] nixosTests.xrdp: migrate to runTest Part Of #386873 --- nixos/tests/all-tests.nix | 2 +- nixos/tests/xrdp.nix | 104 +++++++++++++++++++------------------- 2 files changed, 52 insertions(+), 54 deletions(-) diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index b96f805068d4..0777f5a7b9cf 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -1292,7 +1292,7 @@ in { xmonad = handleTest ./xmonad.nix {}; xmonad-xdg-autostart = handleTest ./xmonad-xdg-autostart.nix {}; xpadneo = handleTest ./xpadneo.nix {}; - xrdp = handleTest ./xrdp.nix {}; + xrdp = runTest ./xrdp.nix; xrdp-with-audio-pulseaudio = runTest ./xrdp-with-audio-pulseaudio.nix; xscreensaver = handleTest ./xscreensaver.nix {}; xss-lock = runTest ./xss-lock.nix; diff --git a/nixos/tests/xrdp.nix b/nixos/tests/xrdp.nix index 10cc80de5056..fdf598a87467 100644 --- a/nixos/tests/xrdp.nix +++ b/nixos/tests/xrdp.nix @@ -1,60 +1,58 @@ -import ./make-test-python.nix ( - { pkgs, ... }: - { - name = "xrdp"; - meta = with pkgs.lib.maintainers; { - maintainers = [ ]; - }; +{ pkgs, ... }: +{ + name = "xrdp"; + meta = with pkgs.lib.maintainers; { + maintainers = [ ]; + }; - nodes = { - server = - { pkgs, ... }: - { - imports = [ ./common/user-account.nix ]; - services.xrdp.enable = true; - services.xrdp.defaultWindowManager = "${pkgs.xterm}/bin/xterm"; - networking.firewall.allowedTCPPorts = [ 3389 ]; - }; + nodes = { + server = + { pkgs, ... }: + { + imports = [ ./common/user-account.nix ]; + services.xrdp.enable = true; + services.xrdp.defaultWindowManager = "${pkgs.xterm}/bin/xterm"; + networking.firewall.allowedTCPPorts = [ 3389 ]; + }; - client = - { pkgs, ... }: - { - imports = [ - ./common/x11.nix - ./common/user-account.nix - ]; - test-support.displayManager.auto.user = "alice"; - environment.systemPackages = [ pkgs.freerdp ]; - services.xrdp.enable = true; - services.xrdp.defaultWindowManager = "${pkgs.icewm}/bin/icewm"; - }; - }; + client = + { pkgs, ... }: + { + imports = [ + ./common/x11.nix + ./common/user-account.nix + ]; + test-support.displayManager.auto.user = "alice"; + environment.systemPackages = [ pkgs.freerdp ]; + services.xrdp.enable = true; + services.xrdp.defaultWindowManager = "${pkgs.icewm}/bin/icewm"; + }; + }; - testScript = - { nodes, ... }: - let - user = nodes.client.config.users.users.alice; - in - '' - start_all() + testScript = + { nodes, ... }: + let + user = nodes.client.users.users.alice; + in + '' + start_all() - client.wait_for_x() - client.wait_for_file("${user.home}/.Xauthority") - client.succeed("xauth merge ${user.home}/.Xauthority") + client.wait_for_x() + client.wait_for_file("${user.home}/.Xauthority") + client.succeed("xauth merge ${user.home}/.Xauthority") - client.sleep(5) + client.sleep(5) - client.execute("xterm >&2 &") - client.sleep(1) - client.send_chars("xfreerdp /cert-tofu /w:640 /h:480 /v:127.0.0.1 /u:${user.name} /p:${user.password}\n") - client.sleep(5) - client.screenshot("localrdp") + client.execute("xterm >&2 &") + client.sleep(1) + client.send_chars("xfreerdp /cert-tofu /w:640 /h:480 /v:127.0.0.1 /u:${user.name} /p:${user.password}\n") + client.sleep(5) + client.screenshot("localrdp") - client.execute("xterm >&2 &") - client.sleep(1) - client.send_chars("xfreerdp /cert-tofu /w:640 /h:480 /v:server /u:${user.name} /p:${user.password}\n") - client.sleep(5) - client.screenshot("remoterdp") - ''; - } -) + client.execute("xterm >&2 &") + client.sleep(1) + client.send_chars("xfreerdp /cert-tofu /w:640 /h:480 /v:server /u:${user.name} /p:${user.password}\n") + client.sleep(5) + client.screenshot("remoterdp") + ''; +} From 6a13f858bd8d8f3ea078ee3b4d37a0b821381ba6 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Fri, 14 Mar 2025 23:18:18 +0100 Subject: [PATCH 20/26] nixosTests.xpadneo: migrate to runTest Part Of #386873 --- nixos/tests/all-tests.nix | 2 +- nixos/tests/xpadneo.nix | 34 ++++++++++++++++------------------ 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 0777f5a7b9cf..21ef7545a853 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -1291,7 +1291,7 @@ in { xfce-wayland = handleTest ./xfce-wayland.nix {}; xmonad = handleTest ./xmonad.nix {}; xmonad-xdg-autostart = handleTest ./xmonad-xdg-autostart.nix {}; - xpadneo = handleTest ./xpadneo.nix {}; + xpadneo = runTest ./xpadneo.nix; xrdp = runTest ./xrdp.nix; xrdp-with-audio-pulseaudio = runTest ./xrdp-with-audio-pulseaudio.nix; xscreensaver = handleTest ./xscreensaver.nix {}; diff --git a/nixos/tests/xpadneo.nix b/nixos/tests/xpadneo.nix index 20ddf4c9d048..4c639a986128 100644 --- a/nixos/tests/xpadneo.nix +++ b/nixos/tests/xpadneo.nix @@ -1,21 +1,19 @@ -import ./make-test-python.nix ( - { lib, pkgs, ... }: - { - name = "xpadneo"; - meta.maintainers = with lib.maintainers; [ kira-bruneau ]; +{ lib, pkgs, ... }: +{ + name = "xpadneo"; + meta.maintainers = with lib.maintainers; [ kira-bruneau ]; - nodes = { - machine = { - config.hardware.xpadneo.enable = true; - }; + nodes = { + machine = { + config.hardware.xpadneo.enable = true; }; + }; - # This is just a sanity check to make sure the module was - # loaded. We'd have to find some way to mock an xbox controller if - # we wanted more in-depth testing. - testScript = '' - machine.start(); - machine.succeed("modinfo hid_xpadneo | grep 'version:\s\+${pkgs.linuxPackages.xpadneo.version}'") - ''; - } -) + # This is just a sanity check to make sure the module was + # loaded. We'd have to find some way to mock an xbox controller if + # we wanted more in-depth testing. + testScript = '' + machine.start(); + machine.succeed("modinfo hid_xpadneo | grep 'version:\s\+${pkgs.linuxPackages.xpadneo.version}'") + ''; +} From 4ada7d8158d069dcfc1b6245a4074c7ac812261a Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Fri, 14 Mar 2025 23:20:54 +0100 Subject: [PATCH 21/26] nixosTests.xmonad-xdg-autostart: migrate to runTest Part Of #386873 --- nixos/tests/all-tests.nix | 2 +- nixos/tests/xmonad-xdg-autostart.nix | 80 ++++++++++++++-------------- 2 files changed, 40 insertions(+), 42 deletions(-) diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 21ef7545a853..9f06d7040844 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -1290,7 +1290,7 @@ in { xfce = handleTest ./xfce.nix {}; xfce-wayland = handleTest ./xfce-wayland.nix {}; xmonad = handleTest ./xmonad.nix {}; - xmonad-xdg-autostart = handleTest ./xmonad-xdg-autostart.nix {}; + xmonad-xdg-autostart = runTest ./xmonad-xdg-autostart.nix; xpadneo = runTest ./xpadneo.nix; xrdp = runTest ./xrdp.nix; xrdp-with-audio-pulseaudio = runTest ./xrdp-with-audio-pulseaudio.nix; diff --git a/nixos/tests/xmonad-xdg-autostart.nix b/nixos/tests/xmonad-xdg-autostart.nix index 419b3e413a08..76ea97c6a0c1 100644 --- a/nixos/tests/xmonad-xdg-autostart.nix +++ b/nixos/tests/xmonad-xdg-autostart.nix @@ -1,44 +1,42 @@ -import ./make-test-python.nix ( - { lib, ... }: - { - name = "xmonad-xdg-autostart"; - meta.maintainers = with lib.maintainers; [ oxalica ]; +{ lib, ... }: +{ + name = "xmonad-xdg-autostart"; + meta.maintainers = with lib.maintainers; [ oxalica ]; - nodes.machine = - { pkgs, config, ... }: - { - imports = [ - ./common/x11.nix - ./common/user-account.nix - ]; - test-support.displayManager.auto.user = "alice"; - services.displayManager.defaultSession = "none+xmonad"; - services.xserver.windowManager.xmonad.enable = true; - services.xserver.desktopManager.runXdgAutostartIfNone = true; + nodes.machine = + { pkgs, config, ... }: + { + imports = [ + ./common/x11.nix + ./common/user-account.nix + ]; + test-support.displayManager.auto.user = "alice"; + services.displayManager.defaultSession = "none+xmonad"; + services.xserver.windowManager.xmonad.enable = true; + services.xserver.desktopManager.runXdgAutostartIfNone = true; - environment.systemPackages = [ - (pkgs.writeTextFile { - name = "test-xdg-autostart"; - destination = "/etc/xdg/autostart/test-xdg-autostart.desktop"; - text = '' - [Desktop Entry] - Name=test-xdg-autoatart - Type=Application - Terminal=false - Exec=${pkgs.coreutils}/bin/touch ${config.users.users.alice.home}/xdg-autostart-executed - ''; - }) - ]; - }; + environment.systemPackages = [ + (pkgs.writeTextFile { + name = "test-xdg-autostart"; + destination = "/etc/xdg/autostart/test-xdg-autostart.desktop"; + text = '' + [Desktop Entry] + Name=test-xdg-autoatart + Type=Application + Terminal=false + Exec=${pkgs.coreutils}/bin/touch ${config.users.users.alice.home}/xdg-autostart-executed + ''; + }) + ]; + }; - testScript = - { nodes, ... }: - let - user = nodes.machine.config.users.users.alice; - in - '' - machine.wait_for_x() - machine.wait_for_file("${user.home}/xdg-autostart-executed") - ''; - } -) + testScript = + { nodes, ... }: + let + user = nodes.machine.users.users.alice; + in + '' + machine.wait_for_x() + machine.wait_for_file("${user.home}/xdg-autostart-executed") + ''; +} From ead8dabde044003989e98b2c582a694d4e58dffd Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Fri, 14 Mar 2025 23:21:51 +0100 Subject: [PATCH 22/26] nixosTests.xmonad: migrate to runTest Part Of #386873 --- nixos/tests/all-tests.nix | 2 +- nixos/tests/xmonad.nix | 222 +++++++++++++++++++------------------- 2 files changed, 111 insertions(+), 113 deletions(-) diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 9f06d7040844..17252dbae27b 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -1289,7 +1289,7 @@ in { xautolock = handleTest ./xautolock.nix {}; xfce = handleTest ./xfce.nix {}; xfce-wayland = handleTest ./xfce-wayland.nix {}; - xmonad = handleTest ./xmonad.nix {}; + xmonad = runTest ./xmonad.nix; xmonad-xdg-autostart = runTest ./xmonad-xdg-autostart.nix; xpadneo = runTest ./xpadneo.nix; xrdp = runTest ./xrdp.nix; diff --git a/nixos/tests/xmonad.nix b/nixos/tests/xmonad.nix index 803d468bd12f..2bc171917cc4 100644 --- a/nixos/tests/xmonad.nix +++ b/nixos/tests/xmonad.nix @@ -1,131 +1,129 @@ -import ./make-test-python.nix ( - { pkgs, ... }: +{ pkgs, ... }: - let - mkConfig = name: keys: '' - import XMonad - import XMonad.Operations (restart) - import XMonad.Util.EZConfig - import XMonad.Util.SessionStart - import Control.Monad (when) - import Text.Printf (printf) - import System.Posix.Process (executeFile) - import System.Info (arch,os) - import System.Environment (getArgs) - import System.FilePath (()) +let + mkConfig = name: keys: '' + import XMonad + import XMonad.Operations (restart) + import XMonad.Util.EZConfig + import XMonad.Util.SessionStart + import Control.Monad (when) + import Text.Printf (printf) + import System.Posix.Process (executeFile) + import System.Info (arch,os) + import System.Environment (getArgs) + import System.FilePath (()) - main = do - dirs <- getDirectories - launch (def { startupHook = startup } `additionalKeysP` myKeys) dirs + main = do + dirs <- getDirectories + launch (def { startupHook = startup } `additionalKeysP` myKeys) dirs - startup = isSessionStart >>= \sessInit -> - spawn "touch /tmp/${name}" - >> if sessInit then setSessionStarted else spawn "xterm" + startup = isSessionStart >>= \sessInit -> + spawn "touch /tmp/${name}" + >> if sessInit then setSessionStarted else spawn "xterm" - myKeys = [${builtins.concatStringsSep ", " keys}] + myKeys = [${builtins.concatStringsSep ", " keys}] - compiledConfig = printf "xmonad-%s-%s" arch os + compiledConfig = printf "xmonad-%s-%s" arch os - compileRestart resume = do - dirs <- asks directories + compileRestart resume = do + dirs <- asks directories - whenX (recompile dirs True) $ - when resume writeStateToFile - *> catchIO - ( do - args <- getArgs - executeFile (cacheDir dirs compiledConfig) False args Nothing - ) - ''; + whenX (recompile dirs True) $ + when resume writeStateToFile + *> catchIO + ( do + args <- getArgs + executeFile (cacheDir dirs compiledConfig) False args Nothing + ) + ''; - oldKeys = [ - ''("M-C-x", spawn "xterm")'' - ''("M-q", restart "xmonad" True)'' - ''("M-C-q", compileRestart True)'' - ''("M-C-t", spawn "touch /tmp/somefile")'' # create somefile + oldKeys = [ + ''("M-C-x", spawn "xterm")'' + ''("M-q", restart "xmonad" True)'' + ''("M-C-q", compileRestart True)'' + ''("M-C-t", spawn "touch /tmp/somefile")'' # create somefile + ]; + + newKeys = [ + ''("M-C-x", spawn "xterm")'' + ''("M-q", restart "xmonad" True)'' + ''("M-C-q", compileRestart True)'' + ''("M-C-r", spawn "rm /tmp/somefile")'' # delete somefile + ]; + + newConfig = pkgs.writeText "xmonad.hs" (mkConfig "newXMonad" newKeys); +in +{ + name = "xmonad"; + meta = with pkgs.lib.maintainers; { + maintainers = [ + nequissimus + ivanbrennan ]; + }; - newKeys = [ - ''("M-C-x", spawn "xterm")'' - ''("M-q", restart "xmonad" True)'' - ''("M-C-q", compileRestart True)'' - ''("M-C-r", spawn "rm /tmp/somefile")'' # delete somefile - ]; - - newConfig = pkgs.writeText "xmonad.hs" (mkConfig "newXMonad" newKeys); - in - { - name = "xmonad"; - meta = with pkgs.lib.maintainers; { - maintainers = [ - nequissimus - ivanbrennan + nodes.machine = + { pkgs, ... }: + { + imports = [ + ./common/x11.nix + ./common/user-account.nix ]; + test-support.displayManager.auto.user = "alice"; + services.displayManager.defaultSession = "none+xmonad"; + services.xserver.windowManager.xmonad = { + enable = true; + enableConfiguredRecompile = true; + enableContribAndExtras = true; + extraPackages = with pkgs.haskellPackages; haskellPackages: [ xmobar ]; + config = mkConfig "oldXMonad" oldKeys; + }; }; - nodes.machine = - { pkgs, ... }: - { - imports = [ - ./common/x11.nix - ./common/user-account.nix - ]; - test-support.displayManager.auto.user = "alice"; - services.displayManager.defaultSession = "none+xmonad"; - services.xserver.windowManager.xmonad = { - enable = true; - enableConfiguredRecompile = true; - enableContribAndExtras = true; - extraPackages = with pkgs.haskellPackages; haskellPackages: [ xmobar ]; - config = mkConfig "oldXMonad" oldKeys; - }; - }; + testScript = + { nodes, ... }: + let + user = nodes.machine.users.users.alice; + in + '' + machine.wait_for_x() + machine.wait_for_file("${user.home}/.Xauthority") + machine.succeed("xauth merge ${user.home}/.Xauthority") + machine.send_key("alt-ctrl-x") + machine.wait_for_window("${user.name}.*machine") + machine.sleep(1) + machine.screenshot("terminal1") + machine.succeed("rm /tmp/oldXMonad") + machine.send_key("alt-q") + machine.wait_for_file("/tmp/oldXMonad") + machine.wait_for_window("${user.name}.*machine") + machine.sleep(1) + machine.screenshot("terminal2") - testScript = - { nodes, ... }: - let - user = nodes.machine.config.users.users.alice; - in - '' - machine.wait_for_x() - machine.wait_for_file("${user.home}/.Xauthority") - machine.succeed("xauth merge ${user.home}/.Xauthority") - machine.send_key("alt-ctrl-x") - machine.wait_for_window("${user.name}.*machine") - machine.sleep(1) - machine.screenshot("terminal1") - machine.succeed("rm /tmp/oldXMonad") - machine.send_key("alt-q") - machine.wait_for_file("/tmp/oldXMonad") - machine.wait_for_window("${user.name}.*machine") - machine.sleep(1) - machine.screenshot("terminal2") + # /tmp/somefile should not exist yet + machine.fail("stat /tmp/somefile") - # /tmp/somefile should not exist yet - machine.fail("stat /tmp/somefile") + # original config has a keybinding that creates somefile + machine.send_key("alt-ctrl-t") + machine.wait_for_file("/tmp/somefile") - # original config has a keybinding that creates somefile - machine.send_key("alt-ctrl-t") - machine.wait_for_file("/tmp/somefile") + # set up the new config + machine.succeed("mkdir -p ${user.home}/.xmonad") + machine.copy_from_host("${newConfig}", "${user.home}/.config/xmonad/xmonad.hs") - # set up the new config - machine.succeed("mkdir -p ${user.home}/.xmonad") - machine.copy_from_host("${newConfig}", "${user.home}/.config/xmonad/xmonad.hs") + # recompile xmonad using the new config + machine.send_key("alt-ctrl-q") + machine.wait_for_file("/tmp/newXMonad") - # recompile xmonad using the new config - machine.send_key("alt-ctrl-q") - machine.wait_for_file("/tmp/newXMonad") + # new config has a keybinding that deletes somefile + machine.send_key("alt-ctrl-r") + machine.wait_until_fails("stat /tmp/somefile", timeout=30) - # new config has a keybinding that deletes somefile - machine.send_key("alt-ctrl-r") - machine.wait_until_fails("stat /tmp/somefile", timeout=30) - - # restart with the old config, and confirm the old keybinding is back - machine.succeed("rm /tmp/oldXMonad") - machine.send_key("alt-q") - machine.wait_for_file("/tmp/oldXMonad") - machine.send_key("alt-ctrl-t") - machine.wait_for_file("/tmp/somefile") - ''; - } -) + # restart with the old config, and confirm the old keybinding is back + machine.succeed("rm /tmp/oldXMonad") + machine.send_key("alt-q") + machine.wait_for_file("/tmp/oldXMonad") + machine.send_key("alt-ctrl-t") + machine.wait_for_file("/tmp/somefile") + ''; +} From 93e131345f30aece0d377bd766d34068f259e4f6 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Fri, 14 Mar 2025 23:34:36 +0100 Subject: [PATCH 23/26] nixosTests.xfce-wayland: migrate to runTest Part Of #386873 --- nixos/tests/all-tests.nix | 2 +- nixos/tests/xfce-wayland.nix | 111 +++++++++++++++++------------------ 2 files changed, 55 insertions(+), 58 deletions(-) diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 17252dbae27b..a6feb52070fa 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -1288,7 +1288,7 @@ in { xandikos = handleTest ./xandikos.nix {}; xautolock = handleTest ./xautolock.nix {}; xfce = handleTest ./xfce.nix {}; - xfce-wayland = handleTest ./xfce-wayland.nix {}; + xfce-wayland = runTest ./xfce-wayland.nix; xmonad = runTest ./xmonad.nix; xmonad-xdg-autostart = runTest ./xmonad-xdg-autostart.nix; xpadneo = runTest ./xpadneo.nix; diff --git a/nixos/tests/xfce-wayland.nix b/nixos/tests/xfce-wayland.nix index f81ec563e7a6..17defe1b4d26 100644 --- a/nixos/tests/xfce-wayland.nix +++ b/nixos/tests/xfce-wayland.nix @@ -1,71 +1,68 @@ -import ./make-test-python.nix ( - { pkgs, ... }: - { - name = "xfce-wayland"; +{ + name = "xfce-wayland"; - nodes.machine = - { pkgs, ... }: + nodes.machine = + { pkgs, ... }: - { - imports = [ - ./common/user-account.nix - ]; + { + imports = [ + ./common/user-account.nix + ]; - services.xserver.enable = true; - services.xserver.displayManager.lightdm.enable = true; - services.displayManager = { - defaultSession = "xfce-wayland"; - autoLogin = { - enable = true; - user = "alice"; - }; + services.xserver.enable = true; + services.xserver.displayManager.lightdm.enable = true; + services.displayManager = { + defaultSession = "xfce-wayland"; + autoLogin = { + enable = true; + user = "alice"; }; - - services.xserver.desktopManager.xfce.enable = true; - services.xserver.desktopManager.xfce.enableWaylandSession = true; - environment.systemPackages = [ pkgs.wlrctl ]; }; - enableOCR = true; + services.xserver.desktopManager.xfce.enable = true; + services.xserver.desktopManager.xfce.enableWaylandSession = true; + environment.systemPackages = [ pkgs.wlrctl ]; + }; - testScript = - { nodes, ... }: - let - user = nodes.machine.users.users.alice; - rtdir = "XDG_RUNTIME_DIR=/run/user/${toString user.uid}"; - in - '' - machine.wait_for_unit("display-manager.service") + enableOCR = true; - with subtest("Wait for Wayland server"): - machine.wait_for_file("/run/user/${toString user.uid}/wayland-0") + testScript = + { nodes, ... }: + let + user = nodes.machine.users.users.alice; + rtdir = "XDG_RUNTIME_DIR=/run/user/${toString user.uid}"; + in + '' + machine.wait_for_unit("display-manager.service") - with subtest("Check that logging in has given the user ownership of devices"): - machine.succeed("getfacl -p /dev/snd/timer | grep -q ${user.name}") + with subtest("Wait for Wayland server"): + machine.wait_for_file("/run/user/${toString user.uid}/wayland-0") - with subtest("Check if Xfce components actually start"): - for p in ["labwc", "xfdesktop", "xfce4-notifyd", "xfconfd", "xfce4-panel"]: - machine.wait_until_succeeds(f"pgrep {p}") + with subtest("Check that logging in has given the user ownership of devices"): + machine.succeed("getfacl -p /dev/snd/timer | grep -q ${user.name}") - with subtest("Open Xfce terminal"): - machine.succeed("su - ${user.name} -c '${rtdir} xfce4-terminal >&2 &'") - machine.wait_until_succeeds("su - ${user.name} -c '${rtdir} wlrctl toplevel list | grep xfce4-terminal'") + with subtest("Check if Xfce components actually start"): + for p in ["labwc", "xfdesktop", "xfce4-notifyd", "xfconfd", "xfce4-panel"]: + machine.wait_until_succeeds(f"pgrep {p}") - with subtest("Open Thunar"): - machine.succeed("su - ${user.name} -c '${rtdir} thunar >&2 &'") - machine.wait_until_succeeds("su - ${user.name} -c '${rtdir} wlrctl toplevel list | grep Thunar'") - machine.wait_for_text('(Pictures|Public|Templates|Videos)') + with subtest("Open Xfce terminal"): + machine.succeed("su - ${user.name} -c '${rtdir} xfce4-terminal >&2 &'") + machine.wait_until_succeeds("su - ${user.name} -c '${rtdir} wlrctl toplevel list | grep xfce4-terminal'") - with subtest("Check if various environment variables are set"): - cmd = "xargs --null --max-args=1 echo < /proc/$(pgrep -xf xfce4-panel)/environ" - machine.succeed(f"{cmd} | grep 'XDG_SESSION_TYPE' | grep 'wayland'") - machine.succeed(f"{cmd} | grep 'XFCE4_SESSION_COMPOSITOR' | grep 'labwc'") - machine.succeed(f"{cmd} | grep 'XDG_CURRENT_DESKTOP' | grep 'XFCE'") + with subtest("Open Thunar"): + machine.succeed("su - ${user.name} -c '${rtdir} thunar >&2 &'") + machine.wait_until_succeeds("su - ${user.name} -c '${rtdir} wlrctl toplevel list | grep Thunar'") + machine.wait_for_text('(Pictures|Public|Templates|Videos)') - with subtest("Check if any coredumps are found"): - machine.succeed("(coredumpctl --json=short 2>&1 || true) | grep 'No coredumps found'") - machine.sleep(10) - machine.screenshot("screen") - ''; - } -) + with subtest("Check if various environment variables are set"): + cmd = "xargs --null --max-args=1 echo < /proc/$(pgrep -xf xfce4-panel)/environ" + machine.succeed(f"{cmd} | grep 'XDG_SESSION_TYPE' | grep 'wayland'") + machine.succeed(f"{cmd} | grep 'XFCE4_SESSION_COMPOSITOR' | grep 'labwc'") + machine.succeed(f"{cmd} | grep 'XDG_CURRENT_DESKTOP' | grep 'XFCE'") + + with subtest("Check if any coredumps are found"): + machine.succeed("(coredumpctl --json=short 2>&1 || true) | grep 'No coredumps found'") + machine.sleep(10) + machine.screenshot("screen") + ''; +} From f7a4d10a084ee5bc9085aa3ac705602445a97d73 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Fri, 14 Mar 2025 23:35:14 +0100 Subject: [PATCH 24/26] nixosTests.xfce: migrate to runTest Part Of #386873 --- nixos/tests/all-tests.nix | 2 +- nixos/tests/xfce.nix | 123 +++++++++++++++++++------------------- 2 files changed, 61 insertions(+), 64 deletions(-) diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index a6feb52070fa..7b9333fdd4b3 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -1287,7 +1287,7 @@ in { wstunnel = runTest ./wstunnel.nix; xandikos = handleTest ./xandikos.nix {}; xautolock = handleTest ./xautolock.nix {}; - xfce = handleTest ./xfce.nix {}; + xfce = runTest ./xfce.nix; xfce-wayland = runTest ./xfce-wayland.nix; xmonad = runTest ./xmonad.nix; xmonad-xdg-autostart = runTest ./xmonad-xdg-autostart.nix; diff --git a/nixos/tests/xfce.nix b/nixos/tests/xfce.nix index d22681dd903b..03921491c7b6 100644 --- a/nixos/tests/xfce.nix +++ b/nixos/tests/xfce.nix @@ -1,76 +1,73 @@ -import ./make-test-python.nix ( - { pkgs, ... }: - { - name = "xfce"; +{ + name = "xfce"; - nodes.machine = - { pkgs, ... }: + nodes.machine = + { pkgs, ... }: - { - imports = [ - ./common/user-account.nix - ]; + { + imports = [ + ./common/user-account.nix + ]; - services.xserver.enable = true; - services.xserver.displayManager.lightdm.enable = true; + services.xserver.enable = true; + services.xserver.displayManager.lightdm.enable = true; - services.displayManager.autoLogin = { - enable = true; - user = "alice"; - }; - - services.xserver.desktopManager.xfce.enable = true; - environment.systemPackages = [ pkgs.xfce.xfce4-whiskermenu-plugin ]; + services.displayManager.autoLogin = { + enable = true; + user = "alice"; }; - enableOCR = true; + services.xserver.desktopManager.xfce.enable = true; + environment.systemPackages = [ pkgs.xfce.xfce4-whiskermenu-plugin ]; + }; - testScript = - { nodes, ... }: - let - user = nodes.machine.users.users.alice; - bus = "DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/${toString user.uid}/bus"; - in - '' - with subtest("Wait for login"): - machine.wait_for_x() - machine.wait_for_file("${user.home}/.Xauthority") - machine.succeed("xauth merge ${user.home}/.Xauthority") + enableOCR = true; - with subtest("Check that logging in has given the user ownership of devices"): - machine.succeed("getfacl -p /dev/snd/timer | grep -q ${user.name}") + testScript = + { nodes, ... }: + let + user = nodes.machine.users.users.alice; + bus = "DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/${toString user.uid}/bus"; + in + '' + with subtest("Wait for login"): + machine.wait_for_x() + machine.wait_for_file("${user.home}/.Xauthority") + machine.succeed("xauth merge ${user.home}/.Xauthority") - with subtest("Check if Xfce components actually start"): - machine.wait_for_window("xfce4-panel") - machine.wait_for_window("Desktop") - for i in ["xfwm4", "xfsettingsd", "xfdesktop", "xfce4-screensaver", "xfce4-notifyd", "xfconfd"]: - machine.wait_until_succeeds(f"pgrep -f {i}") + with subtest("Check that logging in has given the user ownership of devices"): + machine.succeed("getfacl -p /dev/snd/timer | grep -q ${user.name}") - with subtest("Open whiskermenu"): - machine.succeed("su - ${user.name} -c 'DISPLAY=:0 ${bus} xfconf-query -c xfce4-panel -p /plugins/plugin-1 -t string -s whiskermenu -n >&2 &'") - machine.succeed("su - ${user.name} -c 'DISPLAY=:0 ${bus} xfconf-query -c xfce4-panel -p /plugins/plugin-1/stay-on-focus-out -t bool -s true -n >&2 &'") - machine.succeed("su - ${user.name} -c 'DISPLAY=:0 ${bus} xfce4-panel -r >&2 &'") - machine.wait_until_succeeds("journalctl -b --grep 'xfce4-panel: Restarting' -t xsession") - machine.sleep(5) - machine.wait_until_succeeds("pgrep -f libwhiskermenu") - machine.succeed("su - ${user.name} -c 'DISPLAY=:0 ${bus} xfce4-popup-whiskermenu >&2 &'") - machine.wait_for_text('Mail Reader') - # Close the menu. - machine.succeed("su - ${user.name} -c 'DISPLAY=:0 ${bus} xfce4-popup-whiskermenu >&2 &'") + with subtest("Check if Xfce components actually start"): + machine.wait_for_window("xfce4-panel") + machine.wait_for_window("Desktop") + for i in ["xfwm4", "xfsettingsd", "xfdesktop", "xfce4-screensaver", "xfce4-notifyd", "xfconfd"]: + machine.wait_until_succeeds(f"pgrep -f {i}") - with subtest("Open Xfce terminal"): - machine.succeed("su - ${user.name} -c 'DISPLAY=:0 xfce4-terminal >&2 &'") - machine.wait_for_window("Terminal") + with subtest("Open whiskermenu"): + machine.succeed("su - ${user.name} -c 'DISPLAY=:0 ${bus} xfconf-query -c xfce4-panel -p /plugins/plugin-1 -t string -s whiskermenu -n >&2 &'") + machine.succeed("su - ${user.name} -c 'DISPLAY=:0 ${bus} xfconf-query -c xfce4-panel -p /plugins/plugin-1/stay-on-focus-out -t bool -s true -n >&2 &'") + machine.succeed("su - ${user.name} -c 'DISPLAY=:0 ${bus} xfce4-panel -r >&2 &'") + machine.wait_until_succeeds("journalctl -b --grep 'xfce4-panel: Restarting' -t xsession") + machine.sleep(5) + machine.wait_until_succeeds("pgrep -f libwhiskermenu") + machine.succeed("su - ${user.name} -c 'DISPLAY=:0 ${bus} xfce4-popup-whiskermenu >&2 &'") + machine.wait_for_text('Mail Reader') + # Close the menu. + machine.succeed("su - ${user.name} -c 'DISPLAY=:0 ${bus} xfce4-popup-whiskermenu >&2 &'") - with subtest("Open Thunar"): - machine.succeed("su - ${user.name} -c 'DISPLAY=:0 thunar >&2 &'") - machine.wait_for_window("Thunar") - machine.wait_for_text('(Pictures|Public|Templates|Videos)') + with subtest("Open Xfce terminal"): + machine.succeed("su - ${user.name} -c 'DISPLAY=:0 xfce4-terminal >&2 &'") + machine.wait_for_window("Terminal") - with subtest("Check if any coredumps are found"): - machine.succeed("(coredumpctl --json=short 2>&1 || true) | grep 'No coredumps found'") - machine.sleep(10) - machine.screenshot("screen") - ''; - } -) + with subtest("Open Thunar"): + machine.succeed("su - ${user.name} -c 'DISPLAY=:0 thunar >&2 &'") + machine.wait_for_window("Thunar") + machine.wait_for_text('(Pictures|Public|Templates|Videos)') + + with subtest("Check if any coredumps are found"): + machine.succeed("(coredumpctl --json=short 2>&1 || true) | grep 'No coredumps found'") + machine.sleep(10) + machine.screenshot("screen") + ''; +} From ae0871bca2da59ccbea93caa61e2bc28dc46bd42 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Fri, 14 Mar 2025 23:35:56 +0100 Subject: [PATCH 25/26] nixosTests.xautolock: migrate to runTest Part Of #386873 --- nixos/tests/all-tests.nix | 2 +- nixos/tests/xautolock.nix | 44 ++++++++++++++++++--------------------- 2 files changed, 21 insertions(+), 25 deletions(-) diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 7b9333fdd4b3..866ed2170237 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -1286,7 +1286,7 @@ in { writefreely = handleTest ./web-apps/writefreely.nix {}; wstunnel = runTest ./wstunnel.nix; xandikos = handleTest ./xandikos.nix {}; - xautolock = handleTest ./xautolock.nix {}; + xautolock = runTest ./xautolock.nix; xfce = runTest ./xfce.nix; xfce-wayland = runTest ./xfce-wayland.nix; xmonad = runTest ./xmonad.nix; diff --git a/nixos/tests/xautolock.nix b/nixos/tests/xautolock.nix index 5b35f36b7546..f19fbdf9a60e 100644 --- a/nixos/tests/xautolock.nix +++ b/nixos/tests/xautolock.nix @@ -1,27 +1,23 @@ -import ./make-test-python.nix ( - { pkgs, lib, ... }: +{ + name = "xautolock"; + meta.maintainers = [ ]; - { - name = "xautolock"; - meta.maintainers = [ ]; + nodes.machine = { + imports = [ + ./common/x11.nix + ./common/user-account.nix + ]; - nodes.machine = { - imports = [ - ./common/x11.nix - ./common/user-account.nix - ]; + test-support.displayManager.auto.user = "bob"; + services.xserver.xautolock.enable = true; + services.xserver.xautolock.time = 1; + }; - test-support.displayManager.auto.user = "bob"; - services.xserver.xautolock.enable = true; - services.xserver.xautolock.time = 1; - }; - - testScript = '' - machine.start() - machine.wait_for_x() - machine.fail("pgrep xlock") - machine.sleep(120) - machine.succeed("pgrep xlock") - ''; - } -) + testScript = '' + machine.start() + machine.wait_for_x() + machine.fail("pgrep xlock") + machine.sleep(120) + machine.succeed("pgrep xlock") + ''; +} From ca409e5a02e76b05fe244be6d72b941415765600 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Fri, 14 Mar 2025 23:38:25 +0100 Subject: [PATCH 26/26] nixosTests.xandikos: migrate to runTest Part Of #386873 --- nixos/tests/all-tests.nix | 2 +- nixos/tests/xandikos.nix | 124 +++++++++++++++++++------------------- 2 files changed, 62 insertions(+), 64 deletions(-) diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 866ed2170237..85f8eae7ebac 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -1285,7 +1285,7 @@ in { wrappers = handleTest ./wrappers.nix {}; writefreely = handleTest ./web-apps/writefreely.nix {}; wstunnel = runTest ./wstunnel.nix; - xandikos = handleTest ./xandikos.nix {}; + xandikos = runTest ./xandikos.nix; xautolock = runTest ./xautolock.nix; xfce = runTest ./xfce.nix; xfce-wayland = runTest ./xfce-wayland.nix; diff --git a/nixos/tests/xandikos.nix b/nixos/tests/xandikos.nix index 4905a5bc067d..5952009c1e00 100644 --- a/nixos/tests/xandikos.nix +++ b/nixos/tests/xandikos.nix @@ -1,73 +1,71 @@ -import ./make-test-python.nix ( - { pkgs, lib, ... }: +{ lib, ... }: - { - name = "xandikos"; +{ + name = "xandikos"; - meta.maintainers = with lib.maintainers; [ _0x4A6F ]; + meta.maintainers = with lib.maintainers; [ _0x4A6F ]; - nodes = { - xandikos_client = { }; - xandikos_default = { - networking.firewall.allowedTCPPorts = [ 8080 ]; - services.xandikos.enable = true; - }; - xandikos_proxy = { - networking.firewall.allowedTCPPorts = [ - 80 - 8080 - ]; - services.xandikos.enable = true; - services.xandikos.address = "localhost"; - services.xandikos.port = 8080; - services.xandikos.routePrefix = "/xandikos-prefix/"; - services.xandikos.extraOptions = [ - "--defaults" - ]; - services.nginx = { - enable = true; - recommendedProxySettings = true; - virtualHosts."xandikos" = { - serverName = "xandikos.local"; - basicAuth.xandikos = "snakeOilPassword"; - locations."/xandikos/" = { - proxyPass = "http://localhost:8080/xandikos-prefix/"; - }; + nodes = { + xandikos_client = { }; + xandikos_default = { + networking.firewall.allowedTCPPorts = [ 8080 ]; + services.xandikos.enable = true; + }; + xandikos_proxy = { + networking.firewall.allowedTCPPorts = [ + 80 + 8080 + ]; + services.xandikos.enable = true; + services.xandikos.address = "localhost"; + services.xandikos.port = 8080; + services.xandikos.routePrefix = "/xandikos-prefix/"; + services.xandikos.extraOptions = [ + "--defaults" + ]; + services.nginx = { + enable = true; + recommendedProxySettings = true; + virtualHosts."xandikos" = { + serverName = "xandikos.local"; + basicAuth.xandikos = "snakeOilPassword"; + locations."/xandikos/" = { + proxyPass = "http://localhost:8080/xandikos-prefix/"; }; }; }; }; + }; - testScript = '' - start_all() + testScript = '' + start_all() - with subtest("Xandikos default"): - xandikos_default.wait_for_unit("multi-user.target") - xandikos_default.wait_for_unit("xandikos.service") - xandikos_default.wait_for_open_port(8080) - xandikos_default.succeed("curl --fail http://localhost:8080/") - xandikos_default.succeed( - "curl -s --fail --location http://localhost:8080/ | grep -i Xandikos" - ) - xandikos_client.wait_for_unit("network.target") - xandikos_client.fail("curl --fail http://xandikos_default:8080/") + with subtest("Xandikos default"): + xandikos_default.wait_for_unit("multi-user.target") + xandikos_default.wait_for_unit("xandikos.service") + xandikos_default.wait_for_open_port(8080) + xandikos_default.succeed("curl --fail http://localhost:8080/") + xandikos_default.succeed( + "curl -s --fail --location http://localhost:8080/ | grep -i Xandikos" + ) + xandikos_client.wait_for_unit("network.target") + xandikos_client.fail("curl --fail http://xandikos_default:8080/") - with subtest("Xandikos proxy"): - xandikos_proxy.wait_for_unit("multi-user.target") - xandikos_proxy.wait_for_unit("xandikos.service") - xandikos_proxy.wait_for_open_port(8080) - xandikos_proxy.succeed("curl --fail http://localhost:8080/") - xandikos_proxy.succeed( - "curl -s --fail --location http://localhost:8080/ | grep -i Xandikos" - ) - xandikos_client.wait_for_unit("network.target") - xandikos_client.fail("curl --fail http://xandikos_proxy:8080/") - xandikos_client.succeed( - "curl -s --fail -u xandikos:snakeOilPassword -H 'Host: xandikos.local' http://xandikos_proxy/xandikos/ | grep -i Xandikos" - ) - xandikos_client.succeed( - "curl -s --fail -u xandikos:snakeOilPassword -H 'Host: xandikos.local' http://xandikos_proxy/xandikos/user/ | grep -i Xandikos" - ) - ''; - } -) + with subtest("Xandikos proxy"): + xandikos_proxy.wait_for_unit("multi-user.target") + xandikos_proxy.wait_for_unit("xandikos.service") + xandikos_proxy.wait_for_open_port(8080) + xandikos_proxy.succeed("curl --fail http://localhost:8080/") + xandikos_proxy.succeed( + "curl -s --fail --location http://localhost:8080/ | grep -i Xandikos" + ) + xandikos_client.wait_for_unit("network.target") + xandikos_client.fail("curl --fail http://xandikos_proxy:8080/") + xandikos_client.succeed( + "curl -s --fail -u xandikos:snakeOilPassword -H 'Host: xandikos.local' http://xandikos_proxy/xandikos/ | grep -i Xandikos" + ) + xandikos_client.succeed( + "curl -s --fail -u xandikos:snakeOilPassword -H 'Host: xandikos.local' http://xandikos_proxy/xandikos/user/ | grep -i Xandikos" + ) + ''; +}