Skip to content

Commit

Permalink
Drop HTTP gateway from tests, closes #757 (#770)
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-khimov authored Apr 2, 2024
2 parents 859cf55 + 9608dd9 commit 71a7d6e
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 223 deletions.
9 changes: 0 additions & 9 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,6 @@ jobs:
file: 'neofs-rest-gw-linux-amd64'
target: 'neofs-testcases/neofs-rest-gw'

- name: Download latest stable neofs-http-gw
uses: dsaltares/[email protected]
with:
repo: 'nspcc-dev/neofs-http-gw'
version: 'tags/v0.28.0'
file: 'neofs-http-gw-linux-amd64'
target: 'neofs-testcases/neofs-http-gw'

- name: Download latest stable neo-go
uses: dsaltares/[email protected]
with:
Expand Down Expand Up @@ -154,7 +146,6 @@ jobs:
sudo chmod a+x neofs-lens
sudo chmod a+x neofs-node
sudo chmod a+x neofs-rest-gw
sudo chmod a+x neofs-http-gw
sudo chmod a+x neo-go
sudo chmod a+x neofs-s3-authmate
sudo chmod a+x neofs-s3-gw
Expand Down
83 changes: 1 addition & 82 deletions neofs-testlib/neofs_testlib/env/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,11 @@ def __init__(self, neofs_env_config: dict = None):
self.neofs_s3_authmate_path = os.getenv("NEOFS_S3_AUTHMATE_BIN", "./neofs-s3-authmate")
self.neofs_s3_gw_path = os.getenv("NEOFS_S3_GW_BIN", "./neofs-s3-gw")
self.neofs_rest_gw_path = os.getenv("NEOFS_REST_GW_BIN", "./neofs-rest-gw")
self.neofs_http_gw_path = os.getenv("NEOFS_HTTP_GW_BIN", "./neofs-http-gw")
# nodes inside env
self.storage_nodes = []
self.inner_ring_nodes = []
self.s3_gw = None
self.rest_gw = None
self.http_gw = None

@property
def morph_rpc(self):
Expand Down Expand Up @@ -156,17 +154,11 @@ def deploy_s3_gw(self):
self.s3_gw.start()
allure.attach(str(self.s3_gw), "s3_gw", allure.attachment_type.TEXT, ".txt")

@allure.step("Deploy http gateway")
def deploy_http_gw(self):
self.http_gw = HTTP_GW(self)
self.http_gw.start()
allure.attach(str(self.http_gw), "http_gw", allure.attachment_type.TEXT, ".txt")

@allure.step("Deploy rest gateway")
def deploy_rest_gw(self):
self.rest_gw = REST_GW(self)
self.rest_gw.start()
allure.attach(str(self.rest_gw), "http_gw", allure.attachment_type.TEXT, ".txt")
allure.attach(str(self.rest_gw), "rest_gw", allure.attachment_type.TEXT, ".txt")

@allure.step("Generate wallet")
def generate_wallet(
Expand Down Expand Up @@ -210,7 +202,6 @@ def generate_wallet(
@allure.step("Kill current neofs env")
def kill(self):
self.rest_gw.process.kill()
self.http_gw.process.kill()
self.s3_gw.process.kill()
for sn in self.storage_nodes:
sn.process.kill()
Expand All @@ -236,7 +227,6 @@ def log_env_details_to_file(self):

env_details += f"{self.s3_gw}\n"
env_details += f"{self.rest_gw}\n"
env_details += f"{self.http_gw}\n"

fp.write(env_details)

Expand All @@ -250,7 +240,6 @@ def log_versions_to_allure(self):
versions += NeoFSEnv._run_single_command(self.neofs_s3_authmate_path, "--version")
versions += NeoFSEnv._run_single_command(self.neofs_s3_gw_path, "--version")
versions += NeoFSEnv._run_single_command(self.neofs_rest_gw_path, "--version")
versions += NeoFSEnv._run_single_command(self.neofs_http_gw_path, "--version")
allure.attach(versions, f"neofs env versions", allure.attachment_type.TEXT, ".txt")

@allure.step("Download binaries")
Expand All @@ -267,7 +256,6 @@ def download_binaries(self):
(self.neofs_s3_authmate_path, "neofs_s3_authmate"),
(self.neofs_s3_gw_path, "neofs_s3_gw"),
(self.neofs_rest_gw_path, "neofs_rest_gw"),
(self.neofs_http_gw_path, "neofs_http_gw"),
]

for binary in binaries:
Expand Down Expand Up @@ -325,7 +313,6 @@ def simple(cls, neofs_env_config: dict = None) -> "NeoFSEnv":
}
)
neofs_env.deploy_s3_gw()
neofs_env.deploy_http_gw()
neofs_env.deploy_rest_gw()
neofs_env.log_env_details_to_file()
neofs_env.log_versions_to_allure()
Expand Down Expand Up @@ -752,74 +739,6 @@ def _launch_process(self):
)


