recovery_tli_switch_test.pl
application/x-perl
Filename: recovery_tli_switch_test.pl
Type: application/x-perl
Part: 1
use strict;
use warnings;
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More;
my $backup_name = "replica";
my $node_primary = PostgreSQL::Test::Cluster->new('primary');
$node_primary->init(allows_streaming => 1);
$node_primary->start;
$node_primary->backup($backup_name);
# Fill WAL a little bit
$node_primary->safe_psql(
'postgres', qq[
CREATE TABLE test(a int, b int);
INSERT INTO test SELECT s FROM generate_series(1, 10000) AS s;
]);
# Promote the primary node up to TLI 2
$node_primary->stop('immediate');
$node_primary->set_standby_mode;
$node_primary->start;
$node_primary->promote;
# Fill WAL a little bit again
$node_primary->safe_psql(
'postgres', qq[
INSERT INTO test SELECT s FROM generate_series(1, 10000) AS s;
]);
my $node_standby = PostgreSQL::Test::Cluster->new($backup_name);
$node_standby->init_from_backup($node_primary, $backup_name,
has_streaming => 1);
$node_standby->start;
$node_standby->promote;
ok(1);
done_testing();