nixpkgs/nixos/tests/wordpress.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

91 lines
2.4 KiB
Nix
Raw Normal View History

2019-11-23 23:54:06 +01:00
import ./make-test-python.nix ({ pkgs, ... }:
2016-09-27 00:06:56 +02:00
{
name = "wordpress";
meta = with pkgs.lib.maintainers; {
maintainers = [
flokli
grahamc # under duress!
mmilata
];
2016-09-27 00:06:56 +02:00
};
2020-04-06 09:25:07 +02:00
nodes = {
wp_httpd = { ... }: {
services.httpd.adminAddr = "webmaster@site.local";
services.httpd.logPerVirtualHost = true;
services.wordpress.sites = {
2020-04-06 09:25:07 +02:00
"site1.local" = {
database.tablePrefix = "site1_";
};
"site2.local" = {
database.tablePrefix = "site2_";
2020-04-06 09:25:07 +02:00
};
};
2016-09-27 00:06:56 +02:00
2020-04-06 09:25:07 +02:00
networking.firewall.allowedTCPPorts = [ 80 ];
networking.hosts."127.0.0.1" = [ "site1.local" "site2.local" ];
};
wp_nginx = { ... }: {
services.wordpress.webserver = "nginx";
services.wordpress.sites = {
"site1.local" = {
database.tablePrefix = "site1_";
};
"site2.local" = {
database.tablePrefix = "site2_";
};
};
2020-04-06 09:25:07 +02:00
networking.firewall.allowedTCPPorts = [ 80 ];
networking.hosts."127.0.0.1" = [ "site1.local" "site2.local" ];
};
2021-08-03 15:24:34 +02:00
wp_caddy = { ... }: {
services.wordpress.webserver = "caddy";
services.wordpress.sites = {
"site1.local" = {
database.tablePrefix = "site1_";
};
"site2.local" = {
database.tablePrefix = "site2_";
};
};
networking.firewall.allowedTCPPorts = [ 80 ];
networking.hosts."127.0.0.1" = [ "site1.local" "site2.local" ];
};
2020-04-06 09:25:07 +02:00
};
2016-09-27 00:06:56 +02:00
testScript = ''
2019-11-23 23:54:06 +01:00
import re
2016-09-27 00:06:56 +02:00
2019-11-23 23:54:06 +01:00
start_all()
2016-09-27 00:06:56 +02:00
2020-04-06 09:25:07 +02:00
wp_httpd.wait_for_unit("httpd")
wp_nginx.wait_for_unit("nginx")
2021-08-03 15:24:34 +02:00
wp_caddy.wait_for_unit("caddy")
2019-11-23 23:54:06 +01:00
site_names = ["site1.local", "site2.local"]
2021-08-03 15:24:34 +02:00
for machine in (wp_httpd, wp_nginx, wp_caddy):
2019-11-23 23:54:06 +01:00
for site_name in site_names:
2020-04-06 09:25:07 +02:00
machine.wait_for_unit(f"phpfpm-wordpress-{site_name}")
2016-09-27 00:06:56 +02:00
2020-04-06 09:25:07 +02:00
with subtest("website returns welcome screen"):
assert "Welcome to the famous" in machine.succeed(f"curl -L {site_name}")
2019-11-23 23:54:06 +01:00
2020-04-06 09:25:07 +02:00
with subtest("wordpress-init went through"):
info = machine.get_unit_info(f"wordpress-init-{site_name}")
assert info["Result"] == "success"
with subtest("secret keys are set"):
pattern = re.compile(r"^define.*NONCE_SALT.{64,};$", re.MULTILINE)
assert pattern.search(
machine.succeed(f"cat /var/lib/wordpress/{site_name}/secret-keys.php")
)
2019-11-23 23:54:06 +01:00
'';
2016-09-27 00:06:56 +02:00
})