[#278] Small QoL updates

Signed-off-by: a.berezin <a.berezin@yadro.com>
This commit is contained in:
Andrey Berezin 2024-08-07 17:35:02 +03:00
parent 5bdacdf5ba
commit 8a8b35846e
4 changed files with 12 additions and 7 deletions

View file

@ -51,3 +51,5 @@ CREDENTIALS_CREATE_TIMEOUT = "1m"
HOSTING_CONFIG_FILE = os.getenv( HOSTING_CONFIG_FILE = os.getenv(
"HOSTING_CONFIG_FILE", os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "..", ".devenv.hosting.yaml")) "HOSTING_CONFIG_FILE", os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "..", ".devenv.hosting.yaml"))
) )
MORE_LOG = os.getenv("MORE_LOG", "1")

View file

@ -1,15 +1,18 @@
import logging import logging
import subprocess import subprocess
import tempfile import tempfile
from contextlib import nullcontext
from datetime import datetime from datetime import datetime
from typing import IO, Optional from typing import IO, Optional
import pexpect import pexpect
from frostfs_testlib import reporter from frostfs_testlib import reporter
from frostfs_testlib.resources.common import MORE_LOG
from frostfs_testlib.shell.interfaces import CommandInspector, CommandOptions, CommandResult, Shell from frostfs_testlib.shell.interfaces import CommandInspector, CommandOptions, CommandResult, Shell
logger = logging.getLogger("frostfs.testlib.shell") logger = logging.getLogger("frostfs.testlib.shell")
step_context = reporter.step if MORE_LOG == "1" else nullcontext
class LocalShell(Shell): class LocalShell(Shell):
@ -28,7 +31,7 @@ class LocalShell(Shell):
for inspector in [*self.command_inspectors, *extra_inspectors]: for inspector in [*self.command_inspectors, *extra_inspectors]:
command = inspector.inspect(original_command, command) command = inspector.inspect(original_command, command)
with reporter.step(f"Executing command: {command}"): with step_context(f"Executing command: {command}"):
if options.interactive_inputs: if options.interactive_inputs:
return self._exec_interactive(command, options) return self._exec_interactive(command, options)
return self._exec_non_interactive(command, options) return self._exec_non_interactive(command, options)

View file

@ -15,7 +15,7 @@ from frostfs_testlib.storage.cluster import Cluster, ClusterNode
from frostfs_testlib.storage.dataclasses.wallet import WalletInfo from frostfs_testlib.storage.dataclasses.wallet import WalletInfo
from frostfs_testlib.testing import wait_for_success from frostfs_testlib.testing import wait_for_success
from frostfs_testlib.utils import json_utils from frostfs_testlib.utils import json_utils
from frostfs_testlib.utils.cli_utils import parse_cmd_table, parse_netmap_output from frostfs_testlib.utils.cli_utils import parse_netmap_output
from frostfs_testlib.utils.file_utils import TestFile from frostfs_testlib.utils.file_utils import TestFile
logger = logging.getLogger("NeoLogger") logger = logging.getLogger("NeoLogger")
@ -623,25 +623,20 @@ def head_object(
# If response is Complex Object header, it has `splitId` key # If response is Complex Object header, it has `splitId` key
if "splitId" in decoded.keys(): if "splitId" in decoded.keys():
logger.info("decoding split header")
return json_utils.decode_split_header(decoded) return json_utils.decode_split_header(decoded)
# If response is Last or Linking Object header, # If response is Last or Linking Object header,
# it has `header` dictionary and non-null `split` dictionary # it has `header` dictionary and non-null `split` dictionary
if "split" in decoded["header"].keys(): if "split" in decoded["header"].keys():
if decoded["header"]["split"]: if decoded["header"]["split"]:
logger.info("decoding linking object")
return json_utils.decode_linking_object(decoded) return json_utils.decode_linking_object(decoded)
if decoded["header"]["objectType"] == "STORAGE_GROUP": if decoded["header"]["objectType"] == "STORAGE_GROUP":
logger.info("decoding storage group")
return json_utils.decode_storage_group(decoded) return json_utils.decode_storage_group(decoded)
if decoded["header"]["objectType"] == "TOMBSTONE": if decoded["header"]["objectType"] == "TOMBSTONE":
logger.info("decoding tombstone")
return json_utils.decode_tombstone(decoded) return json_utils.decode_tombstone(decoded)
logger.info("decoding simple header")
return json_utils.decode_simple_header(decoded) return json_utils.decode_simple_header(decoded)

View file

@ -47,6 +47,7 @@ class ConditionType(HumanReadableEnum):
class ConditionKey(HumanReadableEnum): class ConditionKey(HumanReadableEnum):
ROLE = '"\\$Actor:role"' ROLE = '"\\$Actor:role"'
PUBLIC_KEY = '"\\$Actor:publicKey"' PUBLIC_KEY = '"\\$Actor:publicKey"'
OBJECT_TYPE = '"\\$Object:objectType"'
class MatchType(HumanReadableEnum): class MatchType(HumanReadableEnum):
@ -75,6 +76,10 @@ class Condition:
def by_key(*args, **kwargs) -> "Condition": def by_key(*args, **kwargs) -> "Condition":
return Condition(ConditionKey.PUBLIC_KEY, *args, **kwargs) return Condition(ConditionKey.PUBLIC_KEY, *args, **kwargs)
@staticmethod
def by_object_type(*args, **kwargs) -> "Condition":
return Condition(ConditionKey.OBJECT_TYPE, *args, **kwargs)
class Rule: class Rule:
def __init__( def __init__(