1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295
|
--- a/t/010_pglogical_create_subscriber.pl
+++ b/t/010_pglogical_create_subscriber.pl
@@ -5,83 +5,90 @@
use TestLib;
use Test::More tests => 11;
-my $PGPORT=$ENV{'PGPORT'};
-my $PROVIDER_PORT=5431;
-my $PROVIDER_DSN = "postgresql://super\@localhost:$PROVIDER_PORT/postgres";
-my $SUBSCRIBER_DSN = "postgresql://super\@localhost:$PGPORT/postgres";
+my $CWD = getcwd;
+my $SOCKETDIR = "$CWD/tmp_check/tmp_socketdir";
+my $PGPORT=65432; #subscriber's port
+my $PROVIDER_PORT=65431;
+my $PROVIDER_DSN = "host=$SOCKETDIR user=super port=$PROVIDER_PORT dbname=postgres";
+my $PROVIDER_DATA = "$CWD/tmp_check/tmp_datadir";
+my $SUBSCRIBER_DSN = "host=$SOCKETDIR user=super port=$PGPORT dbname=postgres";
+my $SUBSCRIBER_DATA = "$CWD/tmp_check/tmp_backupdir";
program_help_ok('pglogical_create_subscriber');
program_options_handling_ok('pglogical_create_subscriber');
-system_or_bail 'rm', '-rf', '/tmp/tmp_datadir';
-system_or_bail 'rm', '-rf', '/tmp/tmp_backupdir';
+system_or_bail 'rm', '-rf', "$SOCKETDIR";
+system_or_bail 'mkdir', '-p', "$SOCKETDIR";
+system_or_bail 'rm', '-rf', "$PROVIDER_DATA";
+system_or_bail 'rm', '-rf', "$SUBSCRIBER_DATA";
-system_or_bail 'initdb', '-A trust', '-D', '/tmp/tmp_datadir';
+system_or_bail 'initdb', '-A trust', '-D', "$PROVIDER_DATA";
system_or_bail 'pwd';
-system_or_bail 'cp', 'regress-pg_hba.conf', '/tmp/tmp_datadir/pg_hba.conf';
+system_or_bail 'cp', 'regress-pg_hba.conf', "$PROVIDER_DATA/pg_hba.conf";
my $pg_version = `pg_config --version| sed 's/[^0-9\.]//g' | awk -F . '{ print \$1\$2 }'`;
if ($pg_version >= 95) {
- `cat t/perl-95-postgresql.conf>>/tmp/tmp_datadir/postgresql.conf`;
+ `cat t/perl-95-postgresql.conf>>$PROVIDER_DATA/postgresql.conf`;
} else {
- `cat t/perl-94-postgresql.conf>>/tmp/tmp_datadir/postgresql.conf`;
+ `cat t/perl-94-postgresql.conf>>$PROVIDER_DATA/postgresql.conf`;
}
-system("postgres -p $PROVIDER_PORT -D /tmp/tmp_datadir -c logging_collector=on &");
+system("postgres -k $SOCKETDIR -p $PROVIDER_PORT -D $PROVIDER_DATA -c logging_collector=on &");
#allow Postgres server to startup
-system_or_bail 'sleep', '17';
+system_or_bail 'sleep', '5';
-system_or_bail 'psql', '-X', '-p', "$PROVIDER_PORT", '-d', "postgres", '-c', "CREATE USER super SUPERUSER";
+system_or_bail 'psql', '-X', '-p', "$PROVIDER_PORT", '-h', "$SOCKETDIR", '-d', "postgres", '-c', "CREATE USER super SUPERUSER";
# insert some pre-seed data
-system_or_bail 'psql', '-X', '-p', "$PROVIDER_PORT", '-d', "postgres", '-c', "CREATE SEQUENCE some_local_seq";
-system_or_bail 'psql', '-X', '-p', "$PROVIDER_PORT", '-d', "postgres", '-c', "CREATE TABLE some_local_tbl(id serial primary key, key text unique not null, data text)";
-system_or_bail 'psql', '-X', '-p', "$PROVIDER_PORT", '-d', "postgres", '-c', "INSERT INTO some_local_tbl(key, data) VALUES('key1', 'data1')";
-system_or_bail 'psql', '-X', '-p', "$PROVIDER_PORT", '-d', "postgres", '-c', "INSERT INTO some_local_tbl(key, data) VALUES('key2', NULL)";
-system_or_bail 'psql', '-X', '-p', "$PROVIDER_PORT", '-d', "postgres", '-c', "INSERT INTO some_local_tbl(key, data) VALUES('key3', 'data3')";
-system_or_bail 'psql', '-X', '-p', "$PROVIDER_PORT", '-d', "postgres", '-c', "CREATE TABLE some_local_tbl1(id serial, key text unique not null, data text)";
-system_or_bail 'psql', '-X', '-p', "$PROVIDER_PORT", '-d', "postgres", '-c', "INSERT INTO some_local_tbl1(key, data) VALUES('key1', 'data1')";
-system_or_bail 'psql', '-X', '-p', "$PROVIDER_PORT", '-d', "postgres", '-c', "INSERT INTO some_local_tbl1(key, data) VALUES('key2', NULL)";
-system_or_bail 'psql', '-X', '-p', "$PROVIDER_PORT", '-d', "postgres", '-c', "INSERT INTO some_local_tbl1(key, data) VALUES('key3', 'data3')";
-system_or_bail 'psql', '-X', '-p', "$PROVIDER_PORT", '-d', "postgres", '-c', "CREATE TABLE some_local_tbl2(id serial, key text, data text)";
-system_or_bail 'psql', '-X', '-p', "$PROVIDER_PORT", '-d', "postgres", '-c', "INSERT INTO some_local_tbl2(key, data) VALUES('key1', 'data1')";
-system_or_bail 'psql', '-X', '-p', "$PROVIDER_PORT", '-d', "postgres", '-c', "INSERT INTO some_local_tbl2(key, data) VALUES('key2', NULL)";
-system_or_bail 'psql', '-X', '-p', "$PROVIDER_PORT", '-d', "postgres", '-c', "INSERT INTO some_local_tbl2(key, data) VALUES('key3', 'data3')";
-system_or_bail 'psql', '-X', '-p', "$PROVIDER_PORT", '-d', "postgres", '-c', "CREATE TABLE some_local_tbl3(id integer, key text, data text)";
-system_or_bail 'psql', '-X', '-p', "$PROVIDER_PORT", '-d', "postgres", '-c', "INSERT INTO some_local_tbl3(key, data) VALUES('key1', 'data1')";
-system_or_bail 'psql', '-X', '-p', "$PROVIDER_PORT", '-d', "postgres", '-c', "INSERT INTO some_local_tbl3(key, data) VALUES('key2', NULL)";
-system_or_bail 'psql', '-X', '-p', "$PROVIDER_PORT", '-d', "postgres", '-c', "INSERT INTO some_local_tbl3(key, data) VALUES('key3', 'data3')";
+system_or_bail 'psql', '-X', '-d', "$PROVIDER_DSN", '-c', "CREATE SEQUENCE some_local_seq";
+system_or_bail 'psql', '-X', '-d', "$PROVIDER_DSN", '-c', "CREATE TABLE some_local_tbl(id serial primary key, key text unique not null, data text)";
+system_or_bail 'psql', '-X', '-d', "$PROVIDER_DSN", '-c', "INSERT INTO some_local_tbl(key, data) VALUES('key1', 'data1')";
+system_or_bail 'psql', '-X', '-d', "$PROVIDER_DSN", '-c', "INSERT INTO some_local_tbl(key, data) VALUES('key2', NULL)";
+system_or_bail 'psql', '-X', '-d', "$PROVIDER_DSN", '-c', "INSERT INTO some_local_tbl(key, data) VALUES('key3', 'data3')";
+system_or_bail 'psql', '-X', '-d', "$PROVIDER_DSN", '-c', "CREATE TABLE some_local_tbl1(id serial, key text unique not null, data text)";
+system_or_bail 'psql', '-X', '-d', "$PROVIDER_DSN", '-c', "INSERT INTO some_local_tbl1(key, data) VALUES('key1', 'data1')";
+system_or_bail 'psql', '-X', '-d', "$PROVIDER_DSN", '-c', "INSERT INTO some_local_tbl1(key, data) VALUES('key2', NULL)";
+system_or_bail 'psql', '-X', '-d', "$PROVIDER_DSN", '-c', "INSERT INTO some_local_tbl1(key, data) VALUES('key3', 'data3')";
+system_or_bail 'psql', '-X', '-d', "$PROVIDER_DSN", '-c', "CREATE TABLE some_local_tbl2(id serial, key text, data text)";
+system_or_bail 'psql', '-X', '-d', "$PROVIDER_DSN", '-c', "INSERT INTO some_local_tbl2(key, data) VALUES('key1', 'data1')";
+system_or_bail 'psql', '-X', '-d', "$PROVIDER_DSN", '-c', "INSERT INTO some_local_tbl2(key, data) VALUES('key2', NULL)";
+system_or_bail 'psql', '-X', '-d', "$PROVIDER_DSN", '-c', "INSERT INTO some_local_tbl2(key, data) VALUES('key3', 'data3')";
+system_or_bail 'psql', '-X', '-d', "$PROVIDER_DSN", '-c', "CREATE TABLE some_local_tbl3(id integer, key text, data text)";
+system_or_bail 'psql', '-X', '-d', "$PROVIDER_DSN", '-c', "INSERT INTO some_local_tbl3(key, data) VALUES('key1', 'data1')";
+system_or_bail 'psql', '-X', '-d', "$PROVIDER_DSN", '-c', "INSERT INTO some_local_tbl3(key, data) VALUES('key2', NULL)";
+system_or_bail 'psql', '-X', '-d', "$PROVIDER_DSN", '-c', "INSERT INTO some_local_tbl3(key, data) VALUES('key3', 'data3')";
# Required for PostgreSQL 9.4 run
-#system_or_bail 'psql', '-X', '-p', "$PROVIDER_PORT", '-d', "postgres", '-c', "CREATE EXTENSION IF NOT EXISTS pglogical_origin";
-system_or_bail 'psql', '-X', '-p', "$PROVIDER_PORT", '-d', "postgres", '-c', "CREATE EXTENSION IF NOT EXISTS pglogical VERSION '1.0.0'";
-system_or_bail 'psql', '-X', '-p', "$PROVIDER_PORT", '-d', "postgres", '-c', "ALTER EXTENSION pglogical UPDATE";
+#system_or_bail 'psql', '-X', '-d', "$PROVIDER_DSN", '-c', "CREATE EXTENSION IF NOT EXISTS pglogical_origin";
+system_or_bail 'psql', '-X', '-d', "$PROVIDER_DSN", '-c', "CREATE EXTENSION IF NOT EXISTS pglogical VERSION '1.0.0'";
+system_or_bail 'psql', '-X', '-d', "$PROVIDER_DSN", '-c', "ALTER EXTENSION pglogical UPDATE";
-system_or_bail 'psql', '-X', '-p', "$PROVIDER_PORT", '-d', "postgres", '-c', "SELECT * FROM pglogical.create_node(node_name := 'test_provider', dsn := 'dbname=postgres user=super')";
+system_or_bail 'psql', '-X', '-d', "$PROVIDER_DSN", '-c', "SELECT * FROM pglogical.create_node(node_name := 'test_provider', dsn := 'dbname=postgres user=super')";
-command_ok([ 'pglogical_create_subscriber', '-D', '/tmp/tmp_backupdir', "--subscriber-name=test_subscriber", "--subscriber-dsn=$SUBSCRIBER_DSN", "--provider-dsn=$PROVIDER_DSN", '--drop-slot-if-exists', '-v', '--hba-conf=regress-pg_hba.conf', '--postgresql-conf=/tmp/tmp_datadir/postgresql.conf'], 'pglogical_create_subscriber check');
+local $ENV{PGPORT} = 65432;
+command_ok([ 'pglogical_create_subscriber', '-D', "$SUBSCRIBER_DATA", "--subscriber-name=test_subscriber", "--subscriber-dsn=$SUBSCRIBER_DSN", "--provider-dsn=$PROVIDER_DSN", '--drop-slot-if-exists', '-v', '--hba-conf=regress-pg_hba.conf', "--postgresql-conf=$PROVIDER_DATA/postgresql.conf"], 'pglogical_create_subscriber check');
#test whether preseed data is there
-command_ok([ 'psql', '-X', '-p', "$PGPORT", '-d', "postgres", '-c', "\\d" ], 'preseed check 1 ');
-command_ok([ 'psql', '-X', '-p', "$PGPORT", '-d', "postgres", '-c', "SELECT * from some_local_tbl" ], 'preseed check 2 ');
+command_ok([ 'psql', '-X', '-d', "$SUBSCRIBER_DSN", '-c', "\\d" ], 'preseed check 1 ');
+command_ok([ 'psql', '-X', '-d', "$SUBSCRIBER_DSN", '-c', "SELECT * from some_local_tbl" ], 'preseed check 2 ');
#insert some new data
-system_or_bail 'psql', '-X', '-p', "$PROVIDER_PORT", '-d', "postgres", '-f', 't/basic.sql';
+system_or_bail 'psql', '-X', '-d', "$PROVIDER_DSN", '-f', 't/basic.sql';
#allow script to complete executing
system_or_bail 'sleep', '11';
#check whether it is replicated
-command_ok([ 'psql', '-X', '-p', "$PGPORT", '-d', "postgres", '-c', "\\d" ], 'replication check 1 ');
-command_ok([ 'psql', '-X', '-p', "$PGPORT", '-d', "postgres", '-c', "SELECT * from basic_dml" ], 'replication check 2 ');
-command_ok([ 'psql', '-X', '-p', "$PGPORT", '-d', "postgres", '-c', "SELECT * from public.basic_dml" ], 'replication check 3 ');
+command_ok([ 'psql', '-X', '-d', "$SUBSCRIBER_DSN", '-c', "\\d" ], 'replication check 1 ');
+command_ok([ 'psql', '-X', '-d', "$SUBSCRIBER_DSN", '-c', "SELECT * from basic_dml" ], 'replication check 2 ');
+command_ok([ 'psql', '-X', '-d', "$SUBSCRIBER_DSN", '-c', "SELECT * from public.basic_dml" ], 'replication check 3 ');
#cleanup
-system("pg_ctl stop -D /tmp/tmp_backupdir -m immediate &");
-system("pg_ctl stop -D /tmp/tmp_datadir -m immediate &");
+system("pg_ctl stop -D $SUBSCRIBER_DATA -m immediate &");
+system("pg_ctl stop -D $PROVIDER_DATA -m immediate &");
--- a/t/020_non_default_replication_set.pl
+++ b/t/020_non_default_replication_set.pl
@@ -5,58 +5,64 @@
use TestLib;
use Test::More tests => 1;
+my $CWD = getcwd;
+my $SOCKETDIR = "$CWD/tmp_check/tmp_socketdir";
my $PGPORT=65432; #subscriber's port
my $PROVIDER_PORT=65431;
-my $PROVIDER_DSN = "postgresql://super\@localhost:$PROVIDER_PORT/postgres";
-my $SUBSCRIBER_DSN = "postgresql://super\@localhost:$PGPORT/postgres";
-
-system_or_bail 'rm', '-rf', '/tmp/tmp_020_pdatadir';
-system_or_bail 'rm', '-rf', '/tmp/tmp_020_sdatadir';
+my $PROVIDER_DSN = "host=$SOCKETDIR user=super port=$PROVIDER_PORT dbname=postgres";
+my $PROVIDER_DATA = "$CWD/tmp_check/tmp_020_pdatadir";
+my $SUBSCRIBER_DSN = "host=$SOCKETDIR user=super port=$PGPORT dbname=postgres";
+my $SUBSCRIBER_DATA = "$CWD/tmp_check/tmp_020_sdatadir";
+
+system_or_bail 'rm', '-rf', "$SOCKETDIR";
+system_or_bail 'mkdir', '-p', "$SOCKETDIR";
+system_or_bail 'rm', '-rf', "$PROVIDER_DATA";
+system_or_bail 'rm', '-rf', "$SUBSCRIBER_DATA";
#provider's and subscriber's datadir
-system_or_bail 'initdb', '-A trust', '-D', '/tmp/tmp_020_pdatadir';
-system_or_bail 'initdb', '-A trust', '-D', '/tmp/tmp_020_sdatadir';
+system_or_bail 'initdb', '-A trust', '-D', "$PROVIDER_DATA";
+system_or_bail 'initdb', '-A trust', '-D', "$SUBSCRIBER_DATA";
system_or_bail 'pwd';
-system_or_bail 'cp', 'regress-pg_hba.conf', '/tmp/tmp_020_pdatadir/pg_hba.conf';
-system_or_bail 'cp', 'regress-pg_hba.conf', '/tmp/tmp_020_sdatadir/pg_hba.conf';
+system_or_bail 'cp', 'regress-pg_hba.conf', "$PROVIDER_DATA/pg_hba.conf";
+system_or_bail 'cp', 'regress-pg_hba.conf', "$SUBSCRIBER_DATA/pg_hba.conf";
my $pg_version = `pg_config --version| sed 's/[^0-9\.]//g' | awk -F . '{ print \$1\$2 }'`;
if ($pg_version >= 95) {
- `cat t/perl-95-postgresql.conf>>/tmp/tmp_020_pdatadir/postgresql.conf`;
- `cat t/perl-95-postgresql.conf>>/tmp/tmp_020_sdatadir/postgresql.conf`;
+ `cat t/perl-95-postgresql.conf>>$PROVIDER_DATA/postgresql.conf`;
+ `cat t/perl-95-postgresql.conf>>$SUBSCRIBER_DATA/postgresql.conf`;
} else {
- `cat t/perl-94-postgresql.conf>>/tmp/tmp_020_pdatadir/postgresql.conf`;
- `cat t/perl-94-postgresql.conf>>/tmp/tmp_020_sdatadir/postgresql.conf`;
+ `cat t/perl-94-postgresql.conf>>$PROVIDER_DATA/postgresql.conf`;
+ `cat t/perl-94-postgresql.conf>>$SUBSCRIBER_DATA/postgresql.conf`;
}
-system("postgres -p $PROVIDER_PORT -D /tmp/tmp_020_pdatadir -c logging_collector=on &");
-system("postgres -p $PGPORT -D /tmp/tmp_020_sdatadir -c logging_collector=on &");
+system("postgres -k $SOCKETDIR -p $PROVIDER_PORT -D $PROVIDER_DATA -c logging_collector=on &");
+system("postgres -k $SOCKETDIR -p $PGPORT -D $SUBSCRIBER_DATA -c logging_collector=on &");
#allow Postgres servers to startup
-system_or_bail 'sleep', '17';
+system_or_bail 'sleep', '5';
-system_or_bail 'psql', '-X', '-p', "$PROVIDER_PORT", '-d', "postgres", '-c', "CREATE USER super SUPERUSER";
-system_or_bail 'psql', '-X', '-p', "$PGPORT", '-d', "postgres", '-c', "CREATE USER super SUPERUSER";
+system_or_bail 'psql', '-X', '-p', "$PROVIDER_PORT", '-h', "$SOCKETDIR", '-d', "postgres", '-c', "CREATE USER super SUPERUSER";
+system_or_bail 'psql', '-X', '-p', "$PGPORT", '-h', "$SOCKETDIR", '-d', "postgres", '-c', "CREATE USER super SUPERUSER";
# Required for PostgreSQL 9.4 run
-#system_or_bail 'psql', '-X', '-p', "$PROVIDER_PORT", '-d', "postgres", '-c', "CREATE EXTENSION IF NOT EXISTS pglogical_origin";
-system_or_bail 'psql', '-X', '-p', "$PROVIDER_PORT", '-d', "postgres", '-c', "CREATE EXTENSION IF NOT EXISTS pglogical VERSION '1.0.0'";
-system_or_bail 'psql', '-X', '-p', "$PROVIDER_PORT", '-d', "postgres", '-c', "ALTER EXTENSION pglogical UPDATE";
+#system_or_bail 'psql', '-X', '-d', "$PROVIDER_DSN", '-c', "CREATE EXTENSION IF NOT EXISTS pglogical_origin";
+system_or_bail 'psql', '-X', '-d', "$PROVIDER_DSN", '-c', "CREATE EXTENSION IF NOT EXISTS pglogical VERSION '1.0.0'";
+system_or_bail 'psql', '-X', '-d', "$PROVIDER_DSN", '-c', "ALTER EXTENSION pglogical UPDATE";
# Required for PostgreSQL 9.4 run
-#system_or_bail 'psql', '-X', '-p', "$PGPORT", '-d', "postgres", '-c', "CREATE EXTENSION IF NOT EXISTS pglogical_origin";
-system_or_bail 'psql', '-X', '-p', "$PGPORT", '-d', "postgres", '-c', "CREATE EXTENSION IF NOT EXISTS pglogical";
+#system_or_bail 'psql', '-X', '-d', "$SUBSCRIBER_DSN", '-c', "CREATE EXTENSION IF NOT EXISTS pglogical_origin";
+system_or_bail 'psql', '-X', '-d', "$SUBSCRIBER_DSN", '-c', "CREATE EXTENSION IF NOT EXISTS pglogical";
-system_or_bail 'psql', '-X', '-p', "$PROVIDER_PORT", '-d', "postgres", '-c', "SELECT * FROM pglogical.create_node(node_name := 'test_provider', dsn := 'dbname=postgres user=super')";
+system_or_bail 'psql', '-X', '-d', "$PROVIDER_DSN", '-c', "SELECT * FROM pglogical.create_node(node_name := 'test_provider', dsn := 'dbname=postgres user=super')";
-system_or_bail 'psql', '-X', '-p', "$PGPORT", '-d', "postgres", '-c', "SELECT * FROM pglogical.create_node(node_name := 'test_subscriber', dsn := '$SUBSCRIBER_DSN')";
+system_or_bail 'psql', '-X', '-d', "$SUBSCRIBER_DSN", '-c', "SELECT * FROM pglogical.create_node(node_name := 'test_subscriber', dsn := '$SUBSCRIBER_DSN')";
-system_or_bail 'psql', '-X', '-p', "$PROVIDER_PORT", '-d', "postgres", '-c', "SELECT * FROM pglogical.create_replication_set('delay')";
+system_or_bail 'psql', '-X', '-d', "$PROVIDER_DSN", '-c', "SELECT * FROM pglogical.create_replication_set('delay')";
-system_or_bail 'psql', '-X', '-p', "$PGPORT", '-d', "postgres", '-c', "SELECT * FROM pglogical.create_subscription(
+system_or_bail 'psql', '-X', '-d', "$SUBSCRIBER_DSN", '-c', "SELECT * FROM pglogical.create_subscription(
subscription_name := 'test_subscription_delay',
provider_dsn := '$PROVIDER_DSN',
replication_sets := '{delay}',
@@ -65,7 +71,7 @@
synchronize_data := false
)";
-system_or_bail 'psql', '-X', '-p', "$PGPORT", '-d', "postgres", '-c', "DO \$\$
+system_or_bail 'psql', '-X', '-d', "$SUBSCRIBER_DSN", '-c', "DO \$\$
BEGIN
FOR i IN 1..100 LOOP
IF EXISTS (SELECT 1 FROM pglogical.show_subscription_status() WHERE status = 'replicating') THEN
@@ -76,9 +82,9 @@
END;
\$\$";
-system_or_bail 'psql', '-X', '-p', "$PGPORT", '-d', "postgres", '-c', "SELECT subscription_name, status, provider_node, replication_sets, forward_origins FROM pglogical.show_subscription_status()";
+system_or_bail 'psql', '-X', '-d', "$SUBSCRIBER_DSN", '-c', "SELECT subscription_name, status, provider_node, replication_sets, forward_origins FROM pglogical.show_subscription_status()";
-system_or_bail 'psql', '-X', '-p', "$PGPORT", '-d', "postgres", '-c', "DO \$\$
+system_or_bail 'psql', '-X', '-d', "$SUBSCRIBER_DSN", '-c', "DO \$\$
BEGIN
FOR i IN 1..300 LOOP
IF EXISTS (SELECT 1 FROM pglogical.local_sync_status WHERE sync_status = 'r') THEN
@@ -88,9 +94,9 @@
END LOOP;
END;\$\$";
-system_or_bail 'psql', '-X', '-p', "$PGPORT", '-d', "postgres", '-c', "SELECT sync_kind, sync_subid, sync_nspname, sync_relname, sync_status FROM pglogical.local_sync_status ORDER BY 2,3,4";
+system_or_bail 'psql', '-X', '-d', "$SUBSCRIBER_DSN", '-c', "SELECT sync_kind, sync_subid, sync_nspname, sync_relname, sync_status FROM pglogical.local_sync_status ORDER BY 2,3,4";
-system_or_bail 'psql', '-X', '-p', "$PROVIDER_PORT", '-d', "postgres", '-c', "CREATE OR REPLACE FUNCTION public.pg_xlog_wait_remote_apply(i_pos pg_lsn, i_pid integer) RETURNS VOID
+system_or_bail 'psql', '-X', '-d', "$PROVIDER_DSN", '-c', "CREATE OR REPLACE FUNCTION public.pg_xlog_wait_remote_apply(i_pos pg_lsn, i_pid integer) RETURNS VOID
AS \$FUNC\$
BEGIN
WHILE EXISTS(SELECT true FROM pg_stat_get_wal_senders() s WHERE s.replay_location < i_pos AND (i_pid = 0 OR s.pid = i_pid)) LOOP
@@ -98,7 +104,7 @@
END LOOP;
END;\$FUNC\$ LANGUAGE plpgsql";
-system_or_bail 'psql', '-X', '-p', "$PROVIDER_PORT", '-d', "postgres", '-c', "SELECT pglogical.replicate_ddl_command(\$\$
+system_or_bail 'psql', '-X', '-d', "$PROVIDER_DSN", '-c', "SELECT pglogical.replicate_ddl_command(\$\$
CREATE TABLE public.basic_dml1 (
id serial primary key,
other integer,
@@ -106,8 +112,8 @@
something interval
);
\$\$)";
-system_or_bail 'psql', '-X', '-p', "$PGPORT", '-d', "postgres", '-c', "select * from pglogical.show_subscription_status('test_subscription_delay');";
-system_or_bail 'psql', '-X', '-p', "$PROVIDER_PORT", '-d', "postgres", '-c', "SELECT * FROM pglogical.replication_set_add_table('delay', 'basic_dml1', true) ";
+system_or_bail 'psql', '-X', '-d', "$SUBSCRIBER_DSN", '-c', "select * from pglogical.show_subscription_status('test_subscription_delay');";
+system_or_bail 'psql', '-X', '-d', "$PROVIDER_DSN", '-c', "SELECT * FROM pglogical.replication_set_add_table('delay', 'basic_dml1', true) ";
#At this point subscriber sync starts crashing (`sync worker`) and recovering
# check logs at this point at:
@@ -116,8 +122,8 @@
# But since the table does not exist on subscriber, the sync worker dies when trying
# to accessing it. It even logs why it dies on the line above.
system_or_bail 'sleep', '10';
-command_fails([ 'psql', '-X', '-p', "$PGPORT", '-d', "postgres", '-c', "SELECT * FROM basic_dml1" ], 'replication check');
+command_fails([ 'psql', '-X', '-d', "$SUBSCRIBER_DSN", '-c', "SELECT * FROM basic_dml1" ], 'replication check');
#cleanup
-system("pg_ctl stop -D /tmp/tmp_020_sdatadir -m immediate &");
-system("pg_ctl stop -D /tmp/tmp_020_pdatadir -m immediate &");
+system("pg_ctl stop -D $SUBSCRIBER_DATA -m immediate &");
+system("pg_ctl stop -D $PROVIDER_DATA -m immediate &");
|