postgresql-wal-receiver: fix test for Pg12 (#80268)
Fixes https://github.com/NixOS/nixpkgs/issues/80060
This commit is contained in:
parent
06d18a5737
commit
56c4800e7f
|
@ -6,17 +6,24 @@ with import ../lib/testing.nix { inherit system pkgs; };
|
||||||
with pkgs.lib;
|
with pkgs.lib;
|
||||||
|
|
||||||
let
|
let
|
||||||
|
makePostgresqlWalReceiverTest = subTestName: postgresqlPackage: let
|
||||||
|
|
||||||
postgresqlDataDir = "/var/db/postgresql/test";
|
postgresqlDataDir = "/var/db/postgresql/test";
|
||||||
replicationUser = "wal_receiver_user";
|
replicationUser = "wal_receiver_user";
|
||||||
replicationSlot = "wal_receiver_slot";
|
replicationSlot = "wal_receiver_slot";
|
||||||
replicationConn = "postgresql://${replicationUser}@localhost";
|
replicationConn = "postgresql://${replicationUser}@localhost";
|
||||||
baseBackupDir = "/tmp/pg_basebackup";
|
baseBackupDir = "/tmp/pg_basebackup";
|
||||||
walBackupDir = "/tmp/pg_wal";
|
walBackupDir = "/tmp/pg_wal";
|
||||||
recoveryConf = pkgs.writeText "recovery.conf" ''
|
atLeast12 = versionAtLeast postgresqlPackage.version "12.0";
|
||||||
|
restoreCommand = ''
|
||||||
restore_command = 'cp ${walBackupDir}/%f %p'
|
restore_command = 'cp ${walBackupDir}/%f %p'
|
||||||
'';
|
'';
|
||||||
|
|
||||||
makePostgresqlWalReceiverTest = subTestName: postgresqlPackage: makeTest {
|
recoveryFile = if atLeast12
|
||||||
|
then pkgs.writeTextDir "recovery.signal" ""
|
||||||
|
else pkgs.writeTextDir "recovery.conf" "${restoreCommand}";
|
||||||
|
|
||||||
|
in makeTest {
|
||||||
name = "postgresql-wal-receiver-${subTestName}";
|
name = "postgresql-wal-receiver-${subTestName}";
|
||||||
meta.maintainers = with maintainers; [ pacien ];
|
meta.maintainers = with maintainers; [ pacien ];
|
||||||
|
|
||||||
|
@ -29,6 +36,9 @@ let
|
||||||
wal_level = archive # alias for replica on pg >= 9.6
|
wal_level = archive # alias for replica on pg >= 9.6
|
||||||
max_wal_senders = 10
|
max_wal_senders = 10
|
||||||
max_replication_slots = 10
|
max_replication_slots = 10
|
||||||
|
'' + optionalString atLeast12 ''
|
||||||
|
${restoreCommand}
|
||||||
|
recovery_end_command = 'touch recovery.done'
|
||||||
'';
|
'';
|
||||||
authentication = ''
|
authentication = ''
|
||||||
host replication ${replicationUser} all trust
|
host replication ${replicationUser} all trust
|
||||||
|
@ -45,6 +55,9 @@ let
|
||||||
slot = replicationSlot;
|
slot = replicationSlot;
|
||||||
directory = walBackupDir;
|
directory = walBackupDir;
|
||||||
};
|
};
|
||||||
|
# This is only to speedup test, it isn't time racing. Service is set to autorestart always,
|
||||||
|
# default 60sec is fine for real system, but is too much for a test
|
||||||
|
systemd.services.postgresql-wal-receiver-main.serviceConfig.RestartSec = mkForce 5;
|
||||||
};
|
};
|
||||||
|
|
||||||
testScript = ''
|
testScript = ''
|
||||||
|
@ -70,7 +83,7 @@ let
|
||||||
# prepare WAL and recovery
|
# prepare WAL and recovery
|
||||||
$machine->succeed('chmod a+rX -R ${walBackupDir}');
|
$machine->succeed('chmod a+rX -R ${walBackupDir}');
|
||||||
$machine->execute('for part in ${walBackupDir}/*.partial; do mv $part ''${part%%.*}; done'); # make use of partial segments too
|
$machine->execute('for part in ${walBackupDir}/*.partial; do mv $part ''${part%%.*}; done'); # make use of partial segments too
|
||||||
$machine->succeed('cp ${recoveryConf} ${postgresqlDataDir}/recovery.conf && chmod 666 ${postgresqlDataDir}/recovery.conf');
|
$machine->succeed('cp ${recoveryFile}/* ${postgresqlDataDir}/ && chmod 666 ${postgresqlDataDir}/recovery*');
|
||||||
|
|
||||||
# replay WAL
|
# replay WAL
|
||||||
$machine->systemctl('start postgresql');
|
$machine->systemctl('start postgresql');
|
||||||
|
|
Loading…
Reference in New Issue
Block a user