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

Commitf6ec367

Browse files
committed
tests: fixes for ".partial" tests
1 parente163c45 commitf6ec367

File tree

1 file changed

+15
-59
lines changed

1 file changed

+15
-59
lines changed

‎tests/archive.py‎

Lines changed: 15 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -411,61 +411,9 @@ def test_arhive_push_file_exists_overwrite(self):
411411
# Clean after yourself
412412
self.del_test_dir(module_name,fname)
413413

414-
# @unittest.skip("skip")
415-
deftest_arhive_push_partial_file_exists(self):
416-
"""Archive-push if file exists"""
417-
fname=self.id().split('.')[3]
418-
backup_dir=os.path.join(self.tmp_path,module_name,fname,'backup')
419-
node=self.make_simple_node(
420-
base_dir=os.path.join(module_name,fname,'node'),
421-
set_replication=True,
422-
initdb_params=['--data-checksums'])
423-
424-
self.init_pb(backup_dir)
425-
self.add_instance(backup_dir,'node',node)
426-
self.set_archiving(backup_dir,'node',node)
427-
428-
node.slow_start()
429-
node.safe_psql(
430-
"postgres",
431-
"create table t_heap as select i as id, md5(i::text) as text, "
432-
"md5(repeat(i::text,10))::tsvector as tsvector "
433-
"from generate_series(0,100500) i")
434-
435-
filename=node.safe_psql(
436-
"postgres",
437-
"SELECT file_name "
438-
"FROM pg_walfile_name_offset(pg_current_wal_flush_lsn());").rstrip()
439-
440-
wals_dir=os.path.join(backup_dir,'wal','node')
441-
ifself.archive_compress:
442-
filename=filename+'.gz'+'.partial'
443-
file=os.path.join(wals_dir,filename)
444-
else:
445-
filename=filename+'.partial'
446-
file=os.path.join(wals_dir,filename)
447-
448-
withopen(file,'a')asf:
449-
f.write(b"blablablaadssaaaaaaaaaaaaaaa")
450-
f.flush()
451-
f.close()
452-
453-
self.switch_wal_segment(node)
454-
sleep(15)
455-
456-
log_file=os.path.join(node.logs_dir,'postgresql.log')
457-
withopen(log_file,'r')asf:
458-
log_content=f.read()
459-
self.assertIn(
460-
'Reusing stale destination temporary WAL file',
461-
log_content)
462-
463-
# Clean after yourself
464-
self.del_test_dir(module_name,fname)
465-
466414
# @unittest.skip("skip")
467415
deftest_archive_push_partial_file_exists(self):
468-
"""Archive-push if file exists"""
416+
"""Archive-push ifstale .partialfile exists"""
469417
fname=self.id().split('.')[3]
470418
backup_dir=os.path.join(self.tmp_path,module_name,fname,'backup')
471419
node=self.make_simple_node(
@@ -479,20 +427,23 @@ def test_archive_push_partial_file_exists(self):
479427

480428
node.slow_start()
481429

430+
# this backup is needed only for validation to xid
431+
self.backup_node(backup_dir,'node',node)
432+
482433
node.safe_psql(
483434
"postgres",
484-
"create table t1()")
485-
self.switch_wal_segment(node)
435+
"create table t1(a int)")
486436

487-
node.safe_psql(
437+
xid=node.safe_psql(
488438
"postgres",
489-
"create table t2()")
439+
"INSERT INTO t1 VALUES (1) RETURNING (xmin)").rstrip()
490440

491441
filename_orig=node.safe_psql(
492442
"postgres",
493443
"SELECT file_name "
494444
"FROM pg_walfile_name_offset(pg_current_wal_flush_lsn());").rstrip()
495445

446+
# form up path to next .partial WAL segment
496447
wals_dir=os.path.join(backup_dir,'wal','node')
497448
ifself.archive_compress:
498449
filename=filename_orig+'.gz'+'.partial'
@@ -502,7 +453,7 @@ def test_archive_push_partial_file_exists(self):
502453
file=os.path.join(wals_dir,filename)
503454

504455
withopen(file,'a')asf:
505-
f.write(b"blablablaadssaaaaaaaaaaaaaaa")
456+
f.write(b"blahblah")
506457
f.flush()
507458
f.close()
508459

@@ -517,6 +468,10 @@ def test_archive_push_partial_file_exists(self):
517468

518469
self.assertTrue(os.path.isfile(file))
519470

471+
self.validate_pb(
472+
backup_dir,'node',
473+
options=['--recovery-target-xid={0}'.format(xid)])
474+
520475
# log_file = os.path.join(node.logs_dir, 'postgresql.log')
521476
# with open(log_file, 'r') as f:
522477
# log_content = f.read()
@@ -529,7 +484,7 @@ def test_archive_push_partial_file_exists(self):
529484

530485
# @unittest.skip("skip")
531486
deftest_archive_push_partial_file_exists_not_stale(self):
532-
"""Archive-push if file exists"""
487+
"""Archive-push if.partialfile exists and it is not stale"""
533488
fname=self.id().split('.')[3]
534489
backup_dir=os.path.join(self.tmp_path,module_name,fname,'backup')
535490
node=self.make_simple_node(
@@ -557,6 +512,7 @@ def test_archive_push_partial_file_exists_not_stale(self):
557512
"SELECT file_name "
558513
"FROM pg_walfile_name_offset(pg_current_wal_flush_lsn());").rstrip()
559514

515+
# form up path to next .partial WAL segment
560516
wals_dir=os.path.join(backup_dir,'wal','node')
561517
ifself.archive_compress:
562518
filename=filename_orig+'.gz'+'.partial'

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp