python312Packages.millheater: 0.11.8 -> 0.12.0
[NixPkgs.git] / nixos / tests / aria2.nix
blob48fe2094b5dcfa959dacc20589e46c8342b341fd
1 import ./make-test-python.nix ({ pkgs, ... }:
2 let
3   rpcSecret = "supersecret";
4   rpc-listen-port = 6800;
5   curlBody = {
6     jsonrpc = 2.0;
7     id = 1;
8     method = "aria2.getVersion";
9     params = [ "token:${rpcSecret}" ];
10   };
12 rec {
13   name = "aria2";
15   nodes.machine = {
16     environment.etc."aria2Rpc".text = rpcSecret;
17     services.aria2 = {
18       enable = true;
19       rpcSecretFile = "/etc/aria2Rpc";
20       settings = {
21         inherit rpc-listen-port;
22         allow-overwrite = false;
23         check-integrity = true;
24         console-log-level = "warn";
25         listen-port = [{ from = 20000; to = 20010; } { from = 22222; to = 22222; }];
26         max-concurrent-downloads = 50;
27         seed-ratio = 1.2;
28         summary-interval = 0;
29       };
30     };
31   };
33   testScript = ''
34     machine.start()
35     machine.wait_for_unit("aria2.service")
36     curl_cmd = 'curl --fail-with-body -X POST -H "Content-Type: application/json" \
37                 -d \'${builtins.toJSON curlBody}\' http://localhost:${toString rpc-listen-port}/jsonrpc'
38     print(machine.wait_until_succeeds(curl_cmd, timeout=10))
39     machine.shutdown()
40   '';
42   meta.maintainers = [ pkgs.lib.maintainers.timhae ];