nixosTests.postgresql: move all postgresql related nixosTests into one folder

This makes it possible to run all those tests at once by building
nixosTests.postgresql and allow a simple entry to ci/OWNERS for all
tests.
This commit is contained in:
Wolfgang Walther 2024-11-02 18:58:52 +01:00
parent db2d6a00ab
commit 9035573855
No known key found for this signature in database
GPG Key ID: B39893FA5F65CAE1
23 changed files with 166 additions and 154 deletions

View File

@ -229,7 +229,7 @@ pkgs/development/python-modules/buildcatrust/ @ajs124 @lukegb @mweinelt
/pkgs/servers/sql/postgresql @NixOS/postgres /pkgs/servers/sql/postgresql @NixOS/postgres
/nixos/modules/services/databases/postgresql.md @NixOS/postgres /nixos/modules/services/databases/postgresql.md @NixOS/postgres
/nixos/modules/services/databases/postgresql.nix @NixOS/postgres /nixos/modules/services/databases/postgresql.nix @NixOS/postgres
/nixos/tests/postgresql.nix @NixOS/postgres /nixos/tests/postgresql @NixOS/postgres
# Hardened profile & related modules # Hardened profile & related modules
/nixos/modules/profiles/hardened.nix @joachifm /nixos/modules/profiles/hardened.nix @joachifm

View File

