8000 tests: more usages for table_checksum · postgrespro/pg_probackup@8d8a92c · GitHub
[go: up one dir, main page]

Skip to content

Commit 8d8a92c

Browse files
committed
tests: more usages for table_checksum
and reduce batch twice for sanity
1 parent 9bcefb2 commit 8d8a92c

File tree

6 files changed

+21
-33
lines changed

6 files changed

+21
-33
lines changed

tests/archive_test.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2215,9 +2215,7 @@ def test_multi_timeline_recovery_prefetching(self):
22152215
node.slow_start()
22162216

22172217
node.pgbench_init(scale=20)
2218-
result = node.safe_psql(
2219-
'postgres',
2220-
'select * from pgbench_accounts')
2218+
result = node.table_checksum("pgbench_accounts", "aid")
22212219
node.stop()
22222220
node.cleanup()
22232221

@@ -2242,9 +2240,7 @@ def test_multi_timeline_recovery_prefetching(self):
22422240

22432241
node.slow_start()
22442242

2245-
result_new = node.safe_psql(
2246-
'postgres',
2247-
'select * from pgbench_accounts')
2243+
result_new = node.table_checksum("pgbench_accounts", "aid")
22482244

22492245
self.assertEqual(result, result_new)
22502246

tests/cfs_backup_test.py

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ def test_multiple_segments(self):
761761
't_heap', tblspace_name)
762762
)
763763

764-
full_result = self.node.safe_psql("postgres", "SELECT * FROM t_heap")
764+
full_result = self.node.table_checksum("t_heap", "id")
765765

766766
try:
767767
backup_id_full = self.backup_node(
@@ -783,7 +783,7 @@ def test_multiple_segments(self):
783783
't_heap')
784784
)
785785

786-
page_result = self.node.safe_psql("postgres", "SELECT * FROM t_heap")
786+
page_result = self.node.table_checksum("t_heap", "id")
787787

788788
try:
789789
backup_id_page = self.backup_node(
@@ -824,7 +824,7 @@ def test_multiple_segments(self):
824824
self.node.slow_start()
825825
self.assertEqual(
826826
full_result,
827-
self.node.safe_psql("postgres", "SELECT * FROM t_heap"),
827+
self.node.table_checksum("t_heap", "id"),
828828
'Lost data after restore')
829829

830830
# CHECK PAGE BACKUP
@@ -843,7 +843,7 @@ def test_multiple_segments(self):
843843
self.node.slow_start()
844844
self.assertEqual(
845845
page_result,
846-
self.node.safe_psql("postgres", "SELECT * FROM t_heap"),
846+
self.node.table_checksum("t_heap", "id"),
847847
'Lost data after restore')
848848

849849
# @unittest.expectedFailure
@@ -877,10 +877,8 @@ def test_multiple_segments_in_multiple_tablespaces(self):
877877
"FROM generate_series(0,1005000) i".format(
878878
't_heap_2', tblspace_name_2))
879879

880-
full_result_1 = self.node.safe_psql(
881-
"postgres", "SELECT * FROM t_heap_1")
882-
full_result_2 = self.node.safe_psql(
883-
"postgres", "SELECT * FROM t_heap_2")
880+
full_result_1 = self.node.table_checksum("t_heap_1", "id")
881+
full_result_2 = self.node.table_checksum("t_heap_2", "id")
884882

885883
try:
886884
backup_id_full = self.backup_node(
@@ -911,10 +909,8 @@ def test_multiple_segments_in_multiple_tablespaces(self):
911909
't_heap_2')
912910
)
913911

914-
page_result_1 = self.node.safe_psql(
915-
"postgres", "SELECT * FROM t_heap_1")
916-
page_result_2 = self.node.safe_psql(
917-
"postgres", "SELECT * FROM t_heap_2")
912+
page_result_1 = self.node.table_checksum("t_heap_1", "id")
913+
page_result_2 = self.node.table_checksum("t_heap_2", "id")
918914

