[#301] Update all tests EC policy
Some checks failed
DCO check / Commits Check (pull_request) Has been cancelled
Some checks failed
DCO check / Commits Check (pull_request) Has been cancelled
Signed-off-by: Dmitriy Zayakin <d.zayakin@yadro.com>
This commit is contained in:
parent
6cc76fba54
commit
c08fd5959b
2 changed files with 38 additions and 46 deletions
|
@ -6,7 +6,6 @@ from datetime import datetime, timedelta, timezone
|
|||
from typing import Optional
|
||||
|
||||
import allure
|
||||
from frostfs_testlib.storage.grpc_operations.client_wrappers import CliClientWrapper
|
||||
import pytest
|
||||
from dateutil import parser
|
||||
from frostfs_testlib import plugins, reporter
|
||||
|
@ -28,6 +27,8 @@ from frostfs_testlib.storage.dataclasses.frostfs_services import StorageNode
|
|||
from frostfs_testlib.storage.dataclasses.object_size import ObjectSize
|
||||
from frostfs_testlib.storage.dataclasses.policy import PlacementPolicy
|
||||
from frostfs_testlib.storage.dataclasses.wallet import WalletInfo
|
||||
from frostfs_testlib.storage.grpc_operations.client_wrappers import CliClientWrapper
|
||||
from frostfs_testlib.storage.grpc_operations.interfaces import GrpcClientWrapper
|
||||
from frostfs_testlib.testing.cluster_test_base import ClusterTestBase
|
||||
from frostfs_testlib.testing.parallel import parallel
|
||||
from frostfs_testlib.testing.test_control import run_optionally, wait_for_success
|
||||
|
@ -41,6 +42,7 @@ logger = logging.getLogger("NeoLogger")
|
|||
SERVICE_ACTIVE_TIME = 20
|
||||
WALLTETS_IN_POOL = 2
|
||||
|
||||
|
||||
# Add logs check test even if it's not fit to mark selectors
|
||||
def pytest_configure(config: pytest.Config):
|
||||
markers = config.option.markexpr
|
||||
|
@ -51,6 +53,8 @@ def pytest_configure(config: pytest.Config):
|
|||
number_key = pytest.StashKey[str]()
|
||||
start_time = pytest.StashKey[int]()
|
||||
test_outcome = pytest.StashKey[str]()
|
||||
|
||||
|
||||
# pytest hook. Do not rename
|
||||
def pytest_collection_modifyitems(items: list[pytest.Item]):
|
||||
# Change order of tests based on @pytest.mark.order(<int>) marker
|
||||
|
@ -108,11 +112,7 @@ def pytest_generate_tests(metafunc: pytest.Metafunc):
|
|||
return
|
||||
|
||||
metafunc.fixturenames.append("cycle")
|
||||
metafunc.parametrize(
|
||||
"cycle",
|
||||
range(1, TEST_CYCLES_COUNT + 1),
|
||||
ids=[f"cycle {cycle}" for cycle in range(1, TEST_CYCLES_COUNT + 1)],
|
||||
)
|
||||
metafunc.parametrize("cycle", range(1, TEST_CYCLES_COUNT + 1), ids=[f"cycle {cycle}" for cycle in range(1, TEST_CYCLES_COUNT + 1)])
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
|
@ -148,11 +148,7 @@ def require_multiple_interfaces(cluster: Cluster):
|
|||
def max_object_size(cluster: Cluster, client_shell: Shell) -> int:
|
||||
storage_node = cluster.storage_nodes[0]
|
||||
wallet = WalletInfo.from_node(storage_node)
|
||||
net_info = get_netmap_netinfo(
|
||||
wallet=wallet,
|
||||
endpoint=storage_node.get_rpc_endpoint(),
|
||||
shell=client_shell,
|
||||
)
|
||||
net_info = get_netmap_netinfo(wallet=wallet, endpoint=storage_node.get_rpc_endpoint(), shell=client_shell)
|
||||
yield net_info["maximum_object_size"]
|
||||
|
||||
|
||||
|
@ -176,8 +172,7 @@ def complex_object_size(max_object_size: int) -> ObjectSize:
|
|||
# By default we want all tests to be executed with both object sizes
|
||||
# This can be overriden in choosen tests if needed
|
||||
@pytest.fixture(
|
||||
scope="session",
|
||||
params=[pytest.param("simple", marks=pytest.mark.simple), pytest.param("complex", marks=pytest.mark.complex)],
|
||||
scope="session", params=[pytest.param("simple", marks=pytest.mark.simple), pytest.param("complex", marks=pytest.mark.complex)]
|
||||
)
|
||||
def object_size(simple_object_size: ObjectSize, complex_object_size: ObjectSize, request: pytest.FixtureRequest) -> ObjectSize:
|
||||
if request.param == "simple":
|
||||
|
@ -203,17 +198,14 @@ def frostfs_cli(client_shell: Shell, default_wallet: WalletInfo) -> FrostfsCli:
|
|||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
@allure.title("Init CliClientWrapper with local Frostfs CLI")
|
||||
def grpc_client(frostfs_cli: FrostfsCli) -> CliClientWrapper:
|
||||
@allure.title("Init GrpcClientWrapper with local Frostfs CLI")
|
||||
def grpc_client(frostfs_cli: FrostfsCli) -> GrpcClientWrapper:
|
||||
return CliClientWrapper(frostfs_cli)
|
||||
|
||||
|
||||
# By default we want all tests to be executed with both storage policies.
|
||||
# This can be overriden in choosen tests if needed.
|
||||
@pytest.fixture(
|
||||
scope="session",
|
||||
params=[pytest.param("rep", marks=pytest.mark.rep), pytest.param("ec", marks=pytest.mark.ec)],
|
||||
)
|
||||
@pytest.fixture(scope="session", params=[pytest.param("rep", marks=pytest.mark.rep), pytest.param("ec", marks=pytest.mark.ec)])
|
||||
def placement_policy(
|
||||
rep_placement_policy: PlacementPolicy, ec_placement_policy: PlacementPolicy, request: pytest.FixtureRequest
|
||||
) -> PlacementPolicy:
|
||||
|
|
|
@ -16,7 +16,7 @@ from frostfs_testlib.storage.controllers import ClusterStateController
|
|||
from frostfs_testlib.storage.controllers.state_managers.config_state_manager import ConfigStateManager
|
||||
from frostfs_testlib.storage.dataclasses.object_size import ObjectSize
|
||||
from frostfs_testlib.storage.dataclasses.storage_object_info import Chunk
|
||||
from frostfs_testlib.storage.grpc_operations.client_wrappers import CliClientWrapper
|
||||
from frostfs_testlib.storage.grpc_operations.interfaces import GrpcClientWrapper
|
||||
from frostfs_testlib.testing.cluster_test_base import ClusterTestBase
|
||||
from frostfs_testlib.testing.test_control import wait_for_success
|
||||
from frostfs_testlib.utils import datetime_utils
|
||||
|
@ -76,7 +76,7 @@ class TestECReplication(ClusterTestBase):
|
|||
return rep_count
|
||||
|
||||
@wait_for_success(120, 5)
|
||||
def wait_replication(self, total_chunks: int, client: CliClientWrapper, cid: str, oid: str, success: bool = True) -> None:
|
||||
def wait_replication(self, total_chunks: int, client: GrpcClientWrapper, cid: str, oid: str, success: bool = True) -> None:
|
||||
if not success:
|
||||
assert not self.check_replication(total_chunks, client, cid, oid)
|
||||
else:
|
||||
|
@ -108,7 +108,7 @@ class TestECReplication(ClusterTestBase):
|
|||
return Chunk(**chunks[0])
|
||||
|
||||
@reporter.step("Check replication chunks={total_chunks} chunks ")
|
||||
def check_replication(self, total_chunks: int, client: CliClientWrapper, cid: str, oid: str) -> bool:
|
||||
def check_replication(self, total_chunks: int, client: GrpcClientWrapper, cid: str, oid: str) -> bool:
|
||||
object_nodes_info = client.object.chunks.get_all(self.cluster.default_rpc_endpoint, cid, oid)
|
||||
return len(object_nodes_info) == total_chunks
|
||||
|
||||
|
@ -132,13 +132,13 @@ class TestECReplication(ClusterTestBase):
|
|||
|
||||
@wait_for_success(300, 15)
|
||||
@reporter.step("Check count nodes chunks")
|
||||
def wait_sync_count_chunks_nodes(self, grpc_client: CliClientWrapper, cid: str, oid: str, count: int):
|
||||
def wait_sync_count_chunks_nodes(self, grpc_client: GrpcClientWrapper, cid: str, oid: str, count: int):
|
||||
all_chunks_after_include_node = grpc_client.object.chunks.get_all(self.cluster.default_rpc_endpoint, cid, oid)
|
||||
chunks_nodes = [node for chunk in all_chunks_after_include_node for node in chunk.confirmed_nodes]
|
||||
assert len(chunks_nodes) == count
|
||||
|
||||
@allure.title("Create container with EC policy (size={object_size})")
|
||||
def test_create_container_with_ec_policy(self, object_size: ObjectSize, rep_count: int, grpc_client: CliClientWrapper) -> None:
|
||||
def test_create_container_with_ec_policy(self, object_size: ObjectSize, rep_count: int, grpc_client: GrpcClientWrapper) -> None:
|
||||
test_file = generate_file(object_size.value)
|
||||
|
||||
with reporter.step("Create container."):
|
||||
|
@ -154,7 +154,7 @@ class TestECReplication(ClusterTestBase):
|
|||
@pytest.mark.failover
|
||||
def test_lose_node_with_data_chunk(
|
||||
self,
|
||||
grpc_client: CliClientWrapper,
|
||||
grpc_client: GrpcClientWrapper,
|
||||
simple_object_size: ObjectSize,
|
||||
cluster_state_controller: ClusterStateController,
|
||||
disable_policer: None,
|
||||
|
@ -188,7 +188,7 @@ class TestECReplication(ClusterTestBase):
|
|||
@pytest.mark.failover
|
||||
def test_lose_node_with_parity_chunk(
|
||||
self,
|
||||
grpc_client: CliClientWrapper,
|
||||
grpc_client: GrpcClientWrapper,
|
||||
simple_object_size: ObjectSize,
|
||||
cluster_state_controller: ClusterStateController,
|
||||
disable_policer: None,
|
||||
|
@ -222,7 +222,7 @@ class TestECReplication(ClusterTestBase):
|
|||
@pytest.mark.failover
|
||||
def test_lose_nodes_data_chunk_and_parity(
|
||||
self,
|
||||
grpc_client: CliClientWrapper,
|
||||
grpc_client: GrpcClientWrapper,
|
||||
simple_object_size: ObjectSize,
|
||||
cluster_state_controller: ClusterStateController,
|
||||
disable_policer: None,
|
||||
|
@ -271,7 +271,7 @@ class TestECReplication(ClusterTestBase):
|
|||
def test_work_policer_with_nodes(
|
||||
self,
|
||||
simple_object_size: ObjectSize,
|
||||
grpc_client: CliClientWrapper,
|
||||
grpc_client: GrpcClientWrapper,
|
||||
cluster_state_controller: ClusterStateController,
|
||||
include_excluded_nodes: None,
|
||||
) -> None:
|
||||
|
@ -316,7 +316,7 @@ class TestECReplication(ClusterTestBase):
|
|||
|
||||
@allure.title("EC X.Y combinations (nodes={node_count},policy={ec_policy},size={object_size})")
|
||||
def test_create_container_with_difference_count_nodes(
|
||||
self, node_count: int, ec_policy: str, object_size: ObjectSize, grpc_client: CliClientWrapper
|
||||
self, node_count: int, ec_policy: str, object_size: ObjectSize, grpc_client: GrpcClientWrapper
|
||||
) -> None:
|
||||
with reporter.step("Create container."):
|
||||
expected_chunks = int(ec_policy.split(" ")[1].split(".")[0]) + int(ec_policy.split(" ")[1].split(".")[1])
|
||||
|
@ -337,7 +337,7 @@ class TestECReplication(ClusterTestBase):
|
|||
assert get_file_hash(test_file) == get_file_hash(file_with_node)
|
||||
|
||||
@allure.title("Request PUT with copies_number flag")
|
||||
def test_put_object_with_copies_number(self, grpc_client: CliClientWrapper, simple_object_size: ObjectSize) -> None:
|
||||
def test_put_object_with_copies_number(self, grpc_client: GrpcClientWrapper, simple_object_size: ObjectSize) -> None:
|
||||
with reporter.step("Create container."):
|
||||
cid = grpc_client.container.create(self.cluster.default_rpc_endpoint, policy="EC 2.1", await_mode=True)
|
||||
|
||||
|
@ -352,7 +352,7 @@ class TestECReplication(ClusterTestBase):
|
|||
@allure.title("Request PUT and 1 node off")
|
||||
@pytest.mark.failover
|
||||
def test_put_object_with_off_cnr_node(
|
||||
self, grpc_client: CliClientWrapper, cluster_state_controller: ClusterStateController, simple_object_size: ObjectSize
|
||||
self, grpc_client: GrpcClientWrapper, cluster_state_controller: ClusterStateController, simple_object_size: ObjectSize
|
||||
) -> None:
|
||||
with reporter.step("Create container."):
|
||||
cid = grpc_client.container.create(self.cluster.default_rpc_endpoint, policy="EC 3.1", await_mode=True)
|
||||
|
@ -365,7 +365,7 @@ class TestECReplication(ClusterTestBase):
|
|||
grpc_client.object.put(test_file, cid, self.cluster.default_rpc_endpoint, copies_number=1)
|
||||
|
||||
@allure.title("Request PUT (size={object_size})")
|
||||
def test_put_object_with_ec_cnr(self, grpc_client: CliClientWrapper, object_size: ObjectSize) -> None:
|
||||
def test_put_object_with_ec_cnr(self, grpc_client: GrpcClientWrapper, object_size: ObjectSize) -> None:
|
||||
with reporter.step("Create container."):
|
||||
cid = grpc_client.container.create(self.cluster.default_rpc_endpoint, policy="EC 2.1", await_mode=True)
|
||||
|
||||
|
@ -384,7 +384,7 @@ class TestECReplication(ClusterTestBase):
|
|||
assert "EC header:" in chunk_head
|
||||
|
||||
@allure.title("Request GET (size={object_size})")
|
||||
def test_get_object_in_ec_cnr(self, grpc_client: CliClientWrapper, object_size: ObjectSize) -> None:
|
||||
def test_get_object_in_ec_cnr(self, grpc_client: GrpcClientWrapper, object_size: ObjectSize) -> None:
|
||||
with reporter.step("Create container."):
|
||||
cid = grpc_client.container.create(self.cluster.default_rpc_endpoint, policy="EC 2.1 CBF 1", await_mode=True)
|
||||
|
||||
|
@ -413,7 +413,7 @@ class TestECReplication(ClusterTestBase):
|
|||
assert hash_file_two == hash_file_one == hash_origin_file
|
||||
|
||||
@allure.title("Request SEARCH with flags 'root' (size={object_size})")
|
||||
def test_search_object_in_ec_cnr_root_flags(self, grpc_client: CliClientWrapper, object_size: ObjectSize) -> None:
|
||||
def test_search_object_in_ec_cnr_root_flags(self, grpc_client: GrpcClientWrapper, object_size: ObjectSize) -> None:
|
||||
with reporter.step("Create container."):
|
||||
cid = grpc_client.container.create(self.cluster.default_rpc_endpoint, policy="EC 2.1", await_mode=True)
|
||||
|
||||
|
@ -426,7 +426,7 @@ class TestECReplication(ClusterTestBase):
|
|||
assert search_output[0] == oid
|
||||
|
||||
@allure.title("Request SEARCH check valid chunk id (size={object_size})")
|
||||
def test_search_object_in_ec_cnr_chunk_id(self, grpc_client: CliClientWrapper, object_size: ObjectSize) -> None:
|
||||
def test_search_object_in_ec_cnr_chunk_id(self, grpc_client: GrpcClientWrapper, object_size: ObjectSize) -> None:
|
||||
with reporter.step("Create container."):
|
||||
cid = grpc_client.container.create(self.cluster.default_rpc_endpoint, policy="EC 2.1", await_mode=True)
|
||||
|
||||
|
@ -441,7 +441,7 @@ class TestECReplication(ClusterTestBase):
|
|||
assert chunk.object_id in search_output
|
||||
|
||||
@allure.title("Request SEARCH check no chunk index info (size={object_size})")
|
||||
def test_search_object_in_ec_cnr(self, grpc_client: CliClientWrapper, object_size: ObjectSize) -> None:
|
||||
def test_search_object_in_ec_cnr(self, grpc_client: GrpcClientWrapper, object_size: ObjectSize) -> None:
|
||||
with reporter.step("Create container."):
|
||||
cid = grpc_client.container.create(self.cluster.default_rpc_endpoint, policy="EC 2.1", await_mode=True)
|
||||
|
||||
|
@ -458,7 +458,7 @@ class TestECReplication(ClusterTestBase):
|
|||
@allure.title("Request DELETE (size={object_size})")
|
||||
@pytest.mark.failover
|
||||
def test_delete_object_in_ec_cnr(
|
||||
self, grpc_client: CliClientWrapper, object_size: ObjectSize, cluster_state_controller: ClusterStateController
|
||||
self, grpc_client: GrpcClientWrapper, object_size: ObjectSize, cluster_state_controller: ClusterStateController
|
||||
) -> None:
|
||||
with reporter.step("Create container."):
|
||||
cid = grpc_client.container.create(self.cluster.default_rpc_endpoint, policy="EC 2.1", await_mode=True)
|
||||
|
@ -504,7 +504,7 @@ class TestECReplication(ClusterTestBase):
|
|||
@pytest.mark.failover
|
||||
def test_lock_object_in_ec_cnr(
|
||||
self,
|
||||
grpc_client: CliClientWrapper,
|
||||
grpc_client: GrpcClientWrapper,
|
||||
frostfs_cli: FrostfsCli,
|
||||
object_size: ObjectSize,
|
||||
cluster_state_controller: ClusterStateController,
|
||||
|
@ -593,7 +593,7 @@ class TestECReplication(ClusterTestBase):
|
|||
|
||||
@allure.title("Create container with EC policy and SELECT (SELECT={select})")
|
||||
@pytest.mark.parametrize("select", [2, 4])
|
||||
def test_create_container_with_select(self, select: int, grpc_client: CliClientWrapper) -> None:
|
||||
def test_create_container_with_select(self, select: int, grpc_client: GrpcClientWrapper) -> None:
|
||||
with reporter.step("Create container"):
|
||||
policy = f"EC 1.1 CBF 1 SELECT {select} FROM *"
|
||||
cid = grpc_client.container.create(self.cluster.default_rpc_endpoint, policy=policy, await_mode=True)
|
||||
|
@ -605,7 +605,7 @@ class TestECReplication(ClusterTestBase):
|
|||
|
||||
@allure.title("Create container with EC policy and CBF (CBF={cbf})")
|
||||
@pytest.mark.parametrize("cbf, expected_nodes", [(1, 2), (2, 4)])
|
||||
def test_create_container_with_cbf(self, cbf: int, expected_nodes: int, grpc_client: CliClientWrapper) -> None:
|
||||
def test_create_container_with_cbf(self, cbf: int, expected_nodes: int, grpc_client: GrpcClientWrapper) -> None:
|
||||
with reporter.step("Create container."):
|
||||
policy = f"EC 1.1 CBF {cbf}"
|
||||
cid = grpc_client.container.create(self.cluster.default_rpc_endpoint, policy=policy, await_mode=True)
|
||||
|
@ -615,7 +615,7 @@ class TestECReplication(ClusterTestBase):
|
|||
assert len(container_nodes) == expected_nodes
|
||||
|
||||
@allure.title("Create container with EC policy and FILTER")
|
||||
def test_create_container_with_filter(self, grpc_client: CliClientWrapper, simple_object_size: ObjectSize) -> None:
|
||||
def test_create_container_with_filter(self, grpc_client: GrpcClientWrapper, simple_object_size: ObjectSize) -> None:
|
||||
with reporter.step("Create Container."):
|
||||
policy = "EC 1.1 IN RUS SELECT 2 FROM RU AS RUS FILTER Country EQ Russia AS RU"
|
||||
cid = grpc_client.container.create(self.cluster.default_rpc_endpoint, policy=policy, await_mode=True)
|
||||
|
@ -639,7 +639,7 @@ class TestECReplication(ClusterTestBase):
|
|||
self,
|
||||
restore_nodes_shards_mode: None,
|
||||
frostfs_cli: FrostfsCli,
|
||||
grpc_client: CliClientWrapper,
|
||||
grpc_client: GrpcClientWrapper,
|
||||
max_object_size: int,
|
||||
type: str,
|
||||
get_chunk,
|
||||
|
@ -668,7 +668,7 @@ class TestECReplication(ClusterTestBase):
|
|||
grpc_client.object.get(cid, oid, self.cluster.default_rpc_endpoint)
|
||||
|
||||
@allure.title("[NEGATIVE] Don`t create more 1 EC policy")
|
||||
def test_more_one_ec_policy(self, grpc_client: CliClientWrapper) -> None:
|
||||
def test_more_one_ec_policy(self, grpc_client: GrpcClientWrapper) -> None:
|
||||
with reporter.step("Create container with policy - 'EC 2.1 EC 1.1'"):
|
||||
with pytest.raises(RuntimeError, match="can't parse placement policy"):
|
||||
grpc_client.container.create(
|
||||
|
@ -678,7 +678,7 @@ class TestECReplication(ClusterTestBase):
|
|||
@allure.title("Create bucket with EC policy (s3_client={s3_client})")
|
||||
@pytest.mark.parametrize("s3_policy, s3_client", [("pytest_tests/resources/files/policy.json", AwsCliClient)], indirect=True)
|
||||
def test_create_bucket_with_ec_location(
|
||||
self, s3_client: S3ClientWrapper, bucket_container_resolver: BucketContainerResolver, grpc_client: CliClientWrapper
|
||||
self, s3_client: S3ClientWrapper, bucket_container_resolver: BucketContainerResolver, grpc_client: GrpcClientWrapper
|
||||
) -> None:
|
||||
with reporter.step("Create bucket with EC location constrain"):
|
||||
bucket = s3_client.create_bucket(location_constraint="ec3.1")
|
||||
|
@ -696,7 +696,7 @@ class TestECReplication(ClusterTestBase):
|
|||
self,
|
||||
s3_client: S3ClientWrapper,
|
||||
bucket_container_resolver: BucketContainerResolver,
|
||||
grpc_client: CliClientWrapper,
|
||||
grpc_client: GrpcClientWrapper,
|
||||
object_size: ObjectSize,
|
||||
) -> None:
|
||||
with reporter.step("Create bucket with EC location constrain"):
|
||||
|
@ -718,7 +718,7 @@ class TestECReplication(ClusterTestBase):
|
|||
assert len(chunks) == expect_chunks
|
||||
|
||||
@allure.title("Replication chunk after drop (size={object_size})")
|
||||
def test_drop_chunk_and_replication(self, grpc_client: CliClientWrapper, object_size: ObjectSize, rep_count: int) -> None:
|
||||
def test_drop_chunk_and_replication(self, grpc_client: GrpcClientWrapper, object_size: ObjectSize, rep_count: int) -> None:
|
||||
with reporter.step("Create container"):
|
||||
cid = grpc_client.container.create(self.cluster.default_rpc_endpoint, policy="EC 2.1 CBF 1", await_mode=True)
|
||||
|
||||
|
|
Loading…
Reference in a new issue