-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: MaxGelbakhiani <[email protected]>
- Loading branch information
1 parent
1f6f121
commit 2931e50
Showing
6 changed files
with
125 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import subprocess | ||
import json | ||
|
||
|
||
def neofs_cli_execute(cmd: str, json_output: bool = False, timeout: int = None): | ||
""" | ||
Executes a given command and returns its output. | ||
:param cmd: Command to execute. | ||
:param json_output: Specifies if the command output is JSON. | ||
:param timeout: Optional timeout for command execution. | ||
:return: Command output as a string or a JSON object. | ||
""" | ||
|
||
try: | ||
compl_proc = subprocess.run( | ||
cmd, | ||
check=True, | ||
text=True, | ||
stdout=subprocess.PIPE, | ||
stderr=subprocess.PIPE, | ||
timeout=timeout, | ||
shell=True, | ||
) | ||
|
||
print(f"RC: {compl_proc.returncode}") | ||
print(f"Output: {compl_proc.stdout}") | ||
|
||
if json_output: | ||
try: | ||
return json.loads(compl_proc.stdout) | ||
except json.JSONDecodeError: | ||
output_list = compl_proc.stdout.splitlines() | ||
return json.dumps(output_list) | ||
else: | ||
return compl_proc.stdout.splitlines() | ||
|
||
except subprocess.CalledProcessError as e: | ||
raise Exception( | ||
f"Command failed: {e.cmd}\n" | ||
f"Error code: {e.returncode}\n" | ||
f"Output: {e.output}\n" | ||
f"Stdout: {e.stdout}\n" | ||
f"Stderr: {e.stderr}\n" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import sys | ||
import pytest | ||
from conftest import DATA_PATH_LIST | ||
|
||
sys.path.insert(0, '..') | ||
from helpers.neofs import neofs_cli_execute | ||
|
||
|
||
def test_objects_number(wallet, wallet_password, network_domain, cid): | ||
cmd = ( | ||
f"NEOFS_CLI_PASSWORD={wallet_password} neofs-cli --rpc-endpoint {network_domain}:8080 " | ||
f"--wallet {wallet} container list-objects --cid {cid}" | ||
) | ||
objects_list = neofs_cli_execute(cmd, json_output=True) | ||
print(objects_list) | ||
obj_number = len(objects_list) | ||
files_num = len(DATA_PATH_LIST) | ||
assert ( | ||
obj_number == files_num | ||
), f"Objects number of {obj_number} in the container and the number {files_num} of uploaded files doesn't match" |