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

Skip to content

Commit 420a527

Browse files
committed
tests: added checkdb.CheckdbTest.test_checkdb_sigint_handling
1 parent 3b9d6c4 commit 420a527

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

tests/checkdb.py

+55
Original file line numberDiff line numberDiff line change
@@ -442,3 +442,58 @@ def test_checkdb_block_validation_sanity(self):
442442

443443
# Clean after yourself
444444
self.del_test_dir(module_name, fname)
445+
446+
# @unittest.skip("skip")
447+
def test_checkdb_sigint_handling(self):
448+
""""""
449+
fname = self.id().split('.')[3]
450+
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
451+
node = self.make_simple_node(
452+
base_dir=os.path.join(module_name, fname, 'node'),
453+
set_replication=True,
454+
initdb_params=['--data-checksums'])
455+
456+
self.init_pb(backup_dir)
457+
self.add_instance(backup_dir, 'node', node)
458+
node.slow_start()
459+
460+
try:
461+
node.safe_psql(
462+
"postgres",
463+
"create extension amcheck")
464+
except QueryException as e:
465+
node.safe_psql(
466+
"postgres",
467+
"create extension amcheck_next")
468+
469+
# truncate log_file
470+
#with open(node.pg_log_file, 'w') as f:
471+
# f.truncate()
472+
# f.close()
473+
474+
# FULL backup
475+
gdb = self.checkdb_node(
476+
backup_dir, 'node', gdb=True,
477+
options=[
478+
'-d', 'postgres', '-j', '4',
479+
'--skip-block-validation',
480+
'--amcheck', '-p', str(node.port)])
481+
482+
gdb.set_breakpoint('amcheck_one_index')
483+
gdb.run_until_break()
484+
485+
gdb.continue_execution_until_break(4)
486+
gdb.remove_all_breakpoints()
487+
488+
gdb._execute('signal SIGINT')
489+
gdb.continue_execution_until_exit()
490+
491+
with open(node.pg_log_file, 'r') as f:
492+
output = f.read()
493+
494+
self.assertNotIn('could not receive data from client', output)
495+
self.assertNotIn('could not send data to client', output)
496+
self.assertNotIn('connection to client lost', output)
497+
498+
# Clean after yourself
499+
self.del_test_dir(module_name, fname)

0 commit comments

Comments
 (0)