Skip to content

[PGPRO-5378] fix unstable tests.replica.ReplicaTest.test_replica_arch… #420

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Aug 12, 2021
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 40 additions & 3 deletions tests/replica.py
Original file line number Diff line number Diff line change
@@ -21,14 +21,18 @@ 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(
base_dir=os.path.join(module_name, fname, 'node1'),
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)

1 change: 1 addition & 0 deletions travis/Dockerfile.in
Original file line number Diff line number Diff line change
@@ -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
19 changes: 17 additions & 2 deletions travis/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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 changes: 6 additions & 0 deletions travis/make_dockerfile.sh
Original file line number Diff line number Diff line change
@@ -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 changes: 6 additions & 0 deletions travis/run_tests.sh
Original file line number Diff line number Diff line change
@@ -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