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

Commitf87fd1b

Browse files
committed
tests: added replica.ReplicaTest.test_replica_promote
1 parent61b733b commitf87fd1b

File tree

1 file changed

+88
-0
lines changed

1 file changed

+88
-0
lines changed

‎tests/replica.py‎

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,3 +437,91 @@ def test_take_backup_from_delayed_replica(self):
437437

438438
# Clean after yourself
439439
self.del_test_dir(module_name,fname)
440+
441+
# @unittest.skip("skip")
442+
deftest_replica_promote(self):
443+
"""
444+
start backup from replica, during backup promote replica
445+
check that backup is failed
446+
"""
447+
fname=self.id().split('.')[3]
448+
backup_dir=os.path.join(self.tmp_path,module_name,fname,'backup')
449+
master=self.make_simple_node(
450+
base_dir=os.path.join(module_name,fname,'master'),
451+
set_replication=True,
452+
initdb_params=['--data-checksums'],
453+
pg_options={
454+
'archive_timeout':'10s',
455+
'checkpoint_timeout':'30s',
456+
'max_wal_size':'32MB'})
457+
458+
self.init_pb(backup_dir)
459+
self.add_instance(backup_dir,'master',master)
460+
self.set_archiving(backup_dir,'master',master)
461+
master.slow_start()
462+
463+
replica=self.make_simple_node(
464+
base_dir=os.path.join(module_name,fname,'replica'))
465+
replica.cleanup()
466+
467+
self.backup_node(backup_dir,'master',master)
468+
469+
master.psql(
470+
"postgres",
471+
"create table t_heap as select i as id, md5(i::text) as text, "
472+
"md5(repeat(i::text,10))::tsvector as tsvector "
473+
"from generate_series(0,165000) i")
474+
475+
self.restore_node(
476+
backup_dir,'master',replica,options=['-R'])
477+
478+
# Settings for Replica
479+
self.add_instance(backup_dir,'replica',replica)
480+
self.set_archiving(backup_dir,'replica',replica,replica=True)
481+
self.set_replica(
482+
master,replica,
483+
replica_name='replica',synchronous=True)
484+
485+
replica.slow_start(replica=True)
486+
487+
master.psql(
488+
"postgres",
489+
"create table t_heap_1 as select i as id, md5(i::text) as text, "
490+
"md5(repeat(i::text,10))::tsvector as tsvector "
491+
"from generate_series(0,165000) i")
492+
493+
self.wait_until_replica_catch_with_master(master,replica)
494+
495+
# start backup from replica
496+
gdb=self.backup_node(
497+
backup_dir,'replica',replica,gdb=True,
498+
options=['--log-level-file=verbose'])
499+
500+
gdb.set_breakpoint('backup_data_file')
501+
gdb.run_until_break()
502+
gdb.continue_execution_until_break(20)
503+
504+
replica.promote()
505+
506+
gdb.remove_all_breakpoints()
507+
gdb.continue_execution_until_exit()
508+
509+
backup_id=self.show_pb(
510+
backup_dir,'replica')[0]["id"]
511+
512+
# read log file content
513+
withopen(os.path.join(backup_dir,'log','pg_probackup.log'))asf:
514+
log_content=f.read()
515+
f.close
516+
517+
self.assertIn(
518+
'ERROR: the standby was promoted during online backup',
519+
log_content)
520+
521+
self.assertIn(
522+
'WARNING: Backup {0} is running, '
523+
'setting its status to ERROR'.format(backup_id),
524+
log_content)
525+
526+
# Clean after yourself
527+
self.del_test_dir(module_name,fname)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp