test: add initial e2e test for nachtigall
Some checks failed
Flake checks / Check (pull_request) Failing after 7m31s

This commit is contained in:
Benjamin Yule Bädorf 2024-04-28 16:04:15 +02:00
parent 087ff3810b
commit 952d6dfc06
Signed by: b12f
GPG key ID: 729956E1124F8F26
8 changed files with 117 additions and 6 deletions

View file

@ -49,7 +49,7 @@
./hosts
];
perSystem = { system, pkgs, config, ... }: {
perSystem = args@{ system, pkgs, config, lib, ... }: {
_module.args = {
inherit inputs;
pkgs = import inputs.nixpkgs {
@ -61,6 +61,9 @@
unstable = import inputs.unstable { inherit system; };
master = import inputs.master { inherit system; };
};
packages = import ./tests ({ inherit inputs self; } // args);
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
deploy-rs
@ -81,8 +84,7 @@
};
};
flake =
let
flake = let
username = "barkeeper";
in
{

View file

@ -14,6 +14,17 @@
];
};
nachtigall-test = {
imports = [
self.inputs.agenix.nixosModules.default
self.nixosModules.home-manager
./nachtigall/test-vm.nix
self.nixosModules.overlays
self.nixosModules.core
self.nixosModules.docker
];
};
flora-6 = self.nixos-flake.lib.mkLinuxSystem {
imports = [
self.inputs.agenix.nixosModules.default

View file

@ -30,7 +30,6 @@
};
};
# keycloak
services.keycloak = {
enable = true;
database.passwordFile = config.age.secrets.keycloak-database-password.path;

View file

@ -0,0 +1,54 @@
{ flake, lib, ... }:
{
imports =
[
./backups.nix
./apps/nginx.nix
./apps/collabora.nix
./apps/coturn.nix
./apps/forgejo.nix
./apps/keycloak.nix
./apps/mailman.nix
./apps/mastodon.nix
./apps/mediawiki.nix
./apps/nextcloud.nix
./apps/nginx-mastodon.nix
./apps/nginx-mastodon-files.nix
./apps/nginx-prometheus-exporters.nix
./apps/nginx-website.nix
./apps/nginx-website-miom.nix
./apps/opensearch.nix
./apps/owncast.nix
./apps/postgresql.nix
./apps/prometheus-exporters.nix
./apps/promtail.nix
./apps/searx.nix
./apps/tmate.nix
./apps/matrix/irc.nix
./apps/matrix/mautrix-telegram.nix
./apps/matrix/synapse.nix
./apps/nginx-matrix.nix
];
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
security.acme.defaults.server = "https://acme-staging-v02.api.letsencrypt.org/directory";
security.acme.preliminarySelfsigned = true;
networking.useDHCP = true;
networking.interfaces."enp35s0".ipv4.addresses = [
{
address = "10.0.0.1";
prefixLength = 26;
}
];
networking.interfaces."enp35s0".ipv6.addresses = [
{
address = "2a01:4f8:172:1c25::1";
prefixLength = 64;
}
];
}

View file

@ -1,8 +1,7 @@
{ self, lib, inputs, ... }: {
# Configuration common to all Linux systems
flake = {
lib =
let
lib = let
callLibs = file: import file { inherit lib; };
in
rec {

5
modules/test-vm.nix Normal file
View file

@ -0,0 +1,5 @@
{ ... }:
{
security.acme.defaults.server = "https://acme-staging-v02.api.letsencrypt.org/directory";
security.acme.preliminarySelfsigned = true;
}

19
tests/default.nix Normal file
View file

@ -0,0 +1,19 @@
args@{
self,
lib,
system,
pkgs,
inputs,
...
}: let
nixos-lib = import (inputs.nixpkgs + "/nixos/lib") { };
loadTestFiles = with lib; dir: mapAttrs' (name: _: let
test = ((import (dir + "/${name}")) args);
in {
name = "test-" + (lib.strings.removeSuffix ".nix" name);
value = nixos-lib.runTest test;
})
(filterAttrs (name: _: (hasSuffix ".nix" name) && name != "default.nix")
(builtins.readDir dir));
in loadTestFiles ./.

22
tests/website.nix Normal file
View file

@ -0,0 +1,22 @@
{
self,
pkgs,
lib,
config,
...
}: {
name = "website";
nodes.nachtigall-test = self.nixosConfigurations.nachtigall-test;
node.specialArgs = self.outputs.nixosConfigurations.nachtigall._module.specialArgs;
hostPkgs = pkgs;
enableOCR = true;
testScript = ''
machine.wait_for_unit("system.slice")
machine.succeed("ping 127.0.0.1 -c 2")
machine.succeed("ping iregendeinscheiss.de -c 2")
'';
}