@ -775,13 +775,10 @@ in {
peering-manager = handleTest ./web-apps/peering-manager.nix {}; peering-manager = handleTest ./web-apps/peering-manager.nix {};
peertube = handleTestOn ["x86_64-linux"] ./web-apps/peertube.nix {}; peertube = handleTestOn ["x86_64-linux"] ./web-apps/peertube.nix {};
peroxide = handleTest ./peroxide.nix {}; peroxide = handleTest ./peroxide.nix {};
pg_anonymizer = handleTest ./pg_anonymizer.nix {};
pgadmin4 = handleTest ./pgadmin4.nix {}; pgadmin4 = handleTest ./pgadmin4.nix {};
pgbouncer = handleTest ./pgbouncer.nix {}; pgbouncer = handleTest ./pgbouncer.nix {};
pghero = runTest ./pghero.nix; pghero = runTest ./pghero.nix;
pgjwt = handleTest ./pgjwt.nix {};
pgmanage = handleTest ./pgmanage.nix {}; pgmanage = handleTest ./pgmanage.nix {};
pgvecto-rs = handleTest ./pgvecto-rs.nix {};
phosh = handleTest ./phosh.nix {}; phosh = handleTest ./phosh.nix {};
photonvision = handleTest ./photonvision.nix {}; photonvision = handleTest ./photonvision.nix {};
photoprism = handleTest ./photoprism.nix {}; photoprism = handleTest ./photoprism.nix {};
@ -814,11 +811,7 @@ in {
postfix = handleTest ./postfix.nix {}; postfix = handleTest ./postfix.nix {};
postfix-raise-smtpd-tls-security-level = handleTest ./postfix-raise-smtpd-tls-security-level.nix {}; postfix-raise-smtpd-tls-security-level = handleTest ./postfix-raise-smtpd-tls-security-level.nix {};
postfixadmin = handleTest ./postfixadmin.nix {}; postfixadmin = handleTest ./postfixadmin.nix {};
postgresql = handleTest ./postgresql.nix {}; postgresql = handleTest ./postgresql {};
postgresql-jit = handleTest ./postgresql-jit.nix {};
postgresql-wal-receiver = handleTest ./postgresql-wal-receiver.nix {};
postgresql-tls-client-cert = handleTest ./postgresql-tls-client-cert.nix {};
postgresql-wal2json = handleTest ./postgresql-wal2json.nix {};
powerdns = handleTest ./powerdns.nix {}; powerdns = handleTest ./powerdns.nix {};
powerdns-admin = handleTest ./powerdns-admin.nix {}; powerdns-admin = handleTest ./powerdns-admin.nix {};
power-profiles-daemon = handleTest ./power-profiles-daemon.nix {}; power-profiles-daemon = handleTest ./power-profiles-daemon.nix {};
@ -1045,7 +1038,6 @@ in {
tiddlywiki = handleTest ./tiddlywiki.nix {}; tiddlywiki = handleTest ./tiddlywiki.nix {};
tigervnc = handleTest ./tigervnc.nix {}; tigervnc = handleTest ./tigervnc.nix {};
tika = runTest ./tika.nix; tika = runTest ./tika.nix;
timescaledb = handleTest ./timescaledb.nix {};
timezone = handleTest ./timezone.nix {}; timezone = handleTest ./timezone.nix {};
timidity = handleTestOn ["aarch64-linux" "x86_64-linux"] ./timidity {}; timidity = handleTestOn ["aarch64-linux" "x86_64-linux"] ./timidity {};
tinc = handleTest ./tinc {}; tinc = handleTest ./tinc {};
@ -1065,7 +1057,6 @@ in {
trezord = handleTest ./trezord.nix {}; trezord = handleTest ./trezord.nix {};
trickster = handleTest ./trickster.nix {}; trickster = handleTest ./trickster.nix {};
trilium-server = handleTestOn ["x86_64-linux"] ./trilium-server.nix {}; trilium-server = handleTestOn ["x86_64-linux"] ./trilium-server.nix {};
tsja = handleTest ./tsja.nix {};
tsm-client-gui = handleTest ./tsm-client-gui.nix {}; tsm-client-gui = handleTest ./tsm-client-gui.nix {};
ttyd = handleTest ./web-servers/ttyd.nix {}; ttyd = handleTest ./web-servers/ttyd.nix {};
txredisapi = handleTest ./txredisapi.nix {}; txredisapi = handleTest ./txredisapi.nix {};

View File

@ -1,52 +0,0 @@
{
system ? builtins.currentSystem,
config ? { },
pkgs ? import ../.. { inherit system config; },
}:
with import ../lib/testing-python.nix { inherit system pkgs; };
let
inherit (pkgs) lib;
makePostgresqlWal2jsonTest =
postgresqlPackage:
makeTest {
name = "postgresql-wal2json-${postgresqlPackage.name}";
meta.maintainers = with pkgs.lib.maintainers; [ euank ];
nodes.machine = {
services.postgresql = {
package = postgresqlPackage;
enable = true;
extraPlugins = with postgresqlPackage.pkgs; [ wal2json ];
settings = {
wal_level = "logical";
max_replication_slots = "10";
max_wal_senders = "10";
};
};
};
testScript = ''
machine.wait_for_unit("postgresql")
machine.succeed(
"sudo -u postgres psql -qAt -f ${./postgresql/wal2json/example2.sql} postgres > /tmp/example2.out"
)
machine.succeed(
"diff ${./postgresql/wal2json/example2.out} /tmp/example2.out"
)
machine.succeed(
"sudo -u postgres psql -qAt -f ${./postgresql/wal2json/example3.sql} postgres > /tmp/example3.out"
)
machine.succeed(
"diff ${./postgresql/wal2json/example3.out} /tmp/example3.out"
)
'';
};
in
lib.concatMapAttrs (n: p: { ${n} = makePostgresqlWal2jsonTest p; }) pkgs.postgresqlVersions
// {
passthru.override = p: makePostgresqlWal2jsonTest p;
}

View File

@ -1,16 +1,13 @@
{ system ? builtins.currentSystem { pkgs
, config ? {} , makeTest
, pkgs ? import ../.. { inherit system config; }
}: }:
with import ../lib/testing-python.nix { inherit system pkgs; };
let let
inherit (pkgs) lib; inherit (pkgs) lib;
makeAnonymizerTest = postgresqlPackage: makeAnonymizerTest = postgresqlPackage:
makeTest { makeTest {
name = "pg_anonymizer-${postgresqlPackage.name}"; name = "postgresql_anonymizer-${postgresqlPackage.name}";
meta.maintainers = lib.teams.flyingcircus.members; meta.maintainers = lib.teams.flyingcircus.members;
nodes.machine = { pkgs, ... }: { nodes.machine = { pkgs, ... }: {
@ -105,7 +102,9 @@ let
''; '';
}; };
in in
pkgs.lib.concatMapAttrs (n: p: { ${n} = makeAnonymizerTest p; }) pkgs.postgresqlVersions pkgs.lib.recurseIntoAttrs (
// { pkgs.lib.concatMapAttrs (n: p: { ${n} = makeAnonymizerTest p; }) pkgs.postgresqlVersions
passthru.override = p: makeAnonymizerTest p; // {
} passthru.override = p: makeAnonymizerTest p;
}
)

View File

@ -0,0 +1,26 @@
{
system ? builtins.currentSystem,
config ? { },
pkgs ? import ../../.. { inherit system config; },
}:
with import ../../lib/testing-python.nix { inherit system pkgs; };
let
importWithArgs = path: import path { inherit pkgs makeTest; };
in
{
# postgresql
postgresql = importWithArgs ./postgresql.nix;
postgresql-jit = importWithArgs ./postgresql-jit.nix;
postgresql-wal-receiver = importWithArgs ./postgresql-wal-receiver.nix;
postgresql-tls-client-cert = importWithArgs ./postgresql-tls-client-cert.nix;
# extensions
anonymizer = importWithArgs ./anonymizer.nix;
pgjwt = importWithArgs ./pgjwt.nix;
pgvecto-rs = importWithArgs ./pgvecto-rs.nix;
timescaledb = importWithArgs ./timescaledb.nix;
tsja = importWithArgs ./tsja.nix;
wal2json = importWithArgs ./wal2json.nix;
}

View File

@ -1,10 +1,7 @@
{ system ? builtins.currentSystem { pkgs
, config ? {} , makeTest
, pkgs ? import ../.. { inherit system config; }
}: }:
with import ../lib/testing-python.nix { inherit system pkgs; };
let let
inherit (pkgs) lib; inherit (pkgs) lib;
@ -41,7 +38,9 @@ let
''; '';
}; };
in in
lib.concatMapAttrs (n: p: { ${n} = makePgjwtTest p; }) pkgs.postgresqlVersions lib.recurseIntoAttrs (
// { lib.concatMapAttrs (n: p: { ${n} = makePgjwtTest p; }) pkgs.postgresqlVersions
passthru.override = p: makePgjwtTest p; // {
} passthru.override = p: makePgjwtTest p;
}
)

