Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit e3685e8

Browse files
committed
tests: minor fixes
1 parent def0ac2 commit e3685e8

File tree

6 files changed

+100
-31
lines changed

6 files changed

+100
-31
lines changed

tests/archive.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ def test_pgpro434_2(self):
246246

247247
# @unittest.skip("skip")
248248
def test_pgpro434_3(self):
249-
"""Check pg_stop_backup_timeout"""
249+
"""Check pg_stop_backup_timeout, needed backup_timeout"""
250250
fname = self.id().split('.')[3]
251251
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
252252
node = self.make_simple_node(
@@ -466,6 +466,7 @@ def test_replica_archive(self):
466466
# Settings for Replica
467467
self.restore_node(backup_dir, 'master', replica)
468468
self.set_replica(master, replica, synchronous=True)
469+
self.add_instance(backup_dir, 'replica', replica)
469470
self.set_archiving(backup_dir, 'replica', replica, replica=True)
470471
replica.start()
471472

@@ -481,7 +482,9 @@ def test_replica_archive(self):
481482
"from generate_series(256,512) i")
482483
before = master.safe_psql("postgres", "SELECT * FROM t_heap")
483484
# ADD INSTANCE 'REPLICA'
484-
self.add_instance(backup_dir, 'replica', replica)
485+
486+
sleep(1)
487+
485488
backup_id = self.backup_node(
486489
backup_dir, 'replica', replica,
487490
options=[

tests/backup_test.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,9 @@ def test_tablespace_in_pgdata_pgpro_1376(self):
439439

440440
self.create_tblspace_in_node(
441441
node, 'tblspace1',
442-
tblspc_path=(os.path.join(node.data_dir, 'pg_clog', '100500'))
442+
tblspc_path=(
443+
os.path.join(
444+
node.data_dir, 'somedirectory', '100500'))
443445
)
444446

445447
self.create_tblspace_in_node(

tests/exclude.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def test_exclude_unlogged_tables(self):
9494
conn = node.connect()
9595
with node.connect("postgres") as conn:
9696

97-
conn.execute("create unlogged table test as select generate_series(0,50050000)::text")
97+
conn.execute("create unlogged table test as select generate_series(0,5005000)::text")
9898
conn.commit()
9999

100100
conn.execute("create index test_idx on test (generate_series)")

tests/helpers/ptrack_helpers.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,6 @@ def make_simple_node(
207207
node.should_rm_dirs = True
208208
node.init(
209209
initdb_params=initdb_params, allow_streaming=set_replication)
210-
print(node.data_dir)
211210

212211
# Sane default parameters, not a shit with fsync = off from testgres
213212
node.append_conf("postgresql.auto.conf", "max_connections = 100")

tests/ptrack.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ def test_ptrack_uncommited_xact(self):
171171

172172
# Physical comparison
173173
if self.paranoia:
174-
pgdata_restored = self.pgdata_content(node_restored.data_dir, ignore_ptrack=False)
174+
pgdata_restored = self.pgdata_content(
175+
node_restored.data_dir, ignore_ptrack=False)
175176
self.compare_pgdata(pgdata, pgdata_restored)
176177

177178
node_restored.append_conf(
@@ -1746,7 +1747,9 @@ def test_atexit_fail(self):
17461747
try:
17471748
self.backup_node(
17481749
backup_dir, 'node', node, backup_type='ptrack',
1749-
options=["--stream", "-j 30"]
1750+
options=[
1751+
"--stream", "-j 30",
1752+
"--log-level-file=verbose"]
17501753
)
17511754
# we should die here because exception is what we expect to happen
17521755
self.assertEqual(

tests/ptrack_clean.py

Lines changed: 86 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22
import unittest
33
from .helpers.ptrack_helpers import ProbackupTest, idx_ptrack
4+
import time
45

56

67
module_name = 'ptrack_clean'
@@ -32,14 +33,25 @@ def test_ptrack_clean(self):
3233
# Create table and indexes
3334
node.safe_psql(
3435
"postgres",
35-
"create sequence t_seq; create table t_heap tablespace somedata as select i as id, nextval('t_seq') as t_seq, md5(i::text) as text, md5(repeat(i::text,10))::tsvector as tsvector from generate_series(0,256) i")
36+
"create sequence t_seq; create table t_heap tablespace somedata "
37+
"as select i as id, nextval('t_seq') as t_seq, "
38+
"md5(i::text) as text, "
39+
"md5(repeat(i::text,10))::tsvector as tsvector "
40+
"from generate_series(0,256) i")
3641
for i in idx_ptrack:
3742
if idx_ptrack[i]['type'] != 'heap' and idx_ptrack[i]['type'] != 'seq':
38-
node.safe_psql("postgres", "create index {0} on {1} using {2}({3}) tablespace somedata".format(
39-
i, idx_ptrack[i]['relation'], idx_ptrack[i]['type'], idx_ptrack[i]['column']))
43+
node.safe_psql(
44+
"postgres",
45+
"create index {0} on {1} using {2}({3}) "
46+
"tablespace somedata".format(
47+
i, idx_ptrack[i]['relation'],
48+
idx_ptrack[i]['type'],
49+
idx_ptrack[i]['column']))
4050

4151
# Take FULL backup to clean every ptrack
42-
self.backup_node(backup_dir, 'node', node, options=['-j10', '--stream'])
52+
self.backup_node(
53+
backup_dir, 'node', node,
54+
options=['-j10', '--stream'])
4355
node.safe_psql('postgres', 'checkpoint')
4456

4557
for i in idx_ptrack:
@@ -53,13 +65,17 @@ def test_ptrack_clean(self):
5365
self.check_ptrack_clean(idx_ptrack[i], idx_ptrack[i]['size'])
5466

5567
# Update everything and vacuum it
56-
node.safe_psql('postgres', "update t_heap set t_seq = nextval('t_seq'), text = md5(text), tsvector = md5(repeat(tsvector::text, 10))::tsvector;")
68+
node.safe_psql(
69+
'postgres',
70+
"update t_heap set t_seq = nextval('t_seq'), "
71+
"text = md5(text), "
72+
"tsvector = md5(repeat(tsvector::text, 10))::tsvector;")
5773
node.safe_psql('postgres', 'vacuum t_heap')
5874

5975
# Take PTRACK backup to clean every ptrack
6076
backup_id = self.backup_node(
6177
backup_dir, 'node', node, backup_type='ptrack',
62-
options=['-j100', '--log-level-file=verbose'])
78+
options=['-j10', '--log-level-file=verbose'])
6379
node.safe_psql('postgres', 'checkpoint')
6480

6581
for i in idx_ptrack:
@@ -74,11 +90,17 @@ def test_ptrack_clean(self):
7490
self.check_ptrack_clean(idx_ptrack[i], idx_ptrack[i]['size'])
7591

7692
# Update everything and vacuum it
77-
node.safe_psql('postgres', "update t_heap set t_seq = nextval('t_seq'), text = md5(text), tsvector = md5(repeat(tsvector::text, 10))::tsvector;")
93+
node.safe_psql(
94+
'postgres',
95+
"update t_heap set t_seq = nextval('t_seq'), "
96+
"text = md5(text), "
97+
"tsvector = md5(repeat(tsvector::text, 10))::tsvector;")
7898
node.safe_psql('postgres', 'vacuum t_heap')
7999

80100
# Take PAGE backup to clean every ptrack
81-
self.backup_node(backup_dir, 'node', node, backup_type='page', options=['-j10'])
101+
self.backup_node(
102+
backup_dir, 'node', node,
103+
backup_type='page', options=['-j10'])
82104
node.safe_psql('postgres', 'checkpoint')
83105

84106
for i in idx_ptrack:
@@ -100,39 +122,58 @@ def test_ptrack_clean(self):
100122
def test_ptrack_clean_replica(self):
101123
"""Take backups of every available types from master and check that PTRACK on replica is clean"""
102124
fname = self.id().split('.')[3]
103-
master = self.make_simple_node(base_dir="{0}/{1}/master".format(module_name, fname),
125+
master = self.make_simple_node(
126+
base_dir="{0}/{1}/master".format(module_name, fname),
104127
set_replication=True,
105128
initdb_params=['--data-checksums'],
106-
pg_options={'ptrack_enable': 'on', 'wal_level': 'replica', 'max_wal_senders': '2'})
129+
pg_options={
130+
'ptrack_enable': 'on',
131+
'wal_level': 'replica',
132+
'max_wal_senders': '2'})
107133
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
108134
self.init_pb(backup_dir)
109135
self.add_instance(backup_dir, 'master', master)
110136
master.start()
111137

112138
self.backup_node(backup_dir, 'master', master, options=['--stream'])
113139

114-
replica = self.make_simple_node(base_dir="{0}/{1}/replica".format(module_name, fname))
140+
replica = self.make_simple_node(
141+
base_dir="{0}/{1}/replica".format(module_name, fname))
115142
replica.cleanup()
116143

117144
self.restore_node(backup_dir, 'master', replica)
118145

119146
self.add_instance(backup_dir, 'replica', replica)
120-
self.set_replica(master, replica)
147+
self.set_replica(master, replica, synchronous=True)
121148
self.set_archiving(backup_dir, 'replica', replica, replica=True)
122149
replica.start()
123150

124151
# Create table and indexes
125152
master.safe_psql(
126153
"postgres",
127-
"create sequence t_seq; create table t_heap as select i as id, nextval('t_seq') as t_seq, md5(i::text) as text, md5(repeat(i::text,10))::tsvector as tsvector from generate_series(0,256) i")
154+
"create sequence t_seq; create table t_heap as select i as id, "
155+
"nextval('t_seq') as t_seq, md5(i::text) as text, "
156+
"md5(repeat(i::text,10))::tsvector as tsvector "
157+
"from generate_series(0,256) i")
128158
for i in idx_ptrack:
129159
if idx_ptrack[i]['type'] != 'heap' and idx_ptrack[i]['type'] != 'seq':
130-
master.safe_psql("postgres", "create index {0} on {1} using {2}({3})".format(
131-
i, idx_ptrack[i]['relation'], idx_ptrack[i]['type'], idx_ptrack[i]['column']))
160+
master.safe_psql(
161+
"postgres",
162+
"create index {0} on {1} using {2}({3})".format(
163+
i, idx_ptrack[i]['relation'],
164+
idx_ptrack[i]['type'],
165+
idx_ptrack[i]['column']))
132166

133167
# Take FULL backup to clean every ptrack
134-
self.backup_node(backup_dir, 'replica', replica, options=['-j10', '--stream',
135-
'--master-host=localhost', '--master-db=postgres', '--master-port={0}'.format(master.port)])
168+
self.backup_node(
169+
backup_dir,
170+
'replica',
171+
replica,
172+
options=[
173+
'-j10', '--stream',
174+
'--master-host=localhost',
175+
'--master-db=postgres',
176+
'--master-port={0}'.format(master.port)])
136177
master.safe_psql('postgres', 'checkpoint')
137178

138179
for i in idx_ptrack:
@@ -146,12 +187,24 @@ def test_ptrack_clean_replica(self):
146187
self.check_ptrack_clean(idx_ptrack[i], idx_ptrack[i]['size'])
147188

148189
# Update everything and vacuum it
149-
master.safe_psql('postgres', "update t_heap set t_seq = nextval('t_seq'), text = md5(text), tsvector = md5(repeat(tsvector::text, 10))::tsvector;")
190+
master.safe_psql(
191+
'postgres',
192+
"update t_heap set t_seq = nextval('t_seq'), "
193+
"text = md5(text), "
194+
"tsvector = md5(repeat(tsvector::text, 10))::tsvector;")
150195
master.safe_psql('postgres', 'vacuum t_heap')
151196

152197
# Take PTRACK backup to clean every ptrack
153-
backup_id = self.backup_node(backup_dir, 'replica', replica, backup_type='ptrack', options=['-j10', '--stream',
154-
'--master-host=localhost', '--master-db=postgres', '--master-port={0}'.format(master.port)])
198+
backup_id = self.backup_node(
199+
backup_dir,
200+
'replica',
201+
replica,
202+
backup_type='ptrack',
203+
options=[
204+
'-j10', '--stream',
205+
'--master-host=localhost',
206+
'--master-db=postgres',
207+
'--master-port={0}'.format(master.port)])
155208
master.safe_psql('postgres', 'checkpoint')
156209

157210
for i in idx_ptrack:
@@ -166,16 +219,25 @@ def test_ptrack_clean_replica(self):
166219
self.check_ptrack_clean(idx_ptrack[i], idx_ptrack[i]['size'])
167220

168221
# Update everything and vacuum it
169-
master.safe_psql('postgres', "update t_heap set t_seq = nextval('t_seq'), text = md5(text), tsvector = md5(repeat(tsvector::text, 10))::tsvector;")
222+
master.safe_psql(
223+
'postgres',
224+
"update t_heap set t_seq = nextval('t_seq'), text = md5(text), "
225+
"tsvector = md5(repeat(tsvector::text, 10))::tsvector;")
170226
master.safe_psql('postgres', 'vacuum t_heap')
171227
master.safe_psql('postgres', 'checkpoint')
172228

173229
# Take PAGE backup to clean every ptrack
174-
self.backup_node(backup_dir, 'replica', replica, backup_type='page', options=['-j10',
175-
'--master-host=localhost', '--master-db=postgres', '--master-port={0}'.format(master.port)])
230+
self.backup_node(
231+
backup_dir,
232+
'replica',
233+
replica,
234+
backup_type='page',
235+
options=[
236+
'-j10', '--master-host=localhost',
237+
'--master-db=postgres',
238+
'--master-port={0}'.format(master.port)])
176239
master.safe_psql('postgres', 'checkpoint')
177240

178-
179241
for i in idx_ptrack:
180242
# get new size of heap and indexes and calculate it in pages
181243
idx_ptrack[i]['size'] = self.get_fork_size(replica, i)

0 commit comments

Comments
 (0)