nixosTests.aria2: migrate to runTest

Part Of #386873
This commit is contained in:
Martin Weinelt 2025-03-13 23:36:28 +01:00
parent f13c50690f
commit 67d315ebd4
No known key found for this signature in database
GPG Key ID: 87C1E9888F856759
2 changed files with 48 additions and 50 deletions

View File

@ -175,7 +175,7 @@ in {
appliance-repart-image-verity-store = runTest ./appliance-repart-image-verity-store.nix; appliance-repart-image-verity-store = runTest ./appliance-repart-image-verity-store.nix;
apparmor = runTest ./apparmor; apparmor = runTest ./apparmor;
archi = runTest ./archi.nix; archi = runTest ./archi.nix;
aria2 = handleTest ./aria2.nix {}; aria2 = runTest ./aria2.nix;
armagetronad = handleTest ./armagetronad.nix {}; armagetronad = handleTest ./armagetronad.nix {};
artalk = runTest ./artalk.nix; artalk = runTest ./artalk.nix;
atd = handleTest ./atd.nix {}; atd = handleTest ./atd.nix {};

View File

@ -1,54 +1,52 @@
import ./make-test-python.nix ( { pkgs, ... }:
{ pkgs, ... }: let
let rpcSecret = "supersecret";
rpcSecret = "supersecret"; rpc-listen-port = 6800;
rpc-listen-port = 6800; curlBody = {
curlBody = { jsonrpc = 2.0;
jsonrpc = 2.0; id = 1;
id = 1; method = "aria2.getVersion";
method = "aria2.getVersion"; params = [ "token:${rpcSecret}" ];
params = [ "token:${rpcSecret}" ]; };
}; in
in {
rec { name = "aria2";
name = "aria2";
nodes.machine = { nodes.machine = {
environment.etc."aria2Rpc".text = rpcSecret; environment.etc."aria2Rpc".text = rpcSecret;
services.aria2 = { services.aria2 = {
enable = true; enable = true;
rpcSecretFile = "/etc/aria2Rpc"; rpcSecretFile = "/etc/aria2Rpc";
settings = { settings = {
inherit rpc-listen-port; inherit rpc-listen-port;
allow-overwrite = false; allow-overwrite = false;
check-integrity = true; check-integrity = true;
console-log-level = "warn"; console-log-level = "warn";
listen-port = [ listen-port = [
{ {
from = 20000; from = 20000;
to = 20010; to = 20010;
} }
{ {
from = 22222; from = 22222;
to = 22222; to = 22222;
} }
]; ];
max-concurrent-downloads = 50; max-concurrent-downloads = 50;
seed-ratio = 1.2; seed-ratio = 1.2;
summary-interval = 0; summary-interval = 0;
};
}; };
}; };
};
testScript = '' testScript = ''
machine.start() machine.start()
machine.wait_for_unit("aria2.service") machine.wait_for_unit("aria2.service")
curl_cmd = 'curl --fail-with-body -X POST -H "Content-Type: application/json" \ curl_cmd = 'curl --fail-with-body -X POST -H "Content-Type: application/json" \
-d \'${builtins.toJSON curlBody}\' http://localhost:${toString rpc-listen-port}/jsonrpc' -d \'${builtins.toJSON curlBody}\' http://localhost:${toString rpc-listen-port}/jsonrpc'
print(machine.wait_until_succeeds(curl_cmd, timeout=10)) print(machine.wait_until_succeeds(curl_cmd, timeout=10))
machine.shutdown() machine.shutdown()
''; '';
meta.maintainers = [ pkgs.lib.maintainers.timhae ]; meta.maintainers = [ pkgs.lib.maintainers.timhae ];
} }
)