Skip to content

Commit

Permalink
env: update get_version method
Browse files Browse the repository at this point in the history
get_version required deployed SN to get related binary version,
but it is not really needed. Just downloaded binaries are needed.

Signed-off-by: Evgeniy Zayats <[email protected]>
  • Loading branch information
Evgeniy Zayats committed Feb 10, 2025
1 parent 742c148 commit 4504048
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 31 deletions.
23 changes: 8 additions & 15 deletions neofs-testlib/neofs_testlib/env/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,13 @@ def download_binary(repo: str, version: str, file: str, target: str):
current_perm = os.stat(target)
os.chmod(target, current_perm.st_mode | stat.S_IEXEC)

def get_binary_version(self, binary_path: str) -> str:
raw_version_output = self._run_single_command(binary_path, "--version")
for line in raw_version_output.splitlines():
if "Version:" in line:
return line.split("Version:")[1].strip()
return ""

def _generate_temp_file(self, base_dir: str, extension: str = "", prefix: str = "tmp_file") -> str:
file_path = f"{base_dir}/{prefix}_{''.join(random.choices(string.ascii_lowercase, k=10))}"
if extension:
Expand Down Expand Up @@ -1108,13 +1115,6 @@ def _wait_until_not_ready(self):
assert "Health status: READY" not in result.stdout, "Health is ready"
assert "Network status: ONLINE" not in result.stdout, "Network is online"

def _get_version(self) -> str:
raw_version_output = self.neofs_env._run_single_command(self.neofs_env.neofs_node_path, "--version")
for line in raw_version_output.splitlines():
if "Version:" in line:
return line.split("Version:")[1].strip()
return ""


class S3_GW:
def __init__(self, neofs_env: NeoFSEnv):
Expand Down Expand Up @@ -1211,18 +1211,11 @@ def _generate_config(self):
peers=peers,
tree_service_endpoint=self.neofs_env.storage_nodes[0].endpoint,
listen_domain=self.neofs_env.domain,
s3_gw_version=self._get_version(),
s3_gw_version=self.neofs_env.get_binary_version(self.neofs_env.neofs_s3_gw_path),
pprof_address=self.pprof_address,
prometheus_address=self.prometheus_address,
)

def _get_version(self) -> str:
raw_version_output = self.neofs_env._run_single_command(self.neofs_env.neofs_s3_gw_path, "--version")
for line in raw_version_output.splitlines():
if "Version:" in line:
return line.split("Version:")[1].strip()
return ""

