test: Push a build to a binary cache

`box` also holds a binary cache's store through
`services.slop-broker-cache`, and the agent builds the profile into it
with `slop build`, which no test covered. The test checks the printed
path, the closure in the cache's store and its GC root. The audit
check now reads more than the default 50 records, which the extra
requests outgrew.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
jackos1998andClaude Opus 5.5 committed 2026-11-29 13:27:48 +00:00
1 parent c33a28c8b8
commit 50ec4833c1
2 files changed
+41 -2

No files matched your search

+38 -2
View File
@@ -3,7 +3,7 @@
#
# - `machine` runs the broker, its builder and the requesters, and is also the deploy node `local`
# (and `other` and `denied`), with a container, `web`.
# - `box` is a second deploy node with a store of its own.
# - `box` is a second deploy node with a store of its own, and holds the binary cache's store.
{ pkgs, slop-broker }:
let
inherit (pkgs) lib;
@@ -57,7 +57,23 @@ pkgs.testers.runNixOSTest {
name = "slop-broker";
nodes.box = { ... }: {
imports = [ deployNode ];
imports = [ deployNode ./modules/nixos/cache.nix ];
# The binary cache: a store of its own, owned by `cache`, which the broker's key may only use
# through the cache's forced command
users.users.cache = {
isNormalUser = true;
home = "/var/lib/slop-cache-home";
createHome = true;
};
systemd.tmpfiles.rules = [ "d /var/lib/slop-cache 0755 cache users -" ];
services.slop-broker-cache = {
enable = true;
user = "cache";
store = "/var/lib/slop-cache";
home = "/var/lib/slop-cache-home";
brokerKeys = [ (publicKey "key") ];
};
};
nodes.machine = { ... }: {
@@ -95,6 +111,7 @@ pkgs.testers.runNixOSTest {
query.action = "auto";
builder.action = "auto";
deploy.action = "auto";
build.action = "auto";
ssh = {
action = "ask";
leases = [ "5m" ];
@@ -118,6 +135,12 @@ pkgs.testers.runNixOSTest {
inherit keyFile;
};
deploy.enable = true;
cache = {
enable = true;
hostname = "box";
user = "cache";
inherit keyFile;
};
};
# The builder only reads the repository, a local copy, so its key is never used
@@ -307,6 +330,19 @@ pkgs.testers.runNixOSTest {
assert status == 0 and "build line two" in out, (status, out)
box.succeed("test -e /tmp/slop-activated-two")
# The binary cache
# Builds go to the cache's store on `box`, closure and all, with a GC root; the output path
# is the last line
status, out = try_slop(f"build packages.x86_64-linux.profile --commit {two}")
print(out)
assert status == 0, (status, out)
path = out.strip().splitlines()[-1]
assert path.startswith("/nix/store/") and path.endswith("-test-profile-two"), out
out = box.succeed(f"nix --extra-experimental-features nix-command path-info --store /var/lib/slop-cache -r {path}")
assert len(out.split()) == 2, out
box.succeed(f"test -L /var/lib/slop-cache/nix/var/nix/gcroots/slop-broker/{path.removeprefix('/nix/store/')}")
# The audit log
# It has the answers and the outcomes; the default 50 records don't reach back far enough
+3
View File
@@ -24,6 +24,9 @@
system = { path = profile; profilePath = "/nix/var/nix/profiles/slop-test"; };
in
{
# For `slop build`
packages.x86_64-linux.profile = profile;
deploy.sshUser = "deploy";
deploy.nodes = {
local = {