class HTTP_GW:
def __init__(self, neofs_env: NeoFSEnv):
self.neofs_env = neofs_env
self.config_path = NeoFSEnv._generate_temp_file(extension="yml", prefix="http_gw_config")
self.wallet = NodeWallet(
path=NeoFSEnv._generate_temp_file(prefix="http_gw_wallet"),
address="",
password=self.neofs_env.default_password,
)
self.address = f"{self.neofs_env.domain}:{NeoFSEnv.get_available_port()}"
self.stdout = "Not initialized"
self.stderr = "Not initialized"
self.process = None

def __str__(self):
return f"""
HTTP Gateway:
- Address: {self.address}
- HTTP GW Config path: {self.config_path}
- STDOUT: {self.stdout}
- STDERR: {self.stderr}
"""

def __getstate__(self):
attributes = self.__dict__.copy()
del attributes["process"]
return attributes

def start(self):
if self.process is not None:
raise RuntimeError(f"This http gw instance has already been started:\n{self}")
self.neofs_env.generate_wallet(WalletType.STORAGE, self.wallet, label=f"http")
logger.info(f"Generating config for http gw at {self.config_path}")
self._generate_config()
logger.info(f"Launching HTTP GW: {self}")
self._launch_process()
logger.info(f"Launched HTTP GW: {self}")

def _generate_config(self):
http_config_template = "http.yaml"

NeoFSEnv.generate_config_file(
config_template=http_config_template,
config_path=self.config_path,
custom=Path(http_config_template).is_file(),
address=self.address,
wallet=self.wallet,
)

def _launch_process(self):
self.stdout = NeoFSEnv._generate_temp_file(prefix="http_gw_stdout")
self.stderr = NeoFSEnv._generate_temp_file(prefix="http_gw_stderr")
stdout_fp = open(self.stdout, "w")
stderr_fp = open(self.stderr, "w")
http_gw_env = {}

for index, sn in enumerate(self.neofs_env.storage_nodes):
http_gw_env[f"HTTP_GW_PEERS_{index}_ADDRESS"] = sn.endpoint
http_gw_env[f"HTTP_GW_PEERS_{index}_WEIGHT"] = "0.2"

self.process = subprocess.Popen(
[self.neofs_env.neofs_http_gw_path, "--config", self.config_path],
stdout=stdout_fp,
stderr=stderr_fp,
env=http_gw_env,
)


class REST_GW:
def __init__(self, neofs_env: NeoFSEnv):
self.neofs_env = neofs_env
Expand Down
16 changes: 0 additions & 16 deletions neofs-testlib/neofs_testlib/env/templates/http.yaml

This file was deleted.

3 changes: 1 addition & 2 deletions pytest_tests/pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ markers =
grpc_api: standard gRPC API tests
grpc_control: tests related to using neofs-cli control commands
grpc_object_lock: gRPC lock tests
http_and_rest_gates: HTTP and REST gates contract
http_gate: HTTP gate contract
rest_gate: REST gate tests
s3_gate: All S3 gate tests
s3_gate_base: Base S3 gate tests
s3_gate_bucket: Bucket S3 gate tests
Expand Down
2 changes: 1 addition & 1 deletion pytest_tests/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def neofs_env(request):
os.makedirs(logs_path, exist_ok=True)

shutil.copyfile(neofs_env.s3_gw.stderr, f"{logs_path}/s3_gw_log.txt")
shutil.copyfile(neofs_env.http_gw.stderr, f"{logs_path}/http_gw_log.txt")
shutil.copyfile(neofs_env.rest_gw.stderr, f"{logs_path}/rest_gw_log.txt")
for idx, ir in enumerate(neofs_env.inner_ring_nodes):
shutil.copyfile(ir.stderr, f"{logs_path}/ir_{idx}_log.txt")
for idx, sn in enumerate(neofs_env.storage_nodes):
Expand Down
15 changes: 0 additions & 15 deletions pytest_tests/tests/services/http_rest_gates/conftest.py

This file was deleted.

11 changes: 11 additions & 0 deletions pytest_tests/tests/services/rest_gate/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import logging

import pytest
from neofs_testlib.env.env import NeoFSEnv

logger = logging.getLogger("NeoLogger")


@pytest.fixture(scope="session")
def gw_endpoint(neofs_env: NeoFSEnv):
return f"http://{neofs_env.rest_gw.address}/v1"
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@


@pytest.mark.sanity
@pytest.mark.http_and_rest_gates
class Test_http_rest_bearer(NeofsEnvTestBase):
@pytest.mark.rest_gate
class Test_rest_bearer(NeofsEnvTestBase):
PLACEMENT_RULE = "REP 2 IN X CBF 1 SELECT 2 FROM * AS X"

@pytest.fixture(scope="class", autouse=True)
@allure.title("[Class/Autouse]: Prepare wallet and deposit")
def prepare_wallet(self, default_wallet):
Test_http_rest_bearer.wallet = default_wallet
Test_rest_bearer.wallet = default_wallet

@pytest.fixture(scope="class")
def user_container(self) -> str:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,37 +28,29 @@


