Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ff31602

Browse files
committed
tests: ptrack madness
1 parent 3088f4f commit ff31602

6 files changed

+61
-55
lines changed

tests/ptrack_truncate.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
class SimpleTest(ProbackupTest, unittest.TestCase):
1010

11-
# @unittest.skip("skip")
11+
@unittest.skip("skip")
1212
# @unittest.expectedFailure
1313
def test_ptrack_truncate(self):
1414
fname = self.id().split('.')[3]
@@ -69,7 +69,7 @@ def test_ptrack_truncate(self):
6969
# Clean after yourself
7070
self.del_test_dir(module_name, fname)
7171

72-
# @unittest.skip("skip")
72+
@unittest.skip("skip")
7373
def test_ptrack_truncate_replica(self):
7474
fname = self.id().split('.')[3]
7575
master = self.make_simple_node(
@@ -136,7 +136,13 @@ def test_ptrack_truncate_replica(self):
136136

137137
# Make full backup to clean every ptrack
138138
self.backup_node(
139-
backup_dir, 'replica', replica, options=['-j10', '--stream'])
139+
backup_dir, 'replica', replica,
140+
options=[
141+
'-j10',
142+
'--master-host=localhost',
143+
'--master-db=postgres',
144+
'--master-port={0}'.format(master.port)])
145+
140146
for i in idx_ptrack:
141147
idx_ptrack[i]['ptrack'] = self.get_ptrack_bits_per_page_for_fork(
142148
replica, idx_ptrack[i]['path'], [idx_ptrack[i]['old_size']])

tests/ptrack_vacuum.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -154,15 +154,6 @@ def test_ptrack_vacuum_replica(self):
154154
lsn))
155155
replica.safe_psql('postgres', 'checkpoint')
156156

157-
for i in idx_ptrack:
158-
# get fork size and calculate it in pages
159-
idx_ptrack[i]['old_size'] = self.get_fork_size(replica, i)
160-
# get path to heap and index files
161-
idx_ptrack[i]['path'] = self.get_fork_path(replica, i)
162-
# calculate md5sums for every page of this fork
163-
idx_ptrack[i]['old_pages'] = self.get_md5_per_page_for_fork(
164-
idx_ptrack[i]['path'], idx_ptrack[i]['old_size'])
165-
166157
# Make FULL backup to clean every ptrack
167158
self.backup_node(
168159
backup_dir, 'replica', replica, options=[
@@ -175,6 +166,15 @@ def test_ptrack_vacuum_replica(self):
175166
replica, idx_ptrack[i]['path'], [idx_ptrack[i]['old_size']])
176167
self.check_ptrack_clean(idx_ptrack[i], idx_ptrack[i]['old_size'])
177168

169+
for i in idx_ptrack:
170+
# get fork size and calculate it in pages
171+
idx_ptrack[i]['old_size'] = self.get_fork_size(replica, i)
172+
# get path to heap and index files
173+
idx_ptrack[i]['path'] = self.get_fork_path(replica, i)
174+
# calculate md5sums for every page of this fork
175+
idx_ptrack[i]['old_pages'] = self.get_md5_per_page_for_fork(
176+
idx_ptrack[i]['path'], idx_ptrack[i]['old_size'])
177+
178178
# Delete some rows, vacuum it and make checkpoint
179179
master.safe_psql('postgres', 'delete from t_heap where id%2 = 1')
180180
master.safe_psql('postgres', 'vacuum t_heap')

tests/ptrack_vacuum_bits_frozen.py

+15-15
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ def test_ptrack_vacuum_bits_frozen(self):
4747

4848
node.safe_psql('postgres', 'checkpoint')
4949

50+
self.backup_node(
51+
backup_dir, 'node', node, options=['-j10', '--stream'])
52+
53+
node.safe_psql('postgres', 'vacuum freeze t_heap')
54+
node.safe_psql('postgres', 'checkpoint')
55+
5056
for i in idx_ptrack:
5157
# get size of heap and indexes. size calculated in pages
5258
idx_ptrack[i]['old_size'] = self.get_fork_size(node, i)
@@ -56,12 +62,6 @@ def test_ptrack_vacuum_bits_frozen(self):
5662
idx_ptrack[i]['old_pages'] = self.get_md5_per_page_for_fork(
5763
idx_ptrack[i]['path'], idx_ptrack[i]['old_size'])
5864

59-
self.backup_node(
60-
backup_dir, 'node', node, options=['-j10', '--stream'])
61-
62-
node.safe_psql('postgres', 'vacuum freeze t_heap')
63-
node.safe_psql('postgres', 'checkpoint')
64-
6565
# CHECK PTRACK SANITY
6666
success = True
6767
for i in idx_ptrack:
@@ -144,15 +144,6 @@ def test_ptrack_vacuum_bits_frozen_replica(self):
144144
lsn))
145145
replica.safe_psql('postgres', 'checkpoint')
146146

