clanServices/zerotier: Add eval tests

Add eval tests to the zerotier clanService module.

The vm module is a stub that acts as an api for the `generate-test-vars`
script, as that currently only works with a vm, not with an eval test.

This checks, if all the peers pick up their respective configuration
correctly. Without running the service itself.
This commit is contained in:
a-kenji
2025-06-13 11:56:50 +02:00
parent eabf7f86fc
commit 96325c0c29
35 changed files with 347 additions and 1 deletions

View File

@@ -0,0 +1,73 @@
{
module,
clanLib,
...
}:
let
testFlake = clanLib.buildClan {
directory = ./vm;
machines.jon = {
nixpkgs.hostPlatform = "x86_64-linux";
};
machines.sara = {
nixpkgs.hostPlatform = "x86_64-linux";
};
machines.bam = {
nixpkgs.hostPlatform = "x86_64-linux";
};
modules.zerotier = module;
inventory.instances = {
zerotier = {
module.name = "zerotier";
roles.peer.tags.all = { };
roles.moon.machines.sara.settings.stableEndpoints = [ "10.0.0.3/9993" ];
roles.controller.machines.bam = { };
};
};
};
in
{
test_peers = {
expr = {
hasNetworkIds = testFlake.nixosConfigurations.jon.config.services.zerotierone.joinNetworks;
isController =
testFlake.nixosConfigurations.jon.config.clan.core.networking.zerotier.controller.enable;
networkName = testFlake.nixosConfigurations.jon.config.clan.core.networking.zerotier.name;
};
expected = {
hasNetworkIds = [ "0e28cb903344475e" ];
isController = false;
networkName = "zerotier";
};
};
test_moon = {
expr = {
hasNetworkIds = testFlake.nixosConfigurations.sara.config.services.zerotierone.joinNetworks;
isController =
testFlake.nixosConfigurations.sara.config.clan.core.networking.zerotier.controller.enable;
networkName = testFlake.nixosConfigurations.sara.config.clan.core.networking.zerotier.name;
};
expected = {
hasNetworkIds = [ "0e28cb903344475e" ];
isController = false;
networkName = "zerotier";
};
};
test_controller = {
expr = {
hasNetworkIds = testFlake.nixosConfigurations.bam.config.services.zerotierone.joinNetworks;
isController =
testFlake.nixosConfigurations.bam.config.clan.core.networking.zerotier.controller.enable;
networkName = testFlake.nixosConfigurations.bam.config.clan.core.networking.zerotier.name;
};
expected = {
hasNetworkIds = [ "0e28cb903344475e" ];
isController = true;
networkName = "zerotier";
};
};
}