forked from TrueCloudLab/frostfs-testcases
Compare commits
2 commits
52eafc3d70
...
930176f544
Author | SHA1 | Date | |
---|---|---|---|
930176f544 | |||
6b83a89b94 |
3 changed files with 101 additions and 18 deletions
|
@ -4,11 +4,11 @@ import allure
|
||||||
from frostfs_testlib.testing.parallel import parallel
|
from frostfs_testlib.testing.parallel import parallel
|
||||||
import pytest
|
import pytest
|
||||||
from frostfs_testlib import reporter
|
from frostfs_testlib import reporter
|
||||||
from frostfs_testlib.steps.cli.container import create_container, search_nodes_with_container
|
from frostfs_testlib.steps.cli.container import create_container, delete_container, search_nodes_with_container, wait_for_container_deletion
|
||||||
from frostfs_testlib.steps.cli.object import delete_object, head_object, put_object_to_random_node
|
from frostfs_testlib.steps.cli.object import delete_object, head_object, put_object_to_random_node
|
||||||
from frostfs_testlib.steps.metrics import check_metrics_counter, get_metrics_value
|
from frostfs_testlib.steps.metrics import calc_metrics_count_from_stdout, check_metrics_counter, get_metrics_value
|
||||||
from frostfs_testlib.steps.storage_policy import get_nodes_with_object
|
from frostfs_testlib.steps.storage_policy import get_nodes_with_object
|
||||||
from frostfs_testlib.storage.cluster import Cluster
|
from frostfs_testlib.storage.cluster import Cluster, ClusterNode
|
||||||
from frostfs_testlib.storage.dataclasses.object_size import ObjectSize
|
from frostfs_testlib.storage.dataclasses.object_size import ObjectSize
|
||||||
from frostfs_testlib.storage.dataclasses.wallet import WalletInfo
|
from frostfs_testlib.storage.dataclasses.wallet import WalletInfo
|
||||||
from frostfs_testlib.testing.cluster_test_base import ClusterTestBase
|
from frostfs_testlib.testing.cluster_test_base import ClusterTestBase
|
||||||
|
@ -25,6 +25,14 @@ class TestContainerMetrics(ClusterTestBase):
|
||||||
oid = put_object_to_random_node(wallet, file_path, cid, self.shell, self.cluster)
|
oid = put_object_to_random_node(wallet, file_path, cid, self.shell, self.cluster)
|
||||||
return oid
|
return oid
|
||||||
|
|
||||||
|
@reporter.step("Get metrics value from node")
|
||||||
|
def get_metrics_search_by_greps_parallel(self, node: ClusterNode, **greps):
|
||||||
|
try:
|
||||||
|
content_stdout = node.metrics.storage.get_metrics_search_by_greps(greps)
|
||||||
|
return calc_metrics_count_from_stdout(content_stdout)
|
||||||
|
except Exception as e:
|
||||||
|
return None
|
||||||
|
|
||||||
@allure.title("Container metrics (obj_size={object_size},policy={policy})")
|
@allure.title("Container metrics (obj_size={object_size},policy={policy})")
|
||||||
@pytest.mark.parametrize("placement_policy, policy", [("REP 2 IN X CBF 2 SELECT 2 FROM * AS X", "REP"), ("EC 1.1 CBF 1", "EC")])
|
@pytest.mark.parametrize("placement_policy, policy", [("REP 2 IN X CBF 2 SELECT 2 FROM * AS X", "REP"), ("EC 1.1 CBF 1", "EC")])
|
||||||
def test_container_metrics(
|
def test_container_metrics(
|
||||||
|
@ -164,3 +172,43 @@ class TestContainerMetrics(ClusterTestBase):
|
||||||
for act_metric in metrics_value_nodes:
|
for act_metric in metrics_value_nodes:
|
||||||
assert act_metric >= 0, "Metrics value is negative"
|
assert act_metric >= 0, "Metrics value is negative"
|
||||||
assert sum(metrics_value_nodes) // len(self.cluster.cluster_nodes) == tombstones_size, "tomstone size of objects not correct"
|
assert sum(metrics_value_nodes) // len(self.cluster.cluster_nodes) == tombstones_size, "tomstone size of objects not correct"
|
||||||
|
|
||||||
|
|
||||||
|
@allure.title("Container metrics (policy={policy})")
|
||||||
|
@pytest.mark.parametrize("placement_policy, policy", [("REP 2 IN X CBF 2 SELECT 2 FROM * AS X", "REP"), ("EC 1.1 CBF 1", "EC")])
|
||||||
|
def test_container_metrics_delete_complex_objects(
|
||||||
|
self,
|
||||||
|
complex_object_size: ObjectSize,
|
||||||
|
default_wallet: WalletInfo,
|
||||||
|
cluster: Cluster,
|
||||||
|
placement_policy: str,
|
||||||
|
policy: str
|
||||||
|
):
|
||||||
|
copies = 2 if policy == "REP" else 1
|
||||||
|
objects_count = 2
|
||||||
|
metric_name = "frostfs_node_engine_container_objects_total"
|
||||||
|
with reporter.step(f"Create container"):
|
||||||
|
cid = create_container(default_wallet, self.shell, cluster.default_rpc_endpoint, rule=placement_policy)
|
||||||
|
|
||||||
|
with reporter.step(f"Put {objects_count} objects"):
|
||||||
|
files_path = [generate_file(complex_object_size.value) for _ in range(objects_count)]
|
||||||
|
futures = parallel(self.put_object_parallel, files_path, wallet=default_wallet, cid=cid)
|
||||||
|
oids = [future.result() for future in futures]
|
||||||
|
|
||||||
|
with reporter.step(f"Check metrics value in each nodes, should be {objects_count} for 'user'"):
|
||||||
|
check_metrics_counter(cluster.cluster_nodes, counter_exp=objects_count * copies, command=metric_name, cid=cid, type="user")
|
||||||
|
|
||||||
|
with reporter.step("Delete objects and container"):
|
||||||
|
for oid in oids:
|
||||||
|
delete_object(default_wallet, cid, oid, self.shell, cluster.default_rpc_endpoint)
|
||||||
|
|
||||||
|
delete_container(default_wallet, cid, self.shell, cluster.default_rpc_endpoint)
|
||||||
|
|
||||||
|
with reporter.step("Tick epoch and check container was deleted"):
|
||||||
|
self.tick_epoch()
|
||||||
|
wait_for_container_deletion(default_wallet, cid, shell=self.shell, endpoint=cluster.default_rpc_endpoint)
|
||||||
|
|
||||||
|
with reporter.step(f"Check metrics value in each nodes, should not be show any result"):
|
||||||
|
futures = parallel(self.get_metrics_search_by_greps_parallel, cluster.cluster_nodes, command=metric_name, cid=cid)
|
||||||
|
metrics_results = [future.result() for future in futures if future.result() is not None]
|
||||||
|
assert len(metrics_results) == 0, f"Metrics value is not empty in Prometheus, actual value in nodes: {metrics_results}"
|
||||||
|
|
|
@ -151,7 +151,7 @@ class TestS3GateBucket:
|
||||||
|
|
||||||
@allure.title("Create bucket with valid name length (s3_client={s3_client}, length={length})")
|
@allure.title("Create bucket with valid name length (s3_client={s3_client}, length={length})")
|
||||||
@pytest.mark.parametrize("length", [3, 4, 32, 62, 63])
|
@pytest.mark.parametrize("length", [3, 4, 32, 62, 63])
|
||||||
def test_create_bucket_with_valid_length(self, s3_client: S3ClientWrapper, length: int):
|
def test_s3_create_bucket_with_valid_length(self, s3_client: S3ClientWrapper, length: int):
|
||||||
bucket_name = string_utils.random_string(length, VALID_SYMBOLS_WITHOUT_DOT)
|
bucket_name = string_utils.random_string(length, VALID_SYMBOLS_WITHOUT_DOT)
|
||||||
while not (bucket_name[0].isalnum() and bucket_name[-1].isalnum()):
|
while not (bucket_name[0].isalnum() and bucket_name[-1].isalnum()):
|
||||||
bucket_name = string_utils.random_string(length, VALID_SYMBOLS_WITHOUT_DOT)
|
bucket_name = string_utils.random_string(length, VALID_SYMBOLS_WITHOUT_DOT)
|
||||||
|
@ -164,7 +164,7 @@ class TestS3GateBucket:
|
||||||
|
|
||||||
@allure.title("[NEGATIVE] Bucket with invalid name length should not be created (s3_client={s3_client}, length={length})")
|
@allure.title("[NEGATIVE] Bucket with invalid name length should not be created (s3_client={s3_client}, length={length})")
|
||||||
@pytest.mark.parametrize("length", [2, 64, 254, 255, 256])
|
@pytest.mark.parametrize("length", [2, 64, 254, 255, 256])
|
||||||
def test_create_bucket_with_invalid_length(self, s3_client: S3ClientWrapper, length: int):
|
def test_s3_create_bucket_with_invalid_length(self, s3_client: S3ClientWrapper, length: int):
|
||||||
bucket_name = string_utils.random_string(length, VALID_SYMBOLS_WITHOUT_DOT)
|
bucket_name = string_utils.random_string(length, VALID_SYMBOLS_WITHOUT_DOT)
|
||||||
while not (bucket_name[0].isalnum() and bucket_name[-1].isalnum()):
|
while not (bucket_name[0].isalnum() and bucket_name[-1].isalnum()):
|
||||||
bucket_name = string_utils.random_string(length, VALID_SYMBOLS_WITHOUT_DOT)
|
bucket_name = string_utils.random_string(length, VALID_SYMBOLS_WITHOUT_DOT)
|
||||||
|
@ -180,17 +180,17 @@ class TestS3GateBucket:
|
||||||
"BUCKET-1",
|
"BUCKET-1",
|
||||||
"buckeT-2",
|
"buckeT-2",
|
||||||
# The following case for AWS CLI is not handled correctly
|
# The following case for AWS CLI is not handled correctly
|
||||||
# "-bucket",
|
# "-bucket-3",
|
||||||
"bucket-3-",
|
"bucket-4-",
|
||||||
".bucket-4",
|
".bucket-5",
|
||||||
"bucket-5.",
|
"bucket-6.",
|
||||||
"bucket..6",
|
"bucket..7",
|
||||||
"bucket+7",
|
"bucket+8",
|
||||||
"bucket_8",
|
"bucket_9",
|
||||||
"bucket 9",
|
"bucket 10",
|
||||||
"127.10.5.10",
|
"127.10.5.11",
|
||||||
"xn--bucket-11",
|
"xn--bucket-12",
|
||||||
"bucket-12-s3alias",
|
"bucket-13-s3alias",
|
||||||
# The following names can be used in FrostFS but are prohibited by the AWS specification.
|
# The following names can be used in FrostFS but are prohibited by the AWS specification.
|
||||||
# "sthree-bucket-14"
|
# "sthree-bucket-14"
|
||||||
# "sthree-configurator-bucket-15"
|
# "sthree-configurator-bucket-15"
|
||||||
|
@ -201,7 +201,42 @@ class TestS3GateBucket:
|
||||||
# "bucket-20.mrap"
|
# "bucket-20.mrap"
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test_create_bucket_with_invalid_name(self, s3_client: S3ClientWrapper, bucket_name: str):
|
def test_s3_create_bucket_with_invalid_name(self, s3_client: S3ClientWrapper, bucket_name: str):
|
||||||
with reporter.step("Create bucket with invalid name and catch exception"):
|
with reporter.step("Create bucket with invalid name and catch exception"):
|
||||||
with pytest.raises(Exception, match=".*(?:InvalidBucketName|Invalid bucket name).*"):
|
with pytest.raises(Exception, match=".*(?:InvalidBucketName|Invalid bucket name).*"):
|
||||||
s3_client.create_bucket(bucket_name)
|
s3_client.create_bucket(bucket_name)
|
||||||
|
|
||||||
|
@allure.title("Non-empty bucket is available after attempting to delete it (s3_client={s3_client})")
|
||||||
|
def test_s3_check_availability_non_empty_bucket_after_deleting(
|
||||||
|
self,
|
||||||
|
s3_client: S3ClientWrapper,
|
||||||
|
simple_object_size: ObjectSize,
|
||||||
|
):
|
||||||
|
bucket = string_utils.unique_name("bucket-")
|
||||||
|
object_path = generate_file(simple_object_size.value)
|
||||||
|
object_name = s3_helper.object_key_from_file_path(object_path)
|
||||||
|
|
||||||
|
with reporter.step("Create bucket"):
|
||||||
|
s3_client.create_bucket(bucket)
|
||||||
|
|
||||||
|
with reporter.step("Check that bucket is created"):
|
||||||
|
buckets = s3_client.list_buckets()
|
||||||
|
assert buckets, f"Expected non-empty bucket list, got {buckets}"
|
||||||
|
assert bucket in buckets, f"Bucket {bucket} not found in bucket list {buckets}"
|
||||||
|
|
||||||
|
with reporter.step("Put object into bucket"):
|
||||||
|
s3_client.put_object(bucket, object_path)
|
||||||
|
|
||||||
|
with reporter.step("Check that object appears in bucket"):
|
||||||
|
objects = s3_client.list_objects(bucket)
|
||||||
|
assert objects, f"Expected bucket with object, got empty {objects}"
|
||||||
|
assert object_name in objects, f"Object {object_name} not found in bucket object list {objects}"
|
||||||
|
|
||||||
|
with reporter.step("Try to delete not empty bucket and get error"):
|
||||||
|
with pytest.raises(Exception, match=r".*The bucket you tried to delete is not empty.*"):
|
||||||
|
s3_client.delete_bucket(bucket)
|
||||||
|
|
||||||
|
with reporter.step("Check bucket availability"):
|
||||||
|
objects = s3_client.list_objects(bucket)
|
||||||
|
assert objects, f"Expected bucket with object, got empty {objects}"
|
||||||
|
assert object_name in objects, f"Object {object_name} not found in bucket object list {objects}"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
allure-pytest==2.13.2
|
allure-pytest==2.13.2
|
||||||
allure-python-commons==2.13.2
|
allure-python-commons==2.13.2
|
||||||
base58==2.1.0
|
base58==2.1.0
|
||||||
boto3==1.16.33
|
boto3==1.35.30
|
||||||
botocore==1.19.33
|
botocore==1.19.33
|
||||||
configobj==5.0.6
|
configobj==5.0.6
|
||||||
neo-mamba==1.0.0
|
neo-mamba==1.0.0
|
||||||
|
|
Loading…
Reference in a new issue