View File

@ -1,9 +1,7 @@
{ system ? builtins.currentSystem { pkgs
, config ? { } , makeTest
, pkgs ? import ../.. { inherit system config; }
}: }:
with import ../lib/testing-python.nix { inherit system pkgs; };
with pkgs.lib; with pkgs.lib;
let let
@ -68,7 +66,9 @@ let
}; };
in in
concatMapAttrs (n: p: { ${n} = makePgVectorsTest p; }) (filterAttrs (n: p: !p.pkgs.pgvecto-rs.meta.broken) pkgs.postgresqlVersions) recurseIntoAttrs (
// { concatMapAttrs (n: p: { ${n} = makePgVectorsTest p; }) (filterAttrs (n: p: !p.pkgs.pgvecto-rs.meta.broken) pkgs.postgresqlVersions)
passthru.override = p: makePgVectorsTest p; // {
} passthru.override = p: makePgVectorsTest p;
}
)

View File

@ -1,10 +1,7 @@
{ system ? builtins.currentSystem { pkgs
, config ? {} , makeTest
, pkgs ? import ../.. { inherit system config; }
}: }:
with import ../lib/testing-python.nix { inherit system pkgs; };
let let
inherit (pkgs) lib; inherit (pkgs) lib;
@ -44,7 +41,9 @@ let
''; '';
}; };
in in
lib.concatMapAttrs (n: p: { ${n} = mkJitTest p; }) (lib.filterAttrs (n: _: lib.hasSuffix "_jit" n) pkgs.postgresqlVersions) lib.recurseIntoAttrs (
// { lib.concatMapAttrs (n: p: { ${n} = mkJitTest p; }) (lib.filterAttrs (n: _: lib.hasSuffix "_jit" n) pkgs.postgresqlVersions)
passthru.override = p: mkJitTest p; // {
} passthru.override = p: mkJitTest p;
}
)