def _launch_process(self):
self.stdout = self.neofs_env._generate_temp_file(self.s3_gw_dir, prefix="s3gw_stdout")
self.stderr = self.neofs_env._generate_temp_file(self.s3_gw_dir, prefix="s3gw_stderr")
Expand Down
2 changes: 1 addition & 1 deletion pytest_tests/tests/acl/test_eacl.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ def test_extended_acl_operations_enforcement(self, wallets, eacl_container_with_
def test_extended_acl_deny_all_operations_exclude_extended_role(
self, wallets, eacl_container_with_objects, role: EACLRoleExtendedType
):
if self.neofs_env.storage_nodes[0]._get_version() > "0.44.2":
if self.neofs_env.get_binary_version(self.neofs_env.neofs_node_path) > "0.44.2":
pytest.skip("This test runs on 0.44.2 and below neofs-node versions")
user_wallet = wallets.get_wallet()
other_wallet, other_wallet_allow = wallets.get_wallets_list(EACLRole.OTHERS)[0:2]
Expand Down
2 changes: 1 addition & 1 deletion pytest_tests/tests/container/test_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def test_container_deletion_while_sn_down(
object_should_be_gc_marked(self.neofs_env, node_to_stop, cid, oid)

def test_container_global_name(self, default_wallet, simple_object_size):
if self.neofs_env.storage_nodes[0]._get_version() <= "0.43.0":
if self.neofs_env.get_binary_version(self.neofs_env.neofs_node_path) <= "0.43.0":
pytest.skip("This test runs only on post 0.43.0 node version")

with allure.step("Create container"):
Expand Down
2 changes: 1 addition & 1 deletion pytest_tests/tests/metrics/test_sn_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def test_sn_metrics(single_noded_env: NeoFSEnv, default_wallet: NodeWallet):
f"invalid value for {metric}"
)

node_version = single_noded_env.storage_nodes[0]._get_version()
node_version = single_noded_env.get_binary_version(single_noded_env.neofs_node_path)
assert after_metrics["neofs_node_version"][0]["params"]["version"] == node_version, (
"invalid value for neofs_node_version"
)
Expand Down
2 changes: 2 additions & 0 deletions pytest_tests/tests/network/test_deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ def test_sn_deployment_with_writecache(clear_neofs_env: NeoFSEnv):
neofs_env = clear_neofs_env
with allure.step("Deploy neofs with writecache enabled"):
neofs_env.download_binaries()
if neofs_env.get_binary_version(neofs_env.neofs_node_path) <= "0.44.2":
pytest.skip("Test requires fresh node version")
neofs_env.deploy_inner_ring_nodes()
neofs_env.deploy_storage_nodes(
count=4,
Expand Down
6 changes: 3 additions & 3 deletions pytest_tests/tests/network/test_ir_controls.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def multi_ir_neofs_env():


def test_control_notary_request_new_epoch(multi_ir_neofs_env: NeoFSEnv):
if multi_ir_neofs_env.storage_nodes[0]._get_version() <= "0.44.2":
if multi_ir_neofs_env.get_binary_version(multi_ir_neofs_env.neofs_node_path) <= "0.44.2":
pytest.skip("Test requires fresh node version")
neofs_env = multi_ir_neofs_env

Expand Down Expand Up @@ -131,7 +131,7 @@ def test_control_notary_request_new_epoch(multi_ir_neofs_env: NeoFSEnv):
],
)
def test_control_notary_request_new_config_value(multi_ir_neofs_env: NeoFSEnv, key: str, value: Union[str, int, bool]):
if multi_ir_neofs_env.storage_nodes[0]._get_version() <= "0.44.2":
if multi_ir_neofs_env.get_binary_version(multi_ir_neofs_env.neofs_node_path) <= "0.44.2":
pytest.skip("Test requires fresh node version")
neofs_env = multi_ir_neofs_env

