From 3e353a7bc2dd6a9edfffe7e045c810b421f7ecc4 Mon Sep 17 00:00:00 2001 From: Simon Riggs Date: Wed, 4 Jan 2017 19:06:45 +0000 Subject: [PATCH] Add new TAP tests for pg_recvlogical Craig Ringer, reviewed by Euler Taveira and Naoki Okano --- src/bin/pg_basebackup/Makefile | 2 + src/bin/pg_basebackup/t/030_pg_recvlogical.pl | 46 +++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 src/bin/pg_basebackup/t/030_pg_recvlogical.pl diff --git a/src/bin/pg_basebackup/Makefile b/src/bin/pg_basebackup/Makefile index 79dcaf1013..a6c307492f 100644 --- a/src/bin/pg_basebackup/Makefile +++ b/src/bin/pg_basebackup/Makefile @@ -12,6 +12,8 @@ PGFILEDESC = "pg_basebackup/pg_receivexlog/pg_recvlogical - streaming WAL and backup receivers" PGAPPICON=win32 +EXTRA_INSTALL=contrib/test_decoding + subdir = src/bin/pg_basebackup top_builddir = ../../.. include $(top_builddir)/src/Makefile.global diff --git a/src/bin/pg_basebackup/t/030_pg_recvlogical.pl b/src/bin/pg_basebackup/t/030_pg_recvlogical.pl new file mode 100644 index 0000000000..dca5ef2181 --- /dev/null +++ b/src/bin/pg_basebackup/t/030_pg_recvlogical.pl @@ -0,0 +1,46 @@ +use strict; +use warnings; +use TestLib; +use PostgresNode; +use Test::More tests => 15; + +program_help_ok('pg_recvlogical'); +program_version_ok('pg_recvlogical'); +program_options_handling_ok('pg_recvlogical'); + +my $node = get_new_node('main'); + +# Initialize node without replication settings +$node->init(allows_streaming => 1, has_archiving => 1); +$node->append_conf('postgresql.conf', q{ +wal_level = 'logical' +max_replication_slots = 4 +max_wal_senders = 4 +log_min_messages = 'debug1' +log_error_verbosity = verbose +}); +$node->dump_info; +$node->start; + +$node->command_fails(['pg_recvlogical'], + 'pg_recvlogical needs a slot name'); +$node->command_fails(['pg_recvlogical', '-S', 'test'], + 'pg_recvlogical needs a database'); +$node->command_fails(['pg_recvlogical', '-S', 'test', '-d', 'postgres'], + 'pg_recvlogical needs an action'); +$node->command_fails(['pg_recvlogical', '-S', 'test', '-d', $node->connstr('postgres'), '--start'], + 'no destionation file'); + +$node->command_ok(['pg_recvlogical', '-S', 'test', '-d', $node->connstr('postgres'), '--create-slot'], + 'slot created'); + +my $slot = $node->slot('test'); +isnt($slot->{'restart_lsn'}, '', 'restart lsn is defined for new slot'); + +$node->psql('postgres', 'CREATE TABLE test_table(x integer)'); +$node->psql('postgres', 'INSERT INTO test_table(x) SELECT y FROM generate_series(1, 10) a(y);'); +my $nextlsn = $node->safe_psql('postgres', 'SELECT pg_current_xlog_insert_location()'); +chomp($nextlsn); + +$node->command_ok(['pg_recvlogical', '-S', 'test', '-d', $node->connstr('postgres'), '--start', '--endpos', "$nextlsn", '--no-loop', '-f', '-'], + 'replayed a transaction'); -- 2.40.0