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:
Elizaveta Chichindaeva 2023-03-14 14:55:01 +03:00
parent 520ac116df
commit 1e6d3e77f9
2 changed files with 25 additions and 29 deletions

View file

@ -3,7 +3,7 @@ repos:
rev: 22.8.0 rev: 22.8.0
hooks: hooks:
- id: black - id: black
language_version: python3.9 language_version: python3.10
- repo: https://github.com/pycqa/isort - repo: https://github.com/pycqa/isort
rev: 5.12.0 rev: 5.12.0
hooks: hooks:

View file

@ -1,4 +1,3 @@
import logging
import os import os
import allure 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.helpers.utility import wait_for_gc_pass_on_storage_nodes
from pytest_tests.steps.cluster_test_base import ClusterTestBase from pytest_tests.steps.cluster_test_base import ClusterTestBase
logger = logging.getLogger("NeoLogger")
OBJECT_NOT_FOUND_ERROR = "not found" OBJECT_NOT_FOUND_ERROR = "not found"
@ -199,9 +197,11 @@ class TestHttpGate(ClusterTestBase):
) )
@allure.title("Test Expiration-Epoch in HTTP header") @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 endpoint = self.cluster.default_rpc_endpoint
http_endpoint = self.cluster.default_http_gate_endpoint http_endpoint = self.cluster.default_http_gate_endpoint
min_valid_epoch = get_epoch(self.shell, self.cluster) + epoch_gap
cid = create_container( cid = create_container(
self.wallet, self.wallet,
@ -211,43 +211,39 @@ class TestHttpGate(ClusterTestBase):
basic_acl=PUBLIC_ACL, basic_acl=PUBLIC_ACL,
) )
file_path = generate_file(simple_object_size) file_path = generate_file(simple_object_size)
oids = [] oids_to_be_expired = []
oids_to_be_valid = []
curr_epoch = get_epoch(self.shell, self.cluster) for gap_until in (0, 1, 2, 100):
epochs = (curr_epoch, curr_epoch + 1, curr_epoch + 2, curr_epoch + 100) valid_until = min_valid_epoch + gap_until
headers = {"X-Attribute-System-Expiration-Epoch": str(valid_until)}
for epoch in epochs:
headers = {"X-Attribute-System-Expiration-Epoch": str(epoch)}
with allure.step("Put objects using HTTP with attribute Expiration-Epoch"): with allure.step("Put objects using HTTP with attribute Expiration-Epoch"):
oids.append( oid = upload_via_http_gate(
upload_via_http_gate(
cid=cid, path=file_path, headers=headers, endpoint=http_endpoint cid=cid, path=file_path, headers=headers, endpoint=http_endpoint
) )
) if get_epoch(self.shell, self.cluster) + 1 <= valid_until:
oids_to_be_valid.append(oid)
assert len(oids) == len(epochs), "Expected all objects have been put successfully" else:
oids_to_be_expired.append(oid)
with allure.step("All objects can be get"): with allure.step("This object can be got"):
for oid in oids:
get_via_http_gate(cid=cid, oid=oid, endpoint=http_endpoint) 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() self.tick_epoch()
# Wait for GC, because object with expiration is counted as alive until GC removes it # Wait for GC, because object with expiration is counted as alive until GC removes it
wait_for_gc_pass_on_storage_nodes() 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( try_to_get_object_and_expect_error(
cid=cid, cid=cid,
oid=oid, oid=oid,
error_pattern=OBJECT_NOT_FOUND_ERROR, error_pattern=OBJECT_NOT_FOUND_ERROR,
endpoint=self.cluster.default_http_gate_endpoint, endpoint=self.cluster.default_http_gate_endpoint,
) )
for oid in oids_to_be_valid:
with allure.step("Other objects can be get"): with allure.step(f"{oid} shall be valid and can be got"):
for oid in not_expired_objects:
get_via_http_gate(cid=cid, oid=oid, endpoint=http_endpoint) get_via_http_gate(cid=cid, oid=oid, endpoint=http_endpoint)
@allure.title("Test Zip in HTTP header") @allure.title("Test Zip in HTTP header")