From 8a8b35846e9bca105233a9cad30d39d8e98dd312 Mon Sep 17 00:00:00 2001 From: "a.berezin" Date: Wed, 7 Aug 2024 17:35:02 +0300 Subject: [PATCH] [#278] Small QoL updates Signed-off-by: a.berezin --- src/frostfs_testlib/resources/common.py | 2 ++ src/frostfs_testlib/shell/local_shell.py | 5 ++++- src/frostfs_testlib/steps/cli/object.py | 7 +------ src/frostfs_testlib/storage/dataclasses/ape.py | 5 +++++ 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/frostfs_testlib/resources/common.py b/src/frostfs_testlib/resources/common.py index 03fdce9..1c93b12 100644 --- a/src/frostfs_testlib/resources/common.py +++ b/src/frostfs_testlib/resources/common.py @@ -51,3 +51,5 @@ CREDENTIALS_CREATE_TIMEOUT = "1m" HOSTING_CONFIG_FILE = os.getenv( "HOSTING_CONFIG_FILE", os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "..", ".devenv.hosting.yaml")) ) + +MORE_LOG = os.getenv("MORE_LOG", "1") diff --git a/src/frostfs_testlib/shell/local_shell.py b/src/frostfs_testlib/shell/local_shell.py index 2fb6631..746070f 100644 --- a/src/frostfs_testlib/shell/local_shell.py +++ b/src/frostfs_testlib/shell/local_shell.py @@ -1,15 +1,18 @@ import logging import subprocess import tempfile +from contextlib import nullcontext from datetime import datetime from typing import IO, Optional import pexpect from frostfs_testlib import reporter +from frostfs_testlib.resources.common import MORE_LOG from frostfs_testlib.shell.interfaces import CommandInspector, CommandOptions, CommandResult, Shell logger = logging.getLogger("frostfs.testlib.shell") +step_context = reporter.step if MORE_LOG == "1" else nullcontext class LocalShell(Shell): @@ -28,7 +31,7 @@ class LocalShell(Shell): for inspector in [*self.command_inspectors, *extra_inspectors]: command = inspector.inspect(original_command, command) - with reporter.step(f"Executing command: {command}"): + with step_context(f"Executing command: {command}"): if options.interactive_inputs: return self._exec_interactive(command, options) return self._exec_non_interactive(command, options) diff --git a/src/frostfs_testlib/steps/cli/object.py b/src/frostfs_testlib/steps/cli/object.py index 7de7a71..72debc2 100644 --- a/src/frostfs_testlib/steps/cli/object.py +++ b/src/frostfs_testlib/steps/cli/object.py @@ -15,7 +15,7 @@ from frostfs_testlib.storage.cluster import Cluster, ClusterNode from frostfs_testlib.storage.dataclasses.wallet import WalletInfo from frostfs_testlib.testing import wait_for_success 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 logger = logging.getLogger("NeoLogger") @@ -623,25 +623,20 @@ def head_object( # If response is Complex Object header, it has `splitId` key if "splitId" in decoded.keys(): - logger.info("decoding split header") return json_utils.decode_split_header(decoded) # If response is Last or Linking Object header, # it has `header` dictionary and non-null `split` dictionary if "split" in decoded["header"].keys(): if decoded["header"]["split"]: - logger.info("decoding linking object") return json_utils.decode_linking_object(decoded) if decoded["header"]["objectType"] == "STORAGE_GROUP": - logger.info("decoding storage group") return json_utils.decode_storage_group(decoded) if decoded["header"]["objectType"] == "TOMBSTONE": - logger.info("decoding tombstone") return json_utils.decode_tombstone(decoded) - logger.info("decoding simple header") return json_utils.decode_simple_header(decoded) diff --git a/src/frostfs_testlib/storage/dataclasses/ape.py b/src/frostfs_testlib/storage/dataclasses/ape.py index 84b3033..de1648e 100644 --- a/src/frostfs_testlib/storage/dataclasses/ape.py +++ b/src/frostfs_testlib/storage/dataclasses/ape.py @@ -47,6 +47,7 @@ class ConditionType(HumanReadableEnum): class ConditionKey(HumanReadableEnum): ROLE = '"\\$Actor:role"' PUBLIC_KEY = '"\\$Actor:publicKey"' + OBJECT_TYPE = '"\\$Object:objectType"' class MatchType(HumanReadableEnum): @@ -75,6 +76,10 @@ class Condition: def by_key(*args, **kwargs) -> "Condition": return Condition(ConditionKey.PUBLIC_KEY, *args, **kwargs) + @staticmethod + def by_object_type(*args, **kwargs) -> "Condition": + return Condition(ConditionKey.OBJECT_TYPE, *args, **kwargs) + class Rule: def __init__(