photoncloud-monorepo/docs/evidence/first-boot-automation-20251220-050900/test.nix

53 lines
1.5 KiB
Nix

let
nixpkgs = builtins.getFlake "nixpkgs";
system = "x86_64-linux";
pkgs = import nixpkgs { inherit system; };
testLib = import "${nixpkgs}/nixos/lib/testing-python.nix" { inherit system; };
firstBootModule = /home/centra/cloud/nix/modules/first-boot-automation.nix;
topologyModule = /home/centra/cloud/nix/modules/nix-nos/topology.nix;
in testLib.makeTest {
name = "first-boot-automation";
nodes.machine = { pkgs, ... }: {
imports = [
topologyModule
firstBootModule
];
system.stateVersion = "24.05";
networking.hostName = "node01";
nix-nos.enable = true;
nix-nos.clusters.plasmacloud = {
name = "plasmacloud";
bootstrapNode = null;
nodes.node01 = {
role = "control-plane";
ip = "10.0.1.10";
services = [ "chainfire" ];
};
};
services.first-boot-automation = {
enable = true;
useNixNOS = true;
nixnosClusterName = "plasmacloud";
configFile = "/etc/nixos/secrets/cluster-config.json";
# Disable joiners to keep the test lean (no daemons required)
enableChainfire = false;
enableFlareDB = false;
enableIAM = false;
enableHealthCheck = false;
};
environment.systemPackages = [ pkgs.jq ];
};
testScript = ''
start_all()
machine.wait_for_unit("multi-user.target")
machine.succeed("cat /etc/nixos/secrets/cluster-config.json | jq -r .node_id | grep node01")
machine.succeed("test -d /var/lib/first-boot-automation")
machine.succeed("systemctl --failed --no-legend")
'';
}