Divide test_expiration_epoch_in_http into several (parametrized)
Two tests now checks if an expired object can be got. X-Attribute-System-Expiration-Epoch -> X-Attribute-System-Expiration-Epoch python3.9 -> 3.10 in .pre-commit-config.yaml Signed-off-by: Liza <e.chichindaeva@yadro.com>
This commit is contained in:
parent
520ac116df
commit
1e6d3e77f9
2 changed files with 25 additions and 29 deletions
|
@ -3,7 +3,7 @@ repos:
|
|||
rev: 22.8.0
|
||||
hooks:
|
||||
- id: black
|
||||
language_version: python3.9
|
||||
language_version: python3.10
|
||||
- repo: https://github.com/pycqa/isort
|
||||
rev: 5.12.0
|
||||
hooks:
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import logging
|
||||
import os
|
||||
|
||||
import allure
|
||||
|
@ -23,7 +22,6 @@ from pytest_tests.helpers.http_gate import (
|
|||
from pytest_tests.helpers.utility import wait_for_gc_pass_on_storage_nodes
|
||||
from pytest_tests.steps.cluster_test_base import ClusterTestBase
|
||||
|
||||
logger = logging.getLogger("NeoLogger")
|
||||
OBJECT_NOT_FOUND_ERROR = "not found"
|
||||
|
||||
|
||||
|
@ -199,9 +197,11 @@ class TestHttpGate(ClusterTestBase):
|
|||
)
|
||||
|
||||
@allure.title("Test Expiration-Epoch in HTTP header")
|
||||
def test_expiration_epoch_in_http(self, simple_object_size):
|
||||
@pytest.mark.parametrize("epoch_gap", [0, 1])
|
||||
def test_expiration_epoch_in_http(self, simple_object_size, epoch_gap):
|
||||
endpoint = self.cluster.default_rpc_endpoint
|
||||
http_endpoint = self.cluster.default_http_gate_endpoint
|
||||
min_valid_epoch = get_epoch(self.shell, self.cluster) + epoch_gap
|
||||
|
||||
cid = create_container(
|
||||
self.wallet,
|
||||
|
@ -211,43 +211,39 @@ class TestHttpGate(ClusterTestBase):
|
|||
basic_acl=PUBLIC_ACL,
|
||||
)
|
||||
file_path = generate_file(simple_object_size)
|
||||
oids = []
|
||||
oids_to_be_expired = []
|
||||
oids_to_be_valid = []
|
||||
|
||||
curr_epoch = get_epoch(self.shell, self.cluster)
|
||||
epochs = (curr_epoch, curr_epoch + 1, curr_epoch + 2, curr_epoch + 100)
|
||||
|
||||
for epoch in epochs:
|
||||
headers = {"X-Attribute-System-Expiration-Epoch": str(epoch)}
|
||||
for gap_until in (0, 1, 2, 100):
|
||||
valid_until = min_valid_epoch + gap_until
|
||||
headers = {"X-Attribute-System-Expiration-Epoch": str(valid_until)}
|
||||
|
||||
with allure.step("Put objects using HTTP with attribute Expiration-Epoch"):
|
||||
oids.append(
|
||||
upload_via_http_gate(
|
||||
oid = upload_via_http_gate(
|
||||
cid=cid, path=file_path, headers=headers, endpoint=http_endpoint
|
||||
)
|
||||
)
|
||||
|
||||
assert len(oids) == len(epochs), "Expected all objects have been put successfully"
|
||||
|
||||
with allure.step("All objects can be get"):
|
||||
for oid in oids:
|
||||
if get_epoch(self.shell, self.cluster) + 1 <= valid_until:
|
||||
oids_to_be_valid.append(oid)
|
||||
else:
|
||||
oids_to_be_expired.append(oid)
|
||||
with allure.step("This object can be got"):
|
||||
get_via_http_gate(cid=cid, oid=oid, endpoint=http_endpoint)
|
||||
|
||||
for expired_objects, not_expired_objects in [(oids[:1], oids[1:]), (oids[:2], oids[2:])]:
|
||||
self.tick_epoch()
|
||||
|
||||
# Wait for GC, because object with expiration is counted as alive until GC removes it
|
||||
wait_for_gc_pass_on_storage_nodes()
|
||||
|
||||
for oid in expired_objects:
|
||||
for oid in oids_to_be_expired:
|
||||
with allure.step(f"{oid} shall be expired and cannot be got"):
|
||||
try_to_get_object_and_expect_error(
|
||||
cid=cid,
|
||||
oid=oid,
|
||||
error_pattern=OBJECT_NOT_FOUND_ERROR,
|
||||
endpoint=self.cluster.default_http_gate_endpoint,
|
||||
)
|
||||
|
||||
with allure.step("Other objects can be get"):
|
||||
for oid in not_expired_objects:
|
||||
for oid in oids_to_be_valid:
|
||||
with allure.step(f"{oid} shall be valid and can be got"):
|
||||
get_via_http_gate(cid=cid, oid=oid, endpoint=http_endpoint)
|
||||
|
||||
@allure.title("Test Zip in HTTP header")
|
||||
|
|
Loading…
Reference in a new issue