summaryrefslogtreecommitdiffstats
path: root/nixos/tests/matomo.nix
blob: 8163502e9ef2f7d17fc0241147b8240e69aef18f (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
{ lib, ... }:
{
  name = "matomo";

  nodes.machine =
    { config, pkgs, ... }:
    {
      services.matomo = {
        enable = true;
        nginx = {
          forceSSL = false;
          enableACME = false;
        };
      };
      services.mysql = {
        enable = true;
        package = pkgs.mariadb;
      };
      services.nginx.enable = true;
    };

  testScript = ''
    start_all()
    machine.wait_for_unit("mysql.service")
    machine.wait_for_unit("phpfpm-matomo.service")
    machine.wait_for_unit("nginx.service")

    with subtest("matomo.js reachable via HTTP"):
      machine.succeed("curl -sSfk http://machine/matomo.js")

    with subtest("js/piwik.js reachable via HTTP"):
      machine.succeed("curl -sSfk http://machine/js/piwik.js")

    with subtest("matomo.php (API) reachable via HTTP"):
      machine.succeed("curl -sSfk http://machine/matomo.php")

    # without the grep the command does not produce valid utf-8 for some reason
    with subtest("welcome screen loads"):
      machine.succeed(
        "curl -sSfL http://localhost/ | grep '<title>Matomo[^<]*Installation'"
      )

    with subtest("killing the phpfpm process should trigger an automatic restart"):
      machine.succeed("systemctl kill -s KILL phpfpm-matomo")
      machine.sleep(1)
      machine.wait_for_unit("phpfpm-matomo.service")
  '';

  meta.maintainers = with lib.maintainers; [
    florianjacob
    mmilata
    twey
    boozedog
    leona
    osnyx
  ];
}