mirror of
https://github.com/postgrespro/pg_probackup.git
synced 2026-06-21 01:34:15 +02:00
mkulagin-220213-test
This commit is contained in:
@@ -3,6 +3,7 @@ from pathlib import Path
|
||||
import signal
|
||||
import unittest
|
||||
from .helpers.ptrack_helpers import ProbackupTest, ProbackupException
|
||||
from time import sleep
|
||||
|
||||
module_name = 'catchup'
|
||||
|
||||
@@ -862,6 +863,95 @@ class CatchupTest(ProbackupTest, unittest.TestCase):
|
||||
src_pg.stop()
|
||||
self.del_test_dir(module_name, self.fname)
|
||||
|
||||
def test_tli_destination_mismatch_pgrewind(self):
|
||||
"""
|
||||
Test 220213
|
||||
"""
|
||||
#if not self.ptrack:
|
||||
# return unittest.skip('Skipped because ptrack support is disabled')
|
||||
|
||||
# preparation 1: source
|
||||
src_pg = self.make_simple_node(
|
||||
base_dir = os.path.join(module_name, self.fname, 'src'),
|
||||
set_replication = True,
|
||||
ptrack_enable = True,
|
||||
initdb_params = ['--data-checksums'],
|
||||
pg_options = { 'wal_log_hints': 'on' }
|
||||
)
|
||||
src_pg.slow_start()
|
||||
src_pg.safe_psql("postgres", "CREATE EXTENSION ptrack")
|
||||
|
||||
# preparation 2: destination
|
||||
dst_pg = self.make_empty_node(os.path.join(module_name, self.fname, 'dst'))
|
||||
self.catchup_node(
|
||||
backup_mode = 'FULL',
|
||||
source_pgdata = src_pg.data_dir,
|
||||
destination_node = dst_pg,
|
||||
options = ['-d', 'postgres', '-p', str(src_pg.port), '--stream']
|
||||
)
|
||||
dst_options = {}
|
||||
dst_options['port'] = str(dst_pg.port)
|
||||
self.set_auto_conf(dst_pg, dst_options)
|
||||
self.set_replica(src_pg, dst_pg)
|
||||
dst_pg.slow_start(replica = True)
|
||||
dst_pg.promote()
|
||||
src_pg.safe_psql("postgres", "CREATE TABLE garbage AS SELECT generate_series(0, 1E6) i")
|
||||
dst_pg.stop()
|
||||
|
||||
# preparation 3: "useful" changes
|
||||
src_pg.safe_psql("postgres", "CREATE TABLE ultimate_question AS SELECT 42 AS answer")
|
||||
src_query_result = src_pg.safe_psql("postgres", "SELECT * FROM ultimate_question")
|
||||
|
||||
# pg_rewind
|
||||
pg_rewind_path = self.get_bin_path('pg_rewind')
|
||||
pg_rewind = self.run_binary(
|
||||
[
|
||||
pg_rewind_path,
|
||||
'--progress',
|
||||
'--target-pgdata={0}'.format(dst_pg.data_dir),
|
||||
#'--source-pgdata={0}'.format(src_pg.data_dir)
|
||||
'--source-server=postgresql://localhost:{0}/postgres'.format(src_pg.port)
|
||||
])
|
||||
src_pg.stop()
|
||||
dst_options = {}
|
||||
dst_options['port'] = str(dst_pg.port)
|
||||
self.set_auto_conf(dst_pg, dst_options)
|
||||
self.set_replica(src_pg, dst_pg)
|
||||
#dst_pg.slow_start(replica = True)
|
||||
dst_pg.start(wait = False)
|
||||
sleep(15)
|
||||
dst_pg.stop()
|
||||
src_pg.slow_start()
|
||||
|
||||
# do ptrack catchup
|
||||
self.catchup_node(
|
||||
backup_mode = 'PTRACK',
|
||||
source_pgdata = src_pg.data_dir,
|
||||
destination_node = dst_pg,
|
||||
options = ['-d', 'postgres', '-p', str(src_pg.port), '--stream']
|
||||
)
|
||||
|
||||
# 1st check: compare data directories
|
||||
self.compare_pgdata(
|
||||
self.pgdata_content(src_pg.data_dir),
|
||||
self.pgdata_content(dst_pg.data_dir)
|
||||
)
|
||||
|
||||
# run&recover catchup'ed instance
|
||||
src_pg.stop()
|
||||
self.set_replica(master = src_pg, replica = dst_pg)
|
||||
dst_options = {}
|
||||
dst_options['port'] = str(dst_pg.port)
|
||||
self.set_auto_conf(dst_pg, dst_options)
|
||||
dst_pg.slow_start(replica = True)
|
||||
|
||||
# 2nd check: run verification query
|
||||
dst_query_result = dst_pg.safe_psql("postgres", "SELECT * FROM ultimate_question")
|
||||
self.assertEqual(src_query_result, dst_query_result, 'Different answer from copy')
|
||||
|
||||
# Cleanup
|
||||
self.del_test_dir(module_name, self.fname)
|
||||
|
||||
def test_tli_source_mismatch(self):
|
||||
"""
|
||||
Test that we detect TLI mismatch in source history
|
||||
|
||||
Reference in New Issue
Block a user