continuous-integration/drone/push Build is passing
This PR adds a declarative integration testing setup which includes 2 local VMs client and server which can be started and stopped via a command. The VMs are run with QEMU and created by https://github.com/microvm-nix/microvm.nix The key pair is generated for this use case and is safe to commit, it resolves the problem that the readFile function can only be used with git tracked files. --------- Co-authored-by: devydave <yannick-dev@tutanota.com> Reviewed-on: #902 Reviewed-by: p4u1 <133+p4u1@noreply.git.coopcloud.tech> Co-authored-by: devydave <bittedanke@tutanota.com>
60 lines
1.4 KiB
Nix
60 lines
1.4 KiB
Nix
{
|
|
lib,
|
|
config,
|
|
...
|
|
}:
|
|
let
|
|
maxVMs = 3;
|
|
in
|
|
{
|
|
options = {
|
|
abra.testing.enable = lib.mkOption {
|
|
type = lib.types.bool;
|
|
default = false;
|
|
description = "Enable the abra integration testing framework";
|
|
};
|
|
abra.testing.externalInterface = lib.mkOption {
|
|
type = lib.types.str;
|
|
default = null;
|
|
description = "Change this to the interface with upstream Internet access";
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf config.abra.testing.enable {
|
|
networking.useNetworkd = true;
|
|
systemd.network.wait-online.enable = false;
|
|
systemd.network.networks = builtins.listToAttrs (
|
|
map (index: {
|
|
name = "30-vm${toString index}";
|
|
value = {
|
|
matchConfig.Name = "vm${toString index}";
|
|
# Host's addresses
|
|
address = [
|
|
"10.0.0.0/32"
|
|
"fec0::/128"
|
|
];
|
|
# Setup routes to the VM
|
|
routes = [
|
|
{
|
|
Destination = "10.0.0.${toString index}/32";
|
|
}
|
|
{
|
|
Destination = "fec0::${lib.toHexString index}/128";
|
|
}
|
|
];
|
|
# Enable routing
|
|
networkConfig = {
|
|
IPv4Forwarding = true;
|
|
IPv6Forwarding = true;
|
|
};
|
|
};
|
|
}) (lib.genList (i: i + 1) maxVMs)
|
|
);
|
|
networking.nat = {
|
|
enable = true;
|
|
internalIPs = [ "10.0.0.0/24" ];
|
|
externalInterface = config.abra.testing.externalInterface;
|
|
};
|
|
};
|
|
}
|