nixosTests.wordpress: port to python

This commit is contained in:
Florian Klink 2019-11-23 23:54:06 +01:00
parent d95112aa73
commit ec16d5c3ba

View File

@ -1,4 +1,4 @@
import ./make-test.nix ({ pkgs, ... }:
import ./make-test-python.nix ({ pkgs, ... }:
{
name = "wordpress";
@ -23,19 +23,31 @@ import ./make-test.nix ({ pkgs, ... }:
};
testScript = ''
startAll;
import re
$machine->waitForUnit("httpd");
$machine->waitForUnit("phpfpm-wordpress-site1.local");
$machine->waitForUnit("phpfpm-wordpress-site2.local");
start_all()
$machine->succeed("curl -L site1.local | grep 'Welcome to the famous'");
$machine->succeed("curl -L site2.local | grep 'Welcome to the famous'");
machine.wait_for_unit("httpd")
$machine->succeed("systemctl --no-pager show wordpress-init-site1.local.service | grep 'ExecStart=.*status=0'");
$machine->succeed("systemctl --no-pager show wordpress-init-site2.local.service | grep 'ExecStart=.*status=0'");
$machine->succeed("grep -E '^define.*NONCE_SALT.{64,};\$' /var/lib/wordpress/site1.local/secret-keys.php");
$machine->succeed("grep -E '^define.*NONCE_SALT.{64,};\$' /var/lib/wordpress/site2.local/secret-keys.php");
machine.wait_for_unit("phpfpm-wordpress-site1.local")
machine.wait_for_unit("phpfpm-wordpress-site2.local")
site_names = ["site1.local", "site2.local"]
with subtest("website returns welcome screen"):
for site_name in site_names:
assert "Welcome to the famous" in machine.succeed(f"curl -L {site_name}")
with subtest("wordpress-init went through"):
for site_name in site_names:
info = machine.get_unit_info(f"wordpress-init-{site_name}")
assert info.Result == "success"
with subtest("secret keys are set"):
re.compile(r"^define.*NONCE_SALT.{64,};$")
for site_name in site_names:
assert r.match(
machine.succeed(f"cat /var/lib/wordpress/{site_name}/secret-keys.php")
)
'';
})