From 0e1d34b2f76050e3cca20ffee8c270065e0cf7f7 Mon Sep 17 00:00:00 2001 From: Yaroslava Lukoyanova Date: Mon, 24 Jul 2023 09:55:14 +0300 Subject: [PATCH] Added http hostname as a header to all http calls --- .devenv.hosting.yaml | 8 +++++ .../services/http_gate/test_http_gate.py | 34 ++++++++++++++++--- .../services/http_gate/test_http_headers.py | 5 +++ .../services/http_gate/test_http_object.py | 4 +++ .../services/http_gate/test_http_streaming.py | 1 + .../http_gate/test_http_system_header.py | 5 +++ 6 files changed, 53 insertions(+), 4 deletions(-) diff --git a/.devenv.hosting.yaml b/.devenv.hosting.yaml index 320f2bb..363dee8 100644 --- a/.devenv.hosting.yaml +++ b/.devenv.hosting.yaml @@ -14,6 +14,8 @@ hosts: endpoint_data0: s01.frostfs.devenv:8080 control_endpoint: s01.frostfs.devenv:8081 un_locode: "RU MOW" + http_hostname: "no_hostname" + s3_hostname: "no_hostname" - name: s02 attributes: container_name: s02 @@ -26,6 +28,8 @@ hosts: endpoint_data0: s02.frostfs.devenv:8080 control_endpoint: s02.frostfs.devenv:8081 un_locode: "RU LED" + http_hostname: "no_hostname" + s3_hostname: "no_hostname" - name: s03 attributes: container_name: s03 @@ -38,6 +42,8 @@ hosts: endpoint_data0: s03.frostfs.devenv:8080 control_endpoint: s03.frostfs.devenv:8081 un_locode: "SE STO" + http_hostname: "no_hostname" + s3_hostname: "no_hostname" - name: s04 attributes: container_name: s04 @@ -50,6 +56,8 @@ hosts: endpoint_data0: s04.frostfs.devenv:8080 control_endpoint: s04.frostfs.devenv:8081 un_locode: "FI HEL" + http_hostname: "no_hostname" + s3_hostname: "no_hostname" - name: s3-gate01 attributes: container_name: s3_gate diff --git a/pytest_tests/testsuites/services/http_gate/test_http_gate.py b/pytest_tests/testsuites/services/http_gate/test_http_gate.py index 1c0fa8c..600384c 100644 --- a/pytest_tests/testsuites/services/http_gate/test_http_gate.py +++ b/pytest_tests/testsuites/services/http_gate/test_http_gate.py @@ -94,6 +94,7 @@ class TestHttpGate(ClusterTestBase): shell=self.shell, nodes=self.cluster.storage_nodes, endpoint=self.cluster.default_http_gate_endpoint, + http_hostname=self.cluster.default_http_hostname, ) @allure.link("https://github.com/TrueCloudLab/frostfs-http-gw#uploading", name="uploading") @@ -142,6 +143,7 @@ class TestHttpGate(ClusterTestBase): shell=self.shell, nodes=self.cluster.storage_nodes, endpoint=self.cluster.default_http_gate_endpoint, + hostname=self.cluster.default_http_hostname, ) @allure.link( @@ -196,8 +198,10 @@ class TestHttpGate(ClusterTestBase): cid=cid, attrs=attributes, endpoint=self.cluster.default_http_gate_endpoint, + http_hostname=self.cluster.default_http_hostname, ) + @pytest.mark.skip("Skipped due to deprecated PUT via http") @allure.title("Test Expiration-Epoch in HTTP header") @pytest.mark.parametrize("epoch_gap", [0, 1]) def test_expiration_epoch_in_http(self, simple_object_size: int, epoch_gap): @@ -222,14 +226,23 @@ class TestHttpGate(ClusterTestBase): with allure.step("Put objects using HTTP with attribute Expiration-Epoch"): oid = upload_via_http_gate( - cid=cid, path=file_path, headers=headers, endpoint=http_endpoint + cid=cid, + path=file_path, + headers=headers, + endpoint=http_endpoint, + http_hostname=self.cluster.default_http_hostname, ) if get_epoch(self.shell, self.cluster) + 1 <= valid_until: oids_to_be_valid.append(oid) else: oids_to_be_expired.append(oid) with allure.step("This object can be got"): - get_via_http_gate(cid=cid, oid=oid, endpoint=http_endpoint) + get_via_http_gate( + cid=cid, + oid=oid, + endpoint=http_endpoint, + http_hostname=self.cluster.default_http_hostname, + ) self.tick_epoch() @@ -243,11 +256,18 @@ class TestHttpGate(ClusterTestBase): oid=oid, error_pattern=OBJECT_NOT_FOUND_ERROR, endpoint=self.cluster.default_http_gate_endpoint, + http_hostname=self.cluster.default_http_hostname, ) for oid in oids_to_be_valid: with allure.step(f"{oid} shall be valid and can be got"): - get_via_http_gate(cid=cid, oid=oid, endpoint=http_endpoint) + get_via_http_gate( + cid=cid, + oid=oid, + endpoint=http_endpoint, + http_hostname=self.cluster.default_http_hostname, + ) + @pytest.mark.skip("Skipped due to deprecated PUT via http") @allure.title("Test Zip in HTTP header") def test_zip_in_http(self, complex_object_size: int, simple_object_size: int): cid = create_container( @@ -279,7 +299,10 @@ class TestHttpGate(ClusterTestBase): ) dir_path = get_via_zip_http_gate( - cid=cid, prefix=common_prefix, endpoint=self.cluster.default_http_gate_endpoint + cid=cid, + prefix=common_prefix, + endpoint=self.cluster.default_http_gate_endpoint, + http_hostname=self.cluster.default_http_hostname, ) with allure.step("Verify hashes"): @@ -323,6 +346,7 @@ class TestHttpGate(ClusterTestBase): shell=self.shell, nodes=self.cluster.storage_nodes, endpoint=self.cluster.default_http_gate_endpoint, + hostname=self.cluster.default_http_hostname, ) verify_object_hash( oid=oid_curl, @@ -332,6 +356,7 @@ class TestHttpGate(ClusterTestBase): shell=self.shell, nodes=self.cluster.storage_nodes, endpoint=self.cluster.default_http_gate_endpoint, + http_hostname=self.cluster.default_http_hostname, object_getter=get_via_http_curl, ) @@ -371,5 +396,6 @@ class TestHttpGate(ClusterTestBase): shell=self.shell, nodes=self.cluster.storage_nodes, endpoint=self.cluster.default_http_gate_endpoint, + http_hostname=self.cluster.default_http_hostname, object_getter=get_via_http_curl, ) diff --git a/pytest_tests/testsuites/services/http_gate/test_http_headers.py b/pytest_tests/testsuites/services/http_gate/test_http_headers.py index a6a26c5..b7863e7 100644 --- a/pytest_tests/testsuites/services/http_gate/test_http_headers.py +++ b/pytest_tests/testsuites/services/http_gate/test_http_headers.py @@ -105,6 +105,7 @@ class Test_http_headers(ClusterTestBase): cid=storage_object_1.cid, attrs={"Chapter2": storage_object_1.attributes["Chapter2"]}, endpoint=self.cluster.default_http_gate_endpoint, + http_hostname=self.cluster.default_http_hostname, ) @allure.title("Test get object2 with different attributes, then delete object2 and get object1") @@ -138,6 +139,7 @@ class Test_http_headers(ClusterTestBase): cid=storage_object_2.cid, attrs=attributes, endpoint=self.cluster.default_http_gate_endpoint, + http_hostname=self.cluster.default_http_hostname, ) with allure.step("Delete object#2 and verify is the container deleted"): delete_object( @@ -152,6 +154,7 @@ class Test_http_headers(ClusterTestBase): oid=storage_object_2.oid, error_pattern=OBJECT_ALREADY_REMOVED_ERROR, endpoint=self.cluster.default_http_gate_endpoint, + http_hostname=self.cluster.default_http_hostname, ) storage_objects_with_attributes.remove(storage_object_2) @@ -165,6 +168,7 @@ class Test_http_headers(ClusterTestBase): cid=storage_object_1.cid, attrs=key_value_pair, endpoint=self.cluster.default_http_gate_endpoint, + http_hostname=self.cluster.default_http_hostname, ) @allure.title("[Negative] Try to put object and get right after container is deleted") @@ -228,4 +232,5 @@ class Test_http_headers(ClusterTestBase): attrs=attrs_obj3, http_request_path=request, endpoint=self.cluster.default_http_gate_endpoint, + http_hostname=self.cluster.default_http_hostname, ) diff --git a/pytest_tests/testsuites/services/http_gate/test_http_object.py b/pytest_tests/testsuites/services/http_gate/test_http_object.py index ef83548..69da8d0 100644 --- a/pytest_tests/testsuites/services/http_gate/test_http_object.py +++ b/pytest_tests/testsuites/services/http_gate/test_http_object.py @@ -91,6 +91,7 @@ class Test_http_object(ClusterTestBase): shell=self.shell, nodes=self.cluster.storage_nodes, endpoint=self.cluster.default_http_gate_endpoint, + http_hostname=self.cluster.default_http_hostname, ) with allure.step("[Negative] try to get object: [get/$CID/chapter1/peace]"): attrs = {obj_key1: obj_value1, obj_key2: obj_value2} @@ -103,6 +104,7 @@ class Test_http_object(ClusterTestBase): http_request_path=request, attrs=attrs, endpoint=self.cluster.default_http_gate_endpoint, + http_hostname=self.cluster.default_http_hostname, ) with allure.step( @@ -114,6 +116,7 @@ class Test_http_object(ClusterTestBase): cid=cid, attrs=attrs, endpoint=self.cluster.default_http_gate_endpoint, + hostname=self.cluster.default_http_hostname, ) with allure.step("[Negative] try to get object: get_by_attribute/$CID/$OID"): request = f"/get_by_attribute/{cid}/{oid}" @@ -123,4 +126,5 @@ class Test_http_object(ClusterTestBase): error_pattern=expected_err_msg, http_request_path=request, endpoint=self.cluster.default_http_gate_endpoint, + hostname=self.cluster.default_http_hostname, ) diff --git a/pytest_tests/testsuites/services/http_gate/test_http_streaming.py b/pytest_tests/testsuites/services/http_gate/test_http_streaming.py index a537369..011b929 100644 --- a/pytest_tests/testsuites/services/http_gate/test_http_streaming.py +++ b/pytest_tests/testsuites/services/http_gate/test_http_streaming.py @@ -67,4 +67,5 @@ class Test_http_streaming(ClusterTestBase): shell=self.shell, nodes=self.cluster.storage_nodes, endpoint=self.cluster.default_http_gate_endpoint, + hostname=self.cluster.default_http_hostname, ) diff --git a/pytest_tests/testsuites/services/http_gate/test_http_system_header.py b/pytest_tests/testsuites/services/http_gate/test_http_system_header.py index bb3e3ae..4ef6551 100644 --- a/pytest_tests/testsuites/services/http_gate/test_http_system_header.py +++ b/pytest_tests/testsuites/services/http_gate/test_http_system_header.py @@ -130,6 +130,7 @@ class Test_http_system_header(ClusterTestBase): shell=self.shell, nodes=self.cluster.storage_nodes, endpoint=self.cluster.default_http_gate_endpoint, + hostname=self.cluster.default_http_hostname, ) head = head_object( wallet=self.wallet, @@ -242,6 +243,7 @@ class Test_http_system_header(ClusterTestBase): oid=oid, error_pattern="404 Not Found", endpoint=self.cluster.default_http_gate_endpoint, + http_hostname=self.cluster.default_http_hostname, ) # check that object is not available via grpc with pytest.raises(Exception, match=OBJECT_NOT_FOUND): @@ -297,6 +299,7 @@ class Test_http_system_header(ClusterTestBase): oid=oid, error_pattern="404 Not Found", endpoint=self.cluster.default_http_gate_endpoint, + http_hostname=self.cluster.default_http_hostname, ) # check that object is not available via grpc with pytest.raises(Exception, match=OBJECT_NOT_FOUND): @@ -352,6 +355,7 @@ class Test_http_system_header(ClusterTestBase): oid=oid, error_pattern="404 Not Found", endpoint=self.cluster.default_http_gate_endpoint, + http_hostname=self.cluster.default_http_hostname, ) # check that object is not available via grpc with pytest.raises(Exception, match=OBJECT_NOT_FOUND): @@ -407,6 +411,7 @@ class Test_http_system_header(ClusterTestBase): oid=oid, error_pattern="404 Not Found", endpoint=self.cluster.default_http_gate_endpoint, + http_hostname=self.cluster.default_http_hostname, ) # check that object is not available via grpc with pytest.raises(Exception, match=OBJECT_NOT_FOUND):