65 lines
1.8 KiB
Nix
65 lines
1.8 KiB
Nix
{ pkgs }:
|
|
let
|
|
inherit (pkgs) hello;
|
|
in
|
|
pkgs.testers.runNixOSTest (_: {
|
|
name = "cache smoke test";
|
|
nodes.machine =
|
|
{ config, ... }:
|
|
{
|
|
imports = [
|
|
./common
|
|
../modules
|
|
];
|
|
|
|
system.extraDependencies = [ hello ];
|
|
|
|
services.tvix-binary-cache = {
|
|
enable = true;
|
|
caches = {
|
|
one.port = 8000;
|
|
two.port = 8001;
|
|
};
|
|
};
|
|
|
|
services.nginx = {
|
|
enable = true;
|
|
recommendedProxySettings = true;
|
|
virtualHosts.cache = {
|
|
default = true;
|
|
locations = {
|
|
"/one".return = "302 /one/";
|
|
"/one/" = {
|
|
proxyPass = "http://localhost:${toString config.services.tvix-binary-cache.caches.one.port}/";
|
|
};
|
|
"/two".return = "302 /two/";
|
|
"/two/" = {
|
|
proxyPass = "http://localhost:${toString config.services.tvix-binary-cache.caches.two.port}/";
|
|
};
|
|
};
|
|
extraConfig = "client_max_body_size 1G;";
|
|
|
|
};
|
|
};
|
|
};
|
|
testScript = ''
|
|
import sys
|
|
import time
|
|
start_all()
|
|
machine.wait_for_unit("nginx.service")
|
|
machine.wait_for_unit("nar-bridge-one.service")
|
|
machine.wait_for_unit("nar-bridge-two.service")
|
|
time.sleep(1)
|
|
with subtest("Nar bridge home"):
|
|
out = machine.succeed("curl -L http://127.0.0.1/one")
|
|
if out != "nar-bridge":
|
|
sys.exit(1)
|
|
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'")
|
|
|
|
'';
|
|
})
|