View File

@ -1,10 +1,7 @@
{ system ? builtins.currentSystem { pkgs
, config ? { } , makeTest
, pkgs ? import ../.. { inherit system config; }
}: }:
with import ../lib/testing-python.nix { inherit system pkgs; };
let let
lib = pkgs.lib; lib = pkgs.lib;
@ -125,7 +122,9 @@ let
}; };
in in
lib.concatMapAttrs (n: p: { ${n} = makePostgresqlTlsClientCertTest p; }) pkgs.postgresqlVersions lib.recurseIntoAttrs (
// { lib.concatMapAttrs (n: p: { ${n} = makePostgresqlTlsClientCertTest p; }) pkgs.postgresqlVersions
passthru.override = p: makePostgresqlTlsClientCertTest p; // {
} passthru.override = p: makePostgresqlTlsClientCertTest p;
}
)

View File

@ -1,10 +1,7 @@
{ system ? builtins.currentSystem, { pkgs
config ? {}, , makeTest
pkgs ? import ../.. { inherit system config; },
}: }:
with import ../lib/testing-python.nix { inherit system pkgs; };
let let
lib = pkgs.lib; lib = pkgs.lib;
@ -107,7 +104,9 @@ let
''; '';
}; };
in in
lib.concatMapAttrs (n: p: { ${n} = makePostgresqlWalReceiverTest p; }) pkgs.postgresqlVersions lib.recurseIntoAttrs (
// { lib.concatMapAttrs (n: p: { ${n} = makePostgresqlWalReceiverTest p; }) pkgs.postgresqlVersions
passthru.override = p: makePostgresqlWalReceiverTest p; // {
} passthru.override = p: makePostgresqlWalReceiverTest p;
}
)

View File

@ -1,9 +1,7 @@
{ system ? builtins.currentSystem, { pkgs
config ? {}, , makeTest
pkgs ? import ../.. { inherit system config; }
}: }:
with import ../lib/testing-python.nix { inherit system pkgs; };
with pkgs.lib; with pkgs.lib;
let let
@ -226,7 +224,9 @@ let
''; '';
}; };
in in
concatMapAttrs (n: p: { ${n} = testsForPackage p; }) pkgs.postgresqlVersions recurseIntoAttrs (
// { concatMapAttrs (n: p: { ${n} = testsForPackage p; }) pkgs.postgresqlVersions
passthru.override = p: testsForPackage p; // {
} passthru.override = p: testsForPackage p;
}
)

View File

@ -1,9 +1,7 @@
{ system ? builtins.currentSystem { pkgs
, config ? { } , makeTest
, pkgs ? import ../.. { inherit system config; }
}: }:
with import ../lib/testing-python.nix { inherit system pkgs; };
with pkgs.lib; with pkgs.lib;
let let
@ -83,7 +81,12 @@ let
}; };
in in
pkgs.lib.concatMapAttrs (n: p: { ${n} = makeTimescaleDbTest p; }) (filterAttrs (n: p: !p.pkgs.timescaledb.meta.broken) pkgs.postgresqlVersions) # Not run by default, because this requires allowUnfree.
// { # To run these tests:
passthru.override = p: makeTimescaleDbTest p; # NIXPKGS_ALLOW_UNFREE=1 nix-build -A nixosTests.postgresql.timescaledb
} dontRecurseIntoAttrs (
pkgs.lib.concatMapAttrs (n: p: { ${n} = makeTimescaleDbTest p; }) (filterAttrs (n: p: !p.pkgs.timescaledb.meta.broken) pkgs.postgresqlVersions)
// {
passthru.override = p: makeTimescaleDbTest p;
}
)

