From 80c65b454e08e9ee1957f25dd0ebefbe138218b4 Mon Sep 17 00:00:00 2001 From: Andrey Berezin Date: Mon, 8 Apr 2024 12:13:59 +0300 Subject: [PATCH] [#203] Remove hostnames cludges Signed-off-by: Andrey Berezin --- src/frostfs_testlib/steps/http/http_gate.py | 17 +++--------- src/frostfs_testlib/storage/cluster.py | 26 +++---------------- src/frostfs_testlib/storage/constants.py | 2 -- .../storage/dataclasses/frostfs_services.py | 9 ------- 4 files changed, 8 insertions(+), 46 deletions(-) diff --git a/src/frostfs_testlib/steps/http/http_gate.py b/src/frostfs_testlib/steps/http/http_gate.py index 3f4d838..373283f 100644 --- a/src/frostfs_testlib/steps/http/http_gate.py +++ b/src/frostfs_testlib/steps/http/http_gate.py @@ -50,9 +50,7 @@ def get_via_http_gate( else: request = f"{node.http_gate.get_endpoint()}{request_path}" - resp = requests.get( - request, headers={"Host": node.storage_node.get_http_hostname()[0]}, stream=True, timeout=timeout, verify=False - ) + resp = requests.get(request, stream=True, timeout=timeout, verify=False) if not resp.ok: raise Exception( @@ -118,7 +116,6 @@ def get_via_http_gate_by_attribute( cid: CID to get object from attribute: attribute {name: attribute} value pair endpoint: http gate endpoint - http_hostname: http host name on the node request_path: (optional) http request path, if ommited - use default [{endpoint}/get_by_attribute/{Key}/{Value}] """ attr_name = list(attribute.keys())[0] @@ -129,9 +126,7 @@ def get_via_http_gate_by_attribute( else: request = f"{node.http_gate.get_endpoint()}{request_path}" - resp = requests.get( - request, stream=True, timeout=timeout, verify=False, headers={"Host": node.storage_node.get_http_hostname()[0]} - ) + resp = requests.get(request, stream=True, timeout=timeout, verify=False) if not resp.ok: raise Exception( @@ -151,11 +146,8 @@ def get_via_http_gate_by_attribute( return file_path -# TODO: pass http_hostname as a header @reporter.step("Upload via HTTP Gate") -def upload_via_http_gate( - cid: str, path: str, endpoint: str, headers: Optional[dict] = None, timeout: Optional[int] = 300 -) -> str: +def upload_via_http_gate(cid: str, path: str, endpoint: str, headers: Optional[dict] = None, timeout: Optional[int] = 300) -> str: """ This function upload given object through HTTP gate cid: CID to get object from @@ -198,7 +190,6 @@ def is_object_large(filepath: str) -> bool: return False -# TODO: pass http_hostname as a header @reporter.step("Upload via HTTP Gate using Curl") def upload_via_http_gate_curl( cid: str, @@ -259,7 +250,7 @@ def get_via_http_curl(cid: str, oid: str, node: ClusterNode) -> str: file_path = os.path.join(os.getcwd(), ASSETS_DIR, f"{cid}_{oid}_{str(uuid.uuid4())}") curl = GenericCli("curl", node.host) - curl(f'-k -H "Host: {node.storage_node.get_http_hostname()[0]}"', f"{request} > {file_path}", shell=local_shell) + curl(f"-k ", f"{request} > {file_path}", shell=local_shell) return file_path diff --git a/src/frostfs_testlib/storage/cluster.py b/src/frostfs_testlib/storage/cluster.py index 23130cb..15827cf 100644 --- a/src/frostfs_testlib/storage/cluster.py +++ b/src/frostfs_testlib/storage/cluster.py @@ -141,30 +141,16 @@ class ClusterNode: return self.host.config.interfaces[interface.value] def get_data_interfaces(self) -> list[str]: - return [ - ip_address for name_interface, ip_address in self.host.config.interfaces.items() if "data" in name_interface - ] + return [ip_address for name_interface, ip_address in self.host.config.interfaces.items() if "data" in name_interface] def get_data_interface(self, search_interface: str) -> list[str]: - return [ - self.host.config.interfaces[interface] - for interface in self.host.config.interfaces.keys() - if search_interface == interface - ] + return [self.host.config.interfaces[interface] for interface in self.host.config.interfaces.keys() if search_interface == interface] def get_internal_interfaces(self) -> list[str]: - return [ - ip_address - for name_interface, ip_address in self.host.config.interfaces.items() - if "internal" in name_interface - ] + return [ip_address for name_interface, ip_address in self.host.config.interfaces.items() if "internal" in name_interface] def get_internal_interface(self, search_internal: str) -> list[str]: - return [ - self.host.config.interfaces[interface] - for interface in self.host.config.interfaces.keys() - if search_internal == interface - ] + return [self.host.config.interfaces[interface] for interface in self.host.config.interfaces.keys() if search_internal == interface] class Cluster: @@ -175,8 +161,6 @@ class Cluster: default_rpc_endpoint: str default_s3_gate_endpoint: str default_http_gate_endpoint: str - default_http_hostname: str - default_s3_hostname: str def __init__(self, hosting: Hosting) -> None: self._hosting = hosting @@ -185,8 +169,6 @@ class Cluster: self.default_rpc_endpoint = self.services(StorageNode)[0].get_rpc_endpoint() self.default_s3_gate_endpoint = self.services(S3Gate)[0].get_endpoint() self.default_http_gate_endpoint = self.services(HTTPGate)[0].get_endpoint() - self.default_http_hostname = self.services(StorageNode)[0].get_http_hostname() - self.default_s3_hostname = self.services(StorageNode)[0].get_s3_hostname() @property def hosts(self) -> list[Host]: diff --git a/src/frostfs_testlib/storage/constants.py b/src/frostfs_testlib/storage/constants.py index 3d75988..66bf5cc 100644 --- a/src/frostfs_testlib/storage/constants.py +++ b/src/frostfs_testlib/storage/constants.py @@ -16,5 +16,3 @@ class ConfigAttributes: ENDPOINT_PROMETHEUS = "endpoint_prometheus" CONTROL_ENDPOINT = "control_endpoint" UN_LOCODE = "un_locode" - HTTP_HOSTNAME = "http_hostname" - S3_HOSTNAME = "s3_hostname" diff --git a/src/frostfs_testlib/storage/dataclasses/frostfs_services.py b/src/frostfs_testlib/storage/dataclasses/frostfs_services.py index 9e671d5..16efd72 100644 --- a/src/frostfs_testlib/storage/dataclasses/frostfs_services.py +++ b/src/frostfs_testlib/storage/dataclasses/frostfs_services.py @@ -154,15 +154,6 @@ class StorageNode(NodeBase): def get_data_directory(self) -> str: return self.host.get_data_directory(self.name) - def get_storage_config(self) -> str: - return self.host.get_storage_config(self.name) - - def get_http_hostname(self) -> list[str]: - return self._get_attribute(ConfigAttributes.HTTP_HOSTNAME) - - def get_s3_hostname(self) -> list[str]: - return self._get_attribute(ConfigAttributes.S3_HOSTNAME) - def delete_blobovnicza(self): self.host.delete_blobovnicza(self.name)