add some smoke tests.

This commit is contained in:
Ingolf Wagner 2024-09-15 07:22:02 +07:00
parent a52e1b39a0
commit 743a9fc885
No known key found for this signature in database
GPG key ID: 76BF5F1928B9618B
4 changed files with 82 additions and 1 deletions

View file

@ -1,4 +1,9 @@
{ config, ... }: {
config,
lib,
pkgs,
...
}:
{ {
networking.firewall.interfaces.wg0.allowedTCPPorts = [ networking.firewall.interfaces.wg0.allowedTCPPorts = [
7878 7878
@ -11,6 +16,27 @@
8989 8989
8686 8686
]; ];
verify.localCommands =
let
curl = lib.getExe pkgs.curl;
grep = lib.getExe pkgs.gnugrep;
command = domain: grepString: ''
if ${curl} -s -o /dev/null -w "%{http_code}" ${domain} | ${grep} -q "200"; then
if ${curl} -s ${domain} | ${grep} -q "${grepString}"; then
echo "[ OK ] Die Seite hat Statuscode 200 und enthält den String '${grepString}'."
else
echo "[Fail] Der Statuscode ist 200, aber die Seite enthält den String '${grepString}' nicht."
fi
else
echo "[Fail] Die Seite hat keinen Statuscode 200."
fi
'';
in
{
sonarr = command "sonarr.ingolf-wagner.de" "Sonarr";
radarr = command "radarr.ingolf-wagner.de" "Radarr";
};
# download series # download series
services.sonarr = { services.sonarr = {

View file

@ -6,6 +6,25 @@
}: }:
{ {
verify.localCommands.forgejo =
let
domain = "https://git.ingolf-wagner.de/explore/repos";
curl = lib.getExe pkgs.curl;
grep = lib.getExe pkgs.gnugrep;
grepString = "palo/nixos-config";
in
''
if ${curl} -s -o /dev/null -w "%{http_code}" ${domain} | ${grep} -q "200"; then
if ${curl} -s ${domain} | ${grep} -q "${grepString}"; then
echo "[ OK ] Die Seite hat Statuscode 200 und enthält den String '${grepString}'."
else
echo "[Fail] Der Statuscode ist 200, aber die Seite enthält den String '${grepString}' nicht."
fi
else
echo "[Fail] Die Seite hat keinen Statuscode 200."
fi
'';
services.nginx = { services.nginx = {
enable = true; enable = true;
statusPage = true; statusPage = true;

View file

@ -33,6 +33,24 @@
}; };
verify.closed.public.ports.nix-serve = [ config.services.nix-serve.port ]; verify.closed.public.ports.nix-serve = [ config.services.nix-serve.port ];
verify.localCommands.nix-serve =
let
domain = "cache.${config.networking.hostName}.wg0/nix-cache-info";
curl = lib.getExe pkgs.curl;
grep = lib.getExe pkgs.gnugrep;
grepString = "Priority: 50";
in
''
if ${curl} -s -o /dev/null -w "%{http_code}" ${domain} | ${grep} -q "200"; then
if ${curl} -s ${domain} | ${grep} -q "${grepString}"; then
echo "[ OK ] Die Seite hat Statuscode 200 und enthält den String '${grepString}'."
else
echo "[Fail] Der Statuscode ist 200, aber die Seite enthält den String '${grepString}' nicht."
fi
else
echo "[Fail] Die Seite hat keinen Statuscode 200."
fi
'';
services.nginx = { services.nginx = {
enable = true; enable = true;

View file

@ -17,6 +17,24 @@ in
# networking.firewall.interfaces.wg0.allowedUDPPorts = [ photoprismPort ]; # networking.firewall.interfaces.wg0.allowedUDPPorts = [ photoprismPort ];
verify.closed.public.ports.photoprism = [ photoprismPort ]; verify.closed.public.ports.photoprism = [ photoprismPort ];
verify.localCommands.photoprism =
let
domain = "http://10.100.0.1:2342/library/login";
curl = lib.getExe pkgs.curl;
grep = lib.getExe pkgs.gnugrep;
grepString = "AI-Powered Photos App";
in
''
if ${curl} -s -o /dev/null -w "%{http_code}" ${domain} | ${grep} -q "200"; then
if ${curl} -s ${domain} | ${grep} -q "${grepString}"; then
echo "[ OK ] Die Seite hat Statuscode 200 und enthält den String '${grepString}'."
else
echo "[Fail] Der Statuscode ist 200, aber die Seite enthält den String '${grepString}' nicht."
fi
else
echo "[Fail] Die Seite hat keinen Statuscode 200."
fi
'';
containers.photoprism = { containers.photoprism = {
privateNetwork = false; privateNetwork = false;