Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hosts/weft/krater-production.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
# ./krater.nix. With it true and the Weave client id still empty, the weft
# build fails on purpose.
{
enable = false;
enable = true;
}
22 changes: 14 additions & 8 deletions tests/krater-weft.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Evaluates weft (hosts/weft) as it is: Krater staging on (its Weave client id
# and env file exist), Krater production off (hosts/weft/krater-production.nix).
# and env file exist), Krater production as hosts/weft/krater-production.nix sets it.
# Checks the units, the nginx routes and the alastor edge routes. Then turns
# staging off, and production on with a placeholder id, to check both
# switches, and checks the database schema for both values of the production
Expand Down Expand Up @@ -56,6 +56,8 @@ let
];
}).config;
edge = mkEdge { };
edgeOff = mkEdge { patchwork.edge.kraterProduction = false; };
edgeOffToml = edgeOff.environment.etc."traefik/conf.d/patchwork.toml".source;
edgeProd = mkEdge { patchwork.edge.kraterProduction = true; };
edgeProdToml = edgeProd.environment.etc."traefik/conf.d/patchwork.toml".source;
units = on.systemd.units;
Expand Down Expand Up @@ -110,11 +112,13 @@ let
"storage volume limit" =
on.patchwork.services.krater.storage.maxVolumes == 8
&& prod.patchwork.services.krater-production.storage.maxVolumes == 8;
"krater is not on skein" = !(skein.config.patchwork.centralDb.apps ? krater);
"production is off by default" = !on.patchwork.services.krater-production.enable;
"no production unit by default" = !(units ? "krater-prod-web.service");
"no production vhost by default" = !(vhosts ? krater-prod);
"no production secret by default" = !(on.age.secrets ? krater-env);
# Each of these follows the switch file: on and off are both valid states.
"krater is on skein only with the switch" =
(skein.config.patchwork.centralDb.apps ? krater) == switchFile;
"production follows the switch file" = on.patchwork.services.krater-production.enable == switchFile;
"production unit follows the switch file" = (units ? "krater-prod-web.service") == switchFile;
"production vhost follows the switch file" = (vhosts ? krater-prod) == switchFile;
"production secret follows the switch file" = (on.age.secrets ? krater-env) == switchFile;
"edge default follows the switch file" = edge.patchwork.edge.kraterProduction == switchFile;
"switch off: krater only on hem" =
!(schemaOff.central.apps ? krater)
Expand Down Expand Up @@ -217,8 +221,10 @@ pkgs.runCommand "krater-weft" { } ''
# alastor routes both names to weft over the tailnet.
grep -F 'Host(`krater-staging.patchworklabs.org`)' ${edgeToml}
grep -F 'Host(`krater-staging-storage.patchworklabs.org`)' ${edgeToml}
absent 'Host(`krater.patchworklabs.org`)' ${edgeToml}
absent 'Host(`krater-storage.patchworklabs.org`)' ${edgeToml}
# With the switch off, alastor has no production routes.
absent 'Host(`krater.patchworklabs.org`)' ${edgeOffToml}
absent 'Host(`krater-storage.patchworklabs.org`)' ${edgeOffToml}
grep -F 'Host(`krater-staging.patchworklabs.org`)' ${edgeOffToml}

# Production: its own network, image repository, state and ports, and skein.
skein="--add-host skein.wildebeest-stargazer.ts.net:100.109.223.51"
Expand Down
Loading