2019-10-04 22:38:58 +02:00
|
|
|
{
|
|
|
|
system ? builtins.currentSystem,
|
|
|
|
config ? { },
|
|
|
|
pkgs ? import ../.. { inherit system config; },
|
|
|
|
}:
|
|
|
|
|
2019-12-01 00:50:55 +01:00
|
|
|
with import ../lib/testing-python.nix { inherit system pkgs; };
|
2019-10-04 22:38:58 +02:00
|
|
|
with pkgs.lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
matomoTest =
|
|
|
|
package:
|
|
|
|
makeTest {
|
2022-06-26 00:14:38 +02:00
|
|
|
name = "matomo";
|
|
|
|
|
2022-03-21 00:15:30 +01:00
|
|
|
nodes.machine =
|
|
|
|
{ config, pkgs, ... }:
|
|
|
|
{
|
2019-10-04 22:38:58 +02:00
|
|
|
services.matomo = {
|
|
|
|
package = package;
|
|
|
|
enable = true;
|
|
|
|
nginx = {
|
|
|
|
forceSSL = false;
|
|
|
|
enableACME = false;
|
2024-12-10 20:26:33 +01:00
|
|
|
};
|
|
|
|
};
|
2019-10-04 22:38:58 +02:00
|
|
|
services.mysql = {
|
|
|
|
enable = true;
|
2021-06-04 16:08:41 +02:00
|
|
|
package = pkgs.mariadb;
|
2024-12-10 20:26:33 +01:00
|
|
|
};
|
2019-10-04 22:38:58 +02:00
|
|
|
services.nginx.enable = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
testScript = ''
|
2019-12-01 00:50:55 +01:00
|
|
|
start_all()
|
|
|
|
machine.wait_for_unit("mysql.service")
|
|
|
|
machine.wait_for_unit("phpfpm-matomo.service")
|
|
|
|
machine.wait_for_unit("nginx.service")
|
|
|
|
|
2025-01-14 16:01:30 +01:00
|
|
|
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")
|
|
|
|
|
2019-12-01 00:50:55 +01:00
|
|
|
# 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'"
|
|
|
|
)
|
2025-01-14 16:01:30 +01:00
|
|
|
|
|
|
|
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")
|
2019-10-04 22:38:58 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
in
|
|
|
|
{
|
|
|
|
matomo = matomoTest pkgs.matomo // {
|
|
|
|
name = "matomo";
|
2024-06-12 10:11:01 +02:00
|
|
|
meta.maintainers =
|
|
|
|
with maintainers;
|
|
|
|
[
|
|
|
|
florianjacob
|
|
|
|
mmilata
|
|
|
|
twey
|
|
|
|
boozedog
|
|
|
|
]
|
|
|
|
++ lib.teams.flyingcircus.members;
|
2024-01-11 08:33:36 +01:00
|
|
|
};
|
2019-10-04 22:38:58 +02:00
|
|
|
}
|