about summary refs log tree commit diff
path: root/nixpkgs/nixos/tests/wordpress.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/nixos/tests/wordpress.nix')
-rw-r--r--nixpkgs/nixos/tests/wordpress.nix42
1 files changed, 29 insertions, 13 deletions
diff --git a/nixpkgs/nixos/tests/wordpress.nix b/nixpkgs/nixos/tests/wordpress.nix
index c6acfa6c1f3d..b7449859f7e6 100644
--- a/nixpkgs/nixos/tests/wordpress.nix
+++ b/nixpkgs/nixos/tests/wordpress.nix
@@ -1,9 +1,13 @@
-import ./make-test.nix ({ pkgs, ... }:
+import ./make-test-python.nix ({ pkgs, ... }:
 
 {
   name = "wordpress";
   meta = with pkgs.stdenv.lib.maintainers; {
-    maintainers = [ grahamc ]; # under duress!
+    maintainers = [
+      flokli
+      grahamc # under duress!
+      mmilata
+    ];
   };
 
   machine =
@@ -23,19 +27,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"):
+        pattern = re.compile(r"^define.*NONCE_SALT.{64,};$", re.MULTILINE)
+        for site_name in site_names:
+            assert pattern.search(
+                machine.succeed(f"cat /var/lib/wordpress/{site_name}/secret-keys.php")
+            )
+  '';
 })