2022-07-05 07:18:37 +00:00
|
|
|
import allure
|
|
|
|
import pytest
|
2023-11-29 13:34:59 +00:00
|
|
|
from frostfs_testlib import reporter
|
2023-05-15 09:59:33 +00:00
|
|
|
from frostfs_testlib.steps.cli.object import put_object_to_random_node
|
|
|
|
from frostfs_testlib.steps.epoch import get_epoch
|
2024-12-17 15:17:10 +00:00
|
|
|
from frostfs_testlib.steps.http_gate import (
|
2022-12-08 13:03:27 +00:00
|
|
|
attr_into_header,
|
|
|
|
get_object_by_attr_and_verify_hashes,
|
2022-09-15 09:46:45 +00:00
|
|
|
get_via_http_curl,
|
|
|
|
get_via_http_gate,
|
|
|
|
get_via_zip_http_gate,
|
2022-12-08 13:03:27 +00:00
|
|
|
try_to_get_object_and_expect_error,
|
2022-09-15 09:46:45 +00:00
|
|
|
upload_via_http_gate,
|
|
|
|
upload_via_http_gate_curl,
|
2023-05-15 09:59:33 +00:00
|
|
|
verify_object_hash,
|
2022-09-15 09:46:45 +00:00
|
|
|
)
|
2023-08-02 11:54:03 +00:00
|
|
|
from frostfs_testlib.storage.dataclasses.object_size import ObjectSize
|
2024-11-26 16:42:53 +00:00
|
|
|
from frostfs_testlib.storage.dataclasses.wallet import WalletInfo
|
2023-05-15 09:59:33 +00:00
|
|
|
from frostfs_testlib.testing.cluster_test_base import ClusterTestBase
|
2024-11-26 16:42:53 +00:00
|
|
|
from frostfs_testlib.utils.file_utils import TestFile, generate_file, get_file_hash
|
2023-05-15 09:59:33 +00:00
|
|
|
|
2024-11-26 16:42:53 +00:00
|
|
|
from ....helpers.container_request import REP_1_1_1_PUBLIC, REP_2_2_2_PUBLIC, requires_container
|
2024-10-29 10:32:07 +00:00
|
|
|
from ....helpers.utility import wait_for_gc_pass_on_storage_nodes
|
2022-12-05 22:31:45 +00:00
|
|
|
|
2022-10-06 07:31:47 +00:00
|
|
|
OBJECT_NOT_FOUND_ERROR = "not found"
|
2022-07-05 07:18:37 +00:00
|
|
|
|
2022-09-15 09:46:45 +00:00
|
|
|
|
|
|
|
@allure.link(
|
2023-11-15 09:21:26 +00:00
|
|
|
"https://git.frostfs.info/TrueCloudLab/frostfs-http-gw#frostfs-http-gateway",
|
2023-01-09 12:46:03 +00:00
|
|
|
name="frostfs-http-gateway",
|
2022-09-15 09:46:45 +00:00
|
|
|
)
|
2023-11-15 09:21:26 +00:00
|
|
|
@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")
|
2024-10-11 09:30:23 +00:00
|
|
|
@pytest.mark.nightly
|
2022-11-10 05:27:52 +00:00
|
|
|
@pytest.mark.sanity
|
2022-07-05 07:18:37 +00:00
|
|
|
@pytest.mark.http_gate
|
2022-12-05 22:31:45 +00:00
|
|
|
class TestHttpGate(ClusterTestBase):
|
2024-11-26 16:42:53 +00:00
|
|
|
@allure.title("Put over gRPC, Get over HTTP (object_size={object_size})")
|
|
|
|
@requires_container(REP_1_1_1_PUBLIC)
|
|
|
|
def test_put_grpc_get_http(self, default_wallet: WalletInfo, container: str, test_file: TestFile):
|
2022-07-05 07:18:37 +00:00
|
|
|
"""
|
|
|
|
Test that object can be put using gRPC interface and get using HTTP.
|
|
|
|
|
|
|
|
Steps:
|
2024-11-26 16:42:53 +00:00
|
|
|
1. Create object.
|
|
|
|
2. Put object using gRPC (frostfs-cli).
|
|
|
|
3. Download object using HTTP gate (https://git.frostfs.info/TrueCloudLab/frostfs-http-gw#downloading).
|
|
|
|
4. Get object using gRPC (frostfs-cli).
|
|
|
|
5. Compare hashes for got object.
|
2022-07-05 07:18:37 +00:00
|
|
|
6. Compare hashes for got and original objects.
|
|
|
|
|
|
|
|
Expected result:
|
|
|
|
Hashes must be the same.
|
|
|
|
"""
|
|
|
|
|
2024-11-26 16:42:53 +00:00
|
|
|
with reporter.step("Put object using gRPC"):
|
|
|
|
object_id = put_object_to_random_node(default_wallet, test_file.path, container, self.shell, self.cluster)
|
2022-07-05 07:18:37 +00:00
|
|
|
|
2024-11-26 16:42:53 +00:00
|
|
|
with reporter.step("Get object and check hash"):
|
2023-05-15 09:59:33 +00:00
|
|
|
verify_object_hash(
|
2024-11-26 16:42:53 +00:00
|
|
|
object_id,
|
|
|
|
test_file.path,
|
|
|
|
default_wallet,
|
|
|
|
container,
|
|
|
|
self.shell,
|
|
|
|
self.cluster.storage_nodes,
|
|
|
|
self.cluster.cluster_nodes[0],
|
2022-12-08 13:03:27 +00:00
|
|
|
)
|
2022-07-05 07:18:37 +00:00
|
|
|
|
2023-08-08 13:40:00 +00:00
|
|
|
|
|
|
|
@allure.link(
|
2023-11-15 09:21:26 +00:00
|
|
|
"https://git.frostfs.info/TrueCloudLab/frostfs-http-gw#frostfs-http-gateway",
|
2023-08-08 13:40:00 +00:00
|
|
|
name="frostfs-http-gateway",
|
|
|
|
)
|
2023-11-15 09:21:26 +00:00
|
|
|
@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")
|
2023-08-08 13:40:00 +00:00
|
|
|
@pytest.mark.http_gate
|
|
|
|
@pytest.mark.http_put
|
|
|
|
class TestHttpPut(ClusterTestBase):
|
2023-11-15 09:21:26 +00:00
|
|
|
@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")
|
2024-11-26 16:42:53 +00:00
|
|
|
@allure.title("Put over HTTP, Get over HTTP (object_size={object_size})")
|
2022-11-10 05:27:52 +00:00
|
|
|
@pytest.mark.smoke
|
2024-11-26 16:42:53 +00:00
|
|
|
@requires_container(REP_2_2_2_PUBLIC)
|
|
|
|
def test_put_http_get_http(self, container: str, default_wallet: WalletInfo, test_file: TestFile):
|
2022-07-05 07:18:37 +00:00
|
|
|
"""
|
|
|
|
Test that object can be put and get using HTTP interface.
|
|
|
|
|
|
|
|
Steps:
|
|
|
|
1. Create simple and large objects.
|
2023-11-15 09:21:26 +00:00
|
|
|
2. Upload objects using HTTP (https://git.frostfs.info/TrueCloudLab/frostfs-http-gw#uploading).
|
|
|
|
3. Download objects using HTTP gate (https://git.frostfs.info/TrueCloudLab/frostfs-http-gw#downloading).
|
2022-07-05 07:18:37 +00:00
|
|
|
4. Compare hashes for got and original objects.
|
|
|
|
|
|
|
|
Expected result:
|
|
|
|
Hashes must be the same.
|
|
|
|
"""
|
|
|
|
|
2024-11-26 16:42:53 +00:00
|
|
|
with reporter.step("Put object using HTTP"):
|
|
|
|
object_id = upload_via_http_gate(container, test_file.path, self.cluster.default_http_gate_endpoint)
|
2022-07-05 07:18:37 +00:00
|
|
|
|
2024-11-26 16:42:53 +00:00
|
|
|
with reporter.step("Get object and check hash"):
|
2023-05-15 09:59:33 +00:00
|
|
|
verify_object_hash(
|
2024-11-26 16:42:53 +00:00
|
|
|
object_id,
|
|
|
|
test_file.path,
|
|
|
|
default_wallet,
|
|
|
|
container,
|
|
|
|
self.shell,
|
|
|
|
self.cluster.storage_nodes,
|
|
|
|
self.cluster.cluster_nodes[0],
|
2022-12-08 13:03:27 +00:00
|
|
|
)
|
2022-07-05 07:18:37 +00:00
|
|
|
|
2022-09-15 09:46:45 +00:00
|
|
|
@allure.link(
|
2023-11-15 09:21:26 +00:00
|
|
|
"https://git.frostfs.info/TrueCloudLab/frostfs-http-gw#by-attributes",
|
2023-01-09 12:46:03 +00:00
|
|
|
name="download by attributes",
|
2022-09-15 09:46:45 +00:00
|
|
|
)
|
2023-11-13 17:24:46 +00:00
|
|
|
@allure.title("Put over HTTP, Get over HTTP with {id} header")
|
2022-07-12 09:59:19 +00:00
|
|
|
@pytest.mark.parametrize(
|
2023-11-13 17:24:46 +00:00
|
|
|
"attributes,id",
|
2022-07-12 09:59:19 +00:00
|
|
|
[
|
2023-11-13 17:24:46 +00:00
|
|
|
({"fileName": "simple_obj_filename"}, "simple"),
|
|
|
|
({"file-Name": "simple obj filename"}, "hyphen"),
|
|
|
|
({"cat%jpeg": "cat%jpeg"}, "percent"),
|
2022-07-12 09:59:19 +00:00
|
|
|
],
|
2022-09-15 09:46:45 +00:00
|
|
|
ids=["simple", "hyphen", "percent"],
|
2022-07-12 09:59:19 +00:00
|
|
|
)
|
2024-11-26 16:42:53 +00:00
|
|
|
@requires_container(REP_2_2_2_PUBLIC)
|
|
|
|
def test_put_http_get_http_with_headers(self, container: str, attributes: dict, simple_object_size: ObjectSize, id: str):
|
2022-07-05 07:18:37 +00:00
|
|
|
"""
|
|
|
|
Test that object can be downloaded using different attributes in HTTP header.
|
|
|
|
|
|
|
|
Steps:
|
|
|
|
1. Create simple and large objects.
|
|
|
|
2. Upload objects using HTTP with particular attributes in the header.
|
2023-11-15 09:21:26 +00:00
|
|
|
3. Download objects by attributes using HTTP gate (https://git.frostfs.info/TrueCloudLab/frostfs-http-gw#by-attributes).
|
2022-07-05 07:18:37 +00:00
|
|
|
4. Compare hashes for got and original objects.
|
|
|
|
|
|
|
|
Expected result:
|
|
|
|
Hashes must be the same.
|
|
|
|
"""
|
2023-08-02 11:54:03 +00:00
|
|
|
file_path = generate_file(simple_object_size.value)
|
2022-07-05 07:18:37 +00:00
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Put objects using HTTP with attribute"):
|
2022-12-08 13:03:27 +00:00
|
|
|
headers = attr_into_header(attributes)
|
2024-11-26 16:42:53 +00:00
|
|
|
oid = upload_via_http_gate(container, file_path, self.cluster.default_http_gate_endpoint, headers)
|
2022-07-05 07:18:37 +00:00
|
|
|
|
2022-12-08 13:03:27 +00:00
|
|
|
get_object_by_attr_and_verify_hashes(
|
2024-11-26 16:42:53 +00:00
|
|
|
oid,
|
|
|
|
file_path,
|
|
|
|
container,
|
|
|
|
attributes,
|
|
|
|
self.cluster.cluster_nodes[0],
|
2022-12-08 13:03:27 +00:00
|
|
|
)
|
2022-07-05 07:18:37 +00:00
|
|
|
|
2023-09-08 10:35:34 +00:00
|
|
|
@allure.title("Expiration-Epoch in HTTP header (epoch_gap={epoch_gap})")
|
2023-03-14 11:55:01 +00:00
|
|
|
@pytest.mark.parametrize("epoch_gap", [0, 1])
|
2024-11-26 16:42:53 +00:00
|
|
|
@requires_container(REP_2_2_2_PUBLIC)
|
|
|
|
def test_expiration_epoch_in_http(self, container: str, simple_object_size: ObjectSize, epoch_gap: int):
|
2022-12-05 22:31:45 +00:00
|
|
|
http_endpoint = self.cluster.default_http_gate_endpoint
|
2023-03-14 11:55:01 +00:00
|
|
|
min_valid_epoch = get_epoch(self.shell, self.cluster) + epoch_gap
|
2022-12-05 22:31:45 +00:00
|
|
|
|
2023-08-02 11:54:03 +00:00
|
|
|
file_path = generate_file(simple_object_size.value)
|
2023-03-14 11:55:01 +00:00
|
|
|
oids_to_be_expired = []
|
|
|
|
oids_to_be_valid = []
|
2022-07-05 07:18:37 +00:00
|
|
|
|
2023-03-14 11:55:01 +00:00
|
|
|
for gap_until in (0, 1, 2, 100):
|
|
|
|
valid_until = min_valid_epoch + gap_until
|
|
|
|
headers = {"X-Attribute-System-Expiration-Epoch": str(valid_until)}
|
2022-07-05 07:18:37 +00:00
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Put objects using HTTP with attribute Expiration-Epoch"):
|
2023-03-14 11:55:01 +00:00
|
|
|
oid = upload_via_http_gate(
|
2024-11-26 16:42:53 +00:00
|
|
|
cid=container,
|
2023-07-24 06:55:14 +00:00
|
|
|
path=file_path,
|
|
|
|
headers=headers,
|
|
|
|
endpoint=http_endpoint,
|
2022-12-05 22:31:45 +00:00
|
|
|
)
|
2023-03-14 11:55:01 +00:00
|
|
|
if get_epoch(self.shell, self.cluster) + 1 <= valid_until:
|
|
|
|
oids_to_be_valid.append(oid)
|
|
|
|
else:
|
|
|
|
oids_to_be_expired.append(oid)
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("This object can be got"):
|
2024-11-26 16:42:53 +00:00
|
|
|
get_via_http_gate(container, oid, self.cluster.cluster_nodes[0])
|
2022-07-05 07:18:37 +00:00
|
|
|
|
2023-03-14 11:55:01 +00:00
|
|
|
self.tick_epoch()
|
2022-07-21 13:52:49 +00:00
|
|
|
|
2023-03-14 11:55:01 +00:00
|
|
|
# Wait for GC, because object with expiration is counted as alive until GC removes it
|
|
|
|
wait_for_gc_pass_on_storage_nodes()
|
2022-07-05 07:18:37 +00:00
|
|
|
|
2023-03-14 11:55:01 +00:00
|
|
|
for oid in oids_to_be_expired:
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step(f"{oid} shall be expired and cannot be got"):
|
2022-12-08 13:03:27 +00:00
|
|
|
try_to_get_object_and_expect_error(
|
2024-11-26 16:42:53 +00:00
|
|
|
cid=container,
|
2022-12-08 13:03:27 +00:00
|
|
|
oid=oid,
|
2024-02-14 13:20:06 +00:00
|
|
|
node=self.cluster.cluster_nodes[0],
|
2022-12-08 13:03:27 +00:00
|
|
|
error_pattern=OBJECT_NOT_FOUND_ERROR,
|
2022-07-12 09:59:19 +00:00
|
|
|
)
|
2023-03-14 11:55:01 +00:00
|
|
|
for oid in oids_to_be_valid:
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step(f"{oid} shall be valid and can be got"):
|
2024-11-26 16:42:53 +00:00
|
|
|
get_via_http_gate(cid=container, oid=oid, node=self.cluster.cluster_nodes[0])
|
2022-07-05 07:18:37 +00:00
|
|
|
|
2023-09-08 10:35:34 +00:00
|
|
|
@allure.title("Zip in HTTP header")
|
2024-11-26 16:42:53 +00:00
|
|
|
@requires_container(REP_2_2_2_PUBLIC)
|
|
|
|
def test_zip_in_http(self, container: str, complex_object_size: ObjectSize, simple_object_size: ObjectSize):
|
2023-08-02 11:54:03 +00:00
|
|
|
file_path_simple = generate_file(simple_object_size.value)
|
|
|
|
file_path_large = generate_file(complex_object_size.value)
|
2022-09-15 09:46:45 +00:00
|
|
|
common_prefix = "my_files"
|
2022-07-05 07:18:37 +00:00
|
|
|
|
2022-09-15 09:46:45 +00:00
|
|
|
headers1 = {"X-Attribute-FilePath": f"{common_prefix}/file1"}
|
|
|
|
headers2 = {"X-Attribute-FilePath": f"{common_prefix}/file2"}
|
2022-07-05 07:18:37 +00:00
|
|
|
|
2022-12-05 22:31:45 +00:00
|
|
|
upload_via_http_gate(
|
2024-11-26 16:42:53 +00:00
|
|
|
cid=container,
|
2022-12-05 22:31:45 +00:00
|
|
|
path=file_path_simple,
|
|
|
|
headers=headers1,
|
|
|
|
endpoint=self.cluster.default_http_gate_endpoint,
|
|
|
|
)
|
2024-11-26 16:42:53 +00:00
|
|
|
upload_via_http_gate(container, file_path_large, headers2, self.cluster.default_http_gate_endpoint)
|
|
|
|
upload_via_http_gate(container, file_path_large, headers2, self.cluster.default_http_gate_endpoint)
|
2022-07-05 07:18:37 +00:00
|
|
|
|
2024-11-26 16:42:53 +00:00
|
|
|
dir_path = get_via_zip_http_gate(cid=container, prefix=common_prefix, node=self.cluster.cluster_nodes[0])
|
2022-07-05 07:18:37 +00:00
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Verify hashes"):
|
2022-09-15 09:46:45 +00:00
|
|
|
assert get_file_hash(f"{dir_path}/file1") == get_file_hash(file_path_simple)
|
|
|
|
assert get_file_hash(f"{dir_path}/file2") == get_file_hash(file_path_large)
|
2022-07-05 07:18:37 +00:00
|
|
|
|
2023-08-07 09:43:16 +00:00
|
|
|
@allure.title("Put over HTTP/Curl, Get over HTTP/Curl for large object")
|
2024-11-26 16:42:53 +00:00
|
|
|
@requires_container(REP_2_2_2_PUBLIC)
|
|
|
|
def test_put_http_get_http_large_file(self, default_wallet: WalletInfo, container: str, complex_object_size: ObjectSize):
|
2022-07-05 07:18:37 +00:00
|
|
|
"""
|
2022-11-10 05:27:52 +00:00
|
|
|
This test checks upload and download using curl with 'large' object.
|
|
|
|
Large is object with size up to 20Mb.
|
2022-07-05 07:18:37 +00:00
|
|
|
"""
|
2023-08-02 11:54:03 +00:00
|
|
|
file_path = generate_file(complex_object_size.value)
|
2022-07-05 07:18:37 +00:00
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Put objects using HTTP"):
|
2024-11-26 16:42:53 +00:00
|
|
|
oid_gate = upload_via_http_gate(cid=container, path=file_path, endpoint=self.cluster.default_http_gate_endpoint)
|
2022-12-05 22:31:45 +00:00
|
|
|
oid_curl = upload_via_http_gate_curl(
|
2024-11-26 16:42:53 +00:00
|
|
|
cid=container,
|
2022-12-05 22:31:45 +00:00
|
|
|
filepath=file_path,
|
|
|
|
endpoint=self.cluster.default_http_gate_endpoint,
|
|
|
|
)
|
2022-07-05 07:18:37 +00:00
|
|
|
|
2023-05-15 09:59:33 +00:00
|
|
|
verify_object_hash(
|
2022-12-08 13:03:27 +00:00
|
|
|
oid=oid_gate,
|
|
|
|
file_name=file_path,
|
2024-11-26 16:42:53 +00:00
|
|
|
wallet=default_wallet,
|
|
|
|
cid=container,
|
2022-12-08 13:03:27 +00:00
|
|
|
shell=self.shell,
|
|
|
|
nodes=self.cluster.storage_nodes,
|
2024-02-14 13:20:06 +00:00
|
|
|
request_node=self.cluster.cluster_nodes[0],
|
2022-12-08 13:03:27 +00:00
|
|
|
)
|
2023-05-15 09:59:33 +00:00
|
|
|
verify_object_hash(
|
2022-12-08 13:03:27 +00:00
|
|
|
oid=oid_curl,
|
|
|
|
file_name=file_path,
|
2024-11-26 16:42:53 +00:00
|
|
|
wallet=default_wallet,
|
|
|
|
cid=container,
|
2022-12-08 13:03:27 +00:00
|
|
|
shell=self.shell,
|
|
|
|
nodes=self.cluster.storage_nodes,
|
2024-02-14 13:20:06 +00:00
|
|
|
request_node=self.cluster.cluster_nodes[0],
|
2022-10-13 16:13:45 +00:00
|
|
|
object_getter=get_via_http_curl,
|
|
|
|
)
|
2022-07-05 07:18:37 +00:00
|
|
|
|
2024-11-26 16:42:53 +00:00
|
|
|
@allure.title("Put/Get over HTTP using Curl utility (object_size={object_size})")
|
|
|
|
@requires_container(REP_2_2_2_PUBLIC)
|
|
|
|
def test_put_http_get_http_curl(self, default_wallet: WalletInfo, container: str, test_file: TestFile):
|
2022-07-05 07:18:37 +00:00
|
|
|
"""
|
|
|
|
Test checks upload and download over HTTP using curl utility.
|
|
|
|
"""
|
|
|
|
|
2024-11-26 16:42:53 +00:00
|
|
|
with reporter.step("Put object using curl utility"):
|
|
|
|
object_id = upload_via_http_gate_curl(container, test_file.path, self.cluster.default_http_gate_endpoint)
|
2022-07-05 07:18:37 +00:00
|
|
|
|
2024-11-26 16:42:53 +00:00
|
|
|
with reporter.step("Get object and check hash"):
|
2023-05-15 09:59:33 +00:00
|
|
|
verify_object_hash(
|
2024-11-26 16:42:53 +00:00
|
|
|
object_id,
|
|
|
|
test_file.path,
|
|
|
|
default_wallet,
|
|
|
|
container,
|
|
|
|
self.shell,
|
|
|
|
self.cluster.storage_nodes,
|
|
|
|
self.cluster.cluster_nodes[0],
|
|
|
|
get_via_http_curl,
|
2022-10-13 16:13:45 +00:00
|
|
|
)
|