View File

@ -1,10 +1,7 @@
{ system ? builtins.currentSystem { pkgs
, config ? {} , makeTest
, pkgs ? import ../.. { inherit system config; }
}: }:
with import ../lib/testing-python.nix { inherit system pkgs; };
let let
makeTsjaTest = postgresqlPackage: makeTsjaTest = postgresqlPackage:
makeTest { makeTest {
@ -41,7 +38,9 @@ let
''; '';
}; };
in in
pkgs.lib.concatMapAttrs (n: p: { ${n} = makeTsjaTest p; }) pkgs.postgresqlVersions pkgs.lib.recurseIntoAttrs (
// { pkgs.lib.concatMapAttrs (n: p: { ${n} = makeTsjaTest p; }) pkgs.postgresqlVersions
passthru.override = p: makeTsjaTest p; // {
} passthru.override = p: makeTsjaTest p;
}
)

View File

@ -0,0 +1,50 @@
{ pkgs
, makeTest
}:
let
inherit (pkgs) lib;
makePostgresqlWal2jsonTest =
postgresqlPackage:
makeTest {
name = "wal2json-${postgresqlPackage.name}";
meta.maintainers = with pkgs.lib.maintainers; [ euank ];
nodes.machine = {
services.postgresql = {
package = postgresqlPackage;
enable = true;
extraPlugins = with postgresqlPackage.pkgs; [ wal2json ];
settings = {
wal_level = "logical";
max_replication_slots = "10";
max_wal_senders = "10";
};
};
};
testScript = ''
machine.wait_for_unit("postgresql")
machine.succeed(
"sudo -u postgres psql -qAt -f ${./wal2json/example2.sql} postgres > /tmp/example2.out"
)
machine.succeed(
"diff ${./wal2json/example2.out} /tmp/example2.out"
)
machine.succeed(
"sudo -u postgres psql -qAt -f ${./wal2json/example3.sql} postgres > /tmp/example3.out"
)
machine.succeed(
"diff ${./wal2json/example3.out} /tmp/example3.out"
)
'';
};
in
lib.recurseIntoAttrs (
lib.concatMapAttrs (n: p: { ${n} = makePostgresqlWal2jsonTest p; }) pkgs.postgresqlVersions
// {
passthru.override = p: makePostgresqlWal2jsonTest p;
}
)

View File

