6
6
import pytest
7
7
from helpers .common import STORAGE_GC_TIME
8
8
from helpers .complex_object_actions import get_link_object , get_nodes_with_object , get_object_chunks
9
- from helpers .container import create_container
9
+ from helpers .container import DEFAULT_PLACEMENT_RULE , create_container
10
10
from helpers .file_helper import generate_file
11
11
from helpers .grpc_responses import (
12
12
LIFETIME_REQUIRED ,
@@ -627,31 +627,15 @@ def test_lock_object_can_be_dropped(self, locked_storage_object: StorageObjectIn
627
627
def test_the_object_lock_should_be_kept_after_metabase_deletion (
628
628
self ,
629
629
new_locked_storage_object : StorageObjectInfo ,
630
- enable_metabase_resync_on_start ,
631
630
neofs_env : NeoFSEnv ,
632
631
):
633
632
"""
634
633
Lock objects should fill metabase on resync_metabase
635
634
"""
636
- with allure .step ("Log nodes with object" ):
637
- get_nodes_with_object (
638
- new_locked_storage_object .cid ,
639
- new_locked_storage_object .oid ,
640
- shell = self .shell ,
641
- nodes = self .neofs_env .storage_nodes ,
642
- neofs_env = neofs_env ,
643
- )
644
-
645
- with allure .step (f"Try to delete object { new_locked_storage_object .oid } before metabase deletion" ):
646
- with pytest .raises (Exception , match = OBJECT_IS_LOCKED ):
647
- delete_object (
648
- new_locked_storage_object .wallet_file_path ,
649
- new_locked_storage_object .cid ,
650
- new_locked_storage_object .oid ,
651
- self .shell ,
652
- self .neofs_env .sn_rpc ,
653
- )
654
-
635
+ rep_setting = re .search (r"REP\s+(\d+)" , DEFAULT_PLACEMENT_RULE )
636
+ if rep_setting is None :
637
+ raise Exception (f"Cannot find REP in default placement rule: { DEFAULT_PLACEMENT_RULE } " )
638
+ rep_setting = int (rep_setting .group (1 ))
655
639
with allure .step ("Log nodes with object" ):
656
640
nodes_with_object_after_first_try = get_nodes_with_object (
657
641
new_locked_storage_object .cid ,
@@ -661,25 +645,22 @@ def test_the_object_lock_should_be_kept_after_metabase_deletion(
661
645
neofs_env = neofs_env ,
662
646
)
663
647
664
- with allure .step ("Delete metabase files from storage nodes" ):
665
- for node in self .neofs_env .storage_nodes :
666
- delete_node_metadata (node )
648
+ assert len (nodes_with_object_after_first_try ) >= rep_setting , "Invalid number of nodes with an object"
667
649
668
- with allure .step ("Start nodes after metabase deletion" ):
669
- start_storage_nodes (self .neofs_env .storage_nodes )
650
+ with allure .step ("Enable metabase resync" ):
651
+ for node in neofs_env .storage_nodes :
652
+ node .set_metabase_resync (True )
670
653
671
654
with allure .step ("Log nodes with object" ):
672
- nodes_with_object_after_metabase_deletion = get_nodes_with_object (
655
+ get_nodes_with_object (
673
656
new_locked_storage_object .cid ,
674
657
new_locked_storage_object .oid ,
675
658
shell = self .shell ,
676
659
nodes = self .neofs_env .storage_nodes ,
677
660
neofs_env = neofs_env ,
678
661
)
679
662
680
- assert len (nodes_with_object_after_metabase_deletion ) >= len (nodes_with_object_after_first_try )
681
-
682
- with allure .step (f"Try to delete object { new_locked_storage_object .oid } after metabase deletion" ):
663
+ with allure .step (f"Try to delete object { new_locked_storage_object .oid } before metabase deletion" ):
683
664
with pytest .raises (Exception , match = OBJECT_IS_LOCKED ):
684
665
delete_object (
685
666
new_locked_storage_object .wallet_file_path ,
@@ -689,6 +670,41 @@ def test_the_object_lock_should_be_kept_after_metabase_deletion(
689
670
self .neofs_env .sn_rpc ,
690
671
)
691
672
673
+ try :
674
+ with allure .step ("Delete metabase files from storage nodes" ):
675
+ for node in self .neofs_env .storage_nodes :
676
+ delete_node_metadata (node )
677
+
678
+ with allure .step ("Start nodes after metabase deletion" ):
679
+ start_storage_nodes (self .neofs_env .storage_nodes )
680
+
681
+ with allure .step ("Get nodes with object" ):
682
+ nodes_with_object_after_metabase_deletion = get_nodes_with_object (
683
+ new_locked_storage_object .cid ,
684
+ new_locked_storage_object .oid ,
685
+ shell = self .shell ,
686
+ nodes = self .neofs_env .storage_nodes ,
687
+ neofs_env = neofs_env ,
688
+ )
689
+
690
+ assert len (nodes_with_object_after_metabase_deletion ) >= rep_setting , (
691
+ "Invalid number of nodes with an object"
692
+ )
693
+
694
+ with allure .step (f"Try to delete object { new_locked_storage_object .oid } after metabase deletion" ):
695
+ with pytest .raises (Exception , match = OBJECT_IS_LOCKED ):
696
+ delete_object (
697
+ new_locked_storage_object .wallet_file_path ,
698
+ new_locked_storage_object .cid ,
699
+ new_locked_storage_object .oid ,
700
+ self .shell ,
701
+ self .neofs_env .sn_rpc ,
702
+ )
703
+ finally :
704
+ with allure .step ("Disable metabase resync" ):
705
+ for node in neofs_env .storage_nodes :
706
+ node .set_metabase_resync (False )
707
+
692
708
@pytest .mark .simple
693
709
def test_locked_object_removal_from_not_owner_node (self , default_wallet : NodeWallet ):
694
710
with allure .step ("Create container" ):
0 commit comments