Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit0b549f3

Browse files
committed
tests: added checkdb.CheckdbTest.test_checkdb_block_validation
1 parent820a0a6 commit0b549f3

File tree

1 file changed

+55
-8
lines changed

1 file changed

+55
-8
lines changed

‎tests/checkdb.py

Lines changed: 55 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,17 @@
1414

1515
classCheckdbTest(ProbackupTest,unittest.TestCase):
1616

17-
deftest_checkdb_index_loss(self):
17+
@unittest.skip("skip")
18+
defcheckdb_index_loss(self):
1819
"""make node, make full and ptrack stream backups,"
1920
" restore them and check data correctness"""
2021
fname=self.id().split('.')[3]
2122
backup_dir=os.path.join(self.tmp_path,module_name,fname,'backup')
2223
node=self.make_simple_node(
2324
base_dir="{0}/{1}/node".format(module_name,fname),
2425
set_replication=True,
25-
initdb_params=['--data-checksums'],
26-
pg_options={
27-
'wal_level':'replica',
28-
'max_wal_senders':'2',
29-
}
30-
)
26+
initdb_params=['--data-checksums'])
27+
3128
self.init_pb(backup_dir)
3229
self.add_instance(backup_dir,'node',node)
3330
self.set_archiving(backup_dir,'node',node)
@@ -59,4 +56,54 @@ def test_checkdb_index_loss(self):
5956
gdb.continue_execution_until_exit()
6057

6158
# Clean after yourself
62-
self.del_test_dir(module_name,fname)
59+
self.del_test_dir(module_name,fname)
60+
61+
# @unittest.skip("skip")
62+
deftest_checkdb_block_validation(self):
63+
"""make node, corrupt some pages, check that checkdb failed"""
64+
fname=self.id().split('.')[3]
65+
node=self.make_simple_node(
66+
base_dir=os.path.join(module_name,fname,'node'),
67+
set_replication=True,
68+
initdb_params=['--data-checksums'])
69+
70+
backup_dir=os.path.join(self.tmp_path,module_name,fname,'backup')
71+
72+
self.init_pb(backup_dir)
73+
self.add_instance(backup_dir,'node',node)
74+
node.slow_start()
75+
76+
#self.backup_node(
77+
# backup_dir, 'node', node,
78+
# backup_type="full", options=["-j", "4", "--stream"])
79+
80+
node.safe_psql(
81+
"postgres",
82+
"create table t_heap as select 1 as id, md5(i::text) as text, "
83+
"md5(repeat(i::text,10))::tsvector as tsvector "
84+
"from generate_series(0,1000) i")
85+
node.safe_psql(
86+
"postgres",
87+
"CHECKPOINT;")
88+
89+
heap_path=node.safe_psql(
90+
"postgres",
91+
"select pg_relation_filepath('t_heap')").rstrip()
92+
93+
withopen(os.path.join(node.data_dir,heap_path),"rb+",0)asf:
94+
f.seek(9000)
95+
f.write(b"bla")
96+
f.flush()
97+
f.close
98+
99+
withopen(os.path.join(node.data_dir,heap_path),"rb+",0)asf:
100+
f.seek(42000)
101+
f.write(b"bla")
102+
f.flush()
103+
f.close
104+
105+
print(self.checkdb_node('node',backup_dir,
106+
data_dir=node.data_dir,options=['--block-validation']))
107+
108+
# Clean after yourself
109+
self.del_test_dir(module_name,fname)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp