Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/SG test with v2 split #781

Merged
merged 3 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions neofs-testlib/neofs_testlib/cli/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from neofs_testlib.cli.neofs_adm import NeofsAdm
from neofs_testlib.cli.neofs_authmate import NeofsAuthmate
from neofs_testlib.cli.neofs_cli import NeofsCli
from neofs_testlib.cli.neofs_lens import NeofsLens
from neofs_testlib.cli.neogo import NeoGo, NetworkType
1 change: 1 addition & 0 deletions neofs-testlib/neofs_testlib/cli/neofs_lens/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from neofs_testlib.cli.neofs_lens.cli import NeofsLens
11 changes: 11 additions & 0 deletions neofs-testlib/neofs_testlib/cli/neofs_lens/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from typing import Optional

from neofs_testlib.cli.neofs_lens.objects import NeofsLensObject
from neofs_testlib.shell import Shell


class NeofsLens:
object: Optional[NeofsLensObject] = None

def __init__(self, shell: Shell, neofs_lens_exec_path: str):
self.object = NeofsLensObject(shell, neofs_lens_exec_path)
23 changes: 23 additions & 0 deletions neofs-testlib/neofs_testlib/cli/neofs_lens/objects.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from typing import Optional

from neofs_testlib.cli.cli_command import CliCommand
from neofs_testlib.shell import CommandResult


class NeofsLensObject(CliCommand):
def link(
self,
file: str,
) -> CommandResult:
"""
Inspect LINK objects from NeoFS.

Args:
file: File with object payload.
Returns:
Command's result.
"""
return self._execute(
"object link",
**{param: value for param, value in locals().items() if param not in ["self"]},
)
7 changes: 6 additions & 1 deletion neofs-testlib/neofs_testlib/env/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import yaml
from tenacity import retry, stop_after_attempt, wait_fixed

from neofs_testlib.cli import NeofsAdm, NeofsCli
from neofs_testlib.cli import NeofsAdm, NeofsCli, NeofsLens
from neofs_testlib.shell import LocalShell
from neofs_testlib.utils import wallet as wallet_utils

Expand Down Expand Up @@ -51,6 +51,7 @@ def __init__(self, neofs_env_config: dict = None):
self.neofs_env_config = neofs_env_config
self.neofs_adm_path = os.getenv("NEOFS_ADM_BIN", "./neofs-adm")
self.neofs_cli_path = os.getenv("NEOFS_CLI_BIN", "./neofs-cli")
self.neofs_lens_path = os.getenv("NEOFS_LENS_BIN", "./neofs-lens")
self.neo_go_path = os.getenv("NEO_GO_BIN", "./neo-go")
self.neofs_ir_path = os.getenv("NEOFS_IR_BIN", "./neofs-ir")
self.neofs_node_path = os.getenv("NEOFS_NODE_BIN", "./neofs-node")
Expand Down Expand Up @@ -100,6 +101,9 @@ def neofs_adm(self, network_config: Optional[str] = None) -> NeofsAdm:
def neofs_cli(self, cli_config_path: str) -> NeofsCli:
return NeofsCli(self.shell, self.neofs_cli_path, cli_config_path)

def neofs_lens(self,) -> NeofsLens:
return NeofsLens(self.shell, self.neofs_lens_path)

def generate_cli_config(self, wallet: NodeWallet):
cli_config_path = NeoFSEnv._generate_temp_file(extension="yml", prefix="cli_config")
NeoFSEnv.generate_config_file(
Expand Down Expand Up @@ -250,6 +254,7 @@ def download_binaries(self):
binaries = [
(self.neofs_adm_path, "neofs_adm"),
(self.neofs_cli_path, "neofs_cli"),
(self.neofs_lens_path, "neofs_lens"),
(self.neo_go_path, "neo_go"),
(self.neofs_ir_path, "neofs_ir"),
(self.neofs_node_path, "neofs_node"),
Expand Down
24 changes: 18 additions & 6 deletions pytest_tests/lib/helpers/storage_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
"""

import logging
import os.path
import string
from typing import Optional

import allure
from helpers.common import NEOFS_CLI_EXEC, WALLET_CONFIG
from helpers.complex_object_actions import get_link_object
from helpers.neofs_verbs import head_object
from helpers.neofs_verbs import get_object
from neofs_testlib.cli import NeofsCli
from neofs_testlib.env.env import NeoFSEnv
from neofs_testlib.shell import Shell
Expand Down Expand Up @@ -210,6 +212,7 @@ def verify_get_storage_group(
wallet_config: str = WALLET_CONFIG,
):
obj_parts = []
exp_size = object_size
endpoint = neofs_env.sn_rpc
if object_size > max_object_size:
for obj in obj_list:
Expand All @@ -222,19 +225,29 @@ def verify_get_storage_group(
bearer=bearer,
wallet_config=wallet_config,
)
obj_head = head_object(

obj_parts.append(link_oid)

link_obj_path = get_object(
wallet=wallet,
cid=cid,
oid=link_oid,
shell=shell,
endpoint=endpoint,
is_raw=True,
bearer=bearer,
wallet_config=wallet_config,
)
obj_parts = obj_head["header"]["split"]["children"]

obj_num = len(obj_list)
resp = neofs_env.neofs_lens().object.link(link_obj_path)

# exclude helper prompt
raw_children = resp.stdout.splitlines()[1:]
# exclude punctuation
children = [x.translate(str.maketrans("", "", string.punctuation)) for x in raw_children]

exp_size = sum([int(x.split()[1]) for x in children]) + os.path.getsize(link_obj_path)
obj_parts += [x.split()[-1] for x in children]

storagegroup_data = get_storagegroup(
shell=shell,
endpoint=endpoint,
Expand All @@ -244,7 +257,6 @@ def verify_get_storage_group(
bearer=bearer,
wallet_config=wallet_config,
)
exp_size = object_size * obj_num
if object_size < max_object_size:
assert int(storagegroup_data["Group size"]) == exp_size
assert storagegroup_data["Members"] == obj_list
Expand Down
Loading