forked from TrueCloudLab/frostfs-testcases
Compare commits
8 commits
add-test-o
...
master
Author | SHA1 | Date | |
---|---|---|---|
bcb1234766 | |||
a5ee580345 | |||
dcad44869f | |||
3941619431 | |||
9cf083fac9 | |||
29a23b1e7e | |||
abf46a7e16 | |||
e098f63251 |
15 changed files with 499 additions and 21 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -18,6 +18,7 @@ xunit_results.xml
|
|||
# ignore caches under any path
|
||||
**/__pycache__
|
||||
**/.pytest_cache
|
||||
*.egg-info
|
||||
|
||||
# ignore work directories and setup files
|
||||
.setup
|
||||
|
|
|
@ -92,7 +92,7 @@ class TestEACLContainer(ClusterTestBase):
|
|||
cluster=self.cluster,
|
||||
)
|
||||
|
||||
with reporter.step(f"Check {not_deny_role_wallet} has full access to eACL public container"):
|
||||
with reporter.step(f"Check {not_deny_role_str} has full access to eACL public container"):
|
||||
check_full_access_to_container(
|
||||
not_deny_role_wallet,
|
||||
cid,
|
||||
|
|
|
@ -23,7 +23,7 @@ from frostfs_testlib.resources.common import (
|
|||
)
|
||||
from frostfs_testlib.s3 import AwsCliClient, Boto3ClientWrapper, S3ClientWrapper, VersioningStatus
|
||||
from frostfs_testlib.shell import LocalShell, Shell
|
||||
from frostfs_testlib.steps.cli.container import DEFAULT_PLACEMENT_RULE, DEFAULT_EC_PLACEMENT_RULE
|
||||
from frostfs_testlib.steps.cli.container import DEFAULT_EC_PLACEMENT_RULE, DEFAULT_PLACEMENT_RULE
|
||||
from frostfs_testlib.steps.cli.object import get_netmap_netinfo
|
||||
from frostfs_testlib.steps.s3 import s3_helper
|
||||
from frostfs_testlib.storage import get_service_registry
|
||||
|
@ -210,6 +210,7 @@ def object_size(
|
|||
|
||||
return complex_object_size
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def rep_placement_policy() -> PlacementPolicy:
|
||||
return PlacementPolicy("rep", DEFAULT_PLACEMENT_RULE)
|
||||
|
@ -234,6 +235,7 @@ def placement_policy(
|
|||
|
||||
return ec_placement_policy
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def cluster(temp_directory: str, hosting: Hosting, client_shell: Shell) -> Cluster:
|
||||
cluster = Cluster(hosting)
|
||||
|
@ -266,10 +268,12 @@ def healthcheck(cluster: Cluster) -> Healthcheck:
|
|||
return healthcheck_cls()
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
@pytest.fixture
|
||||
def cluster_state_controller(client_shell: Shell, cluster: Cluster, healthcheck: Healthcheck) -> ClusterStateController:
|
||||
controller = ClusterStateController(client_shell, cluster, healthcheck)
|
||||
yield controller
|
||||
controller.start_stopped_hosts()
|
||||
controller.start_all_stopped_services()
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
|
|
97
pytest_tests/testsuites/metrics/test_container_metrics.py
Normal file
97
pytest_tests/testsuites/metrics/test_container_metrics.py
Normal file
|
@ -0,0 +1,97 @@
|
|||
import math
|
||||
import re
|
||||
|
||||
import allure
|
||||
import pytest
|
||||
from frostfs_testlib import reporter
|
||||
from frostfs_testlib.steps.cli.container import create_container, delete_container
|
||||
from frostfs_testlib.steps.cli.object import delete_object, get_object_nodes, put_object_to_random_node
|
||||
from frostfs_testlib.storage.cluster import Cluster, ClusterNode
|
||||
from frostfs_testlib.storage.dataclasses.object_size import ObjectSize
|
||||
from frostfs_testlib.storage.dataclasses.wallet import WalletInfo
|
||||
from frostfs_testlib.testing.cluster_test_base import ClusterTestBase
|
||||
from frostfs_testlib.testing.test_control import wait_for_success
|
||||
from frostfs_testlib.utils.file_utils import generate_file
|
||||
|
||||
|
||||
@pytest.mark.container
|
||||
class TestContainerMetrics(ClusterTestBase):
|
||||
@wait_for_success(interval=10)
|
||||
def check_sum_counter_metrics_in_nodes(
|
||||
self, cluster_nodes: list[ClusterNode], cid: str, phy_exp: int, logic_exp: int, user_exp: int
|
||||
):
|
||||
counter_phy = 0
|
||||
counter_logic = 0
|
||||
counter_user = 0
|
||||
for cluster_node in cluster_nodes:
|
||||
metric_result = cluster_node.metrics.storage.get_metric_container(f"container_objects_total", cid)
|
||||
counter_phy += self.get_count_metric_type_from_stdout(metric_result.stdout, "phy")
|
||||
counter_logic += self.get_count_metric_type_from_stdout(metric_result.stdout, "logic")
|
||||
counter_user += self.get_count_metric_type_from_stdout(metric_result.stdout, "user")
|
||||
|
||||
assert counter_phy == phy_exp, f"Expected metric Phy={phy_exp}, Actual: {counter_phy} in nodes: {cluster_nodes}"
|
||||
assert (
|
||||
counter_logic == logic_exp
|
||||
), f"Expected metric logic={logic_exp}, Actual: {counter_logic} in nodes: {cluster_nodes}"
|
||||
assert (
|
||||
counter_user == user_exp
|
||||
), f"Expected metric User={user_exp}, Actual: {counter_user} in nodes: {cluster_nodes}"
|
||||
|
||||
@staticmethod
|
||||
def get_count_metric_type_from_stdout(metric_result_stdout: str, metric_type: str):
|
||||
result = re.findall(rf'type="{metric_type}"}}\s(\d+)', metric_result_stdout)
|
||||
return sum(map(int, result))
|
||||
|
||||
@allure.title("Container metrics (obj_size={object_size})")
|
||||
def test_container_metrics(
|
||||
self, object_size: ObjectSize, max_object_size: int, default_wallet: WalletInfo, cluster: Cluster
|
||||
):
|
||||
file_path = generate_file(object_size.value)
|
||||
placement_policy = "REP 2 IN X CBF 2 SELECT 2 FROM * AS X"
|
||||
copies = 2
|
||||
object_chunks = 0
|
||||
head_object = 1
|
||||
link_object = 0
|
||||
if object_size.value > max_object_size:
|
||||
object_chunks = math.ceil(object_size.value / max_object_size)
|
||||
link_object = 1
|
||||
|
||||
with reporter.step(f"Create container with policy {placement_policy}"):
|
||||
cid = create_container(
|
||||
default_wallet,
|
||||
rule=placement_policy,
|
||||
shell=self.shell,
|
||||
endpoint=self.cluster.default_rpc_endpoint,
|
||||
)
|
||||
|
||||
with reporter.step("Put object to random node"):
|
||||
storage_object_id = put_object_to_random_node(
|
||||
wallet=default_wallet,
|
||||
path=file_path,
|
||||
cid=cid,
|
||||
shell=self.shell,
|
||||
cluster=cluster,
|
||||
)
|
||||
|
||||
with reporter.step("Check metric appears in node where the object is located"):
|
||||
object_nodes = get_object_nodes(
|
||||
cluster=cluster, cid=cid, oid=storage_object_id, alive_node=cluster.cluster_nodes[0]
|
||||
)
|
||||
count_metrics_exp = (object_chunks + head_object + link_object) * copies
|
||||
self.check_sum_counter_metrics_in_nodes(
|
||||
object_nodes, cid, phy_exp=count_metrics_exp, logic_exp=count_metrics_exp, user_exp=copies
|
||||
)
|
||||
|
||||
with reporter.step("Delete file, wait until gc remove object"):
|
||||
delete_object(default_wallet, cid, storage_object_id, self.shell, self.cluster.default_rpc_endpoint)
|
||||
count_metrics_exp = len(object_nodes)
|
||||
self.check_sum_counter_metrics_in_nodes(
|
||||
object_nodes, cid, phy_exp=count_metrics_exp, logic_exp=count_metrics_exp, user_exp=0
|
||||
)
|
||||
|
||||
with reporter.step("Check metrics(Phy, Logic, User) in each nodes"):
|
||||
# Phy and Logic metrics are 4, because in rule 'CBF 2 SELECT 2 FROM', cbf2*sel2=4
|
||||
self.check_sum_counter_metrics_in_nodes(cluster.cluster_nodes, cid, phy_exp=4, logic_exp=4, user_exp=0)
|
||||
|
||||
with reporter.step("Delete container"):
|
||||
delete_container(default_wallet, cid, shell=self.shell, endpoint=self.cluster.default_rpc_endpoint)
|
318
pytest_tests/testsuites/metrics/test_object_metrics.py
Normal file
318
pytest_tests/testsuites/metrics/test_object_metrics.py
Normal file
|
@ -0,0 +1,318 @@
|
|||
import random
|
||||
import re
|
||||
|
||||
import allure
|
||||
import pytest
|
||||
from frostfs_testlib import reporter
|
||||
from frostfs_testlib.steps.cli.container import create_container, delete_container, search_nodes_with_container
|
||||
from frostfs_testlib.steps.cli.object import (
|
||||
delete_object,
|
||||
get_object_nodes,
|
||||
lock_object,
|
||||
put_object,
|
||||
put_object_to_random_node,
|
||||
)
|
||||
from frostfs_testlib.storage.cluster import Cluster, ClusterNode
|
||||
from frostfs_testlib.storage.controllers.cluster_state_controller import ClusterStateController
|
||||
from frostfs_testlib.storage.dataclasses.object_size import ObjectSize
|
||||
from frostfs_testlib.storage.dataclasses.wallet import WalletInfo
|
||||
from frostfs_testlib.testing.cluster_test_base import ClusterTestBase
|
||||
from frostfs_testlib.testing.test_control import wait_for_success
|
||||
from frostfs_testlib.utils.file_utils import generate_file
|
||||
|
||||
|
||||
class TestObjectMetrics(ClusterTestBase):
|
||||
@wait_for_success(interval=10)
|
||||
def check_metrics_by_type(
|
||||
self, cluster_nodes: list[ClusterNode], metric_command: str, grep_by: str, metric_type: str, counter_exp: int
|
||||
):
|
||||
counter_act = 0
|
||||
for cluster_node in cluster_nodes:
|
||||
try:
|
||||
metric_result = cluster_node.metrics.storage.get_metrics_search_by_greps(
|
||||
command=metric_command, grep_by=grep_by
|
||||
)
|
||||
counter_act += self.calc_metrics_count_from_stdout(metric_result.stdout, metric_type)
|
||||
except RuntimeError as e:
|
||||
...
|
||||
assert (
|
||||
counter_act == counter_exp
|
||||
), f"Expected metric {metric_type}={counter_exp}, Actual: {counter_act} in nodes: {cluster_nodes}"
|
||||
|
||||
@staticmethod
|
||||
def calc_metrics_count_from_stdout(metric_result_stdout: str, metric_type: str):
|
||||
result = re.findall(rf'type="{metric_type}"}}\s(\d+)', metric_result_stdout)
|
||||
return sum(map(int, result))
|
||||
|
||||
@wait_for_success(interval=10)
|
||||
def check_object_metrics_total_and_container(
|
||||
self, cluster_nodes: list[ClusterNode], cid: str, objects_metric_total: int, objects_metric_container: int
|
||||
):
|
||||
self.check_metrics_by_type(
|
||||
cluster_nodes,
|
||||
"frostfs_node_engine_objects_total",
|
||||
grep_by="user",
|
||||
metric_type="user",
|
||||
counter_exp=objects_metric_total,
|
||||
)
|
||||
|
||||
objects_metric_container_act = 0
|
||||
for node in cluster_nodes:
|
||||
try:
|
||||
metrics_container = node.metrics.storage.get_metrics_search_by_greps(
|
||||
command="frostfs_node_engine_container_objects_total", cid=cid, type="user"
|
||||
)
|
||||
objects_metric_container_act += self.calc_metrics_count_from_stdout(
|
||||
metrics_container.stdout, metric_type="user"
|
||||
)
|
||||
except RuntimeError as e:
|
||||
...
|
||||
assert (
|
||||
objects_metric_container_act == objects_metric_container
|
||||
), f"Expected {objects_metric_container} objects in container"
|
||||
|
||||
@wait_for_success(max_wait_time=120, interval=10)
|
||||
def check_object_metrics_container(
|
||||
self, cluster_nodes: list[ClusterNode], cid: str, objects_metric_container_exp: int
|
||||
):
|
||||
objects_metric_container_act = 0
|
||||
for node in cluster_nodes:
|
||||
try:
|
||||
metrics_container = node.metrics.storage.get_metrics_search_by_greps(
|
||||
command="frostfs_node_engine_container_objects_total", cid=cid, type="user"
|
||||
)
|
||||
objects_metric_container_act += self.calc_metrics_count_from_stdout(
|
||||
metrics_container.stdout, metric_type="user"
|
||||
)
|
||||
except RuntimeError as e:
|
||||
...
|
||||
assert (
|
||||
objects_metric_container_act == objects_metric_container_exp
|
||||
), f"Expected {objects_metric_container_exp} objects in container"
|
||||
|
||||
@allure.title("Object metrics of removed container")
|
||||
def test_object_metrics_removed_container(
|
||||
self, object_size: ObjectSize, default_wallet: WalletInfo, cluster: Cluster
|
||||
):
|
||||
file_path = generate_file(object_size.value)
|
||||
placement_policy = "REP 2 IN X CBF 2 SELECT 2 FROM * AS X"
|
||||
copies = 2
|
||||
|
||||
with reporter.step(f"Create container with policy {placement_policy}"):
|
||||
cid = create_container(
|
||||
default_wallet,
|
||||
rule=placement_policy,
|
||||
shell=self.shell,
|
||||
endpoint=self.cluster.default_rpc_endpoint,
|
||||
)
|
||||
|
||||
with reporter.step("Put object to random node"):
|
||||
storage_object_id = put_object_to_random_node(
|
||||
wallet=default_wallet,
|
||||
path=file_path,
|
||||
cid=cid,
|
||||
shell=self.shell,
|
||||
cluster=cluster,
|
||||
)
|
||||
|
||||
with reporter.step("Check metric appears in node where the object is located"):
|
||||
object_nodes = get_object_nodes(
|
||||
cluster=cluster, cid=cid, oid=storage_object_id, alive_node=cluster.cluster_nodes[0]
|
||||
)
|
||||
|
||||
self.check_metrics_by_type(object_nodes, "frostfs_node_engine_container_objects_total", cid, "user", copies)
|
||||
|
||||
with reporter.step("Delete container"):
|
||||
delete_container(default_wallet, cid, shell=self.shell, endpoint=self.cluster.default_rpc_endpoint)
|
||||
|
||||
with reporter.step("Tick Epoch"):
|
||||
self.tick_epochs(epochs_to_tick=2, wait_block=2)
|
||||
|
||||
with reporter.step("Check metrics of removed containers doesn't appear in the storage node"):
|
||||
self.check_metrics_by_type(object_nodes, "frostfs_node_engine_container_objects_total", cid, "user", 0)
|
||||
|
||||
for node in object_nodes:
|
||||
with pytest.raises(RuntimeError):
|
||||
node.metrics.storage.get_metric_container(f"frostfs_node_engine_container_size_byte", cid)
|
||||
|
||||
@allure.title("Object metrics, locked object, (policy={placement_policy})")
|
||||
@pytest.mark.parametrize(
|
||||
"placement_policy", ["REP 1 IN X CBF 1 SELECT 1 FROM * AS X", "REP 2 IN X CBF 2 SELECT 2 FROM * AS X"]
|
||||
)
|
||||
def test_object_metrics_blocked_object(
|
||||
self, object_size: ObjectSize, default_wallet: WalletInfo, cluster: Cluster, placement_policy: str
|
||||
):
|
||||
file_path = generate_file(object_size.value)
|
||||
metric_step = int(re.search(r"REP\s(\d+)", placement_policy).group(1))
|
||||
|
||||
with reporter.step(f"Create container with policy {placement_policy}"):
|
||||
cid = create_container(
|
||||
wallet=default_wallet,
|
||||
rule=placement_policy,
|
||||
shell=self.shell,
|
||||
endpoint=self.cluster.default_rpc_endpoint,
|
||||
)
|
||||
|
||||
with reporter.step("Search container nodes"):
|
||||
container_nodes = search_nodes_with_container(
|
||||
wallet=default_wallet,
|
||||
cid=cid,
|
||||
shell=self.shell,
|
||||
endpoint=self.cluster.default_rpc_endpoint,
|
||||
cluster=cluster,
|
||||
)
|
||||
|
||||
with reporter.step("Get current metrics for metric_type=user"):
|
||||
objects_metric_counter = 0
|
||||
for node in container_nodes:
|
||||
metric_objects_total = node.metrics.storage.get_metrics_search_by_greps(
|
||||
command="frostfs_node_engine_objects_total", type="user"
|
||||
)
|
||||
objects_metric_counter += self.calc_metrics_count_from_stdout(
|
||||
metric_objects_total.stdout, metric_type="user"
|
||||
)
|
||||
|
||||
with reporter.step("Put object to container node"):
|
||||
oid = put_object(
|
||||
wallet=default_wallet,
|
||||
path=file_path,
|
||||
cid=cid,
|
||||
shell=self.shell,
|
||||
endpoint=container_nodes[0].storage_node.get_rpc_endpoint(),
|
||||
)
|
||||
|
||||
with reporter.step(f"Check metric user 'the counter should increase by {metric_step}'"):
|
||||
objects_metric_counter += metric_step
|
||||
self.check_object_metrics_total_and_container(container_nodes, cid, objects_metric_counter, metric_step)
|
||||
|
||||
with reporter.step("Delete object"):
|
||||
delete_object(default_wallet, cid, oid, self.shell, self.cluster.default_rpc_endpoint)
|
||||
|
||||
with reporter.step(f"Check metric user 'the counter should decrease by {metric_step}'"):
|
||||
objects_metric_counter -= metric_step
|
||||
self.check_object_metrics_total_and_container(container_nodes, cid, objects_metric_counter, 0)
|
||||
|
||||
with reporter.step("Put object and lock it"):
|
||||
oid = put_object(
|
||||
default_wallet, file_path, cid, self.shell, container_nodes[0].storage_node.get_rpc_endpoint()
|
||||
)
|
||||
current_epoch = self.get_epoch()
|
||||
lock_object(
|
||||
default_wallet,
|
||||
cid,
|
||||
oid,
|
||||
self.shell,
|
||||
container_nodes[0].storage_node.get_rpc_endpoint(),
|
||||
expire_at=current_epoch + 1,
|
||||
)
|
||||
|
||||
with reporter.step(f"Check metric user 'the counter should increase by {metric_step}'"):
|
||||
objects_metric_counter += metric_step
|
||||
self.check_object_metrics_total_and_container(container_nodes, cid, objects_metric_counter, metric_step)
|
||||
|
||||
with reporter.step(f"Wait until remove locking 'the counter doesn't change'"):
|
||||
self.tick_epochs(epochs_to_tick=2)
|
||||
self.check_object_metrics_total_and_container(container_nodes, cid, objects_metric_counter, metric_step)
|
||||
|
||||
with reporter.step("Delete object"):
|
||||
delete_object(default_wallet, cid, oid, self.shell, self.cluster.default_rpc_endpoint)
|
||||
|
||||
with reporter.step(f"Check metric user 'the counter should decrease by {metric_step}'"):
|
||||
objects_metric_counter -= metric_step
|
||||
self.check_object_metrics_total_and_container(container_nodes, cid, objects_metric_counter, 0)
|
||||
|
||||
with reporter.step("Put object with expire_at"):
|
||||
current_epoch = self.get_epoch()
|
||||
oid = put_object(
|
||||
default_wallet,
|
||||
file_path,
|
||||
cid,
|
||||
self.shell,
|
||||
container_nodes[0].storage_node.get_rpc_endpoint(),
|
||||
expire_at=current_epoch + 1,
|
||||
)
|
||||
|
||||
with reporter.step(f"Check metric user 'the counter should increase by {metric_step}'"):
|
||||
objects_metric_counter += metric_step
|
||||
self.check_object_metrics_total_and_container(container_nodes, cid, objects_metric_counter, metric_step)
|
||||
|
||||
with reporter.step("Tick Epoch"):
|
||||
self.tick_epochs(epochs_to_tick=2)
|
||||
|
||||
with reporter.step(f"Check metric user 'the counter should decrease by {metric_step}'"):
|
||||
objects_metric_counter -= metric_step
|
||||
self.check_object_metrics_total_and_container(container_nodes, cid, objects_metric_counter, 0)
|
||||
|
||||
with reporter.step("Delete container"):
|
||||
delete_container(default_wallet, cid, shell=self.shell, endpoint=self.cluster.default_rpc_endpoint)
|
||||
|
||||
@allure.title("Object metrics, stop the node")
|
||||
def test_object_metrics_stop_node(
|
||||
self,
|
||||
object_size: ObjectSize,
|
||||
max_object_size: int,
|
||||
default_wallet: WalletInfo,
|
||||
cluster_state_controller: ClusterStateController,
|
||||
):
|
||||
placement_policy = "REP 2 IN X CBF 2 SELECT 2 FROM * AS X"
|
||||
file_path = generate_file(object_size.value)
|
||||
copies = 2
|
||||
|
||||
with reporter.step(f"Create container with policy {placement_policy}"):
|
||||
cid = create_container(
|
||||
wallet=default_wallet,
|
||||
rule=placement_policy,
|
||||
shell=self.shell,
|
||||
endpoint=self.cluster.default_rpc_endpoint,
|
||||
)
|
||||
|
||||
with reporter.step("Search container nodes"):
|
||||
container_nodes = search_nodes_with_container(
|
||||
wallet=default_wallet,
|
||||
cid=cid,
|
||||
shell=self.shell,
|
||||
endpoint=self.cluster.default_rpc_endpoint,
|
||||
cluster=self.cluster,
|
||||
)
|
||||
|
||||
with reporter.step("Get current metrics for container nodes"):
|
||||
objects_metric_counter = 0
|
||||
for node in container_nodes:
|
||||
metric_objects_total = node.metrics.storage.get_metrics_search_by_greps(
|
||||
command="frostfs_node_engine_objects_total", type="user"
|
||||
)
|
||||
objects_metric_counter += self.calc_metrics_count_from_stdout(
|
||||
metric_objects_total.stdout, metric_type="user"
|
||||
)
|
||||
|
||||
with reporter.step("Put object to container node"):
|
||||
oid = put_object(
|
||||
wallet=default_wallet,
|
||||
path=file_path,
|
||||
cid=cid,
|
||||
shell=self.shell,
|
||||
endpoint=container_nodes[0].storage_node.get_rpc_endpoint(),
|
||||
)
|
||||
|
||||
with reporter.step(f"Check metric in container nodes 'the counter should increase by {copies}'"):
|
||||
objects_metric_counter += copies
|
||||
self.check_object_metrics_total_and_container(container_nodes, cid, objects_metric_counter, copies)
|
||||
|
||||
with reporter.step(f"Select node to stop"):
|
||||
node_to_stop = container_nodes[0]
|
||||
alive_nodes = [node for node in container_nodes if node != node_to_stop]
|
||||
|
||||
with reporter.step(f"Stop the node, wait until the object is replicated to another node"):
|
||||
cluster_state_controller.stop_node_host(node_to_stop, "hard")
|
||||
|
||||
with reporter.step(f"Check metric in alive nodes 'the counter should increase by 1'"):
|
||||
self.check_object_metrics_container(alive_nodes, cid, copies)
|
||||
|
||||
with reporter.step("Start node"):
|
||||
cluster_state_controller.start_node_host(node_to_stop)
|
||||
|
||||
with reporter.step(f"Check metric in container nodes 'the counter doesn't change'"):
|
||||
self.check_object_metrics_total_and_container(container_nodes, cid, objects_metric_counter, copies)
|
||||
|
||||
with reporter.step("Delete container"):
|
||||
delete_container(default_wallet, cid, shell=self.shell, endpoint=self.cluster.default_rpc_endpoint)
|
|
@ -10,6 +10,7 @@ from frostfs_testlib.resources.error_patterns import (
|
|||
INVALID_OFFSET_SPECIFIER,
|
||||
INVALID_RANGE_OVERFLOW,
|
||||
INVALID_RANGE_ZERO_LENGTH,
|
||||
OBJECT_ALREADY_REMOVED,
|
||||
OUT_OF_RANGE,
|
||||
)
|
||||
from frostfs_testlib.shell import Shell
|
||||
|
@ -23,7 +24,7 @@ from frostfs_testlib.steps.cli.object import (
|
|||
search_object,
|
||||
)
|
||||
from frostfs_testlib.steps.complex_object_actions import get_complex_object_split_ranges
|
||||
from frostfs_testlib.steps.storage_object import delete_objects
|
||||
from frostfs_testlib.steps.storage_object import delete_object, delete_objects
|
||||
from frostfs_testlib.steps.storage_policy import get_complex_object_copies, get_simple_object_copies
|
||||
from frostfs_testlib.storage.cluster import Cluster
|
||||
from frostfs_testlib.storage.dataclasses.object_size import ObjectSize
|
||||
|
@ -94,11 +95,17 @@ def generate_ranges(
|
|||
scope="module"
|
||||
)
|
||||
def storage_objects(
|
||||
default_wallet: WalletInfo, client_shell: Shell, cluster: Cluster, object_size: ObjectSize, placement_policy: PlacementPolicy
|
||||
default_wallet: WalletInfo,
|
||||
client_shell: Shell,
|
||||
cluster: Cluster,
|
||||
object_size: ObjectSize,
|
||||
placement_policy: PlacementPolicy,
|
||||
) -> list[StorageObjectInfo]:
|
||||
wallet = default_wallet
|
||||
# Separate containers for complex/simple objects to avoid side-effects
|
||||
cid = create_container(wallet, shell=client_shell, rule=placement_policy.value, endpoint=cluster.default_rpc_endpoint)
|
||||
cid = create_container(
|
||||
wallet, shell=client_shell, rule=placement_policy.value, endpoint=cluster.default_rpc_endpoint
|
||||
)
|
||||
|
||||
file_path = generate_file(object_size.value)
|
||||
file_hash = get_file_hash(file_path)
|
||||
|
@ -209,6 +216,24 @@ class TestObjectApi(ClusterTestBase):
|
|||
)
|
||||
self.check_header_is_presented(head_info, storage_object_2.attributes)
|
||||
|
||||
@allure.title("Head deleted object with --raw arg (obj_size={object_size}, policy={placement_policy})")
|
||||
def test_object_head_raw(self, default_wallet: str, object_size: ObjectSize, placement_policy: PlacementPolicy):
|
||||
with reporter.step("Create container"):
|
||||
cid = create_container(
|
||||
default_wallet, self.shell, self.cluster.default_rpc_endpoint, placement_policy.value
|
||||
)
|
||||
|
||||
with reporter.step("Upload object"):
|
||||
file_path = generate_file(object_size.value)
|
||||
oid = put_object_to_random_node(default_wallet, file_path, cid, self.shell, self.cluster)
|
||||
|
||||
with reporter.step("Delete object"):
|
||||
delete_object(default_wallet, cid, oid, self.shell, self.cluster.default_rpc_endpoint)
|
||||
|
||||
with reporter.step("Call object head --raw and expect error"):
|
||||
with pytest.raises(Exception, match=OBJECT_ALREADY_REMOVED):
|
||||
head_object(default_wallet, cid, oid, self.shell, self.cluster.default_rpc_endpoint, is_raw=True)
|
||||
|
||||
@allure.title("Search objects by native API (obj_size={object_size}, policy={placement_policy})")
|
||||
def test_search_object_api(self, storage_objects: list[StorageObjectInfo]):
|
||||
"""
|
||||
|
|
|
@ -22,7 +22,6 @@ from frostfs_testlib.utils.file_utils import generate_file
|
|||
logger = logging.getLogger("NeoLogger")
|
||||
|
||||
|
||||
@pytest.mark.skip("Skipped temporarly")
|
||||
@pytest.mark.http_gate
|
||||
@pytest.mark.http_put
|
||||
class Test_http_bearer(ClusterTestBase):
|
||||
|
|
|
@ -102,7 +102,6 @@ class TestHttpGate(ClusterTestBase):
|
|||
)
|
||||
@allure.link("https://git.frostfs.info/TrueCloudLab/frostfs-http-gw#uploading", name="uploading")
|
||||
@allure.link("https://git.frostfs.info/TrueCloudLab/frostfs-http-gw#downloading", name="downloading")
|
||||
@pytest.mark.skip("Skipped temporarly")
|
||||
@pytest.mark.http_gate
|
||||
@pytest.mark.http_put
|
||||
class TestHttpPut(ClusterTestBase):
|
||||
|
|
|
@ -28,7 +28,6 @@ OBJECT_ALREADY_REMOVED_ERROR = "object already removed"
|
|||
logger = logging.getLogger("NeoLogger")
|
||||
|
||||
|
||||
@pytest.mark.skip("Skipped temporarly")
|
||||
@pytest.mark.http_gate
|
||||
@pytest.mark.http_put
|
||||
class Test_http_headers(ClusterTestBase):
|
||||
|
|
|
@ -13,7 +13,6 @@ from frostfs_testlib.utils.file_utils import generate_file
|
|||
logger = logging.getLogger("NeoLogger")
|
||||
|
||||
|
||||
@pytest.mark.skip("Skipped temporarly")
|
||||
@pytest.mark.http_gate
|
||||
@pytest.mark.http_put
|
||||
class Test_http_streaming(ClusterTestBase):
|
||||
|
|
|
@ -32,7 +32,6 @@ SYSTEM_EXPIRATION_TIMESTAMP = "System-Expiration-Timestamp"
|
|||
SYSTEM_EXPIRATION_RFC3339 = "System-Expiration-RFC3339"
|
||||
|
||||
|
||||
@pytest.mark.skip("Skipped temporarly")
|
||||
@pytest.mark.http_gate
|
||||
@pytest.mark.http_put
|
||||
class Test_http_system_header(ClusterTestBase):
|
||||
|
|
|
@ -17,15 +17,23 @@ PART_SIZE = 5 * 1024 * 1024
|
|||
class TestS3GateMultipart(ClusterTestBase):
|
||||
NO_SUCH_UPLOAD = "The upload ID may be invalid, or the upload may have been aborted or completed."
|
||||
|
||||
@allure.title("Object Multipart API (s3_client={s3_client})")
|
||||
@pytest.mark.parametrize("versioning_status", [VersioningStatus.ENABLED], indirect=True)
|
||||
def test_s3_object_multipart(self, s3_client: S3ClientWrapper, bucket: str):
|
||||
@allure.title("Object Multipart API (s3_client={s3_client}, bucket versioning = {versioning_status})")
|
||||
@pytest.mark.parametrize("versioning_status", [VersioningStatus.ENABLED, VersioningStatus.UNDEFINED], indirect=True)
|
||||
def test_s3_object_multipart(
|
||||
self, s3_client: S3ClientWrapper, bucket: str, default_wallet: WalletInfo, versioning_status: str
|
||||
):
|
||||
parts_count = 5
|
||||
file_name_large = generate_file(PART_SIZE * parts_count) # 5Mb - min part
|
||||
object_key = s3_helper.object_key_from_file_path(file_name_large)
|
||||
part_files = split_file(file_name_large, parts_count)
|
||||
parts = []
|
||||
|
||||
with reporter.step(f"Get related container_id for bucket"):
|
||||
for cluster_node in self.cluster.cluster_nodes:
|
||||
container_id = search_container_by_name(bucket, cluster_node)
|
||||
if container_id:
|
||||
break
|
||||
|
||||
with reporter.step("Upload first part"):
|
||||
upload_id = s3_client.create_multipart_upload(bucket, object_key)
|
||||
uploads = s3_client.list_multipart_uploads(bucket)
|
||||
|
@ -39,7 +47,11 @@ class TestS3GateMultipart(ClusterTestBase):
|
|||
etag = s3_client.upload_part(bucket, object_key, upload_id, part_id, file_path)
|
||||
parts.append((part_id, etag))
|
||||
got_parts = s3_client.list_parts(bucket, object_key, upload_id)
|
||||
s3_client.complete_multipart_upload(bucket, object_key, upload_id, parts)
|
||||
response = s3_client.complete_multipart_upload(bucket, object_key, upload_id, parts)
|
||||
|
||||
version_id = None
|
||||
if versioning_status == VersioningStatus.ENABLED:
|
||||
version_id = response["VersionId"]
|
||||
assert len(got_parts) == len(part_files), f"Expected {parts_count} parts, got\n{got_parts}"
|
||||
|
||||
with reporter.step("Check upload list is empty"):
|
||||
|
@ -50,6 +62,21 @@ class TestS3GateMultipart(ClusterTestBase):
|
|||
got_object = s3_client.get_object(bucket, object_key)
|
||||
assert get_file_hash(got_object) == get_file_hash(file_name_large)
|
||||
|
||||
if version_id:
|
||||
with reporter.step("Delete the object version"):
|
||||
s3_client.delete_object(bucket, object_key, version_id)
|
||||
else:
|
||||
with reporter.step("Delete the object"):
|
||||
s3_client.delete_object(bucket, object_key)
|
||||
|
||||
with reporter.step("List objects in the bucket, expect to be empty"):
|
||||
objects_list = s3_client.list_objects(bucket)
|
||||
assert not objects_list, f"Expected empty bucket, got {objects_list}"
|
||||
|
||||
with reporter.step("List objects in the container via rpc, expect to be empty"):
|
||||
objects = list_objects(default_wallet, self.shell, container_id, self.cluster.default_rpc_endpoint)
|
||||
assert len(objects) == 0, f"Expected no objects in container, got\n{objects}"
|
||||
|
||||
@allure.title("Abort Multipart Upload (s3_client={s3_client})")
|
||||
@pytest.mark.parametrize("versioning_status", [VersioningStatus.ENABLED], indirect=True)
|
||||
def test_s3_abort_multipart(
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
import json
|
||||
import os
|
||||
|
||||
import allure
|
||||
import pytest
|
||||
from botocore.exceptions import ClientError
|
||||
from frostfs_testlib import reporter
|
||||
from frostfs_testlib.s3 import S3ClientWrapper, VersioningStatus
|
||||
from frostfs_testlib.steps.cli.container import search_container_by_name
|
||||
|
@ -87,23 +89,24 @@ class TestS3GatePolicy(ClusterTestBase):
|
|||
|
||||
@allure.title("Bucket policy (s3_client={s3_client})")
|
||||
def test_s3_bucket_policy(self, s3_client: S3ClientWrapper):
|
||||
with reporter.step("Create bucket with default policy"):
|
||||
with reporter.step("Create bucket"):
|
||||
bucket = s3_client.create_bucket()
|
||||
s3_helper.set_bucket_versioning(s3_client, bucket, VersioningStatus.ENABLED)
|
||||
|
||||
with reporter.step("GetBucketPolicy"):
|
||||
s3_client.get_bucket_policy(bucket)
|
||||
with pytest.raises((RuntimeError, ClientError)):
|
||||
s3_client.get_bucket_policy(bucket)
|
||||
|
||||
with reporter.step("Put new policy"):
|
||||
custom_policy = f"file://{os.getcwd()}/pytest_tests/resources/files/bucket_policy.json"
|
||||
custom_policy = {
|
||||
"Version": "2008-10-17",
|
||||
"Version": "2012-10-17",
|
||||
"Id": "aaaa-bbbb-cccc-dddd",
|
||||
"Statement": [
|
||||
{
|
||||
"Sid": "AddPerm",
|
||||
"Effect": "Allow",
|
||||
"Principal": {"AWS": "*"},
|
||||
"Principal": "*",
|
||||
"Action": ["s3:GetObject"],
|
||||
"Resource": [f"arn:aws:s3:::{bucket}/*"],
|
||||
}
|
||||
|
@ -112,8 +115,16 @@ class TestS3GatePolicy(ClusterTestBase):
|
|||
|
||||
s3_client.put_bucket_policy(bucket, custom_policy)
|
||||
with reporter.step("GetBucketPolicy"):
|
||||
policy_1 = s3_client.get_bucket_policy(bucket)
|
||||
print(policy_1)
|
||||
returned_policy = json.loads(s3_client.get_bucket_policy(bucket))
|
||||
|
||||
assert returned_policy == custom_policy, "Wrong policy was received"
|
||||
|
||||
with reporter.step("Delete the policy"):
|
||||
s3_client.delete_bucket_policy(bucket)
|
||||
|
||||
with reporter.step("GetBucketPolicy"):
|
||||
with pytest.raises((RuntimeError, ClientError)):
|
||||
s3_client.get_bucket_policy(bucket)
|
||||
|
||||
@allure.title("Bucket CORS (s3_client={s3_client})")
|
||||
def test_s3_cors(self, s3_client: S3ClientWrapper):
|
||||
|
|
Loading…
Reference in a new issue