Skip to content

[pbckp-128] dry-run option for catchup #477

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 14 commits into from
Jun 1, 2022
Merged
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
Fix catchup tests for dry-run option
  • Loading branch information
dlepikhova committed Apr 13, 2022
commit 4d6a3e9adcf7b06b08aaa40f8bb9a45dcebfe495
78 changes: 74 additions & 4 deletions tests/catchup.py
Original file line number Diff line number Diff line change
Expand Up @@ -1470,13 +1470,18 @@ def test_dry_run_catchup_full(self):
pg_options = { 'wal_log_hints': 'on' }
)
src_pg.slow_start()
src_pg.safe_psql(
"postgres",
"CREATE TABLE ultimate_question(answer int)")

# preparation 2: make clean shutdowned lagging behind replica
dst_pg = self.make_empty_node(os.path.join(module_name, self.fname, 'dst'))

src_pg.safe_psql(
"postgres",
"CREATE TABLE ultimate_question(answer int)")
src_pg.pgbench_init(scale = 10)
pgbench = src_pg.pgbench(options=['-T', '10', '--no-vacuum'])
pgbench.wait()
src_pg.safe_psql("postgres", "INSERT INTO ultimate_question VALUES(42)")

# save the condition before dry-run
content_before = self.pgdata_content(dst_pg.data_dir)

Expand All @@ -1496,10 +1501,12 @@ def test_dry_run_catchup_full(self):

# Cleanup
src_pg.stop()
dst_pg.stop()
self.del_test_dir(module_name, self.fname)

def test_dry_run_catchup_ptrack(self):
"""
Test dry-run option for catchup in incremental mode
Test dry-run option for catchup in incremental ptrack mode
"""
if not self.ptrack:
return unittest.skip('Skipped because ptrack support is disabled')
Expand All @@ -1514,6 +1521,10 @@ def test_dry_run_catchup_ptrack(self):
src_pg.safe_psql(
"postgres",
"CREATE TABLE ultimate_question(answer int)")
src_pg.pgbench_init(scale = 10)
pgbench = src_pg.pgbench(options=['-T', '10', '--no-vacuum'])
pgbench.wait()
src_pg.safe_psql("postgres", "INSERT INTO ultimate_question VALUES(42)")

# preparation 2: make clean shutdowned lagging behind replica
dst_pg = self.make_empty_node(os.path.join(module_name, self.fname, 'dst'))
Expand Down Expand Up @@ -1549,4 +1560,63 @@ def test_dry_run_catchup_ptrack(self):

# Cleanup
src_pg.stop()
dst_pg.stop()
self.del_test_dir(module_name, self.fname)

def test_dry_run_catchup_delta(self):
"""
Test dry-run option for catchup in incremental delta mode
"""

# preparation 1: source
src_pg = self.make_simple_node(
base_dir = os.path.join(module_name, self.fname, 'src'),
set_replication = True,
pg_options = { 'wal_log_hints': 'on' }
)
src_pg.slow_start()
src_pg.safe_psql(
"postgres",
"CREATE TABLE ultimate_question(answer int)")
src_pg.pgbench_init(scale = 10)
pgbench = src_pg.pgbench(options=['-T', '10', '--no-vacuum'])
pgbench.wait()
src_pg.safe_psql("postgres", "INSERT INTO ultimate_question VALUES(42)")

# preparation 2: make clean shutdowned lagging behind replica
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']
)
self.set_replica(src_pg, 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)
dst_pg.stop()

# save the condition before dry-run
content_before = self.pgdata_content(dst_pg.data_dir)

# do incremental catchup
self.catchup_node(
backup_mode = 'DELTA',
source_pgdata = src_pg.data_dir,
destination_node = dst_pg,
options = ['-d', 'postgres', '-p', str(src_pg.port), '--stream', '--dry-run']
)

# compare data dirs before and after cathup
self.compare_pgdata(
content_before,
self.pgdata_content(dst_pg.data_dir)
)

# Cleanup
src_pg.stop()
dst_pg.stop()
self.del_test_dir(module_name, self.fname)