git.iko.soy/typeable/nixpkgs
on master help sign in
nixosTests.wordpress: port to python
commitec16d5c3ba641be9f9021a64926c77ae23d294fb authorFlorian Klink <flokli@flokli.de> dateSat 23 Nov 2019, 23:54 (7 years ago) parentd95112a
1 file changed+24−12
nixos/tests/wordpress.nix+24−12
nixos/tests/wordpress.nix+24−12
@@ -1,4 +1,4 @@
1−import ./make-test.nix ({ pkgs, ... }:
1+import ./make-test-python.nix ({ pkgs, ... }:
22
33{
44 name = "wordpress";
@@ -23,19 +23,31 @@ import ./make-test.nix ({ pkgs, ... }:
2323 };
2424
2525 testScript = ''
26− startAll;
26+ import re
2727
28− $machine->waitForUnit("httpd");
29− $machine->waitForUnit("phpfpm-wordpress-site1.local");
30− $machine->waitForUnit("phpfpm-wordpress-site2.local");
28+ start_all()
3129
32− $machine->succeed("curl -L site1.local | grep 'Welcome to the famous'");
33− $machine->succeed("curl -L site2.local | grep 'Welcome to the famous'");
30+ machine.wait_for_unit("httpd")
3431
35− $machine->succeed("systemctl --no-pager show wordpress-init-site1.local.service | grep 'ExecStart=.*status=0'");
36− $machine->succeed("systemctl --no-pager show wordpress-init-site2.local.service | grep 'ExecStart=.*status=0'");
37− $machine->succeed("grep -E '^define.*NONCE_SALT.{64,};\$' /var/lib/wordpress/site1.local/secret-keys.php");
38− $machine->succeed("grep -E '^define.*NONCE_SALT.{64,};\$' /var/lib/wordpress/site2.local/secret-keys.php");
39− '';
32+ machine.wait_for_unit("phpfpm-wordpress-site1.local")
33+ machine.wait_for_unit("phpfpm-wordpress-site2.local")
34+
35+ site_names = ["site1.local", "site2.local"]
36+
37+ with subtest("website returns welcome screen"):
38+ for site_name in site_names:
39+ assert "Welcome to the famous" in machine.succeed(f"curl -L {site_name}")
4040
41+ with subtest("wordpress-init went through"):
42+ for site_name in site_names:
43+ info = machine.get_unit_info(f"wordpress-init-{site_name}")
44+ assert info.Result == "success"
45+
46+ with subtest("secret keys are set"):
47+ re.compile(r"^define.*NONCE_SALT.{64,};$")
48+ for site_name in site_names:
49+ assert r.match(
50+ machine.succeed(f"cat /var/lib/wordpress/{site_name}/secret-keys.php")
51+ )
52+ '';
4153})