8000 [PGPRO-146] cfs_catchup test · postgrespro/pg_probackup@f253798 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f253798

Browse files
committed
[PGPRO-146] cfs_catchup test
Test full catchup and delta catchup.
1 parent a20eb7b commit f253798

File tree

1 file changed

+107
-0
lines changed

1 file changed

+107
-0
lines changed

tests/cfs_catchup.py

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
import os
2+
import unittest
3+
import random
4+
import shutil
5+
6+
from .helpers.cfs_helpers import find_by_extensions, find_by_name, find_by_pattern, corrupt_file
7+
from .helpers.ptrack_helpers import ProbackupTest, ProbackupException
8+
9+
module_name = 'cfs_catchup'
10+
tblspace_name = 'cfs_tblspace'
11+
12+
13+
class CfsCatchupNoEncTest(ProbackupTest, unittest.TestCase):
14+
def setUp(self):
15+
self.fname = self.id().split('.')[3]
16+
17+
@unittest.skipUnless(ProbackupTest.enterprise, 'skip')
18+
def test_full_catchup_with_tablespace(self):
19+
"""
20+
Test tablespace transfers
21+
"""
22+
# preparation
23+
src_pg = self.make_simple_node(
24+
base_dir = os.path.join(module_name, self.fname, 'src'),
25+
set_replication = True
26+
)
27+
src_pg.slow_start()
28+
tblspace1_old_path = self.get_tblspace_path(src_pg, 'tblspace1_old')
29+
self.create_tblspace_in_node(src_pg, 'tblspace1', tblspc_path = tblspace1_old_path, cfs=True)
30+
src_pg.safe_psql(
31+
"postgres",
32+
"CREATE TABLE ultimate_question TABLESPACE tblspace1 AS SELECT 42 AS answer")
33+
src_query_result = src_pg.safe_psql("postgres", "SELECT * FROM ultimate_question")
34+
src_pg.safe_psql(
35+
"postgres",
36+
"CHECKPOINT")
37+
38+
# do full catchup with tablespace mapping
39+
dst_pg = self.make_empty_node(os.path.join(module_name, self.fname, 'dst'))
40+
tblspace1_new_path = self.get_tblspace_path(dst_pg, 'tblspace1_new')
41+
self.catchup_node(
42+
backup_mode = 'FULL',
43+
source_pgdata = src_pg.data_dir,
44+
destination_node = dst_pg,
45+
options = [
46+
'-d', 'postgres',
47+
'-p', str(src_pg.port),
48+
'--stream',
49+
'-T', '{0}={1}'.format(tblspace1_old_path, tblspace1_new_path)
50+
]
51+
)
52+
53+
# 1st check: compare data directories
54+
self.compare_pgdata(
55+
self.pgdata_content(src_pg.data_dir),
56+
self.pgdata_content(dst_pg.data_dir)
57+
)
58+
59+
# make changes in master tablespace
60+
src_pg.safe_psql(
61+
"postgres",
62+
"UPDATE ultimate_question SET answer = -1")
63+
src_pg.safe_psql(
64+
"postgres",
65+
"CHECKPOINT")
66+
67+
# run&recover catchup'ed instance
68+
dst_options = {}
69+
dst_options['port'] = str(dst_pg.port)
70+
self.set_auto_conf(dst_pg, dst_options)
71+
dst_pg.slow_start()
72+
73+
# 2nd check: run verification query
74+
dst_query_result = dst_pg.safe_psql("postgres", "SELECT * FROM ultimate_question")
75+
self.assertEqual(src_query_result, dst_query_result, 'Different answer from copy')
76+
77+
# and now delta backup
78+
dst_pg.stop()
79+
80+
self.catchup_node(
81+
backup_mode = 'DELTA',
82+
source_pgdata = src_pg.data_dir,
83+
destination_node = dst_pg,
84+
options = [
85+
'-d', 'postgres',
86+
'-p', str(src_pg.port),
87+
'--stream',
88+
'-T', '{0}={1}'.format(tblspace1_old_path, tblspace1_new_path)
89+
]
90+
)
91+
92+
# run&recover catchup'ed instance
93+
dst_options = {}
94+
dst_options['port'] = str(dst_pg.port)
95+
self.set_auto_conf(dst_pg, dst_options)
96+
dst_pg.slow_start()
97+
98+
99+
# 3rd check: run verification query
100+
src_query_result = src_pg.safe_psql("postgres", "SELECT * FROM ultimate_question")
101+
dst_query_result = dst_pg.safe_psql("postgres", "SELECT * FROM ultimate_question")
102+
self.assertEqual(src_query_result, dst_query_result, 'Different answer from copy')
103+
104+
# Cleanup
105+
src_pg.stop()
106+
dst_pg.stop()
107+
self.del_test_dir(module_name, self.fname)

0 commit comments

Comments
 (0)
0