5
5
import subprocess
6
6
from sys import exit
7
7
from time import sleep
8
+ from shutil import copyfile
8
9
9
10
10
11
module_name = 'archive'
@@ -39,8 +40,7 @@ def test_pgpro434_1(self):
39
40
40
41
result = node .safe_psql ("postgres" , "SELECT * FROM t_heap" )
41
42
self .backup_node (
42
- backup_dir , 'node' , node ,
43
- options = ["--log-level-file=verbose" ])
43
+ backup_dir , 'node' , node )
44
44
node .cleanup ()
45
45
46
46
self .restore_node (
@@ -53,8 +53,7 @@ def test_pgpro434_1(self):
53
53
54
54
# Make backup
55
55
self .backup_node (
56
- backup_dir , 'node' , node ,
57
- options = ["--log-level-file=verbose" ])
56
+ backup_dir , 'node' , node )
58
57
node .cleanup ()
59
58
60
59
# Restore Database
@@ -253,7 +252,6 @@ def test_pgpro434_3(self):
253
252
backup_dir , 'node' , node ,
254
253
options = [
255
254
"--archive-timeout=60" ,
256
- "--log-level-file=verbose" ,
257
255
"--stream" ]
258
256
)
259
257
# we should die here because exception is what we expect to happen
@@ -402,7 +400,7 @@ def test_arhive_push_file_exists_overwrite(self):
402
400
self .del_test_dir (module_name , fname )
403
401
404
402
# @unittest.expectedFailure
405
- # @unittest.skip("skip")
403
+ @unittest .skip ("skip" )
406
404
def test_replica_archive (self ):
407
405
"""
408
406
make node without archiving, take stream backup and
@@ -417,7 +415,7 @@ def test_replica_archive(self):
417
415
initdb_params = ['--data-checksums' ],
418
416
pg_options = {
419
417
'max_wal_senders' : '2' ,
420
- 'checkpoint_timeout ' : '30s ' ,
418
+ 'archive_timeout ' : '10s ' ,
421
419
'max_wal_size' : '1GB' }
422
420
)
423
421
self .init_pb (backup_dir )
@@ -433,7 +431,7 @@ def test_replica_archive(self):
433
431
"postgres" ,
434
432
"create table t_heap as select i as id, md5(i::text) as text, "
435
433
"md5(repeat(i::text,10))::tsvector as tsvector "
436
- "from generate_series(0,256 ) i" )
434
+ "from generate_series(0,2560 ) i" )
437
435
438
436
self .backup_node (backup_dir , 'master' , master , options = ['--stream' ])
439
437
before = master .safe_psql ("postgres" , "SELECT * FROM t_heap" )
@@ -459,17 +457,16 @@ def test_replica_archive(self):
459
457
"md5(repeat(i::text,10))::tsvector as tsvector "
460
458
"from generate_series(256,512) i" )
461
459
before = master .safe_psql ("postgres" , "SELECT * FROM t_heap" )
462
- # ADD INSTANCE 'REPLICA'
463
-
464
- sleep (1 )
465
460
466
461
backup_id = self .backup_node (
467
462
backup_dir , 'replica' , replica ,
468
463
options = [
469
464
'--archive-timeout=30' ,
470
465
'--master-host=localhost' ,
471
466
'--master-db=postgres' ,
472
- '--master-port={0}' .format (master .port )])
467
+ '--master-port={0}' .format (master .port ),
468
+ '--stream' ])
469
+
473
470
self .validate_pb (backup_dir , 'replica' )
474
471
self .assertEqual (
475
472
'OK' , self .show_pb (backup_dir , 'replica' , backup_id )['status' ])
@@ -493,16 +490,28 @@ def test_replica_archive(self):
493
490
"postgres" ,
494
491
"insert into t_heap as select i as id, md5(i::text) as text, "
495
492
"md5(repeat(i::text,10))::tsvector as tsvector "
496
- "from generate_series(512,768) i" )
493
+ "from generate_series(512,20680) i" )
494
+
497
495
before = master .safe_psql ("postgres" , "SELECT * FROM t_heap" )
496
+
497
+ master .safe_psql (
498
+ "postgres" ,
499
+ "CHECKPOINT" )
500
+
501
+ # copyfile(
502
+ # os.path.join(backup_dir, 'wal/master/000000010000000000000002'),
503
+ # os.path.join(backup_dir, 'wal/replica/000000010000000000000002'))
504
+
498
505
backup_id = self .backup_node (
499
506
backup_dir , 'replica' ,
500
507
replica , backup_type = 'page' ,
501
508
options = [
502
- '--archive-timeout=30' , '--log-level-file=verbose' ,
503
- '--master-host=localhost' , '--master-db=postgres' ,
504
- '--master-port={0}' .format (master .port )]
505
- )
509
+ '--archive-timeout=30' ,
510
+ '--master-db=postgres' ,
511
+ '--master-host=localhost' ,
512
+ '--master-port={0}' .format (master .port ),
513
+ '--stream' ])
514
+
506
515
self .validate_pb (backup_dir , 'replica' )
507
516
self .assertEqual (
508
517
'OK' , self .show_pb (backup_dir , 'replica' , backup_id )['status' ])
@@ -511,8 +520,10 @@ def test_replica_archive(self):
511
520
node .cleanup ()
512
521
self .restore_node (
513
522
backup_dir , 'replica' , data_dir = node .data_dir , backup_id = backup_id )
523
+
514
524
node .append_conf (
515
525
'postgresql.auto.conf' , 'port = {0}' .format (node .port ))
526
+
516
527
node .slow_start ()
517
528
# CHECK DATA CORRECTNESS
518
529
after = node .safe_psql ("postgres" , "SELECT * FROM t_heap" )
@@ -537,7 +548,7 @@ def test_master_and_replica_parallel_archiving(self):
537
548
set_replication = True ,
538
549
initdb_params = ['--data-checksums' ],
539
550
pg_options = {
540
- 'checkpoint_timeout ' : '30s ' }
551
+ 'archive_timeout ' : '10s ' }
541
552
)
542
553
replica = self .make_simple_node (
543
554
base_dir = "{0}/{1}/replica" .format (module_name , fname ))
@@ -568,7 +579,7 @@ def test_master_and_replica_parallel_archiving(self):
568
579
pgdata_replica = self .pgdata_content (replica .data_dir )
569
580
self .compare_pgdata (pgdata_master , pgdata_replica )
570
581
571
- self .set_replica (master , replica , synchronous = True )
582
+ self .set_replica (master , replica )
572
583
# ADD INSTANCE REPLICA
573
584
self .add_instance (backup_dir , 'replica' , replica )
574
585
# SET ARCHIVING FOR REPLICA
@@ -579,16 +590,26 @@ def test_master_and_replica_parallel_archiving(self):
579
590
after = replica .safe_psql ("postgres" , "SELECT * FROM t_heap" )
580
591
self .assertEqual (before , after )
581
592
593
+ master .psql (
594
+ "postgres" ,
595
+ "insert into t_heap select i as id, md5(i::text) as text, "
596
+ "md5(repeat(i::text,10))::tsvector as tsvector "
597
+ "from generate_series(0, 60000) i" )
598
+
582
599
# TAKE FULL ARCHIVE BACKUP FROM REPLICA
600
+ copyfile (
601
+ os .path .join (backup_dir , 'wal/master/000000010000000000000001' ),
602
+ os .path .join (backup_dir , 'wal/replica/000000010000000000000001' ))
603
+
583
604
backup_id = self .backup_node (
584
605
backup_dir , 'replica' , replica ,
585
606
options = [
586
- '--archive-timeout=20' ,
587
- '--log-level-file=verbose' ,
607
+ '--archive-timeout=30' ,
588
608
'--master-host=localhost' ,
589
609
'--master-db=postgres' ,
590
- '--master-port={0}' .format (master .port )]
591
- )
610
+ '--master-port={0}' .format (master .port ),
611
+ '--stream' ])
612
+
592
613
self .validate_pb (backup_dir , 'replica' )
593
614
self .assertEqual (
594
615
'OK' , self .show_pb (backup_dir , 'replica' , backup_id )['status' ])
@@ -618,7 +639,8 @@ def test_master_and_replica_concurrent_archiving(self):
618
639
set_replication = True ,
619
640
initdb_params = ['--data-checksums' ],
620
641
pg_options = {
621
- 'checkpoint_timeout' : '30s' }
642
+ 'checkpoint_timeout' : '30s' ,
643
+ 'archive_timeout' : '10s' }
622
644
)
623
645
replica = self .make_simple_node (
624
646
base_dir = "{0}/{1}/replica" .format (module_name , fname ))
0 commit comments