python310Packages.pydeconz: 104 -> 105
[NixPkgs.git] / nixos / tests / php / fpm.nix
blob64b61a377e28a84b6a0ce5a57001c8a6b94e1bdc
1 import ../make-test-python.nix ({ pkgs, lib, php, ... }: {
2   name = "php-${php.version}-fpm-nginx-test";
3   meta.maintainers = lib.teams.php.members;
5   nodes.machine = { config, lib, pkgs, ... }: {
6     environment.systemPackages = [ php ];
8     services.nginx = {
9       enable = true;
11       virtualHosts."phpfpm" =
12         let
13           testdir = pkgs.writeTextDir "web/index.php" "<?php phpinfo();";
14         in
15         {
16           root = "${testdir}/web";
17           locations."~ \\.php$".extraConfig = ''
18             fastcgi_pass unix:${config.services.phpfpm.pools.foobar.socket};
19             fastcgi_index index.php;
20             include ${config.services.nginx.package}/conf/fastcgi_params;
21             include ${pkgs.nginx}/conf/fastcgi.conf;
22           '';
23           locations."/" = {
24             tryFiles = "$uri $uri/ index.php";
25             index = "index.php index.html index.htm";
26           };
27         };
28     };
30     services.phpfpm.pools."foobar" = {
31       user = "nginx";
32       phpPackage = php;
33       settings = {
34         "listen.group" = "nginx";
35         "listen.mode" = "0600";
36         "listen.owner" = "nginx";
37         "pm" = "dynamic";
38         "pm.max_children" = 5;
39         "pm.max_requests" = 500;
40         "pm.max_spare_servers" = 3;
41         "pm.min_spare_servers" = 1;
42         "pm.start_servers" = 2;
43       };
44     };
45   };
46   testScript = { ... }: ''
47     machine.wait_for_unit("nginx.service")
48     machine.wait_for_unit("phpfpm-foobar.service")
50     # Check so we get an evaluated PHP back
51     response = machine.succeed("curl -fvvv -s http://127.0.0.1:80/")
52     assert "PHP Version ${php.version}" in response, "PHP version not detected"
54     # Check so we have database and some other extensions loaded
55     for ext in ["json", "opcache", "pdo_mysql", "pdo_pgsql", "pdo_sqlite", "apcu"]:
56         assert ext in response, f"Missing {ext} extension"
57         machine.succeed(f'test -n "$(php -m | grep -i {ext})"')
58   '';