diff --git a/tests/replica.py b/tests/replica.py index 828305da7..383a4979a 100644 --- a/tests/replica.py +++ b/tests/replica.py @@ -21,7 +21,6 @@ def test_replica_switchover(self): over the course of several switchovers https://www.postgresql.org/message-id/54b059d4-2b48-13a4-6f43-95a087c92367%40postgrespro.ru """ - fname = self.id().split('.')[3] backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup') node1 = self.make_simple_node( @@ -29,6 +28,11 @@ def test_replica_switchover(self): set_replication=True, initdb_params=['--data-checksums']) + if self.get_version(node1) < self.version_to_num('9.6.0'): + self.del_test_dir(module_name, fname) + return unittest.skip( + 'Skipped because backup from replica is not supported in PG 9.5') + self.init_pb(backup_dir) self.add_instance(backup_dir, 'node1', node1) @@ -287,6 +291,16 @@ def test_replica_archive_page_backup(self): self.wait_until_replica_catch_with_master(master, replica) + master.pgbench_init(scale=5) + # Continuous making some changes on master, + # because WAL archiving on replica in idle DB in PostgreSQL is broken: + # replica will not archive the previous WAL until it receives new records in the next WAL file, + # this "lazy" archiving can be seen in src/backend/replication/walreceiver.c:XLogWalRcvWrite() + # (see !XLByteInSeg checking and XLogArchiveNotify() calling). + pgbench = master.pgbench( + stdout=subprocess.PIPE, stderr=subprocess.STDOUT, + options=['-T', '3', '-c', '1', '--no-vacuum']) + backup_id = self.backup_node( backup_dir, 'replica', replica, options=[ @@ -295,6 +309,9 @@ def test_replica_archive_page_backup(self): '--master-db=postgres', '--master-port={0}'.format(master.port)]) + pgbench.wait() + pgbench.stdout.close() + self.validate_pb(backup_dir, 'replica') self.assertEqual( 'OK', self.show_pb(backup_dir, 'replica', backup_id)['status']) @@ -317,8 +334,6 @@ def test_replica_archive_page_backup(self): # Change data on master, make PAGE backup from replica, # restore taken backup and check that restored data equal # to original data - master.pgbench_init(scale=5) - pgbench = master.pgbench( options=['-T', '30', '-c', '2', '--no-vacuum']) @@ -535,6 +550,11 @@ def test_replica_promote(self): start backup from replica, during backup promote replica check that backup is failed """ + if not self.gdb: + self.skipTest( + "Specify PGPROBACKUP_GDB and build without " + "optimizations for run this test" + ) fname = self.id().split('.')[3] backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup') master = self.make_simple_node( @@ -706,6 +726,7 @@ def test_replica_stop_lsn_null_offset(self): output) # Clean after yourself + gdb_checkpointer.kill() self.del_test_dir(module_name, fname) # @unittest.skip("skip") @@ -1085,6 +1106,7 @@ def test_replica_toast(self): self.compare_pgdata(pgdata, pgdata_restored) # Clean after yourself + gdb_checkpointer.kill() self.del_test_dir(module_name, fname) # @unittest.skip("skip") @@ -1313,6 +1335,11 @@ def test_replica_promote_archive_delta(self): 'checkpoint_timeout': '30s', 'archive_timeout': '30s'}) + if self.get_version(node1) < self.version_to_num('9.6.0'): + self.del_test_dir(module_name, fname) + return unittest.skip( + 'Skipped because backup from replica is not supported in PG 9.5') + self.init_pb(backup_dir) self.add_instance(backup_dir, 'node', node1) self.set_config( @@ -1433,6 +1460,11 @@ def test_replica_promote_archive_page(self): 'checkpoint_timeout': '30s', 'archive_timeout': '30s'}) + if self.get_version(node1) < self.version_to_num('9.6.0'): + self.del_test_dir(module_name, fname) + return unittest.skip( + 'Skipped because backup from replica is not supported in PG 9.5') + self.init_pb(backup_dir) self.add_instance(backup_dir, 'node', node1) self.set_archiving(backup_dir, 'node', node1) @@ -1550,6 +1582,11 @@ def test_parent_choosing(self): set_replication=True, initdb_params=['--data-checksums']) + if self.get_version(master) < self.version_to_num('9.6.0'): + self.del_test_dir(module_name, fname) + return unittest.skip( + 'Skipped because backup from replica is not supported in PG 9.5') + self.init_pb(backup_dir) self.add_instance(backup_dir, 'master', master) diff --git a/travis/Dockerfile.in b/travis/Dockerfile.in index a1f30d7f6..3e451e24f 100644 --- a/travis/Dockerfile.in +++ b/travis/Dockerfile.in @@ -10,6 +10,7 @@ RUN python3 -m pip install virtualenv # Environment ENV PG_MAJOR=${PG_VERSION} PG_BRANCH=${PG_BRANCH} +ENV PGPROBACKUP_GDB=${PGPROBACKUP_GDB} ENV LANG=C.UTF-8 PGHOME=/pg/testdir/pgbin # Make directories diff --git a/travis/docker-compose.yml b/travis/docker-compose.yml index 471ab779f..fc6545567 100644 --- a/travis/docker-compose.yml +++ b/travis/docker-compose.yml @@ -1,2 +1,17 @@ -tests: - build: . +version: "3.7" +services: + tests: + build: + context: . + + cap_add: + - SYS_PTRACE + + security_opt: + - seccomp=unconfined + + # don't work + #sysctls: + # kernel.yama.ptrace_scope: 0 + privileged: true + diff --git a/travis/make_dockerfile.sh b/travis/make_dockerfile.sh index 3e6938bd9..2e8ccd5a3 100755 --- a/travis/make_dockerfile.sh +++ b/travis/make_dockerfile.sh @@ -14,12 +14,18 @@ if [ -z ${MODE+x} ]; then MODE=basic fi +if [ -z ${PGPROBACKUP_GDB+x} ]; then + PGPROBACKUP_GDB=ON +fi + echo PG_VERSION=${PG_VERSION} echo PG_BRANCH=${PG_BRANCH} echo MODE=${MODE} +echo PGPROBACKUP_GDB=${PGPROBACKUP_GDB} sed \ -e 's/${PG_VERSION}/'${PG_VERSION}/g \ -e 's/${PG_BRANCH}/'${PG_BRANCH}/g \ -e 's/${MODE}/'${MODE}/g \ + -e 's/${PGPROBACKUP_GDB}/'${PGPROBACKUP_GDB}/g \ Dockerfile.in > Dockerfile diff --git a/travis/run_tests.sh b/travis/run_tests.sh index 325b89060..488d8ee45 100755 --- a/travis/run_tests.sh +++ b/travis/run_tests.sh @@ -65,6 +65,12 @@ which pg_config echo "############### pg_config:" pg_config +# Show kernel parameters +echo "############### kernel params:" +cat /proc/sys/kernel/yama/ptrace_scope +sudo sysctl kernel.yama.ptrace_scope=0 +cat /proc/sys/kernel/yama/ptrace_scope + # Build and install pg_probackup (using PG_CPPFLAGS and SHLIB_LINK for gcov) echo "############### Compiling and installing pg_probackup:" # make USE_PGXS=1 PG_CPPFLAGS="-coverage" SHLIB_LINK="-coverage" top_srcdir=$CUSTOM_PG_SRC install