919915
try:
920916
backup_id_page = self.backup_node(
@@ -955,11 +951,11 @@ def test_multiple_segments_in_multiple_tablespaces(self):
955951

956952
self.assertEqual(
957953
full_result_1,
958-
self.node.safe_psql("postgres", "SELECT * FROM t_heap_1"),
954+
self.node.table_checksum("t_heap_1", "id"),
959955
'Lost data after restore')
960956
self.assertEqual(
961957
full_result_2,
962-
self.node.safe_psql("postgres", "SELECT * FROM t_heap_2"),
958+
self.node.table_checksum("t_heap_2", "id"),
963959
'Lost data after restore')
964960

965961
# CHECK PAGE BACKUP
@@ -976,11 +972,11 @@ def test_multiple_segments_in_multiple_tablespaces(self):
976972

977973
self.assertEqual(
978974
page_result_1,
979-
self.node.safe_psql("postgres", "SELECT * FROM t_heap_1"),
975+
self.node.table_checksum("t_heap_1", "id"),
980976
'Lost data after restore')
981977
self.assertEqual(
982978
page_result_2,
983-
self.node.safe_psql("postgres", "SELECT * FROM t_heap_2"),
979+
self.node.table_checksum("t_heap_2", "id"),
984980
'Lost data after restore')
985981

986982
# @unittest.expectedFailure

tests/helpers/ptrack_helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ def table_checksum(self, table, sort, dbname="postgres"):
215215
""")
216216

217217
while True:
218-
rows = con.execute(f"FETCH FORWARD 10000 FROM {curname}")
218+
rows = con.execute(f"FETCH FORWARD 5000 FROM {curname}")
219219
if not rows:
220220
break
221221
for row in rows:

tests/page_test.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,8 +1191,7 @@ def test_multi_timeline_page(self):
11911191

11921192
pgdata = self.pgdata_content(node.data_dir)
11931193

1194-
result = node.safe_psql(
1195-
"postgres", "select * from pgbench_accounts")
1194+
result = node.table_checksum("pgbench_accounts", "aid")
11961195

11971196
node_restored = self.make_simple_node(
11981197
base_dir=os.path.join(self.module_name, self.fname, 'node_restored'))
@@ -1204,8 +1203,7 @@ def test_multi_timeline_page(self):
12041203
self.set_auto_conf(node_restored, {'port': node_restored.port})
12051204
node_restored.slow_start()
12061205

1207-
result_new = node_restored.safe_psql(
1208-
"postgres", "select * from pgbench_accounts")
1206+
result_new = node_restored.table_checksum("pgbench_accounts", "aid")
12091207

12101208
self.assertEqual(result, result_new)
12111209

tests/ptrack_test.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ def test_ptrack_eat_my_data(self):
375375

376376
self.switch_wal_segment(node)
377377

378-
result = node.safe_psql("postgres", "SELECT * FROM pgbench_accounts")
378+
result = node.table_checksum("pgbench_accounts", "aid")
379379

380380
node_restored.cleanup()
381381
self.restore_node(backup_dir, 'node', node_restored)
@@ -396,9 +396,7 @@ def test_ptrack_eat_my_data(self):
396396
# Logical comparison
397397
self.assertEqual(
398398
result,
399-
node_restored.safe_psql(
400-
'postgres',
401-
'SELECT * FROM pgbench_accounts'),
399+
node.table_checksum("pgbench_accounts", "aid"),
402400
'Data loss')
403401

404402
# @unittest.skip("skip")

tests/replica_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ def test_replica_archive_page_backup(self):
326326

327327
self.switch_wal_segment(master)
328328

329-
before = master.safe_psql("postgres", "SELECT * FROM pgbench_accounts")
329+
before = master.table_checksum("pgbench_accounts", "aid")
330330

331331
self.validate_pb(backup_dir, 'replica')
332332
self.assertEqual(
@@ -342,7 +342,7 @@ def test_replica_archive_page_backup(self):
342342
node.slow_start()
343343

344344
# CHECK DATA CORRECTNESS
345-
after = node.safe_psql("postgres", "SELECT * FROM pgbench_accounts")
345+
after = master.table_checksum("pgbench_accounts", "aid")
346346
self.assertEqual(
347347
before, after, 'Restored data is not equal to original')
348348

0 commit comments

Comments
 (0)
0