147-
for i in idx_ptrack:
148-
# get size of heap and indexes. size calculated in pages
149-
idx_ptrack[i]['old_size'] = self.get_fork_size(replica, i)
150-
# get path to heap and index files
151-
idx_ptrack[i]['path'] = self.get_fork_path(replica, i)
152-
# calculate md5sums of pages
153-
idx_ptrack[i]['old_pages'] = self.get_md5_per_page_for_fork(
154-
idx_ptrack[i]['path'], idx_ptrack[i]['old_size'])
155-
156147
# Take PTRACK backup to clean every ptrack
157148
self.backup_node(
158149
backup_dir, 'replica', replica,
@@ -162,6 +153,15 @@ def test_ptrack_vacuum_bits_frozen_replica(self):
162153
'--master-db=postgres',
163154
'--master-port={0}'.format(master.port)])
164155

156+
for i in idx_ptrack:
157+
# get size of heap and indexes. size calculated in pages
158+
idx_ptrack[i]['old_size'] = self.get_fork_size(replica, i)
159+
# get path to heap and index files
160+
idx_ptrack[i]['path'] = self.get_fork_path(replica, i)
161+
# calculate md5sums of pages
162+
idx_ptrack[i]['old_pages'] = self.get_md5_per_page_for_fork(
163+
idx_ptrack[i]['path'], idx_ptrack[i]['old_size'])
164+
165165
master.safe_psql('postgres', 'vacuum freeze t_heap')
166166
master.safe_psql('postgres', 'checkpoint')
167167

tests/ptrack_vacuum_bits_visibility.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ def test_ptrack_vacuum_bits_visibility(self):
4747

4848
node.safe_psql('postgres', 'checkpoint')
4949

50+
self.backup_node(
51+
backup_dir, 'node', node, options=['-j10', '--stream'])
52+
5053
for i in idx_ptrack:
5154
# get size of heap and indexes. size calculated in pages
5255
idx_ptrack[i]['old_size'] = self.get_fork_size(node, i)
@@ -56,9 +59,6 @@ def test_ptrack_vacuum_bits_visibility(self):
5659
idx_ptrack[i]['old_pages'] = self.get_md5_per_page_for_fork(
5760
idx_ptrack[i]['path'], idx_ptrack[i]['old_size'])
5861

59-
self.backup_node(
60-
backup_dir, 'node', node, options=['-j10', '--stream'])
61-
6262
node.safe_psql('postgres', 'vacuum t_heap')
6363
node.safe_psql('postgres', 'checkpoint')
6464

tests/ptrack_vacuum_full.py

+13-13
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ def test_ptrack_vacuum_full(self):
4747
node.safe_psql('postgres', 'vacuum t_heap')
4848
node.safe_psql('postgres', 'checkpoint')
4949

50+
self.backup_node(
51+
backup_dir, 'node', node, options=['-j10', '--stream'])
52+
5053
for i in idx_ptrack:
5154
# get size of heap and indexes. size calculated in pages
5255
idx_ptrack[i]['old_size'] = self.get_fork_size(node, i)
@@ -56,9 +59,6 @@ def test_ptrack_vacuum_full(self):
5659
idx_ptrack[i]['old_pages'] = self.get_md5_per_page_for_fork(
5760
idx_ptrack[i]['path'], idx_ptrack[i]['old_size'])
5861

59-
self.backup_node(
60-
backup_dir, 'node', node, options=['-j10', '--stream'])
61-
6262
node.safe_psql('postgres', 'delete from t_heap where id%2 = 1')
6363
node.safe_psql('postgres', 'vacuum full t_heap')
6464
node.safe_psql('postgres', 'checkpoint')
@@ -124,7 +124,7 @@ def test_ptrack_vacuum_full_replica(self):
124124
"postgres",
125125
"create sequence t_seq; create table t_heap as select i as id, "
126126
"md5(i::text) as text, md5(repeat(i::text,10))::tsvector as "
127-
"tsvector from generate_series(0,2560) i")
127+
"tsvector from generate_series(0,256000) i")
128128
for i in idx_ptrack:
129129
if idx_ptrack[i]['type'] != 'heap' and idx_ptrack[i]['type'] != 'seq':
130130
master.safe_psql(
@@ -146,15 +146,6 @@ def test_ptrack_vacuum_full_replica(self):
146146
lsn))
147147
replica.safe_psql('postgres', 'checkpoint')
148148

