mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-09 09:36:20 +09:00
nixosTests.php: migrate to runTest
This commit is contained in:
parent
a212f0886c
commit
e44f5a37cf
5 changed files with 180 additions and 168 deletions
|
@ -914,11 +914,26 @@ in {
|
|||
phosh = handleTest ./phosh.nix {};
|
||||
photonvision = handleTest ./photonvision.nix {};
|
||||
photoprism = handleTest ./photoprism.nix {};
|
||||
php = handleTest ./php {};
|
||||
php81 = handleTest ./php { php = pkgs.php81; };
|
||||
php82 = handleTest ./php { php = pkgs.php82; };
|
||||
php83 = handleTest ./php { php = pkgs.php83; };
|
||||
php84 = handleTest ./php { php = pkgs.php84; };
|
||||
php = import ./php/default.nix {
|
||||
inherit runTest;
|
||||
php = pkgs.php;
|
||||
};
|
||||
php81 = import ./php/default.nix {
|
||||
inherit runTest;
|
||||
php = pkgs.php81;
|
||||
};
|
||||
php82 = import ./php/default.nix {
|
||||
inherit runTest;
|
||||
php = pkgs.php82;
|
||||
};
|
||||
php83 = import ./php/default.nix {
|
||||
inherit runTest;
|
||||
php = pkgs.php83;
|
||||
};
|
||||
php84 = import ./php/default.nix {
|
||||
inherit runTest;
|
||||
php = pkgs.php84;
|
||||
};
|
||||
phylactery = handleTest ./web-apps/phylactery.nix {};
|
||||
pict-rs = handleTest ./pict-rs.nix {};
|
||||
pingvin-share = handleTest ./pingvin-share.nix {} ;
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
{
|
||||
system ? builtins.currentSystem,
|
||||
config ? { },
|
||||
pkgs ? import ../../.. { inherit system config; },
|
||||
php ? pkgs.php,
|
||||
runTest,
|
||||
php,
|
||||
}:
|
||||
|
||||
let
|
||||
|
@ -11,16 +9,16 @@ let
|
|||
};
|
||||
in
|
||||
{
|
||||
fpm = import ./fpm.nix {
|
||||
inherit system pkgs;
|
||||
php = php';
|
||||
fpm = runTest {
|
||||
imports = [ ./fpm.nix ];
|
||||
_module.args.php = php';
|
||||
};
|
||||
httpd = import ./httpd.nix {
|
||||
inherit system pkgs;
|
||||
php = php';
|
||||
httpd = runTest {
|
||||
imports = [ ./httpd.nix ];
|
||||
_module.args.php = php';
|
||||
};
|
||||
pcre = import ./pcre.nix {
|
||||
inherit system pkgs;
|
||||
php = php';
|
||||
pcre = runTest {
|
||||
imports = [ ./pcre.nix ];
|
||||
_module.args.php = php';
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,59 +1,64 @@
|
|||
import ../make-test-python.nix ({ pkgs, lib, php, ... }: {
|
||||
{ lib, php, ... }:
|
||||
{
|
||||
name = "php-${php.version}-fpm-nginx-test";
|
||||
meta.maintainers = lib.teams.php.members;
|
||||
|
||||
nodes.machine = { config, lib, pkgs, ... }: {
|
||||
environment.systemPackages = [ php ];
|
||||
nodes.machine =
|
||||
{ config, pkgs, ... }:
|
||||
{
|
||||
environment.systemPackages = [ php ];
|
||||
|
||||
services.nginx = {
|
||||
enable = true;
|
||||
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 ${config.services.nginx.package}/conf/fastcgi_params;
|
||||
include ${pkgs.nginx}/conf/fastcgi.conf;
|
||||
'';
|
||||
locations."/" = {
|
||||
tryFiles = "$uri $uri/ index.php";
|
||||
index = "index.php index.html index.htm";
|
||||
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 ${config.services.nginx.package}/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";
|
||||
phpPackage = php;
|
||||
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;
|
||||
services.phpfpm.pools."foobar" = {
|
||||
user = "nginx";
|
||||
phpPackage = php;
|
||||
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")
|
||||
testScript =
|
||||
{ ... }:
|
||||
''
|
||||
machine.wait_for_unit("nginx.service")
|
||||
machine.wait_for_unit("phpfpm-foobar.service")
|
||||
|
||||
# Check so we get an evaluated PHP back
|
||||
response = machine.succeed("curl -fvvv -s http://127.0.0.1:80/")
|
||||
assert "PHP Version ${php.version}" in response, "PHP version not detected"
|
||||
# Check so we get an evaluated PHP back
|
||||
response = machine.succeed("curl -fvvv -s http://127.0.0.1:80/")
|
||||
assert "PHP Version ${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", "apcu"]:
|
||||
assert ext in response, f"Missing {ext} extension"
|
||||
machine.succeed(f'test -n "$(php -m | grep -i {ext})"')
|
||||
'';
|
||||
})
|
||||
# Check so we have database and some other extensions loaded
|
||||
for ext in ["json", "opcache", "pdo_mysql", "pdo_pgsql", "pdo_sqlite", "apcu"]:
|
||||
assert ext in response, f"Missing {ext} extension"
|
||||
machine.succeed(f'test -n "$(php -m | grep -i {ext})"')
|
||||
'';
|
||||
}
|
||||
|
|
|
@ -1,51 +1,47 @@
|
|||
import ../make-test-python.nix (
|
||||
{
|
||||
pkgs,
|
||||
lib,
|
||||
php,
|
||||
...
|
||||
}:
|
||||
{
|
||||
name = "php-${php.version}-httpd-test";
|
||||
meta.maintainers = lib.teams.php.members;
|
||||
{
|
||||
lib,
|
||||
php,
|
||||
...
|
||||
}:
|
||||
{
|
||||
name = "php-${php.version}-httpd-test";
|
||||
meta.maintainers = lib.teams.php.members;
|
||||
|
||||
nodes.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";
|
||||
};
|
||||
nodes.machine =
|
||||
{
|
||||
config,
|
||||
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";
|
||||
};
|
||||
phpPackage = php;
|
||||
enablePHP = true;
|
||||
};
|
||||
};
|
||||
phpPackage = php;
|
||||
enablePHP = true;
|
||||
};
|
||||
testScript =
|
||||
{ ... }:
|
||||
''
|
||||
machine.wait_for_unit("httpd.service")
|
||||
};
|
||||
testScript =
|
||||
{ ... }:
|
||||
''
|
||||
machine.wait_for_unit("httpd.service")
|
||||
|
||||
# Check so we get an evaluated PHP back
|
||||
response = machine.succeed("curl -fvvv -s http://127.0.0.1:80/")
|
||||
assert "PHP Version ${php.version}" in response, "PHP version not detected"
|
||||
# Check so we get an evaluated PHP back
|
||||
response = machine.succeed("curl -fvvv -s http://127.0.0.1:80/")
|
||||
assert "PHP Version ${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"
|
||||
'';
|
||||
}
|
||||
)
|
||||
# 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"
|
||||
'';
|
||||
}
|
||||
|
|
|
@ -1,63 +1,61 @@
|
|||
let
|
||||
testString = "can-use-subgroups";
|
||||
in
|
||||
import ../make-test-python.nix (
|
||||
{
|
||||
pkgs,
|
||||
lib,
|
||||
php,
|
||||
...
|
||||
}:
|
||||
{
|
||||
name = "php-${php.version}-httpd-pcre-jit-test";
|
||||
meta.maintainers = lib.teams.php.members;
|
||||
{
|
||||
pkgs,
|
||||
lib,
|
||||
php,
|
||||
...
|
||||
}:
|
||||
{
|
||||
name = "php-${php.version}-httpd-pcre-jit-test";
|
||||
meta.maintainers = lib.teams.php.members;
|
||||
|
||||
nodes.machine =
|
||||
{ lib, pkgs, ... }:
|
||||
{
|
||||
time.timeZone = "UTC";
|
||||
services.httpd = {
|
||||
enable = true;
|
||||
adminAddr = "please@dont.contact";
|
||||
phpPackage = php;
|
||||
enablePHP = true;
|
||||
phpOptions = "pcre.jit = true";
|
||||
extraConfig =
|
||||
let
|
||||
testRoot = pkgs.writeText "index.php" ''
|
||||
<?php
|
||||
preg_match('/(${testString})/', '${testString}', $result);
|
||||
var_dump($result);
|
||||
'';
|
||||
in
|
||||
''
|
||||
Alias / ${testRoot}/
|
||||
|
||||
<Directory ${testRoot}>
|
||||
Require all granted
|
||||
</Directory>
|
||||
nodes.machine =
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
time.timeZone = "UTC";
|
||||
services.httpd = {
|
||||
enable = true;
|
||||
adminAddr = "please@dont.contact";
|
||||
phpPackage = php;
|
||||
enablePHP = true;
|
||||
phpOptions = "pcre.jit = true";
|
||||
extraConfig =
|
||||
let
|
||||
testRoot = pkgs.writeText "index.php" ''
|
||||
<?php
|
||||
preg_match('/(${testString})/', '${testString}', $result);
|
||||
var_dump($result);
|
||||
'';
|
||||
};
|
||||
in
|
||||
''
|
||||
Alias / ${testRoot}/
|
||||
|
||||
<Directory ${testRoot}>
|
||||
Require all granted
|
||||
</Directory>
|
||||
'';
|
||||
};
|
||||
testScript =
|
||||
let
|
||||
# PCRE JIT SEAlloc feature does not play well with fork()
|
||||
# The feature needs to either be disabled or PHP configured correctly
|
||||
# More information in https://bugs.php.net/bug.php?id=78927 and https://bugs.php.net/bug.php?id=78630
|
||||
pcreJitSeallocForkIssue = pkgs.writeText "pcre-jit-sealloc-issue.php" ''
|
||||
<?php
|
||||
preg_match('/nixos/', 'nixos');
|
||||
$pid = pcntl_fork();
|
||||
pcntl_wait($pid);
|
||||
'';
|
||||
in
|
||||
''
|
||||
machine.wait_for_unit("httpd.service")
|
||||
# Ensure php evaluation by matching on the var_dump syntax
|
||||
response = machine.succeed("curl -fvvv -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."
|
||||
machine.succeed("${php}/bin/php -f ${pcreJitSeallocForkIssue}")
|
||||
};
|
||||
testScript =
|
||||
let
|
||||
# PCRE JIT SEAlloc feature does not play well with fork()
|
||||
# The feature needs to either be disabled or PHP configured correctly
|
||||
# More information in https://bugs.php.net/bug.php?id=78927 and https://bugs.php.net/bug.php?id=78630
|
||||
pcreJitSeallocForkIssue = pkgs.writeText "pcre-jit-sealloc-issue.php" ''
|
||||
<?php
|
||||
preg_match('/nixos/', 'nixos');
|
||||
$pid = pcntl_fork();
|
||||
pcntl_wait($pid);
|
||||
'';
|
||||
}
|
||||
)
|
||||
in
|
||||
''
|
||||
machine.wait_for_unit("httpd.service")
|
||||
# Ensure php evaluation by matching on the var_dump syntax
|
||||
response = machine.succeed("curl -fvvv -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."
|
||||
machine.succeed("${php}/bin/php -f ${pcreJitSeallocForkIssue}")
|
||||
'';
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue