Merge pull request #85402 from jtojnar/httpd-php

This commit is contained in:
Jan Tojnar 2020-04-22 04:23:24 +02:00 committed by GitHub
commit b231ac2101
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 42 additions and 10 deletions

View File

@ -12,7 +12,7 @@ let
httpdConf = cfg.configFile;
php = cfg.phpPackage.override { apacheHttpd = pkg.dev; /* otherwise it only gets .out */ };
php = cfg.phpPackage.override { apacheHttpd = pkg; };
phpMajorVersion = lib.versions.major (lib.getVersion php);
@ -338,6 +338,7 @@ let
}
''
cat ${php}/etc/php.ini > $out
cat ${php}/lib/custom-php.ini > $out
echo "$options" >> $out
'';

View File

@ -115,6 +115,7 @@ in rec {
(onFullSupported "nixos.tests.openssh")
(onFullSupported "nixos.tests.pantheon")
(onFullSupported "nixos.tests.php.fpm")
(onFullSupported "nixos.tests.php.httpd")
(onFullSupported "nixos.tests.php.pcre")
(onFullSupported "nixos.tests.plasma5")
(onFullSupported "nixos.tests.predictable-interface-names.predictableNetworkd")

View File

@ -3,5 +3,6 @@
pkgs ? import ../../.. { inherit system config; }
}: {
fpm = import ./fpm.nix { inherit system pkgs; };
httpd = import ./httpd.nix { inherit system pkgs; };
pcre = import ./pcre.nix { inherit system pkgs; };
}

View File

@ -43,13 +43,11 @@ import ../make-test-python.nix ({pkgs, ...}: {
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/")
response = machine.succeed("curl -vvv -s http://127.0.0.1:80/")
assert "PHP Version ${pkgs.php.version}" in response, "PHP version not detected"
# 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/")
for ext in ["json", "opcache", "pdo_mysql", "pdo_pgsql", "pdo_sqlite"]:
assert ext in response, f"Missing {ext} extension"
'';
})

31
nixos/tests/php/httpd.nix Normal file
View File

@ -0,0 +1,31 @@
import ../make-test-python.nix ({pkgs, ...}: {
name = "php-httpd-test";
meta.maintainers = with pkgs.stdenv.lib.maintainers; [ etu ];
machine = { config, lib, pkgs, ... }: {
services.httpd = {
enable = true;
adminAddr = "admin@phpfpm";
virtualHosts."phpfpm" = let
testdir = pkgs.writeTextDir "web/index.php" "<?php phpinfo();";
in {
documentRoot = "${testdir}/web";
locations."/" = {
index = "index.php index.html";
};
};
enablePHP = true;
};
};
testScript = { ... }: ''
machine.wait_for_unit("httpd.service")
# Check so we get an evaluated PHP back
response = machine.succeed("curl -vvv -s http://127.0.0.1:80/")
assert "PHP Version ${pkgs.php.version}" in response, "PHP version not detected"
# Check so we have database and some other extensions loaded
for ext in ["json", "opcache", "pdo_mysql", "pdo_pgsql", "pdo_sqlite"]:
assert ext in response, f"Missing {ext} extension"
'';
})

View File

@ -30,8 +30,8 @@ in import ../make-test-python.nix ({ ...}: {
''
machine.wait_for_unit("httpd.service")
# Ensure php evaluation by matching on the var_dump syntax
assert 'string(${toString (builtins.stringLength testString)}) "${testString}"' in machine.succeed(
"curl -vvv -s http://127.0.0.1:80/index.php"
)
response = machine.succeed("curl -vvv -s http://127.0.0.1:80/index.php")
expected = 'string(${toString (builtins.stringLength testString)}) "${testString}"'
assert expected in response, "Does not appear to be able to use subgroups."
'';
})