149-
for i in idx_ptrack:
150-
# get size of heap and indexes. size calculated in pages
151-
idx_ptrack[i]['old_size'] = self.get_fork_size(replica, i)
152-
# get path to heap and index files
153-
idx_ptrack[i]['path'] = self.get_fork_path(replica, i)
154-
# calculate md5sums of pages
155-
idx_ptrack[i]['old_pages'] = self.get_md5_per_page_for_fork(
156-
idx_ptrack[i]['path'], idx_ptrack[i]['old_size'])
157-
158149
# Take FULL backup to clean every ptrack
159150
self.backup_node(
160151
backup_dir, 'replica', replica,
@@ -166,9 +157,18 @@ def test_ptrack_vacuum_full_replica(self):
166157
]
167158
)
168159
# TODO: check that all ptrack are nullified
160+
for i in idx_ptrack:
161+
# get size of heap and indexes. size calculated in pages
162+
idx_ptrack[i]['old_size'] = self.get_fork_size(replica, i)
163+
# get path to heap and index files
164+
idx_ptrack[i]['path'] = self.get_fork_path(replica, i)
165+
# calculate md5sums of pages
166+
idx_ptrack[i]['old_pages'] = self.get_md5_per_page_for_fork(
167+
idx_ptrack[i]['path'], idx_ptrack[i]['old_size'])
169168

170169
master.safe_psql('postgres', 'delete from t_heap where id%2 = 1')
171170
master.safe_psql('postgres', 'vacuum full t_heap')
171+
master.safe_psql('postgres', 'checkpoint')
172172

173173
# Sync master and replica
174174
lsn = master.safe_psql(

tests/ptrack_vacuum_truncate.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ def test_ptrack_vacuum_truncate(self):
4646
node.safe_psql('postgres', 'vacuum t_heap')
4747
node.safe_psql('postgres', 'checkpoint')
4848

49+
self.backup_node(
50+
backup_dir, 'node', node, options=['-j10', '--stream'])
51+
4952
for i in idx_ptrack:
5053
# get size of heap and indexes. size calculated in pages
5154
idx_ptrack[i]['old_size'] = self.get_fork_size(node, i)
@@ -55,9 +58,6 @@ def test_ptrack_vacuum_truncate(self):
5558
idx_ptrack[i]['old_pages'] = self.get_md5_per_page_for_fork(
5659
idx_ptrack[i]['path'], idx_ptrack[i]['old_size'])
5760

58-
self.backup_node(
59-
backup_dir, 'node', node, options=['-j10', '--stream'])
60-
6161
node.safe_psql('postgres', 'delete from t_heap where id > 128;')
6262
node.safe_psql('postgres', 'vacuum t_heap')
6363
node.safe_psql('postgres', 'checkpoint')
@@ -138,15 +138,6 @@ def test_ptrack_vacuum_truncate_replica(self):
138138
master.safe_psql('postgres', 'vacuum t_heap')
139139
master.safe_psql('postgres', 'checkpoint')
140140

141-
for i in idx_ptrack:
142-
# get size of heap and indexes. size calculated in pages
143-
idx_ptrack[i]['old_size'] = self.get_fork_size(replica, i)
144-
# get path to heap and index files
145-
idx_ptrack[i]['path'] = self.get_fork_path(replica, i)
146-
# calculate md5sums of pages
147-
idx_ptrack[i]['old_pages'] = self.get_md5_per_page_for_fork(
148-
idx_ptrack[i]['path'], idx_ptrack[i]['old_size'])
149-
150141
# Take PTRACK backup to clean every ptrack
151142
self.backup_node(
152143
backup_dir, 'replica', replica,
@@ -158,6 +149,15 @@ def test_ptrack_vacuum_truncate_replica(self):
158149
]
159150
)
160151

152+
for i in idx_ptrack:
153+
# get size of heap and indexes. size calculated in pages
154+
idx_ptrack[i]['old_size'] = self.get_fork_size(replica, i)
155+
# get path to heap and index files
156+
idx_ptrack[i]['path'] = self.get_fork_path(replica, i)
157+
# calculate md5sums of pages
158+
idx_ptrack[i]['old_pages'] = self.get_md5_per_page_for_fork(
159+
idx_ptrack[i]['path'], idx_ptrack[i]['old_size'])
160+
161161
master.safe_psql('postgres', 'delete from t_heap where id > 128;')
162162
master.safe_psql('postgres', 'vacuum t_heap')
163163
master.safe_psql('postgres', 'checkpoint')

0 commit comments

Comments
 (0)