From 9271e8859f9f78818b561825c9c7d580f7e700c6 Mon Sep 17 00:00:00 2001 From: Evgeniy Zayats Date: Thu, 24 Oct 2024 19:05:41 -0400 Subject: [PATCH] tests: adapt rest gw tests to update network info closes #882 Signed-off-by: Evgeniy Zayats --- .github/workflows/run-tests.yml | 19 +++++++++++++++++++ neofs-testlib/neofs_testlib/env/env.py | 7 +++++++ .../rest_gate/test_rest_system_header.py | 16 +++++++++++++--- 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index e0950a051..a927f1ed4 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -98,6 +98,25 @@ jobs: make build working-directory: xk6-neofs + - name: Checkout neofs-rest-gw repository + uses: actions/checkout@v4 + with: + repository: nspcc-dev/neofs-rest-gw + ref: master + path: neofs-rest-gw + + - name: Build neofs-rest-gw + run: | + make all + working-directory: neofs-rest-gw + + - name: Copy and chmod built neofs-rest-gw + timeout-minutes: 30 + run: | + cp ../neofs-rest-gw/bin/* . + sudo chmod a+x neofs-rest-gw + working-directory: neofs-testcases + - name: Prepare venv id: prepare_venv timeout-minutes: 30 diff --git a/neofs-testlib/neofs_testlib/env/env.py b/neofs-testlib/neofs_testlib/env/env.py index 38d4f23d8..2b7663aaa 100644 --- a/neofs-testlib/neofs_testlib/env/env.py +++ b/neofs-testlib/neofs_testlib/env/env.py @@ -1245,6 +1245,13 @@ def _launch_process(self): env=rest_gw_env, ) + def _get_version(self) -> str: + raw_version_output = self.neofs_env._run_single_command(self.neofs_env.neofs_rest_gw_path, "--version") + for line in raw_version_output.splitlines(): + if "Version:" in line: + return line.split("Version:")[1].strip() + return "" + class XK6: def __init__(self, neofs_env: NeoFSEnv): diff --git a/pytest_tests/tests/services/rest_gate/test_rest_system_header.py b/pytest_tests/tests/services/rest_gate/test_rest_system_header.py index 2aa5894c3..f9b2c6226 100644 --- a/pytest_tests/tests/services/rest_gate/test_rest_system_header.py +++ b/pytest_tests/tests/services/rest_gate/test_rest_system_header.py @@ -12,6 +12,7 @@ from helpers.neofs_verbs import get_netmap_netinfo, get_object_from_random_node, head_object from helpers.rest_gate import ( attr_into_str_header, + get_epoch_duration_via_rest_gate, try_to_get_object_and_expect_error, upload_via_rest_gate, ) @@ -251,7 +252,10 @@ def test_http_attr_priority_dur_timestamp( ): self.tick_epochs_and_wait(1) epoch_count = 2 - expected_epoch = neofs_epoch.get_epoch(self.neofs_env) + epoch_count + if self.neofs_env.rest_gw._get_version() <= "0.11.0": + expected_epoch = neofs_epoch.get_epoch(self.neofs_env) + epoch_count + else: + expected_epoch = int(get_epoch_duration_via_rest_gate(gw_endpoint)) + epoch_count logger.info( f"epoch duration={epoch_duration}, current_epoch= {neofs_epoch.get_epoch(self.neofs_env)} expected_epoch {expected_epoch}" ) @@ -307,7 +311,10 @@ def test_http_attr_priority_timestamp_rfc( ): self.tick_epochs_and_wait(1) epoch_count = 2 - expected_epoch = neofs_epoch.get_epoch(self.neofs_env) + epoch_count + if self.neofs_env.rest_gw._get_version() <= "0.11.0": + expected_epoch = neofs_epoch.get_epoch(self.neofs_env) + epoch_count + else: + expected_epoch = int(get_epoch_duration_via_rest_gate(gw_endpoint)) + epoch_count logger.info( f"epoch duration={epoch_duration}, current_epoch= {neofs_epoch.get_epoch(self.neofs_env)} expected_epoch {expected_epoch}" ) @@ -363,7 +370,10 @@ def test_http_rfc_object_unavailable_after_expir( ): self.tick_epochs_and_wait(1) epoch_count = 2 - expected_epoch = neofs_epoch.get_epoch(self.neofs_env) + epoch_count + if self.neofs_env.rest_gw._get_version() <= "0.11.0": + expected_epoch = neofs_epoch.get_epoch(self.neofs_env) + epoch_count + else: + expected_epoch = int(get_epoch_duration_via_rest_gate(gw_endpoint)) + epoch_count logger.info( f"epoch duration={epoch_duration}, current_epoch= {neofs_epoch.get_epoch(self.neofs_env)} expected_epoch {expected_epoch}" )