add 2 cases for test object lock #80
|
@ -126,6 +126,27 @@ def locked_storage_object(
|
|||
logger.debug(ex_message)
|
||||
|
||||
|
||||
@wait_for_success(datetime_utils.parse_time(STORAGE_GC_TIME))
|
||||
def check_object_not_found(wallet_file_path: str, cid: str, oid: str, shell: Shell, rpc_endpoint: str):
|
||||
abereziny marked this conversation as resolved
Outdated
|
||||
with pytest.raises(Exception, match=OBJECT_NOT_FOUND):
|
||||
head_object(
|
||||
wallet_file_path,
|
||||
cid,
|
||||
oid,
|
||||
shell,
|
||||
rpc_endpoint,
|
||||
)
|
||||
|
||||
def verify_object_available(wallet_file_path: str, cid: str, oid: str, shell: Shell, rpc_endpoint: str):
|
||||
with expect_not_raises():
|
||||
head_object(
|
||||
wallet_file_path,
|
||||
cid,
|
||||
oid,
|
||||
shell,
|
||||
rpc_endpoint,
|
||||
)
|
||||
|
||||
@pytest.mark.sanity
|
||||
@pytest.mark.grpc_object_lock
|
||||
class TestObjectLockWithGrpc(ClusterTestBase):
|
||||
|
@ -328,20 +349,13 @@ class TestObjectLockWithGrpc(ClusterTestBase):
|
|||
self.cluster.default_rpc_endpoint,
|
||||
)
|
||||
|
||||
@wait_for_success(datetime_utils.parse_time(STORAGE_GC_TIME))
|
||||
def check_object_not_found():
|
||||
with pytest.raises(Exception, match=OBJECT_NOT_FOUND):
|
||||
head_object(
|
||||
storage_object.wallet_file_path,
|
||||
with allure.step("Wait for object to be deleted after third epoch"):
|
||||
self.tick_epoch()
|
||||
check_object_not_found(storage_object.wallet_file_path,
|
||||
storage_object.cid,
|
||||
storage_object.oid,
|
||||
self.shell,
|
||||
self.cluster.default_rpc_endpoint,
|
||||
)
|
||||
|
||||
with allure.step("Wait for object to be deleted after third epoch"):
|
||||
self.tick_epoch()
|
||||
check_object_not_found()
|
||||
self.cluster.default_rpc_endpoint)
|
||||
|
||||
@allure.title("Should be possible to lock multiple objects at once for {object_size}")
|
||||
@pytest.mark.parametrize(
|
||||
|
@ -658,3 +672,156 @@ class TestObjectLockWithGrpc(ClusterTestBase):
|
|||
self.shell,
|
||||
self.cluster.default_rpc_endpoint,
|
||||
)
|
||||
|
||||
@allure.title("Expired object should be removed after all locks were expired for {object_size}")
|
||||
@pytest.mark.parametrize(
|
||||
abereziny marked this conversation as resolved
Outdated
abereziny
commented
`object_size: int` -> `object_size: ObjectSize` everywhere
|
||||
"object_size",
|
||||
[pytest.lazy_fixture("simple_object_size"), pytest.lazy_fixture("complex_object_size")],
|
||||
ids=["simple object size", "complex object size"],
|
||||
)
|
||||
abereziny marked this conversation as resolved
Outdated
abereziny
commented
Same title correction :) Same title correction :)
|
||||
def test_expired_object_should_be_removed_after_relocks_expare_at(
|
||||
self,
|
||||
request: FixtureRequest,
|
||||
user_container: StorageContainer,
|
||||
object_size: ObjectSize,
|
||||
):
|
||||
abereziny marked this conversation as resolved
Outdated
abereziny
commented
We may be more specific here We may be more specific here
`"Apply first lock to object for 3 epochs"`
|
||||
|
||||
allure.dynamic.title(
|
||||
f"Expired object should be removed after all locks were expired for {request.node.callspec.id}"
|
||||
)
|
||||
|
||||
current_epoch = self.ensure_fresh_epoch()
|
||||
storage_object = user_container.generate_object(object_size.value, expire_at=current_epoch + 1)
|
||||
|
||||
with allure.step("Apply first lock to object for 3 epochs"):
|
||||
lock_object_id_0 = lock_object(
|
||||
abereziny marked this conversation as resolved
Outdated
abereziny
commented
We can move it near Also, the logic can be made simplier
We can move it near `check_object_not_found` (for better test readability)
Also, the logic can be made simplier
```
def verify_lock_available(lock_object_id: str):
with expect_not_raises():
head_object(
storage_object.wallet_file_path,
storage_object.cid,
lock_object_id,
self.shell,
self.cluster.default_rpc_endpoint,
)
```
|
||||
storage_object.wallet_file_path,
|
||||
storage_object.cid,
|
||||
storage_object.oid,
|
||||
self.shell,
|
||||
self.cluster.default_rpc_endpoint,
|
||||
expire_at=current_epoch + 3,
|
||||
)
|
||||
|
||||
self.tick_epochs(2)
|
||||
|
||||
with allure.step("Check first lock is still available"):
|
||||
verify_object_available(
|
||||
storage_object.wallet_file_path,
|
||||
storage_object.cid,
|
||||
lock_object_id_0,
|
||||
self.shell,
|
||||
self.cluster.default_rpc_endpoint)
|
||||
|
||||
with allure.step("Apply second lock to object for 3 more epochs"):
|
||||
abereziny marked this conversation as resolved
Outdated
abereziny
commented
`"Check first lock is still available"`
|
||||
lock_object_id_1 = lock_object(
|
||||
storage_object.wallet_file_path,
|
||||
storage_object.cid,
|
||||
abereziny marked this conversation as resolved
Outdated
abereziny
commented
"Apply second lock to object for 3 more epochs" "Apply second lock to object for 3 more epochs"
|
||||
storage_object.oid,
|
||||
self.shell,
|
||||
self.cluster.default_rpc_endpoint,
|
||||
expire_at=current_epoch + 5,
|
||||
)
|
||||
|
||||
self.tick_epochs(2)
|
||||
|
||||
with allure.step("Verify first lock is expired and removed"):
|
||||
check_object_not_found(
|
||||
storage_object.wallet_file_path,
|
||||
storage_object.cid,
|
||||
abereziny marked this conversation as resolved
Outdated
abereziny
commented
Separate to 2 steps:
Separate to 2 steps:
`Verify first lock is expired and removed`
`Verify second lock is still available`
|
||||
lock_object_id_0,
|
||||
self.shell,
|
||||
self.cluster.default_rpc_endpoint
|
||||
)
|
||||
|
||||
with allure.step("Verify second lock is still available"):
|
||||
verify_object_available(
|
||||
storage_object.wallet_file_path,
|
||||
abereziny marked this conversation as resolved
Outdated
abereziny
commented
"Apply third lock to object for 3 more epochs" "Apply third lock to object for 3 more epochs"
|
||||
storage_object.cid,
|
||||
lock_object_id_1,
|
||||
self.shell,
|
||||
self.cluster.default_rpc_endpoint
|
||||
)
|
||||
|
||||
with allure.step("Apply third lock to object for 3 more epochs"):
|
||||
lock_object(
|
||||
storage_object.wallet_file_path,
|
||||
storage_object.cid,
|
||||
abereziny marked this conversation as resolved
Outdated
abereziny
commented
"Verify object is deleted after all locks are expired" "Verify object is deleted after all locks are expired"
|
||||
storage_object.oid,
|
||||
self.shell,
|
||||
self.cluster.default_rpc_endpoint,
|
||||
expire_at=current_epoch + 7,
|
||||
)
|
||||
|
||||
with allure.step("Verify object is deleted after all locks are expired"):
|
||||
self.tick_epochs(4)
|
||||
check_object_not_found(
|
||||
abereziny marked this conversation as resolved
Outdated
abereziny
commented
Two expired objects with one lock should be deleted after lock expiration Two expired objects with one lock should be deleted after lock expiration
|
||||
storage_object.wallet_file_path,
|
||||
storage_object.cid,
|
||||
storage_object.oid,
|
||||
self.shell,
|
||||
abereziny marked this conversation as resolved
Outdated
abereziny
commented
`simple object size` and `complex object size` everywhere :)
|
||||
self.cluster.default_rpc_endpoint
|
||||
)
|
||||
|
||||
@allure.title("Two expired objects with one lock should be deleted after lock expiration for {object_size}")
|
||||
@pytest.mark.parametrize(
|
||||
"object_size",
|
||||
[pytest.lazy_fixture("simple_object_size"), pytest.lazy_fixture("complex_object_size")],
|
||||
ids=["simple object size", "complex object size"],
|
||||
)
|
||||
def test_two_objects_expiration_with_one_lock(
|
||||
self,
|
||||
request: FixtureRequest,
|
||||
user_container: StorageContainer,
|
||||
object_size: ObjectSize,
|
||||
):
|
||||
|
||||
allure.dynamic.title(
|
||||
f"Two expired objects with one lock should be deleted after lock expiration for {request.node.callspec.id}"
|
||||
)
|
||||
|
||||
current_epoch = self.ensure_fresh_epoch()
|
||||
storage_objects: list[StorageObjectInfo] = []
|
||||
|
||||
with allure.step("Generate two objects"):
|
||||
abereziny marked this conversation as resolved
Outdated
abereziny
commented
`Lock objects for 4(? please use correct number) epochs`
|
||||
for epoch_i in range(2):
|
||||
storage_objects.append(
|
||||
user_container.generate_object(object_size.value, expire_at=current_epoch + epoch_i + 3)
|
||||
)
|
||||
|
||||
self.tick_epoch()
|
||||
|
||||
with allure.step("Lock objects for 4 epochs"):
|
||||
lock_object(
|
||||
storage_objects[0].wallet_file_path,
|
||||
abereziny marked this conversation as resolved
Outdated
abereziny
commented
Verify objects are available during next three epochs Verify objects are available during next three epochs
|
||||
storage_objects[0].cid,
|
||||
",".join([storage_object.oid for storage_object in storage_objects]),
|
||||
self.shell,
|
||||
self.cluster.default_rpc_endpoint,
|
||||
expire_at=current_epoch + 4,
|
||||
)
|
||||
|
||||
with allure.step("Verify objects are available during next three epochs"):
|
||||
for epoch_i in range(3):
|
||||
self.tick_epoch()
|
||||
with allure.step(f"Check objects at epoch {current_epoch + epoch_i + 2}"):
|
||||
for storage_object in storage_objects:
|
||||
verify_object_available(
|
||||
storage_object.wallet_file_path,
|
||||
abereziny marked this conversation as resolved
Outdated
abereziny
commented
"Verify objects are deleted after lock was expired" "Verify objects are deleted after lock was expired"
|
||||
storage_object.cid,
|
||||
storage_object.oid,
|
||||
self.shell,
|
||||
self.cluster.default_rpc_endpoint
|
||||
)
|
||||
|
||||
with allure.step("Verify objects are deleted after lock was expired"):
|
||||
self.tick_epoch()
|
||||
for storage_object in storage_objects:
|
||||
check_object_not_found(
|
||||
abereziny marked this conversation as resolved
Outdated
abereziny
commented
Redundant new lines (must be one in the end of file) Redundant new lines (must be one in the end of file)
|
||||
storage_object.wallet_file_path,
|
||||
storage_object.cid,
|
||||
storage_object.oid,
|
||||
self.shell,
|
||||
self.cluster.default_rpc_endpoint
|
||||
)
|
||||
|
can use StorageObjectInfo here instead of multiple single params
also
default_rpc_endpoint
should be justrpc_endpoint
here