From 67d315ebd48c5a79d0b3305be9889a38b57bef12 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Thu, 13 Mar 2025 23:36:28 +0100 Subject: [PATCH] nixosTests.aria2: migrate to runTest Part Of #386873 --- nixos/tests/all-tests.nix | 2 +- nixos/tests/aria2.nix | 96 +++++++++++++++++++-------------------- 2 files changed, 48 insertions(+), 50 deletions(-) diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 345b8f2baeae..44287aadb42c 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -175,7 +175,7 @@ in { appliance-repart-image-verity-store = runTest ./appliance-repart-image-verity-store.nix; apparmor = runTest ./apparmor; archi = runTest ./archi.nix; - aria2 = handleTest ./aria2.nix {}; + aria2 = runTest ./aria2.nix; armagetronad = handleTest ./armagetronad.nix {}; artalk = runTest ./artalk.nix; atd = handleTest ./atd.nix {}; diff --git a/nixos/tests/aria2.nix b/nixos/tests/aria2.nix index cf8e4da8977c..fbae6598b6c6 100644 --- a/nixos/tests/aria2.nix +++ b/nixos/tests/aria2.nix @@ -1,54 +1,52 @@ -import ./make-test-python.nix ( - { pkgs, ... }: - let - rpcSecret = "supersecret"; - rpc-listen-port = 6800; - curlBody = { - jsonrpc = 2.0; - id = 1; - method = "aria2.getVersion"; - params = [ "token:${rpcSecret}" ]; - }; - in - rec { - name = "aria2"; +{ pkgs, ... }: +let + rpcSecret = "supersecret"; + rpc-listen-port = 6800; + curlBody = { + jsonrpc = 2.0; + id = 1; + method = "aria2.getVersion"; + params = [ "token:${rpcSecret}" ]; + }; +in +{ + name = "aria2"; - nodes.machine = { - environment.etc."aria2Rpc".text = rpcSecret; - services.aria2 = { - enable = true; - rpcSecretFile = "/etc/aria2Rpc"; - settings = { - inherit rpc-listen-port; - allow-overwrite = false; - check-integrity = true; - console-log-level = "warn"; - listen-port = [ - { - from = 20000; - to = 20010; - } - { - from = 22222; - to = 22222; - } - ]; - max-concurrent-downloads = 50; - seed-ratio = 1.2; - summary-interval = 0; - }; + nodes.machine = { + environment.etc."aria2Rpc".text = rpcSecret; + services.aria2 = { + enable = true; + rpcSecretFile = "/etc/aria2Rpc"; + settings = { + inherit rpc-listen-port; + allow-overwrite = false; + check-integrity = true; + console-log-level = "warn"; + listen-port = [ + { + from = 20000; + to = 20010; + } + { + from = 22222; + to = 22222; + } + ]; + max-concurrent-downloads = 50; + seed-ratio = 1.2; + summary-interval = 0; }; }; + }; - testScript = '' - machine.start() - machine.wait_for_unit("aria2.service") - curl_cmd = 'curl --fail-with-body -X POST -H "Content-Type: application/json" \ - -d \'${builtins.toJSON curlBody}\' http://localhost:${toString rpc-listen-port}/jsonrpc' - print(machine.wait_until_succeeds(curl_cmd, timeout=10)) - machine.shutdown() - ''; + testScript = '' + machine.start() + machine.wait_for_unit("aria2.service") + curl_cmd = 'curl --fail-with-body -X POST -H "Content-Type: application/json" \ + -d \'${builtins.toJSON curlBody}\' http://localhost:${toString rpc-listen-port}/jsonrpc' + print(machine.wait_until_succeeds(curl_cmd, timeout=10)) + machine.shutdown() + ''; - meta.maintainers = [ pkgs.lib.maintainers.timhae ]; - } -) + meta.maintainers = [ pkgs.lib.maintainers.timhae ]; +}