binary-cache/tests/ingest.nix
2024-07-20 18:22:43 +02:00

50 lines
1.3 KiB
Nix

{ pkgs }:
let
#hello = pkgs.hello.overrideAttrs { pname = "custom-hello"; };
inherit (pkgs) hello;
references = pkgs.runCommandNoCC "hello-refs" {
exportReferencesGraph.hello = hello;
__structuredAttrs = true;
nativeBuildInputs = [ pkgs.jq ];
} "jq -r \"{closure : .hello}\" < .attrs.json > $out"; # "jq -r '.hello' < .attrs.json > $out";
in
pkgs.testers.runNixOSTest (_: {
name = "ingestion with tvix copy";
nodes = {
cache = {
imports = [
./common
../modules
];
system.extraDependencies = [
hello
references
];
services.tvix-binary-cache = {
enable = true;
enableNginx = true;
nginx = {
clientMaxBodySize = "50G";
host = "cache";
};
caches = {
cache.port = 8000;
};
};
networking.firewall.allowedTCPPorts = [ 80 ];
};
};
testScript = ''
import time
start_all()
cache.wait_for_unit("nginx.service")
cache.wait_for_unit("tvix-store-cache.service")
time.sleep(1)
socket_addr = "grpc+unix:///run/tvix-store-cache/socket"
cache.succeed(f"BLOB_SERVICE_ADDR={socket_addr} DIRECTORY_SERVICE_ADDR={socket_addr} PATH_INFO_SERVICE_ADDR={socket_addr} tvix-store copy ${builtins.toString references}")
'';
})