nixosTests.nginx{auth,etag,etag-compression,globalredirect,mime,modsecurity,moreheaders}: migrate to runTest (#394455)

This commit is contained in:
Gaétan Lepage 2025-03-30 00:15:33 +01:00 committed by GitHub
commit c9947f03d1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 269 additions and 258 deletions

View File

@ -797,15 +797,15 @@ in {
nfs3 = handleTest ./nfs { version = 3; }; nfs3 = handleTest ./nfs { version = 3; };
nfs4 = handleTest ./nfs { version = 4; }; nfs4 = handleTest ./nfs { version = 4; };
nghttpx = handleTest ./nghttpx.nix {}; nghttpx = handleTest ./nghttpx.nix {};
nginx = handleTest ./nginx.nix {}; nginx = runTest ./nginx.nix;
nginx-auth = handleTest ./nginx-auth.nix {}; nginx-auth = runTest ./nginx-auth.nix;
nginx-etag = handleTest ./nginx-etag.nix {}; nginx-etag = runTest ./nginx-etag.nix;
nginx-etag-compression = handleTest ./nginx-etag-compression.nix {}; nginx-etag-compression = runTest ./nginx-etag-compression.nix;
nginx-globalredirect = handleTest ./nginx-globalredirect.nix {}; nginx-globalredirect = runTest ./nginx-globalredirect.nix;
nginx-http3 = handleTest ./nginx-http3.nix {}; nginx-http3 = handleTest ./nginx-http3.nix {};
nginx-mime = handleTest ./nginx-mime.nix {}; nginx-mime = runTest ./nginx-mime.nix;
nginx-modsecurity = handleTest ./nginx-modsecurity.nix {}; nginx-modsecurity = runTest ./nginx-modsecurity.nix;
nginx-moreheaders = handleTest ./nginx-moreheaders.nix {}; nginx-moreheaders = runTest ./nginx-moreheaders.nix;
nginx-njs = handleTest ./nginx-njs.nix {}; nginx-njs = handleTest ./nginx-njs.nix {};
nginx-proxyprotocol = handleTest ./nginx-proxyprotocol {}; nginx-proxyprotocol = handleTest ./nginx-proxyprotocol {};
nginx-pubhtml = handleTest ./nginx-pubhtml.nix {}; nginx-pubhtml = handleTest ./nginx-pubhtml.nix {};

View File

@ -1,4 +1,3 @@
import ./make-test-python.nix (
{ pkgs, ... }: { pkgs, ... }:
{ {
name = "nginx-auth"; name = "nginx-auth";
@ -51,4 +50,3 @@ import ./make-test-python.nix (
) )
''; '';
} }
)

View File

@ -1,4 +1,5 @@
import ./make-test-python.nix { { ... }:
{
name = "nginx-etag-compression"; name = "nginx-etag-compression";
nodes.machine = nodes.machine =

View File

@ -1,4 +1,5 @@
import ./make-test-python.nix { { ... }:
{
name = "nginx-etag"; name = "nginx-etag";
nodes = { nodes = {
@ -85,7 +86,7 @@ import ./make-test-python.nix {
testScript = testScript =
{ nodes, ... }: { nodes, ... }:
let let
inherit (nodes.server.config.system.build) toplevel; inherit (nodes.server.system.build) toplevel;
newSystem = "${toplevel}/specialisation/pass-checks"; newSystem = "${toplevel}/specialisation/pass-checks";
in in
'' ''

View File

@ -1,5 +1,4 @@
import ./make-test-python.nix ( { ... }:
{ pkgs, ... }:
{ {
name = "nginx-globalredirect"; name = "nginx-globalredirect";
@ -26,4 +25,3 @@ import ./make-test-python.nix (
webserver.fail("curl --fail -si http://localhost/noredirect | grep '^Location:'") webserver.fail("curl --fail -si http://localhost/noredirect | grep '^Location:'")
''; '';
} }
)

View File

@ -1,4 +1,3 @@
import ./make-test-python.nix (
{ lib, pkgs, ... }: { lib, pkgs, ... }:
{ {
name = "nginx-mime"; name = "nginx-mime";
@ -23,4 +22,3 @@ import ./make-test-python.nix (
server.shutdown() server.shutdown()
''; '';
} }
)

View File

@ -1,5 +1,4 @@
import ./make-test-python.nix ( { ... }:
{ pkgs, lib, ... }:
{ {
name = "nginx-modsecurity"; name = "nginx-modsecurity";
@ -48,4 +47,3 @@ import ./make-test-python.nix (
machine.fail("curl -fvvv -s http://127.0.0.1/secret.html") machine.fail("curl -fvvv -s http://127.0.0.1/secret.html")
''; '';
} }
)

View File

@ -1,4 +1,5 @@
import ./make-test-python.nix { { ... }:
{
name = "nginx-more-headers"; name = "nginx-more-headers";
nodes = { nodes = {

View File

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