use strict;
use warnings FATAL => 'all';

use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More;

my $primary = PostgreSQL::Test::Cluster->new('primary');
$primary->init(allows_streaming => 1);
$primary->append_conf(
        'postgresql.conf', q{
max_worker_processes = 0
max_locks_per_transaction = 10

autovacuum_max_workers = 1000
});
$primary->start;

$primary->backup('backup');

my $standby = PostgreSQL::Test::Cluster->new('standby');
$standby->init_from_backup($primary, 'backup', has_streaming => 1);
$standby->append_conf(
        'postgresql.conf', q{
hot_standby = on
max_worker_processes = 0
max_locks_per_transaction = 10

autovacuum_max_workers = 1
});

$primary->safe_psql('postgres', q{
BEGIN;
SELECT format('CREATE TABLE t_%s (x int)', g) FROM generate_series(1, 500) g
\gexec
COMMIT;
});

$standby->start();

sleep(3);
$standby->safe_psql('postgres', 'SELECT 1');
