mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-14 13:39:15 +03:00
nixos/tests: add postgresql wal2json test
This test should ensure wal2json functions. I'm planning to upgrade wal2json, so it seems nice to have a test here. It passes on my machine.
This commit is contained in:
parent
864bb34b78
commit
554ec1c0f0
9 changed files with 248 additions and 1 deletions
60
nixos/tests/postgresql-wal2json.nix
Normal file
60
nixos/tests/postgresql-wal2json.nix
Normal file
|
@ -0,0 +1,60 @@
|
|||
{
|
||||
system ? builtins.currentSystem,
|
||||
config ? { },
|
||||
pkgs ? import ../.. { inherit system config; },
|
||||
postgresql ? null,
|
||||
}:
|
||||
|
||||
let
|
||||
makeTest = import ./make-test-python.nix;
|
||||
# Makes a test for a PostgreSQL package, given by name and looked up from `pkgs`.
|
||||
makeTestAttribute = name: {
|
||||
inherit name;
|
||||
value = makePostgresqlWal2jsonTest pkgs."${name}";
|
||||
};
|
||||
|
||||
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
|
||||
# By default, create one test per postgresql version
|
||||
if postgresql == null then
|
||||
builtins.listToAttrs (
|
||||
map makeTestAttribute (builtins.attrNames (import ../../pkgs/servers/sql/postgresql pkgs))
|
||||
)
|
||||
# but if postgresql is set, we're being made as a passthru test for a specific postgres + wal2json version, just run one
|
||||
else
|
||||
makePostgresqlWal2jsonTest postgresql
|
Loading…
Add table
Add a link
Reference in a new issue