forked from Fediversity/Fediversity
165 lines
4.9 KiB
Nix
165 lines
4.9 KiB
Nix
{
|
|
testers,
|
|
...
|
|
}:
|
|
testers.runNixOSTest (
|
|
{
|
|
config,
|
|
hostPkgs,
|
|
...
|
|
}:
|
|
let
|
|
sources = import ../../../npins;
|
|
pkgs = hostPkgs;
|
|
# dummyFile = hostPkgs.writeText "dummy" "";
|
|
tf = pkgs.callPackage ../../../launch/tf.nix { };
|
|
tfEnv = pkgs.callPackage ../../../launch/tf-env.nix { };
|
|
inherit (pkgs) lib;
|
|
inherit (import ../../../panel/env.nix { inherit lib pkgs; }) BIN_PATH;
|
|
tfVars = builtins.path {
|
|
name = "basic.tfvars";
|
|
path = ./basic.tfvars;
|
|
};
|
|
|
|
fakeMachine = pkgs.nixos [
|
|
../basic/minimalTarget.nix
|
|
../../../launch/options.nix
|
|
../../../launch/shared.nix
|
|
../../../launch/garage.nix
|
|
../../../launch/mastodon.nix
|
|
../../../launch/pixelfed.nix
|
|
../../../launch/peertube.nix
|
|
../../../infra/test-machines/test06
|
|
{
|
|
nix.nixPath = [ "/dummy/nix/path" ];
|
|
users.users.root.openssh.authorizedKeys.keys = [ "dummykey" ];
|
|
}
|
|
{
|
|
terraform = {
|
|
domain = "fediversity.net";
|
|
hostname = "base";
|
|
initialUser = {
|
|
displayName = "Testy McTestface";
|
|
username = "test";
|
|
email = "test@test.com";
|
|
password = "testtest";
|
|
};
|
|
};
|
|
}
|
|
];
|
|
|
|
extraDependenciesFromMachine =
|
|
machine:
|
|
[
|
|
machine.system.build.toplevel.inputDerivation
|
|
machine.system.build.etc.inputDerivation
|
|
machine.system.build.etcBasedir.inputDerivation
|
|
machine.system.build.etcMetadataImage.inputDerivation
|
|
machine.system.build.extraUtils.inputDerivation
|
|
machine.system.path.inputDerivation
|
|
machine.system.build.setEnvironment.inputDerivation
|
|
machine.system.build.vm.inputDerivation
|
|
# machine.system.build.vmWithBootLoader.inputDerivation
|
|
machine.system.build.bootStage1.inputDerivation
|
|
machine.system.build.bootStage2.inputDerivation
|
|
]
|
|
++ lib.concatLists (
|
|
lib.mapAttrsToList (
|
|
_k: v: if v ? source.inputDerivation then [ v.source.inputDerivation ] else [ ]
|
|
) machine.environment.etc
|
|
);
|
|
inherit (config) targetMachines pathToRoot pathFromRoot;
|
|
in
|
|
{
|
|
name = "deployment-basic";
|
|
|
|
imports = [
|
|
(import ../common/nixosTest.nix { inherit config lib hostPkgs; })
|
|
];
|
|
|
|
targetMachines = [
|
|
"hello"
|
|
"cowsay"
|
|
];
|
|
pathToRoot = ../../..;
|
|
pathFromRoot = "deployment/check/basic";
|
|
|
|
nodes =
|
|
{
|
|
deployer =
|
|
{ pkgs, nodes, ... }:
|
|
{
|
|
virtualisation = {
|
|
memorySize = 32 * 1024; # FIXME: trim down - maybe make it an option
|
|
diskSize = 50 * 1024; # FIXME: trim down - maybe make it an option
|
|
cores = 8; # FIXME: trim down - maybe make it an option
|
|
};
|
|
|
|
nix.settings = {
|
|
substituters = lib.mkForce [ ];
|
|
hashed-mirrors = null;
|
|
connect-timeout = 1;
|
|
};
|
|
|
|
system.extraDependencies =
|
|
lib.attrValues sources
|
|
++ [
|
|
pkgs.stdenv
|
|
pkgs.stdenvNoCC
|
|
# pkgs
|
|
tfVars
|
|
pkgs.bash
|
|
pkgs.bash.inputDerivation
|
|
pkgs.acl
|
|
pkgs.acl.inputDerivation
|
|
pkgs.attr
|
|
pkgs.attr.inputDerivation
|
|
pkgs.autoconf
|
|
pkgs.autoconf.inputDerivation
|
|
pkgs.automake
|
|
pkgs.automake.inputDerivation
|
|
pkgs.python3
|
|
pkgs.python3.inputDerivation
|
|
|
|
pkgs.peertube
|
|
pkgs.peertube.inputDerivation
|
|
pkgs.gixy
|
|
pkgs.gixy.inputDerivation
|
|
|
|
pkgs.postgresql_15
|
|
]
|
|
++ lib.concatLists (
|
|
map extraDependenciesFromMachine (map (tm: nodes.${tm}) targetMachines ++ [ fakeMachine.config ])
|
|
);
|
|
environment.systemPackages = [
|
|
tf
|
|
tfEnv
|
|
];
|
|
};
|
|
|
|
}
|
|
// lib.genAttrs targetMachines (_: {
|
|
imports = [ ../basic/minimalTarget.nix ];
|
|
users.users.root.openssh.authorizedKeys.keyFiles = [
|
|
(pathToRoot + "/${pathFromRoot}/deployer.pub")
|
|
];
|
|
});
|
|
|
|
extraTestScript = ''
|
|
with subtest("Check the status before deployment"):
|
|
hello.fail("hello 1>&2")
|
|
cowsay.fail("cowsay 1>&2")
|
|
|
|
with subtest("Validate config"):
|
|
deployer.wait_for_unit("multi-user.target")
|
|
deployer.succeed("${lib.getExe tf} -chdir='${tfEnv}/launch' validate")
|
|
|
|
with subtest("Run the deployment"):
|
|
deployer.succeed("PATH=${BIN_PATH} ${lib.getExe tf} -chdir='${tfEnv}/launch' apply --auto-approve -lock=false -parallelism=1 -var-file='${tfVars}'")
|
|
|
|
with subtest("Check the deployment"):
|
|
hello.succeed("hello 1>&2")
|
|
cowsay.succeed("cowsay hi 1>&2")
|
|
'';
|
|
}
|
|
)
|