blob: f5de6075102f74cdd1ab407474b6730ce82695d7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
{
testName,
lib,
pkgs,
...
}:
{
name = testName;
meta = with lib.maintainers; {
maintainers = [
aciceri
kalbasit
];
};
nodes = {
harmonia = {
services.harmonia = {
enable = true;
signKeyPaths = [
(pkgs.writeText "cache-key" "cache.example.com-1:9FhO0w+7HjZrhvmzT1VlAZw4OSAlFGTgC24Seg3tmPl4gZBdwZClzTTHr9cVzJpwsRSYLTu7hEAQe3ljy92CWg==")
];
settings.priority = 35;
};
networking.firewall.allowedTCPPorts = [ 5000 ];
system.extraDependencies = [ pkgs.emptyFile ];
nix.enable = true; # disabled by default. See all-tests.nix / tag(no-nix-by-default)
};
ncps = {
services.ncps = {
enable = true;
analytics.reporting.enable = false;
cache = {
hostName = "ncps";
secretKeyPath = toString (
pkgs.writeText "ncps-cache-key" "ncps:dcrGsrku0KvltFhrR5lVIMqyloAdo0y8vYZOeIFUSLJS2IToL7dPHSSCk/fi+PJf8EorpBn8PU7MNhfvZoI8mA=="
);
upstream = {
urls = [ "http://harmonia:5000" ];
publicKeys = [
"cache.example.com-1:eIGQXcGQpc00x6/XFcyacLEUmC07u4RAEHt5Y8vdglo="
];
};
};
};
networking.firewall.allowedTCPPorts = [ 8501 ];
nix.enable = true; # disabled by default. See all-tests.nix / tag(no-nix-by-default)
};
client = {
nix.settings = {
substituters = lib.mkForce [ "http://ncps:8501" ];
trusted-public-keys = lib.mkForce [
"ncps:UtiE6C+3Tx0kgpP34vjyX/BKK6QZ/D1OzDYX72aCPJg="
];
};
nix.enable = true; # disabled by default. See all-tests.nix / tag(no-nix-by-default)
};
};
testScript =
{ nodes, ... }:
''
start_all()
harmonia.wait_for_unit("harmonia.socket")
ncps.wait_for_unit("ncps.service")
client.wait_until_succeeds("curl -f http://ncps:8501/ | grep '\"hostname\":\"${toString nodes.ncps.services.ncps.cache.hostName}\"' >&2")
client.succeed("cat /etc/nix/nix.conf >&2")
client.succeed("nix-store --realise ${pkgs.emptyFile}")
# Verify that the NAR file exists in the cache storage
# We query the NAR hash from the client and then check if a file with that hash exists in the ncps storage
nar_hash = client.succeed("nix-store -q --hash ${pkgs.emptyFile}").strip().split(":")[1]
ncps.succeed(f"find ${nodes.ncps.services.ncps.cache.storage.local} -type f | grep {nar_hash}")
'';
}
|