ci: type-check the semi-spread and swarm-builder-offline test scripts with stand-in values
This commit is contained in:
parent
a401b0c8ef
commit
de43dac33c
1 changed files with 321 additions and 259 deletions
|
|
@ -130,178 +130,21 @@ let
|
|||
pkgs.wireguard-tools
|
||||
];
|
||||
};
|
||||
in
|
||||
pkgs.testers.runNixOSTest (
|
||||
{ config, ... }:
|
||||
let
|
||||
swarmCfg = config.nodes.swarm.services.hyperhive;
|
||||
inherit (swarmCfg) swarm;
|
||||
controllerSocket = swarmCfg.deploy.swarm-controller.socketPath;
|
||||
settingsJson =
|
||||
config.nodes.swarm.systemd.services.swarm-controller.environment.SWARM_CONTROLLER_META_FLAKE;
|
||||
|
||||
# What the public DNS holds (semi-spread-deploy.md, "DNS"), and the rest of
|
||||
# the swarm's names, which only the VPN resolves.
|
||||
publicNames = {
|
||||
ui = swarm.domain;
|
||||
forge = swarm.forge.domain;
|
||||
chat = swarm.matrix.gatewayHost;
|
||||
auth = swarm.authelia.domain;
|
||||
};
|
||||
privateNames = {
|
||||
grafana = swarm.grafana.domain;
|
||||
metrics = swarm.victoriametrics.domain;
|
||||
logs = swarm.victorialogs.domain;
|
||||
otel = swarm.otel.domain;
|
||||
bao-ui = swarm.bao.ui.domain;
|
||||
attic = swarm.attic.ownDomain;
|
||||
};
|
||||
# Every internal name, with the machine whose VPN address it resolves to.
|
||||
internalNames =
|
||||
lib.genAttrs [
|
||||
"ui"
|
||||
"forge"
|
||||
"chat"
|
||||
"auth"
|
||||
"grafana"
|
||||
"metrics"
|
||||
"logs"
|
||||
"otel"
|
||||
"bao-ui"
|
||||
"bao"
|
||||
"nats"
|
||||
] (_: "swarm-central")
|
||||
// {
|
||||
attic = "swarm-heavyduty";
|
||||
};
|
||||
nameOf = {
|
||||
inherit (publicNames)
|
||||
ui
|
||||
forge
|
||||
chat
|
||||
auth
|
||||
;
|
||||
inherit (privateNames)
|
||||
grafana
|
||||
metrics
|
||||
logs
|
||||
otel
|
||||
bao-ui
|
||||
attic
|
||||
;
|
||||
bao = swarm.bao.domain;
|
||||
nats = swarm.nats.domain;
|
||||
};
|
||||
in
|
||||
{
|
||||
name = "semi-spread";
|
||||
|
||||
# Three hosts' boots, the setup ceremony and the agents' build and pull.
|
||||
globalTimeout = 10800;
|
||||
|
||||
nodes.swarm =
|
||||
{ config, ... }:
|
||||
{
|
||||
imports = [
|
||||
self.nixosModules.default
|
||||
tools
|
||||
(wgKey "swarm")
|
||||
"${exampleCopy}/common.nix"
|
||||
"${exampleCopy}/swarm-central.nix"
|
||||
"${exampleCopy}/swarm-services.nix"
|
||||
];
|
||||
networking.hostName = "swarm-central";
|
||||
system.stateVersion = "25.11";
|
||||
|
||||
services.hyperhive = {
|
||||
# swarm-services.nix says the store is elsewhere; here it is on this machine.
|
||||
deploy.bao.enable = lib.mkForce true;
|
||||
deploy.bao.seal = "shamir";
|
||||
deploy.bao.bootstrapTokenFile = "/var/lib/swarm-bao-bootstrap/grant.token";
|
||||
# Names this machine serves are not in the example's table, and a
|
||||
# process on the machine reaches them on the machine.
|
||||
gateway.localHostsEntry = true;
|
||||
# The test pushes its own hyperhive/hyperhive; a mirror of the
|
||||
# upstream could not be created offline and would race the push.
|
||||
deploy.forgejo.hyperhiveUpstream = null;
|
||||
# The cache answers on the private addresses only, as on the
|
||||
# example's heavyduty.
|
||||
gateway.vhosts.${config.services.hyperhive.swarm.attic.ownDomain}.public = false;
|
||||
};
|
||||
|
||||
# 8 GB: the store and the swarm's services in containers, the
|
||||
# controller, and the forge's repositories.
|
||||
virtualisation.memorySize = 8192;
|
||||
virtualisation.cores = 4;
|
||||
virtualisation.diskSize = 20480;
|
||||
virtualisation.writableStoreUseTmpfs = false;
|
||||
virtualisation.additionalPaths = [ hyperhiveRepo ];
|
||||
|
||||
# The store's raft data is on a tmpfs, for the reason in ./full-setup.nix.
|
||||
fileSystems."/var/lib/nixos-containers/${config.services.hyperhive.swarm.bao.machine}/var/lib/private" =
|
||||
{
|
||||
device = "tmpfs";
|
||||
fsType = "tmpfs";
|
||||
options = [
|
||||
"mode=0700"
|
||||
"size=1G"
|
||||
];
|
||||
};
|
||||
|
||||
environment.systemPackages = [ pkgs.git ];
|
||||
};
|
||||
|
||||
nodes.heavyduty = {
|
||||
imports = [
|
||||
self.nixosModules.default
|
||||
tools
|
||||
offline
|
||||
(wgKey "heavyduty")
|
||||
"${exampleCopy}/common.nix"
|
||||
"${exampleCopy}/swarm-heavyduty.nix"
|
||||
];
|
||||
networking.hostName = "swarm-heavyduty";
|
||||
system.stateVersion = "25.11";
|
||||
|
||||
# 5 GB: the builder evaluates and builds the agents' flake, beside the
|
||||
# cache and the CI runner. The disk holds the toplevels and the cache's
|
||||
# copy of them.
|
||||
virtualisation.memorySize = 5120;
|
||||
virtualisation.cores = 4;
|
||||
virtualisation.diskSize = 40960;
|
||||
virtualisation.writableStoreUseTmpfs = false;
|
||||
# The toplevels, and the source trees the meta flake's lock names.
|
||||
virtualisation.additionalPaths = sourcePaths ++ toplevels settingsJson;
|
||||
};
|
||||
|
||||
nodes.hive = {
|
||||
imports = [
|
||||
self.nixosModules.default
|
||||
tools
|
||||
offline
|
||||
(wgKey "hive")
|
||||
"${exampleCopy}/common.nix"
|
||||
"${exampleCopy}/hive.nix"
|
||||
];
|
||||
networking.hostName = "hive-one";
|
||||
system.stateVersion = "25.11";
|
||||
|
||||
# 4 GB: the hive and two agent containers. The disk holds the pulled
|
||||
# closures.
|
||||
virtualisation.memorySize = 4096;
|
||||
virtualisation.cores = 2;
|
||||
virtualisation.diskSize = 30720;
|
||||
virtualisation.writableStoreUseTmpfs = false;
|
||||
};
|
||||
|
||||
nodes.outside = {
|
||||
environment.systemPackages = [ pkgs.curl ];
|
||||
# The public DNS: the four names, at the swarm machine's public address.
|
||||
networking.hosts.${lanAddr.swarm} = lib.attrValues publicNames;
|
||||
virtualisation.memorySize = 512;
|
||||
};
|
||||
|
||||
testScript = ''
|
||||
# The script is a function of the values it reads from node config and the
|
||||
# agent toplevels, so the type check can build it with stand-in values and
|
||||
# evaluate no node.
|
||||
scriptWith =
|
||||
{
|
||||
controllerSocket,
|
||||
publicNames,
|
||||
swarm,
|
||||
nameOf,
|
||||
internalNames,
|
||||
toplevelPaths,
|
||||
hyperhiveRepo,
|
||||
}:
|
||||
''
|
||||
import json
|
||||
import shlex
|
||||
import time
|
||||
|
|
@ -310,7 +153,7 @@ pkgs.testers.runNixOSTest (
|
|||
SOCKET = "${controllerSocket}"
|
||||
FORGE = "https://${publicNames.forge}"
|
||||
HIVE = "${hiveName}"
|
||||
TOPLEVELS = ${builtins.toJSON (map toString (toplevels settingsJson))}
|
||||
TOPLEVELS = ${builtins.toJSON toplevelPaths}
|
||||
INIT = "/root/bao-init.json"
|
||||
FORGE_AUTH = "/root/forge-auth.header"
|
||||
NIX = "nix --extra-experimental-features nix-command"
|
||||
|
|
@ -674,5 +517,202 @@ pkgs.testers.runNixOSTest (
|
|||
# Not built on the swarm machine, which has no copy.
|
||||
swarm.fail(f"{NIX} path-info {toplevel}")
|
||||
'';
|
||||
in
|
||||
pkgs.testers.runNixOSTest (
|
||||
{ config, ... }:
|
||||
let
|
||||
swarmCfg = config.nodes.swarm.services.hyperhive;
|
||||
inherit (swarmCfg) swarm;
|
||||
controllerSocket = swarmCfg.deploy.swarm-controller.socketPath;
|
||||
settingsJson =
|
||||
config.nodes.swarm.systemd.services.swarm-controller.environment.SWARM_CONTROLLER_META_FLAKE;
|
||||
|
||||
# What the public DNS holds (semi-spread-deploy.md, "DNS"), and the rest of
|
||||
# the swarm's names, which only the VPN resolves.
|
||||
publicNames = {
|
||||
ui = swarm.domain;
|
||||
forge = swarm.forge.domain;
|
||||
chat = swarm.matrix.gatewayHost;
|
||||
auth = swarm.authelia.domain;
|
||||
};
|
||||
privateNames = {
|
||||
grafana = swarm.grafana.domain;
|
||||
metrics = swarm.victoriametrics.domain;
|
||||
logs = swarm.victorialogs.domain;
|
||||
otel = swarm.otel.domain;
|
||||
bao-ui = swarm.bao.ui.domain;
|
||||
attic = swarm.attic.ownDomain;
|
||||
};
|
||||
# Every internal name, with the machine whose VPN address it resolves to.
|
||||
internalNames =
|
||||
lib.genAttrs [
|
||||
"ui"
|
||||
"forge"
|
||||
"chat"
|
||||
"auth"
|
||||
"grafana"
|
||||
"metrics"
|
||||
"logs"
|
||||
"otel"
|
||||
"bao-ui"
|
||||
"bao"
|
||||
"nats"
|
||||
] (_: "swarm-central")
|
||||
// {
|
||||
attic = "swarm-heavyduty";
|
||||
};
|
||||
nameOf = {
|
||||
inherit (publicNames)
|
||||
ui
|
||||
forge
|
||||
chat
|
||||
auth
|
||||
;
|
||||
inherit (privateNames)
|
||||
grafana
|
||||
metrics
|
||||
logs
|
||||
otel
|
||||
bao-ui
|
||||
attic
|
||||
;
|
||||
bao = swarm.bao.domain;
|
||||
nats = swarm.nats.domain;
|
||||
};
|
||||
in
|
||||
{
|
||||
name = "semi-spread";
|
||||
|
||||
# Three hosts' boots, the setup ceremony and the agents' build and pull.
|
||||
globalTimeout = 10800;
|
||||
|
||||
nodes.swarm =
|
||||
{ config, ... }:
|
||||
{
|
||||
imports = [
|
||||
self.nixosModules.default
|
||||
tools
|
||||
(wgKey "swarm")
|
||||
"${exampleCopy}/common.nix"
|
||||
"${exampleCopy}/swarm-central.nix"
|
||||
"${exampleCopy}/swarm-services.nix"
|
||||
];
|
||||
networking.hostName = "swarm-central";
|
||||
system.stateVersion = "25.11";
|
||||
|
||||
services.hyperhive = {
|
||||
# swarm-services.nix says the store is elsewhere; here it is on this machine.
|
||||
deploy.bao.enable = lib.mkForce true;
|
||||
deploy.bao.seal = "shamir";
|
||||
deploy.bao.bootstrapTokenFile = "/var/lib/swarm-bao-bootstrap/grant.token";
|
||||
# Names this machine serves are not in the example's table, and a
|
||||
# process on the machine reaches them on the machine.
|
||||
gateway.localHostsEntry = true;
|
||||
# The test pushes its own hyperhive/hyperhive; a mirror of the
|
||||
# upstream could not be created offline and would race the push.
|
||||
deploy.forgejo.hyperhiveUpstream = null;
|
||||
# The cache answers on the private addresses only, as on the
|
||||
# example's heavyduty.
|
||||
gateway.vhosts.${config.services.hyperhive.swarm.attic.ownDomain}.public = false;
|
||||
};
|
||||
|
||||
# 8 GB: the store and the swarm's services in containers, the
|
||||
# controller, and the forge's repositories.
|
||||
virtualisation.memorySize = 8192;
|
||||
virtualisation.cores = 4;
|
||||
virtualisation.diskSize = 20480;
|
||||
virtualisation.writableStoreUseTmpfs = false;
|
||||
virtualisation.additionalPaths = [ hyperhiveRepo ];
|
||||
|
||||
# The store's raft data is on a tmpfs, for the reason in ./full-setup.nix.
|
||||
fileSystems."/var/lib/nixos-containers/${config.services.hyperhive.swarm.bao.machine}/var/lib/private" =
|
||||
{
|
||||
device = "tmpfs";
|
||||
fsType = "tmpfs";
|
||||
options = [
|
||||
"mode=0700"
|
||||
"size=1G"
|
||||
];
|
||||
};
|
||||
|
||||
environment.systemPackages = [ pkgs.git ];
|
||||
};
|
||||
|
||||
nodes.heavyduty = {
|
||||
imports = [
|
||||
self.nixosModules.default
|
||||
tools
|
||||
offline
|
||||
(wgKey "heavyduty")
|
||||
"${exampleCopy}/common.nix"
|
||||
"${exampleCopy}/swarm-heavyduty.nix"
|
||||
];
|
||||
networking.hostName = "swarm-heavyduty";
|
||||
system.stateVersion = "25.11";
|
||||
|
||||
# 5 GB: the builder evaluates and builds the agents' flake, beside the
|
||||
# cache and the CI runner. The disk holds the toplevels and the cache's
|
||||
# copy of them.
|
||||
virtualisation.memorySize = 5120;
|
||||
virtualisation.cores = 4;
|
||||
virtualisation.diskSize = 40960;
|
||||
virtualisation.writableStoreUseTmpfs = false;
|
||||
# The toplevels, and the source trees the meta flake's lock names.
|
||||
virtualisation.additionalPaths = sourcePaths ++ toplevels settingsJson;
|
||||
};
|
||||
|
||||
nodes.hive = {
|
||||
imports = [
|
||||
self.nixosModules.default
|
||||
tools
|
||||
offline
|
||||
(wgKey "hive")
|
||||
"${exampleCopy}/common.nix"
|
||||
"${exampleCopy}/hive.nix"
|
||||
];
|
||||
networking.hostName = "hive-one";
|
||||
system.stateVersion = "25.11";
|
||||
|
||||
# 4 GB: the hive and two agent containers. The disk holds the pulled
|
||||
# closures.
|
||||
virtualisation.memorySize = 4096;
|
||||
virtualisation.cores = 2;
|
||||
virtualisation.diskSize = 30720;
|
||||
virtualisation.writableStoreUseTmpfs = false;
|
||||
};
|
||||
|
||||
nodes.outside = {
|
||||
environment.systemPackages = [ pkgs.curl ];
|
||||
# The public DNS: the four names, at the swarm machine's public address.
|
||||
networking.hosts.${lanAddr.swarm} = lib.attrValues publicNames;
|
||||
virtualisation.memorySize = 512;
|
||||
};
|
||||
|
||||
testScript = scriptWith {
|
||||
inherit
|
||||
controllerSocket
|
||||
publicNames
|
||||
swarm
|
||||
nameOf
|
||||
internalNames
|
||||
hyperhiveRepo
|
||||
;
|
||||
toplevelPaths = map toString (toplevels settingsJson);
|
||||
};
|
||||
|
||||
# What `nix/vm-test-typecheck.nix` checks: the same text with stand-in values.
|
||||
passthru.typecheckScript = scriptWith {
|
||||
controllerSocket = "/stub/socket";
|
||||
publicNames.forge = "forge.stub";
|
||||
swarm = {
|
||||
bao.machine = "stub";
|
||||
dashboardDomains.${hiveName} = "dashboard.stub";
|
||||
attic.domain = "attic.stub";
|
||||
};
|
||||
nameOf.stub = "stub.stub";
|
||||
internalNames.stub = "stub";
|
||||
toplevelPaths = [ "/nix/store/stub" ];
|
||||
hyperhiveRepo = "/nix/store/stub";
|
||||
};
|
||||
}
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue