binary-cache/tests/multi-cache.nix

54 lines
1.3 KiB
Nix
Raw Normal View History

2024-07-19 10:51:57 +02:00
{ pkgs }:
let
inherit (pkgs) hello;
in
pkgs.testers.runNixOSTest (_: {
name = "cache multi-cache smoke test";
nodes.machine = {
imports = [
./common
../modules
];
system.extraDependencies = [ hello ];
services.tvix-binary-cache = {
enable = true;
enableNginx = true;
nginx = {
clientMaxBodySize = "50G";
host = "cache";
};
caches = {
one.port = 8000;
two.port = 8001;
};
};
services.nginx = {
enable = true;
recommendedProxySettings = true;
virtualHosts.cache = {
default = true;
};
};
};
testScript = ''
import time
start_all()
machine.wait_for_unit("nginx.service")
machine.wait_for_unit("tvix-store-one.service")
machine.wait_for_unit("tvix-store-two.service")
2024-07-19 10:51:57 +02:00
time.sleep(1)
with subtest("Nar bridge home"):
machine.succeed("curl -L http://127.0.0.1/one/nix-cache-info")
2024-07-19 10:51:57 +02:00
with subtest("Nar upload"):
machine.succeed("nix copy --to 'http://127.0.0.1/one/?compression=none' ${hello}")
with subtest("narinfo retrieve"):
narHash = "${hello}"[11:11+32]
machine.succeed(f"curl -f 'http://127.0.0.1/one/{narHash}.narinfo'")
machine.fail(f"curl -f 'http://127.0.0.1/two/{narHash}.narinfo'")
'';
})