at 23.11-pre 1.4 kB view raw
1import ../make-test-python.nix ({ lib, pkgs, ... }: { 2 name = "healthchecks"; 3 4 meta = with lib.maintainers; { 5 maintainers = [ phaer ]; 6 }; 7 8 nodes.machine = { ... }: { 9 services.healthchecks = { 10 enable = true; 11 settings = { 12 SITE_NAME = "MyUniqueInstance"; 13 COMPRESS_ENABLED = "True"; 14 SECRET_KEY_FILE = pkgs.writeText "secret" 15 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; 16 }; 17 }; 18 }; 19 20 testScript = '' 21 machine.start() 22 machine.wait_for_unit("healthchecks.target") 23 machine.wait_until_succeeds("journalctl --since -1m --unit healthchecks --grep Listening") 24 25 with subtest("Home screen loads"): 26 machine.succeed( 27 "curl -sSfL http://localhost:8000 | grep '<title>Sign In'" 28 ) 29 30 with subtest("Setting SITE_NAME via freeform option works"): 31 machine.succeed( 32 "curl -sSfL http://localhost:8000 | grep 'MyUniqueInstance</title>'" 33 ) 34 35 with subtest("Manage script works"): 36 # "shell" sucommand should succeed, needs python in PATH. 37 assert "foo\n" == machine.succeed("echo 'print(\"foo\")' | sudo -u healthchecks healthchecks-manage shell") 38 39 # Shouldn't fail if not called by healthchecks user 40 assert "foo\n" == machine.succeed("echo 'print(\"foo\")' | healthchecks-manage shell") 41 ''; 42})