Expand Down Expand Up @@ -176,7 +176,7 @@ def test_control_notary_request_new_config_value(multi_ir_neofs_env: NeoFSEnv, k


def test_control_notary_request_node_removal(multi_ir_neofs_env: NeoFSEnv):
if multi_ir_neofs_env.storage_nodes[0]._get_version() <= "0.44.2":
if multi_ir_neofs_env.get_binary_version(multi_ir_neofs_env.neofs_node_path) <= "0.44.2":
pytest.skip("Test requires fresh node version")
neofs_env = multi_ir_neofs_env

Expand Down
2 changes: 1 addition & 1 deletion pytest_tests/tests/s3/s3_extensions/test_s3_gate_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def test_s3_bucket_location(self, simple_object_size):

@allure.title("Test S3: Verify bucket creation with policies from config file")
def test_s3_bucket_location_from_config_file(self, simple_object_size):
if self.neofs_env.s3_gw._get_version() <= "0.31.1":
if self.neofs_env.get_binary_version(self.neofs_env.neofs_s3_gw_path) <= "0.31.1":
pytest.skip("This test runs only on post 0.31.1 S3 gw version")
file_path_1 = generate_file(simple_object_size)
file_name_1 = object_key_from_file_path(file_path_1)
Expand Down
6 changes: 3 additions & 3 deletions pytest_tests/tests/s3/test_s3_ACL.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class TestS3ACL(TestNeofsS3Base):
@pytest.mark.sanity
@allure.title("Test S3: Object ACL")
def test_s3_object_ACL(self, bucket, simple_object_size):
if self.neofs_env.s3_gw._get_version() <= "0.32.0":
if self.neofs_env.get_binary_version(self.neofs_env.neofs_s3_gw_path) <= "0.32.0":
pytest.skip("This test runs only on post 0.32.0 S3 gw version")
file_path = generate_file(simple_object_size)
file_name = object_key_from_file_path(file_path)
Expand Down Expand Up @@ -74,7 +74,7 @@ def test_s3_object_eligible_acls(self, bucket, simple_object_size):
By default with disabled ACLs, user should be able to set object 'private'
and 'bucket-owner-full-control' ACLs
"""
if self.neofs_env.s3_gw._get_version() <= "0.32.0":
if self.neofs_env.get_binary_version(self.neofs_env.neofs_s3_gw_path) <= "0.32.0":
pytest.skip("This test runs only on post 0.32.0 S3 gw version")
file_path = generate_file(simple_object_size)
file_name = object_key_from_file_path(file_path)
Expand Down Expand Up @@ -128,7 +128,7 @@ def test_s3_bucket_ACL(self):

@allure.title("Test S3: Bucket Enable Disable ACL")
def test_s3_bucket_disable_enable_ACL(self):
if self.neofs_env.s3_gw._get_version() <= "0.32.0":
if self.neofs_env.get_binary_version(self.neofs_env.neofs_s3_gw_path) <= "0.32.0":
pytest.skip("This test runs only on post 0.32.0 S3 gw version")
with allure.step("Create bucket"):
bucket = s3_bucket.create_bucket_s3(
Expand Down
4 changes: 2 additions & 2 deletions pytest_tests/tests/s3/test_s3_multipart.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def test_s3_object_multipart(self):
assert get_file_hash(got_object) == get_file_hash(file_name_large)

def test_s3_object_multipart_non_sequential(self):
if self.neofs_env.s3_gw._get_version() <= "0.32.0":
if self.neofs_env.get_binary_version(self.neofs_env.neofs_s3_gw_path) <= "0.32.0":
pytest.skip("This test runs only on post 0.32.0 S3 gw version")
bucket = s3_bucket.create_bucket_s3(self.s3_client, bucket_configuration="rep-1")
set_bucket_versioning(self.s3_client, bucket, s3_bucket.VersioningStatus.ENABLED)
Expand Down Expand Up @@ -96,7 +96,7 @@ def test_s3_object_multipart_non_sequential(self):
assert get_file_hash(got_object) == get_file_hash(file_name_large)

def test_s3_object_multipart_random(self):
if self.neofs_env.s3_gw._get_version() <= "0.32.0":
if self.neofs_env.get_binary_version(self.neofs_env.neofs_s3_gw_path) <= "0.32.0":
pytest.skip("This test runs only on post 0.32.0 S3 gw version")

bucket = s3_bucket.create_bucket_s3(self.s3_client, bucket_configuration="rep-1")
Expand Down
2 changes: 1 addition & 1 deletion pytest_tests/tests/s3/test_s3_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ def test_s3_put_object_acl(
assert get_file_hash(file_path_1) == get_file_hash(object_1), "Hashes must be the same"

with allure.step("Put object with acl public-read"):
if self.neofs_env.s3_gw._get_version() > "0.32.0":
if self.neofs_env.get_binary_version(self.neofs_env.neofs_s3_gw_path) > "0.32.0":
with allure.step("Enable ACLs"):
s3_bucket.put_bucket_ownership_controls(
self.s3_client, bucket, s3_bucket.ObjectOwnership.BUCKET_OWNER_PREFERRED
Expand Down
2 changes: 1 addition & 1 deletion pytest_tests/tests/s3/test_s3_presigned.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def test_s3_get_object_with_presigned_url(self, bucket, simple_object_size, url_
";cool,name!",
]

if self.neofs_env.s3_gw._get_version() <= "0.33.0":
if self.neofs_env.get_binary_version(self.neofs_env.neofs_s3_gw_path) <= "0.33.0":
file_names_to_check = ["temp_file_12345"]

for file_name in file_names_to_check:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ def test_static_session_signed_by_other(
)
signed_token_file = sign_session_token(self.shell, session_token_file, stranger_wallet)
expected_error = INVALID_SESSION_TOKEN_OWNER
if self.neofs_env.storage_nodes[0]._get_version() <= "0.43.0":
if self.neofs_env.get_binary_version(self.neofs_env.neofs_node_path) <= "0.43.0":
expected_error = OBJECT_ACCESS_DENIED
with pytest.raises(Exception, match=expected_error):
head_object(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def test_static_session_token_container_create_with_other_wallet(
def test_static_session_token_container_create_signed_with_wrong_wallet(
self, owner_wallet: NodeWallet, user_wallet: NodeWallet, stranger_wallet: NodeWallet, temp_directory: str
):
if self.neofs_env.storage_nodes[0]._get_version() <= "0.43.0":
if self.neofs_env.get_binary_version(self.neofs_env.neofs_node_path) <= "0.43.0":
pytest.skip("This test runs only on post 0.43.0 neofs-node version")
session_token_file = generate_container_session_token(
owner_wallet=user_wallet,
Expand Down

0 comments on commit 4504048

Please sign in to comment.