Skip to content

Commit b122966

Browse files
committed
PGPRO-427: additional test added
1 parent e2b2dee commit b122966

File tree

1 file changed

+61
-4
lines changed

1 file changed

+61
-4
lines changed

tests/page.py

Lines changed: 61 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from datetime import datetime, timedelta
55
import subprocess
66
import time
7-
import ipdb
87

98
module_name = 'page'
109

@@ -558,14 +557,72 @@ def test_parallel_pagemap(self):
558557
# Fill instance with data and make several WAL segments ...
559558
node.safe_psql("postgres", "create table test (id int)")
560559
for x in range(0, 8):
561-
node.safe_psql("postgres",
560+
node.safe_psql(
561+
"postgres",
562562
"insert into test select i from generate_series(1,100) s(i)")
563563
self.switch_wal_segment(node)
564564
count1 = node.safe_psql("postgres", "select count(*) from test")
565565

566566
# ... and do page backup with parallel pagemap
567-
self.backup_node(backup_dir, 'node', node, backup_type="page",
568-
options=["-j", "4"])
567+
self.backup_node(
568+
backup_dir, 'node', node, backup_type="page", options=["-j", "4"])
569+
show_backup = self.show_pb(backup_dir, 'node')[1]
570+
571+
self.assertEqual(show_backup['status'], "OK")
572+
self.assertEqual(show_backup['backup-mode'], "PAGE")
573+
574+
# Drop node and restore it
575+
node.cleanup()
576+
self.restore_node(backup_dir, 'node', node)
577+
node.start()
578+
579+
# Check restored node
580+
count2 = node.safe_psql("postgres", "select count(*) from test")
581+
582+
self.assertEqual(count1, count2)
583+
584+
# Clean after yourself
585+
node.cleanup()
586+
self.del_test_dir(module_name, fname)
587+
588+
def test_parallel_pagemap_1(self):
589+
"""
590+
Test for parallel WAL segments reading, during which pagemap is built
591+
"""
592+
fname = self.id().split('.')[3]
593+
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
594+
595+
# Initialize instance and backup directory
596+
node = self.make_simple_node(
597+
base_dir="{0}/{1}/node".format(module_name, fname),
598+
initdb_params=['--data-checksums'],
599+
pg_options={}
600+
)
601+
602+
self.init_pb(backup_dir)
603+
self.add_instance(backup_dir, 'node', node)
604+
self.set_archiving(backup_dir, 'node', node)
605+
node.start()
606+
607+
# Do full backup
608+
self.backup_node(backup_dir, 'node', node)
609+
show_backup = self.show_pb(backup_dir, 'node')[0]
610+
611+
self.assertEqual(show_backup['status'], "OK")
612+
self.assertEqual(show_backup['backup-mode'], "FULL")
613+
614+
# Fill instance with data and make several WAL segments ...
615+
node.pgbench_init(scale=10)
616+
617+
# do page backup in single thread
618+
page_id = self.backup_node(
619+
backup_dir, 'node', node, backup_type="page")
620+
621+
self.delete_pb(backup_dir, 'node', page_id)
622+
623+
# ... and do page backup with parallel pagemap
624+
self.backup_node(
625+
backup_dir, 'node', node, backup_type="page", options=["-j", "4"])
569626
show_backup = self.show_pb(backup_dir, 'node')[1]
570627

571628
self.assertEqual(show_backup['status'], "OK")

0 commit comments

Comments
 (0)