1
0
Fork 0
selfhostblocks/test/services/monitoring.nix

77 lines
1.4 KiB
Nix
Raw Normal View History

2024-07-16 10:38:26 +02:00
{ pkgs, ... }:
2024-03-20 06:50:41 +01:00
let
pkgs' = pkgs;
2024-06-07 09:10:46 +02:00
2024-07-12 13:01:26 +02:00
testLib = pkgs.callPackage ../common.nix {};
2024-06-07 09:10:46 +02:00
subdomain = "grafana";
domain = "example.com";
password = "securepw";
2024-07-12 13:01:26 +02:00
commonTestScript = testLib.accessScript {
2024-07-16 10:38:26 +02:00
inherit subdomain domain;
2024-07-12 13:01:26 +02:00
hasSSL = { node, ... }: !(isNull node.config.shb.monitoring.ssl);
waitForServices = { ... }: [
2024-07-16 10:38:26 +02:00
"grafana.service"
2024-07-12 13:01:26 +02:00
];
waitForPorts = { node, ... }: [
node.config.shb.monitoring.grafanaPort
];
};
2024-06-07 09:10:46 +02:00
2024-07-16 10:38:26 +02:00
base = testLib.base pkgs' [
../../modules/blocks/monitoring.nix
];
2024-06-07 09:10:46 +02:00
basic = { config, ... }: {
shb.monitoring = {
enable = true;
inherit subdomain domain;
2024-07-16 10:38:26 +02:00
2024-06-07 09:10:46 +02:00
grafanaPort = 3000;
adminPasswordFile = pkgs.writeText "admin_password" password;
secretKeyFile = pkgs.writeText "secret_key" "secret_key";
};
};
https = { config, ...}: {
shb.monitoring = {
ssl = config.shb.certs.certs.selfsigned.n;
};
};
2024-03-20 06:50:41 +01:00
in
{
2024-06-07 09:10:46 +02:00
basic = pkgs.testers.runNixOSTest {
2024-07-16 10:38:26 +02:00
name = "monitoring_basic";
2024-07-16 10:38:26 +02:00
nodes.server = {
imports = [
base
basic
];
};
2024-06-07 09:10:46 +02:00
nodes.client = {};
2024-06-07 09:10:46 +02:00
testScript = commonTestScript;
};
2024-06-07 09:10:46 +02:00
https = pkgs.testers.runNixOSTest {
2024-07-16 10:38:26 +02:00
name = "monitoring_https";
nodes.server = {
imports = [
base
(testLib.certs domain)
basic
https
];
};
2024-06-07 09:10:46 +02:00
nodes.client = {};
testScript = commonTestScript;
};
}