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
/nixos/modules/services/databases/postgresql.md @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
/nixos/modules/profiles/hardened.nix @joachifm

View File

@ -775,13 +775,10 @@ in {
peering-manager = handleTest ./web-apps/peering-manager.nix {};
peertube = handleTestOn ["x86_64-linux"] ./web-apps/peertube.nix {};
peroxide = handleTest ./peroxide.nix {};
pg_anonymizer = handleTest ./pg_anonymizer.nix {};
pgadmin4 = handleTest ./pgadmin4.nix {};
pgbouncer = handleTest ./pgbouncer.nix {};
pghero = runTest ./pghero.nix;
pgjwt = handleTest ./pgjwt.nix {};
pgmanage = handleTest ./pgmanage.nix {};
pgvecto-rs = handleTest ./pgvecto-rs.nix {};
phosh = handleTest ./phosh.nix {};
photonvision = handleTest ./photonvision.nix {};
photoprism = handleTest ./photoprism.nix {};
@ -814,11 +811,7 @@ in {
postfix = handleTest ./postfix.nix {};
postfix-raise-smtpd-tls-security-level = handleTest ./postfix-raise-smtpd-tls-security-level.nix {};
postfixadmin = handleTest ./postfixadmin.nix {};
postgresql = handleTest ./postgresql.nix {};
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 {};
postgresql = handleTest ./postgresql {};
powerdns = handleTest ./powerdns.nix {};
powerdns-admin = handleTest ./powerdns-admin.nix {};
power-profiles-daemon = handleTest ./power-profiles-daemon.nix {};
@ -1045,7 +1038,6 @@ in {
tiddlywiki = handleTest ./tiddlywiki.nix {};
tigervnc = handleTest ./tigervnc.nix {};
tika = runTest ./tika.nix;
timescaledb = handleTest ./timescaledb.nix {};
timezone = handleTest ./timezone.nix {};
timidity = handleTestOn ["aarch64-linux" "x86_64-linux"] ./timidity {};
tinc = handleTest ./tinc {};
@ -1065,7 +1057,6 @@ in {
trezord = handleTest ./trezord.nix {};
trickster = handleTest ./trickster.nix {};
trilium-server = handleTestOn ["x86_64-linux"] ./trilium-server.nix {};
tsja = handleTest ./tsja.nix {};
tsm-client-gui = handleTest ./tsm-client-gui.nix {};
ttyd = handleTest ./web-servers/ttyd.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
, config ? {}
, pkgs ? import ../.. { inherit system config; }
{ pkgs
, makeTest
}:
with import ../lib/testing-python.nix { inherit system pkgs; };
let
inherit (pkgs) lib;
makeAnonymizerTest = postgresqlPackage:
makeTest {
name = "pg_anonymizer-${postgresqlPackage.name}";
name = "postgresql_anonymizer-${postgresqlPackage.name}";
meta.maintainers = lib.teams.flyingcircus.members;
nodes.machine = { pkgs, ... }: {
@ -105,7 +102,9 @@ let
'';
};
in
pkgs.lib.concatMapAttrs (n: p: { ${n} = makeAnonymizerTest p; }) pkgs.postgresqlVersions
// {
passthru.override = p: makeAnonymizerTest p;
}
pkgs.lib.recurseIntoAttrs (
pkgs.lib.concatMapAttrs (n: p: { ${n} = makeAnonymizerTest p; }) pkgs.postgresqlVersions
// {
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
, config ? {}
, pkgs ? import ../.. { inherit system config; }
{ pkgs
, makeTest
}:
with import ../lib/testing-python.nix { inherit system pkgs; };
let
inherit (pkgs) lib;
@ -41,7 +38,9 @@ let
'';
};
in
lib.concatMapAttrs (n: p: { ${n} = makePgjwtTest p; }) pkgs.postgresqlVersions
// {
passthru.override = p: makePgjwtTest p;
}
lib.recurseIntoAttrs (
lib.concatMapAttrs (n: p: { ${n} = makePgjwtTest p; }) pkgs.postgresqlVersions
// {
passthru.override = p: makePgjwtTest p;
}
)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,9 +1,7 @@
{ system ? builtins.currentSystem
, config ? { }
, pkgs ? import ../.. { inherit system config; }
{ pkgs
, makeTest
}:
with import ../lib/testing-python.nix { inherit system pkgs; };
with pkgs.lib;
let
@ -83,7 +81,12 @@ let
};
in
pkgs.lib.concatMapAttrs (n: p: { ${n} = makeTimescaleDbTest p; }) (filterAttrs (n: p: !p.pkgs.timescaledb.meta.broken) pkgs.postgresqlVersions)
// {
passthru.override = p: makeTimescaleDbTest p;
}
# Not run by default, because this requires allowUnfree.
# To run these tests:
# 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
, config ? {}
, pkgs ? import ../.. { inherit system config; }
{ pkgs
, makeTest
}:
with import ../lib/testing-python.nix { inherit system pkgs; };
let
makeTsjaTest = postgresqlPackage:
makeTest {
@ -41,7 +38,9 @@ let
'';
};
in
pkgs.lib.concatMapAttrs (n: p: { ${n} = makeTsjaTest p; }) pkgs.postgresqlVersions
// {
passthru.override = p: makeTsjaTest p;
}
pkgs.lib.recurseIntoAttrs (
pkgs.lib.concatMapAttrs (n: p: { ${n} = makeTsjaTest p; }) pkgs.postgresqlVersions
// {
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=";
passthru.tests = { inherit (nixosTests) pg_anonymizer; };
passthru.tests = { inherit (nixosTests.postgresql) anonymizer; };
nativeBuildInputs = [ makeWrapper ];
postInstall = ''

View File

@ -26,7 +26,7 @@ stdenv.mkDerivation (finalAttrs: {
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 // {
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.tests = lib.recurseIntoAttrs {
pgjwt = nixosTests.pgjwt.passthru.override postgresql;
pgjwt = nixosTests.postgresql.pgjwt.passthru.override postgresql;
extension = postgresqlTestExtension {
inherit (finalAttrs) finalPackage;

View File

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

View File

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

View File

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

View File

@ -32,7 +32,7 @@ stdenv.mkDerivation rec {
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; {
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
'';
passthru.tests = nixosTests.postgresql-wal2json.passthru.override postgresql;
passthru.tests = nixosTests.postgresql.wal2json.passthru.override postgresql;
meta = with lib; {
description = "PostgreSQL JSON output plugin for changeset extraction";

View File

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