Skip to content

Commit 208e204

Browse files
authored
tests: fix test_the_object_lock_should_be_kept_after_metabase_deletion (#1134)
closes #1130
2 parents 75c9a57 + e7edd4a commit 208e204

File tree

1 file changed

+46
-30
lines changed

1 file changed

+46
-30
lines changed

pytest_tests/tests/object/test_object_lock.py

Lines changed: 46 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import pytest
77
from helpers.common import STORAGE_GC_TIME
88
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
1010
from helpers.file_helper import generate_file
1111
from helpers.grpc_responses import (
1212
LIFETIME_REQUIRED,
@@ -627,31 +627,15 @@ def test_lock_object_can_be_dropped(self, locked_storage_object: StorageObjectIn
627627
def test_the_object_lock_should_be_kept_after_metabase_deletion(
628628
self,
629629
new_locked_storage_object: StorageObjectInfo,
630-
enable_metabase_resync_on_start,
631630
neofs_env: NeoFSEnv,
632631
):
633632
"""
634633
Lock objects should fill metabase on resync_metabase
635634
"""
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))
655639
with allure.step("Log nodes with object"):
656640
nodes_with_object_after_first_try = get_nodes_with_object(
657641
new_locked_storage_object.cid,
@@ -661,25 +645,22 @@ def test_the_object_lock_should_be_kept_after_metabase_deletion(
661645
neofs_env=neofs_env,
662646
)
663647

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"
667649

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)
670653

671654
with allure.step("Log nodes with object"):
672-
nodes_with_object_after_metabase_deletion = get_nodes_with_object(
655+
get_nodes_with_object(
673656
new_locked_storage_object.cid,
674657
new_locked_storage_object.oid,
675658
shell=self.shell,
676659
nodes=self.neofs_env.storage_nodes,
677660
neofs_env=neofs_env,
678661
)
679662

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"):
683664
with pytest.raises(Exception, match=OBJECT_IS_LOCKED):
684665
delete_object(
685666
new_locked_storage_object.wallet_file_path,
@@ -689,6 +670,41 @@ def test_the_object_lock_should_be_kept_after_metabase_deletion(
689670
self.neofs_env.sn_rpc,
690671
)
691672

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+
692708
@pytest.mark.simple
693709
def test_locked_object_removal_from_not_owner_node(self, default_wallet: NodeWallet):
694710
with allure.step("Create container"):

0 commit comments

Comments
 (0)