diff options
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/tests/all-tests.nix | 1 | ||||
-rw-r--r-- | nixos/tests/php/default.nix | 6 | ||||
-rw-r--r-- | nixos/tests/php/fpm.nix | 55 |
3 files changed, 62 insertions, 0 deletions
diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index a84f2c5d2616..e003372ef9d4 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -240,6 +240,7 @@ in peerflix = handleTest ./peerflix.nix {}; pgjwt = handleTest ./pgjwt.nix {}; pgmanage = handleTest ./pgmanage.nix {}; + php = handleTest ./php {}; php-pcre = handleTest ./php-pcre.nix {}; plasma5 = handleTest ./plasma5.nix {}; plotinus = handleTest ./plotinus.nix {}; diff --git a/nixos/tests/php/default.nix b/nixos/tests/php/default.nix new file mode 100644 index 000000000000..c5735bd664d7 --- /dev/null +++ b/nixos/tests/php/default.nix @@ -0,0 +1,6 @@ +{ system ? builtins.currentSystem, + config ? {}, + pkgs ? import ../../.. { inherit system config; } +}: { + fpm = import ./fpm.nix { inherit system pkgs; }; +} diff --git a/nixos/tests/php/fpm.nix b/nixos/tests/php/fpm.nix new file mode 100644 index 000000000000..e93a31834185 --- /dev/null +++ b/nixos/tests/php/fpm.nix @@ -0,0 +1,55 @@ +import ../make-test-python.nix ({pkgs, ...}: { + name = "php-fpm-nginx-test"; + meta.maintainers = with pkgs.stdenv.lib.maintainers; [ etu ]; + + machine = { config, lib, pkgs, ... }: { + services.nginx = { + enable = true; + + virtualHosts."phpfpm" = let + testdir = pkgs.writeTextDir "web/index.php" "<?php phpinfo();"; + in { + root = "${testdir}/web"; + locations."~ \.php$".extraConfig = '' + fastcgi_pass unix:${config.services.phpfpm.pools.foobar.socket}; + fastcgi_index index.php; + include ${pkgs.nginx}/conf/fastcgi_params; + include ${pkgs.nginx}/conf/fastcgi.conf; + ''; + locations."/" = { + tryFiles = "$uri $uri/ index.php"; + index = "index.php index.html index.htm"; + }; + }; + }; + + services.phpfpm.pools."foobar" = { + user = "nginx"; + settings = { + "listen.group" = "nginx"; + "listen.mode" = "0600"; + "listen.owner" = "nginx"; + "pm" = "dynamic"; + "pm.max_children" = 5; + "pm.max_requests" = 500; + "pm.max_spare_servers" = 3; + "pm.min_spare_servers" = 1; + "pm.start_servers" = 2; + }; + }; + }; + testScript = { ... }: '' + machine.wait_for_unit("nginx.service") + machine.wait_for_unit("phpfpm-foobar.service") + + # Check so we get an evaluated PHP back + assert "PHP Version ${pkgs.php.version}" in machine.succeed("curl -vvv -s http://127.0.0.1:80/") + + # Check so we have database and some other extensions loaded + assert "json" in machine.succeed("curl -vvv -s http://127.0.0.1:80/") + assert "opcache" in machine.succeed("curl -vvv -s http://127.0.0.1:80/") + assert "pdo_mysql" in machine.succeed("curl -vvv -s http://127.0.0.1:80/") + assert "pdo_pgsql" in machine.succeed("curl -vvv -s http://127.0.0.1:80/") + assert "pdo_sqlite" in machine.succeed("curl -vvv -s http://127.0.0.1:80/") + ''; +}) |