@allure.link(
"https://github.com/nspcc-dev/neofs-http-gw#neofs-http-gateway", name="neofs-http-gateway"
"https://github.com/nspcc-dev/neofs-rest-gw?tab=readme-ov-file#neofs-rest-gw",
name="neofs-rest-gateway",
)
@allure.link("https://github.com/nspcc-dev/neofs-http-gw#uploading", name="uploading")
@allure.link("https://github.com/nspcc-dev/neofs-http-gw#downloading", name="downloading")
@pytest.mark.sanity
@pytest.mark.http_and_rest_gates
class TestHttpRestGate(NeofsEnvTestBase):
@pytest.mark.rest_gate
class TestRestGate(NeofsEnvTestBase):
PLACEMENT_RULE_1 = "REP 1 IN X CBF 1 SELECT 1 FROM * AS X"
PLACEMENT_RULE_2 = "REP 2 IN X CBF 2 SELECT 2 FROM * AS X"

@pytest.fixture(scope="class", autouse=True)
@allure.title("[Class/Autouse]: Prepare wallet and deposit")
def prepare_wallet(self, default_wallet):
TestHttpRestGate.wallet = default_wallet

@pytest.fixture(scope="class", params=["HTTP", "REST"])
def gw_params(self, request):
gw_type = request.param
if gw_type == "HTTP":
return {
"endpoint": f"http://{self.neofs_env.http_gw.address}",
"wallet_path": self.neofs_env.http_gw.wallet.path,
}
else: # Assuming REST
return {
"endpoint": f"http://{self.neofs_env.rest_gw.address}/v1",
"wallet_path": self.neofs_env.rest_gw.wallet.path,
}
TestRestGate.wallet = default_wallet

@pytest.fixture(scope="class")
def gw_params(self):
return {
"endpoint": f"http://{self.neofs_env.rest_gw.address}/v1",
"wallet_path": self.neofs_env.rest_gw.wallet.path,
}

@allure.title("Test Put over gRPC, Get over HTTP")
def test_put_grpc_get_http(self, complex_object_size, simple_object_size):
def test_put_grpc_get_http(self, complex_object_size, simple_object_size, gw_endpoint):
"""
Test that object can be put using gRPC interface and get using HTTP.
Expand Down Expand Up @@ -108,7 +100,7 @@ def test_put_grpc_get_http(self, complex_object_size, simple_object_size):
cid=cid,
shell=self.shell,
nodes=self.neofs_env.storage_nodes,
endpoint=f"http://{self.neofs_env.http_gw.address}",
endpoint=gw_endpoint,
)

@allure.title("Verify Content-Disposition header")
Expand Down Expand Up @@ -439,44 +431,6 @@ def test_expiration_epoch_in_http(self, simple_object_size, gw_params):
for oid in not_expired_objects:
get_via_http_gate(cid=cid, oid=oid, endpoint=gw_params["endpoint"])

@allure.title("Test Zip in HTTP header")
def test_zip_in_http(self, complex_object_size, simple_object_size):
cid = create_container(
self.wallet.path,
shell=self.shell,
endpoint=self.neofs_env.sn_rpc,
rule=self.PLACEMENT_RULE_2,
basic_acl=PUBLIC_ACL,
)
file_path_simple, file_path_large = generate_file(simple_object_size), generate_file(
complex_object_size
)
common_prefix = "my_files"

headers1 = {"X-Attribute-FilePath": f"{common_prefix}/file1"}
headers2 = {"X-Attribute-FilePath": f"{common_prefix}/file2"}

upload_via_http_gate(
cid=cid,
path=file_path_simple,
headers=headers1,
endpoint=f"http://{self.neofs_env.http_gw.address}",
)
upload_via_http_gate(
cid=cid,
path=file_path_large,
headers=headers2,
endpoint=f"http://{self.neofs_env.http_gw.address}",
)

dir_path = get_via_zip_http_gate(
cid=cid, prefix=common_prefix, endpoint=f"http://{self.neofs_env.http_gw.address}"
)

with allure.step("Verify hashes"):
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)

@pytest.mark.long
@allure.title("Test Put over HTTP/Curl, Get over HTTP/Curl for large object")
def test_put_http_get_http_large_file(self, complex_object_size, gw_params):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@


@pytest.mark.sanity
@pytest.mark.http_and_rest_gates
class Test_http_rest_headers(NeofsEnvTestBase):
@pytest.mark.rest_gate
class Test_rest_headers(NeofsEnvTestBase):
PLACEMENT_RULE = "REP 2 IN X CBF 1 SELECT 4 FROM * AS X"
obj1_keys = ["Writer", "Chapter1", "Chapter2"]
obj2_keys = ["Writer", "Ch$pter1", "chapter2"]
Expand All @@ -41,7 +41,7 @@ class Test_http_rest_headers(NeofsEnvTestBase):
@pytest.fixture(scope="class", autouse=True)
@allure.title("[Class/Autouse]: Prepare wallet and deposit")
def prepare_wallet(self, default_wallet):
Test_http_rest_headers.wallet = default_wallet
Test_rest_headers.wallet = default_wallet

@pytest.fixture(
params=[
Expand Down
Loading

0 comments on commit 71a7d6e

Please sign in to comment.