nixosTests.nginx: migrate to runTest

Part of #386873
This commit is contained in:
Piotr Kwiecinski 2025-03-29 23:45:36 +01:00
parent 073a164a60
commit 389f2fb908
No known key found for this signature in database
GPG key ID: EC0DE1CB9D5258B4
2 changed files with 123 additions and 107 deletions

View file

@ -797,7 +797,7 @@ in {
nfs3 = handleTest ./nfs { version = 3; };
nfs4 = handleTest ./nfs { version = 4; };
nghttpx = handleTest ./nghttpx.nix {};
nginx = handleTest ./nginx.nix {};
nginx = runTest ./nginx.nix;
nginx-auth = handleTest ./nginx-auth.nix {};
nginx-etag = handleTest ./nginx-etag.nix {};
nginx-etag-compression = handleTest ./nginx-etag-compression.nix {};

View file

@ -4,14 +4,20 @@
# 2. whether the ETag header is properly generated whenever we're serving
# files in Nix store paths
# 3. nginx doesn't restart on configuration changes (only reloads)
import ./make-test-python.nix ({ pkgs, ... }: {
{ pkgs, ... }:
{
name = "nginx";
meta = with pkgs.lib.maintainers; {
maintainers = [ mbbx6spp danbst ];
maintainers = [
mbbx6spp
danbst
];
};
nodes = {
webserver = { pkgs, lib, ... }: {
webserver =
{ pkgs, lib, ... }:
{
services.nginx.enable = true;
services.nginx.commonHttpConfig = ''
log_format ceeformat '@cee: {"status":"$status",'
@ -34,7 +40,7 @@ import ./make-test-python.nix ({ pkgs, ... }: {
};
services.nginx.virtualHosts.localhost = {
root = pkgs.runCommand "testdir" {} ''
root = pkgs.runCommand "testdir" { } ''
mkdir "$out"
echo hello world > "$out/index.html"
'';
@ -44,15 +50,22 @@ import ./make-test-python.nix ({ pkgs, ... }: {
specialisation.etagSystem.configuration = {
services.nginx.virtualHosts.localhost = {
root = lib.mkForce (pkgs.runCommand "testdir2" {} ''
root = lib.mkForce (
pkgs.runCommand "testdir2" { } ''
mkdir "$out"
echo content changed > "$out/index.html"
'');
''
);
};
};
specialisation.justReloadSystem.configuration = {
services.nginx.virtualHosts."1.my.test".listen = [ { addr = "127.0.0.1"; port = 8080; }];
services.nginx.virtualHosts."1.my.test".listen = [
{
addr = "127.0.0.1";
port = 8080;
}
];
};
specialisation.reloadRestartSystem.configuration = {
@ -66,12 +79,15 @@ import ./make-test-python.nix ({ pkgs, ... }: {
};
};
testScript = { nodes, ... }: let
testScript =
{ nodes, ... }:
let
etagSystem = "${nodes.webserver.system.build.toplevel}/specialisation/etagSystem";
justReloadSystem = "${nodes.webserver.system.build.toplevel}/specialisation/justReloadSystem";
reloadRestartSystem = "${nodes.webserver.system.build.toplevel}/specialisation/reloadRestartSystem";
reloadWithErrorsSystem = "${nodes.webserver.system.build.toplevel}/specialisation/reloadWithErrorsSystem";
in ''
in
''
url = "http://localhost/index.html"
@ -134,4 +150,4 @@ import ./make-test-python.nix ({ pkgs, ... }: {
"${reloadWithErrorsSystem}/bin/switch-to-configuration test >&2"
)
'';
})
}