diff options
author | Manuel Bärenz <m.baerenz@sonnen.de> | 2022-11-25 14:55:08 +0100 |
---|---|---|
committer | Izorkin <izorkin@elven.pw> | 2022-12-16 16:19:41 +0300 |
commit | 3479b871826978c4c7ac1bf87a890aa9ddad8fc0 (patch) | |
tree | 261b57dd4514030365a6adbfdf59d198ce9fc4e2 /nixos/tests/web-apps | |
parent | 883a56c0cc44a25407bbacab66027e8f4ab54fcc (diff) |
nixosTests.mastodon: Put script in separate file
Diffstat (limited to 'nixos/tests/web-apps')
-rw-r--r-- | nixos/tests/web-apps/mastodon/remote-postgresql.nix | 63 | ||||
-rw-r--r-- | nixos/tests/web-apps/mastodon/script.nix | 54 | ||||
-rw-r--r-- | nixos/tests/web-apps/mastodon/standard.nix | 56 |
3 files changed, 76 insertions, 97 deletions
diff --git a/nixos/tests/web-apps/mastodon/remote-postgresql.nix b/nixos/tests/web-apps/mastodon/remote-postgresql.nix index 551b456ad4358..2fd3983e13ec3 100644 --- a/nixos/tests/web-apps/mastodon/remote-postgresql.nix +++ b/nixos/tests/web-apps/mastodon/remote-postgresql.nix @@ -144,54 +144,17 @@ in }; }; - testScript = '' - start_all() - - database.wait_for_unit("postgresql.service") - database.wait_for_open_port(5432) - - server.wait_for_unit("redis-mastodon.service") - server.wait_for_unit("mastodon-sidekiq.service") - server.wait_for_unit("mastodon-streaming.service") - server.wait_for_unit("mastodon-web.service") - server.wait_for_open_port(55000) - server.wait_for_open_port(55001) - - # Check that mastodon-media-auto-remove is scheduled - server.succeed("systemctl status mastodon-media-auto-remove.timer") - - # Check Mastodon version from remote client - client.succeed("curl --fail https://mastodon.local/api/v1/instance | jq -r '.version' | grep '${pkgs.mastodon.version}'") - - # Check access from remote client - client.succeed("curl --fail https://mastodon.local/about | grep 'Mastodon hosted on mastodon.local'") - client.succeed("curl --fail $(curl https://mastodon.local/api/v1/instance 2> /dev/null | jq -r .thumbnail) --output /dev/null") - - # Simple check tootctl commands - # Check Mastodon version - server.succeed("mastodon-tootctl version | grep '${pkgs.mastodon.version}") - - # Manage accounts - server.succeed("mastodon-tootctl email_domain_blocks add example.com") - server.succeed("mastodon-tootctl email_domain_blocks list | grep example.com") - server.fail("mastodon-tootctl email_domain_blocks list | grep mastodon.local") - server.fail("mastodon-tootctl accounts create alice --email=alice@example.com") - server.succeed("mastodon-tootctl email_domain_blocks remove example.com") - server.succeed("mastodon-tootctl accounts create bob --email=bob@example.com") - server.succeed("mastodon-tootctl accounts approve bob") - server.succeed("mastodon-tootctl accounts delete bob") - - # Manage IP access - server.succeed("mastodon-tootctl ip_blocks add 192.168.0.0/16 --severity=no_access") - server.succeed("mastodon-tootctl ip_blocks export | grep 192.168.0.0/16") - server.fail("mastodon-tootctl ip_blocks export | grep 172.16.0.0/16") - client.fail("curl --fail https://mastodon.local/about") - server.succeed("mastodon-tootctl ip_blocks remove 192.168.0.0/16") - client.succeed("curl --fail https://mastodon.local/about") - - server.shutdown() - client.shutdown() - database.shutdown() - nginx.shutdown() - ''; + testScript = import ./script.nix { + inherit pkgs; + extraInit = '' + nginx.wait_for_unit("nginx.service") + nginx.wait_for_open_port(443) + database.wait_for_unit("postgresql.service") + database.wait_for_open_port(5432) + ''; + extraShutdown = '' + nginx.shutdown() + database.shutdown() + ''; + }; }) diff --git a/nixos/tests/web-apps/mastodon/script.nix b/nixos/tests/web-apps/mastodon/script.nix new file mode 100644 index 0000000000000..cdb1d4379b645 --- /dev/null +++ b/nixos/tests/web-apps/mastodon/script.nix @@ -0,0 +1,54 @@ +{ pkgs +, extraInit ? "" +, extraShutdown ? "" +}: + +'' + start_all() + + ${extraInit} + + server.wait_for_unit("redis-mastodon.service") + server.wait_for_unit("mastodon-sidekiq.service") + server.wait_for_unit("mastodon-streaming.service") + server.wait_for_unit("mastodon-web.service") + server.wait_for_open_port(55000) + server.wait_for_open_port(55001) + + # Check that mastodon-media-auto-remove is scheduled + server.succeed("systemctl status mastodon-media-auto-remove.timer") + + # Check Mastodon version from remote client + client.succeed("curl --fail https://mastodon.local/api/v1/instance | jq -r '.version' | grep '${pkgs.mastodon.version}'") + + # Check access from remote client + client.succeed("curl --fail https://mastodon.local/about | grep 'Mastodon hosted on mastodon.local'") + client.succeed("curl --fail $(curl https://mastodon.local/api/v1/instance 2> /dev/null | jq -r .thumbnail) --output /dev/null") + + # Simple check tootctl commands + # Check Mastodon version + server.succeed("mastodon-tootctl version | grep '${pkgs.mastodon.version}'") + + # Manage accounts + server.succeed("mastodon-tootctl email_domain_blocks add example.com") + server.succeed("mastodon-tootctl email_domain_blocks list | grep example.com") + server.fail("mastodon-tootctl email_domain_blocks list | grep mastodon.local") + server.fail("mastodon-tootctl accounts create alice --email=alice@example.com") + server.succeed("mastodon-tootctl email_domain_blocks remove example.com") + server.succeed("mastodon-tootctl accounts create bob --email=bob@example.com") + server.succeed("mastodon-tootctl accounts approve bob") + server.succeed("mastodon-tootctl accounts delete bob") + + # Manage IP access + server.succeed("mastodon-tootctl ip_blocks add 192.168.0.0/16 --severity=no_access") + server.succeed("mastodon-tootctl ip_blocks export | grep 192.168.0.0/16") + server.fail("mastodon-tootctl ip_blocks export | grep 172.16.0.0/16") + client.fail("curl --fail https://mastodon.local/about") + server.succeed("mastodon-tootctl ip_blocks remove 192.168.0.0/16") + client.succeed("curl --fail https://mastodon.local/about") + + server.shutdown() + client.shutdown() + + ${extraShutdown} +'' diff --git a/nixos/tests/web-apps/mastodon/standard.nix b/nixos/tests/web-apps/mastodon/standard.nix index 50ed5e5dc6dde..14311afea3f78 100644 --- a/nixos/tests/web-apps/mastodon/standard.nix +++ b/nixos/tests/web-apps/mastodon/standard.nix @@ -80,51 +80,13 @@ in }; }; - testScript = '' - start_all() - - server.wait_for_unit("nginx.service") - server.wait_for_unit("redis-mastodon.service") - server.wait_for_unit("postgresql.service") - server.wait_for_unit("mastodon-sidekiq.service") - server.wait_for_unit("mastodon-streaming.service") - server.wait_for_unit("mastodon-web.service") - server.wait_for_open_port(55000) - server.wait_for_open_port(55001) - - # Check that mastodon-media-auto-remove is scheduled - server.succeed("systemctl status mastodon-media-auto-remove.timer") - - # Check Mastodon version from remote client - client.succeed("curl --fail https://mastodon.local/api/v1/instance | jq -r '.version' | grep '${pkgs.mastodon.version}'") - - # Check access from remote client - client.succeed("curl --fail https://mastodon.local/about | grep 'Mastodon hosted on mastodon.local'") - client.succeed("curl --fail $(curl https://mastodon.local/api/v1/instance 2> /dev/null | jq -r .thumbnail) --output /dev/null") - - # Simple check tootctl commands - # Check Mastodon version - server.succeed("mastodon-tootctl version | grep '${pkgs.mastodon.version}'") - - # Manage accounts - server.succeed("mastodon-tootctl email_domain_blocks add example.com") - server.succeed("mastodon-tootctl email_domain_blocks list | grep example.com") - server.fail("mastodon-tootctl email_domain_blocks list | grep mastodon.local") - server.fail("mastodon-tootctl accounts create alice --email=alice@example.com") - server.succeed("mastodon-tootctl email_domain_blocks remove example.com") - server.succeed("mastodon-tootctl accounts create bob --email=bob@example.com") - server.succeed("mastodon-tootctl accounts approve bob") - server.succeed("mastodon-tootctl accounts delete bob") - - # Manage IP access - server.succeed("mastodon-tootctl ip_blocks add 192.168.0.0/16 --severity=no_access") - server.succeed("mastodon-tootctl ip_blocks export | grep 192.168.0.0/16") - server.fail("mastodon-tootctl ip_blocks export | grep 172.16.0.0/16") - client.fail("curl --fail https://mastodon.local/about") - server.succeed("mastodon-tootctl ip_blocks remove 192.168.0.0/16") - client.succeed("curl --fail https://mastodon.local/about") - - server.shutdown() - client.shutdown() - ''; + testScript = import ./script.nix { + inherit pkgs; + extraInit = '' + server.wait_for_unit("nginx.service") + server.wait_for_open_port(443) + server.wait_for_unit("postgresql.service") + server.wait_for_open_port(5432) + ''; + }; }) |