@ -14,7 +14,7 @@ buildGoModule rec {
vendorHash = "sha256-CwU1zoIayxvfnGL9kPdummPJiV+ECfSz4+q6gZGb8pw="; vendorHash = "sha256-CwU1zoIayxvfnGL9kPdummPJiV+ECfSz4+q6gZGb8pw=";
passthru.tests = { inherit (nixosTests) pg_anonymizer; }; passthru.tests = { inherit (nixosTests.postgresql) anonymizer; };
nativeBuildInputs = [ makeWrapper ]; nativeBuildInputs = [ makeWrapper ];
postInstall = '' postInstall = ''

View File

@ -26,7 +26,7 @@ stdenv.mkDerivation (finalAttrs: {
EOF EOF
''; '';
passthru.tests = nixosTests.pg_anonymizer.passthru.override postgresql; passthru.tests = nixosTests.postgresql.anonymizer.passthru.override postgresql;
meta = lib.getAttrs [ "homepage" "maintainers" "license" ] pg-dump-anon.meta // { meta = lib.getAttrs [ "homepage" "maintainers" "license" ] pg-dump-anon.meta // {
description = "Extension to mask or replace personally identifiable information (PII) or commercially sensitive data from a PostgreSQL database"; description = "Extension to mask or replace personally identifiable information (PII) or commercially sensitive data from a PostgreSQL database";

View File

@ -20,7 +20,7 @@ stdenv.mkDerivation (finalAttrs: {
passthru.updateScript = unstableGitUpdater { }; passthru.updateScript = unstableGitUpdater { };
passthru.tests = lib.recurseIntoAttrs { passthru.tests = lib.recurseIntoAttrs {
pgjwt = nixosTests.pgjwt.passthru.override postgresql; pgjwt = nixosTests.postgresql.pgjwt.passthru.override postgresql;
extension = postgresqlTestExtension { extension = postgresqlTestExtension {
inherit (finalAttrs) finalPackage; inherit (finalAttrs) finalPackage;

View File

@ -86,7 +86,7 @@ in
passthru = { passthru = {
updateScript = nix-update-script { }; updateScript = nix-update-script { };
tests = nixosTests.pgvecto-rs.passthru.override postgresql; tests = nixosTests.postgresql.pgvecto-rs.passthru.override postgresql;
}; };
meta = with lib; { meta = with lib; {

View File

@ -32,7 +32,7 @@ stdenv.mkDerivation rec {
done done
''; '';
passthru.tests = nixosTests.timescaledb.passthru.override postgresql; passthru.tests = nixosTests.postgresql.timescaledb.passthru.override postgresql;
meta = with lib; { meta = with lib; {
description = "Scales PostgreSQL for time-series data via automatic partitioning across time and space"; description = "Scales PostgreSQL for time-series data via automatic partitioning across time and space";

View File

@ -25,7 +25,7 @@
passthru = { passthru = {
updateScript = nix-update-script { }; updateScript = nix-update-script { };
tests = nixosTests.timescaledb.passthru.override postgresql; tests = nixosTests.postgresql.timescaledb.passthru.override postgresql;
}; };
# tests take really long # tests take really long

View File

@ -32,7 +32,7 @@ stdenv.mkDerivation rec {
mv dbinit_libtsja.txt $out/share/postgresql/extension/libtsja_dbinit.sql mv dbinit_libtsja.txt $out/share/postgresql/extension/libtsja_dbinit.sql
''; '';
passthru.tests = nixosTests.tsja.passthru.override postgresql; passthru.tests = nixosTests.postgresql.tsja.passthru.override postgresql;
meta = with lib; { meta = with lib; {
description = "PostgreSQL extension implementing Japanese text search"; description = "PostgreSQL extension implementing Japanese text search";

View File

@ -27,7 +27,7 @@ stdenv.mkDerivation rec {
install -D -t $out/share/postgresql/extension sql/*.sql install -D -t $out/share/postgresql/extension sql/*.sql
''; '';
passthru.tests = nixosTests.postgresql-wal2json.passthru.override postgresql; passthru.tests = nixosTests.postgresql.wal2json.passthru.override postgresql;
meta = with lib; { meta = with lib; {
description = "PostgreSQL JSON output plugin for changeset extraction"; description = "PostgreSQL JSON output plugin for changeset extraction";

View File

@ -312,12 +312,12 @@ let
}; };
tests = { tests = {
postgresql = nixosTests.postgresql.passthru.override finalAttrs.finalPackage; postgresql = nixosTests.postgresql.postgresql.passthru.override finalAttrs.finalPackage;
postgresql-tls-client-cert = nixosTests.postgresql-tls-client-cert.passthru.override finalAttrs.finalPackage; postgresql-tls-client-cert = nixosTests.postgresql.postgresql-tls-client-cert.passthru.override finalAttrs.finalPackage;
postgresql-wal-receiver = nixosTests.postgresql-wal-receiver.passthru.override finalAttrs.finalPackage; postgresql-wal-receiver = nixosTests.postgresql.postgresql-wal-receiver.passthru.override finalAttrs.finalPackage;
pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage; pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
} // lib.optionalAttrs jitSupport { } // lib.optionalAttrs jitSupport {
postgresql-jit = nixosTests.postgresql-jit.passthru.override finalAttrs.finalPackage; postgresql-jit = nixosTests.postgresql.postgresql-jit.passthru.override finalAttrs.finalPackage;
}; };
}; };