@@ -440,3 +440,101 @@ def test_locking_concurrent_validate_and_backup(self):
440
440
441
441
# Clean after yourself
442
442
self .del_test_dir (module_name , fname )
443
+
444
+ def test_locking_concurren_restore_and_delete (self ):
445
+ """
446
+ make node, take full backup, launch restore
447
+ and stop it in the middle, delete full backup.
448
+ Expect it to fail.
449
+ """
450
+ fname = self .id ().split ('.' )[3 ]
451
+ node = self .make_simple_node (
452
+ base_dir = os .path .join (module_name , fname , 'node' ),
453
+ initdb_params = ['--data-checksums' ])
454
+
455
+ backup_dir = os .path .join (self .tmp_path , module_name , fname , 'backup' )
456
+ self .init_pb (backup_dir )
457
+ self .add_instance (backup_dir , 'node' , node )
458
+ self .set_archiving (backup_dir , 'node' , node )
459
+ node .slow_start ()
460
+
461
+ # FULL
462
+ full_id = self .backup_node (backup_dir , 'node' , node )
463
+
464
+ node .cleanup ()
465
+ gdb = self .restore_node (backup_dir , 'node' , node , gdb = True )
466
+
467
+ gdb .set_breakpoint ('create_data_directories' )
468
+ gdb .run_until_break ()
469
+
470
+ # This PAGE backup is expected to be successfull
471
+ try :
472
+ self .delete_pb (backup_dir , 'node' , full_id )
473
+ self .assertEqual (
474
+ 1 , 0 ,
475
+ "Expecting Error because backup is locked\n "
476
+ "Output: {0} \n CMD: {1}" .format (
477
+ repr (self .output ), self .cmd ))
478
+ except ProbackupException as e :
479
+ self .assertIn (
480
+ "ERROR: Cannot lock backup {0} directory" .format (full_id ),
481
+ e .message ,
482
+ '\n Unexpected Error Message: {0}\n CMD: {1}' .format (
483
+ repr (e .message ), self .cmd ))
484
+
485
+ # Clean after yourself
486
+ self .del_test_dir (module_name , fname )
487
+
488
+ def test_backup_directory_name (self ):
489
+ """
490
+ """
491
+ fname = self .id ().split ('.' )[3 ]
492
+ node = self .make_simple_node (
493
+ base_dir = os .path .join (module_name , fname , 'node' ),
494
+ initdb_params = ['--data-checksums' ])
495
+
496
+ backup_dir = os .path .join (self .tmp_path , module_name , fname , 'backup' )
497
+ self .init_pb (backup_dir )
498
+ self .add_instance (backup_dir , 'node' , node )
499
+ self .set_archiving (backup_dir , 'node' , node )
500
+ node .slow_start ()
501
+
502
+ # FULL
503
+ full_id_1 = self .backup_node (backup_dir , 'node' , node )
504
+ page_id_1 = self .backup_node (backup_dir , 'node' , node , backup_type = 'page' )
505
+
506
+ full_id_2 = self .backup_node (backup_dir , 'node' , node )
507
+ page_id_2 = self .backup_node (backup_dir , 'node' , node , backup_type = 'page' )
508
+
509
+ node .cleanup ()
510
+
511
+ old_path = os .path .join (backup_dir , 'backups' , 'node' , full_id_1 )
512
+ new_path = os .path .join (backup_dir , 'backups' , 'node' , 'hello_kitty' )
513
+
514
+ os .rename (old_path , new_path )
515
+
516
+ # This PAGE backup is expected to be successfull
517
+ self .show_pb (backup_dir , 'node' , full_id_1 )
518
+
519
+ self .validate_pb (backup_dir )
520
+ self .validate_pb (backup_dir , 'node' )
521
+ self .validate_pb (backup_dir , 'node' , full_id_1 )
522
+
523
+ self .restore_node (backup_dir , 'node' , node , backup_id = full_id_1 )
524
+
525
+ self .delete_pb (backup_dir , 'node' , full_id_1 )
526
+
527
+ old_path = os .path .join (backup_dir , 'backups' , 'node' , full_id_2 )
528
+ new_path = os .path .join (backup_dir , 'backups' , 'node' , 'hello_kitty' )
529
+
530
+ self .set_backup (
531
+ backup_dir , 'node' , full_id_2 , options = ['--note=hello' ])
532
+
533
+ self .merge_backup (backup_dir , 'node' , page_id_2 , options = ["-j" , "4" ])
534
+
535
+ self .assertNotIn (
536
+ 'note' ,
537
+ self .show_pb (backup_dir , 'node' , page_id_2 ))
538
+
539
+ # Clean after yourself
540
+ self .del_test_dir (module_name , fname )
0 commit comments