1
0
mirror of https://github.com/postgrespro/pg_probackup.git synced 2026-06-21 01:34:15 +02:00

[PGPRO-5378] fix various tests (#420)

* [PGPRO-5378] tests.replica.ReplicaTest.test_replica_archive_page_backup stabilization
* Skip some tests on PG-9.5 (test_replica_switchover, test_replica_promote_archive_delta, test_replica_promote_archive_page, test_parent_choosing)
* travis: Fix compatibility issues with GDB
This commit is contained in:
Mikhail A. Kulagin
2021-08-13 02:59:20 +03:00
committed by GitHub
parent 384cf6dcfd
commit 002d7b53b9
5 changed files with 70 additions and 5 deletions
+40 -3
View File
@@ -21,7 +21,6 @@ class ReplicaTest(ProbackupTest, unittest.TestCase):
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 @@ class ReplicaTest(ProbackupTest, unittest.TestCase):
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 @@ class ReplicaTest(ProbackupTest, unittest.TestCase):
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 @@ class ReplicaTest(ProbackupTest, unittest.TestCase):
'--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 @@ class ReplicaTest(ProbackupTest, unittest.TestCase):
# 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 @@ class ReplicaTest(ProbackupTest, unittest.TestCase):
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 @@ class ReplicaTest(ProbackupTest, unittest.TestCase):
output)
# Clean after yourself
gdb_checkpointer.kill()
self.del_test_dir(module_name, fname)
# @unittest.skip("skip")
@@ -1085,6 +1106,7 @@ class ReplicaTest(ProbackupTest, unittest.TestCase):
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 @@ class ReplicaTest(ProbackupTest, unittest.TestCase):
'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 @@ class ReplicaTest(ProbackupTest, unittest.TestCase):
'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 @@ class ReplicaTest(ProbackupTest, unittest.TestCase):
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)
+1
View File
@@ -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
+17 -2
View File
@@ -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
+6
View File
@@ -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
+6
View File
@@ -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