aboutsummaryrefslogtreecommitdiff
path: root/nixos/tests/wordpress.nix
blob: 774ef6293b51d0526955fec5fe162eb73c69af1a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import ./make-test.nix ({ pkgs, ... }:

{
  name = "wordpress";
  meta = with pkgs.stdenv.lib.maintainers; {
    maintainers = [ grahamc ]; # under duress!
  };

  machine =
    { ... }:
    { services.httpd.adminAddr = "webmaster@site.local";
      services.httpd.logPerVirtualHost = true;

      services.wordpress."site1.local" = {
        database.tablePrefix = "site1_";
      };

      services.wordpress."site2.local" = {
        database.tablePrefix = "site2_";
      };

      networking.hosts."127.0.0.1" = [ "site1.local" "site2.local" ];

      # required for wordpress-init.service to succeed
      systemd.tmpfiles.rules = [
        "F /var/lib/wordpress/site1.local/secret-keys.php 0440 wordpress wwwrun - -"
        "F /var/lib/wordpress/site2.local/secret-keys.php 0440 wordpress wwwrun - -"
      ];
    };

  testScript = ''
    startAll;

    $machine->waitForUnit("httpd");
    $machine->waitForUnit("phpfpm-wordpress-site1.local");
    $machine->waitForUnit("phpfpm-wordpress-site2.local");

    $machine->succeed("curl -L site1.local | grep 'Welcome to the famous'");
    $machine->succeed("curl -L site2.local | grep 'Welcome to the famous'");
  '';

})