Skip to content

Commit

Permalink
Fix warnings (#868)
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-khimov authored Oct 2, 2024
2 parents 93723c4 + 2c89f46 commit 14236d1
Show file tree
Hide file tree
Showing 42 changed files with 39 additions and 164 deletions.
2 changes: 1 addition & 1 deletion neofs-testlib/neofs_testlib/env/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class NeoFSEnv:
_busy_ports = []

def __init__(self, neofs_env_config: dict = None):
self._id = datetime.datetime.now().strftime("%Y-%m-%d-%H-%M-%S")
self._id = datetime.datetime.now(datetime.UTC).strftime("%Y-%m-%d-%H-%M-%S")
self._env_dir = f"env_files/neofs-env-{self._id}"

self.domain = "localhost"
Expand Down
10 changes: 5 additions & 5 deletions neofs-testlib/neofs_testlib/shell/local_shell.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
import subprocess
import tempfile
from datetime import datetime
from datetime import UTC, datetime
from typing import IO, Optional

import pexpect
Expand Down Expand Up @@ -33,7 +33,7 @@ def exec(self, command: str, options: Optional[CommandOptions] = None) -> Comman
return self._exec_non_interactive(command, options)

def _exec_interactive(self, command: str, options: CommandOptions) -> CommandResult:
start_time = datetime.utcnow()
start_time = datetime.now(UTC)
log_file = tempfile.TemporaryFile() # File is reliable cross-platform way to capture output

try:
Expand All @@ -54,15 +54,15 @@ def _exec_interactive(self, command: str, options: CommandOptions) -> CommandRes
finally:
result = self._get_pexpect_process_result(command_process)
log_file.close()
end_time = datetime.utcnow()
end_time = datetime.now(UTC)
self._report_command_result(command, start_time, end_time, result)

if options.check and result.return_code != 0:
raise RuntimeError(f"Command: {command}\nreturn code: {result.return_code}\n" f"Output: {result.stdout}")
return result

def _exec_non_interactive(self, command: str, options: CommandOptions) -> CommandResult:
start_time = datetime.utcnow()
start_time = datetime.now(UTC)
result = None

try:
Expand Down Expand Up @@ -94,7 +94,7 @@ def _exec_non_interactive(self, command: str, options: CommandOptions) -> Comman
except (OSError, subprocess.SubprocessError) as exc:
raise RuntimeError(f"Command: {command}\nOutput: {exc.strerror}") from exc
finally:
end_time = datetime.utcnow()
end_time = datetime.now(UTC)
self._report_command_result(command, start_time, end_time, result)
return result

Expand Down
6 changes: 3 additions & 3 deletions neofs-testlib/neofs_testlib/shell/ssh_shell.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
import socket
import textwrap
from datetime import datetime
from datetime import UTC, datetime
from functools import lru_cache, wraps
from time import sleep
from typing import ClassVar, Optional, Tuple
Expand Down Expand Up @@ -41,9 +41,9 @@ def wrapper(shell: "SSHShell", command: str, options: CommandOptions, *args, **k
with reporter.step(command_info):
logger.info(f'Execute command "{command}" on "{shell.host}"')

start_time = datetime.utcnow()
start_time = datetime.now(UTC)
result = func(shell, command, options, *args, **kwargs)
end_time = datetime.utcnow()
end_time = datetime.now(UTC)

elapsed_time = end_time - start_time
log_message = (
Expand Down
12 changes: 6 additions & 6 deletions pytest_tests/lib/helpers/cli_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import subprocess
import sys
from contextlib import suppress
from datetime import datetime
from datetime import UTC, datetime
from textwrap import shorten
from typing import Union

Expand All @@ -27,10 +27,10 @@ def _cmd_run(cmd: str, timeout: int = 30) -> str:
in case of failure returns error message.
"""
compl_proc = None
start_time = datetime.now()
start_time = datetime.now(UTC)
try:
logger.info(f"{COLOR_GREEN}Executing command: {cmd}{COLOR_OFF}")
start_time = datetime.utcnow()
start_time = datetime.now(UTC)
compl_proc = subprocess.run(
cmd,
check=True,
Expand All @@ -42,14 +42,14 @@ def _cmd_run(cmd: str, timeout: int = 30) -> str:
)
output = compl_proc.stdout
return_code = compl_proc.returncode
end_time = datetime.utcnow()
end_time = datetime.now(UTC)
logger.info(f"{COLOR_GREEN}Output: {output}{COLOR_OFF}")
_attach_allure_log(cmd, output, return_code, start_time, end_time)

return output
except subprocess.CalledProcessError as exc:
logger.info(f"Command: {cmd}\n" f"Error:\nreturn code: {exc.returncode} " f"\nOutput: {exc.output}")
end_time = datetime.now()
end_time = datetime.now(UTC)
return_code, cmd_output = subprocess.getstatusoutput(cmd)
_attach_allure_log(cmd, cmd_output, return_code, start_time, end_time)

Expand All @@ -60,7 +60,7 @@ def _cmd_run(cmd: str, timeout: int = 30) -> str:
raise RuntimeError(f"Command: {cmd}\n" f"Output: {exc.strerror}") from exc
except Exception as exc:
return_code, cmd_output = subprocess.getstatusoutput(cmd)
end_time = datetime.now()
end_time = datetime.now(UTC)
_attach_allure_log(cmd, cmd_output, return_code, start_time, end_time)
logger.info(
f"Command: {cmd}\n"
Expand Down
4 changes: 2 additions & 2 deletions pytest_tests/lib/helpers/neofs_verbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,9 +548,9 @@ def str_to_bool(val: str) -> bool:
raise ValueError(f"Invalid value: {val}")

patterns = [
(re.compile("(.*): (\d+)"), int),
(re.compile(r"(.*): (\d+)"), int),
(re.compile("(.*): (false|true)"), str_to_bool),
(re.compile("(.*): (\d+\.\d+)"), float),
(re.compile(r"(.*): (\d+\.\d+)"), float),
]
for pattern, func in patterns:
for setting, value in re.findall(pattern, output.stdout):
Expand Down
39 changes: 2 additions & 37 deletions pytest_tests/pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,5 @@ log_format = [%(threadName)s] %(asctime)s [%(levelname)4s] %(message)s [%(thread
log_cli_date_format = %Y-%m-%d %H:%M:%S
log_date_format = %H:%M:%S
markers =
# special markers
staging: test to be excluded from run in verifier/pr-validation/sanity jobs and run test in staging job
sanity: test runs in sanity testrun
smoke: test runs in smoke testrun
# functional markers
container: tests for container creation
grpc_api: standard gRPC API tests
grpc_control: tests related to using neofs-cli control commands
grpc_object_lock: gRPC lock tests
rest_gate: REST gate tests
s3_gate: All S3 gate tests
s3_gate_base: Base S3 gate tests
s3_gate_bucket: Bucket S3 gate tests
s3_gate_locking: Locking S3 gate tests
s3_gate_multipart: S3 gate tests with multipart object
s3_gate_object: Object S3 gate tests
s3_gate_tagging: Tagging S3 gate tests
s3_gate_versioning: Versioning S3 gate tests
long: long tests (with long execution time)
node_mgmt: neofs control commands
session_token: tests for operations with session token
static_session: tests for operations with static session token
bearer: tests for bearer tokens
acl: All tests for ACL
acl_basic: tests for basic ACL
acl_bearer: tests for ACL with bearer
acl_extended: tests for extended ACL
acl_filters: tests for extended ACL with filters and headers
storage_group: tests for storage groups
failover: tests for system recovery after a failure
failover_panic: tests for system recovery after panic reboot of a node
failover_network: tests for network failure
failover_reboot: tests for system recovery after reboot of a node
add_nodes: add nodes to cluster
check_binaries: check neofs installed binaries versions
payments: tests for payment associated operations
load: performance tests
sanity: short number of tests to ensure basic system functionality works
aws_cli_only: for s3 tests to run only with aws cli
4 changes: 0 additions & 4 deletions pytest_tests/tests/acl/test_acl.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
from neofs_testlib.env.env import NodeWallet


@pytest.mark.smoke
@pytest.mark.acl
@pytest.mark.acl_basic
class TestACLBasic(NeofsEnvTestBase):
@pytest.fixture(scope="function")
def public_container(self, user_wallet: NodeWallet):
Expand Down Expand Up @@ -64,7 +61,6 @@ def read_only_container(self, user_wallet: NodeWallet):
yield cid_read_only

@pytest.mark.sanity
@pytest.mark.test_basic_acl_public
@allure.title("Test basic ACL on public container")
def test_basic_acl_public(self, not_owner_wallet: NodeWallet, user_wallet: NodeWallet, public_container, file_path):
"""
Expand Down
2 changes: 0 additions & 2 deletions pytest_tests/tests/acl/test_bearer.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@
ContainerTuple = namedtuple("ContainerTuple", ["cid", "objects_oids"])


@pytest.mark.acl
@pytest.mark.acl_bearer
class TestACLBearer(NeofsEnvTestBase):
@pytest.mark.parametrize("role", [EACLRole.USER, EACLRole.OTHERS])
def test_bearer_token_operations(self, wallets, eacl_container_with_objects, role):
Expand Down
8 changes: 0 additions & 8 deletions pytest_tests/tests/acl/test_eacl.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@
from neofs_testlib.env.env import NeoFSEnv


@pytest.mark.acl
@pytest.mark.acl_extended
class TestEACLContainer(NeofsEnvTestBase):
@pytest.fixture(scope="function")
def eacl_full_placement_container_with_object(self, wallets, file_path) -> tuple[str, str, str]:
Expand Down Expand Up @@ -441,8 +439,6 @@ def test_extended_acl_deny_replication(self, wallets, eacl_full_placement_contai
with allure.step("Wait for dropped object replicated"):
wait_object_replication(cid, oid, len(storage_nodes), self.shell, storage_nodes, self.neofs_env)

@pytest.mark.trusted_party_proved
@pytest.mark.system_eacl
@allure.title("Test case for verifying the impossible to change system extended ACL")
def test_deprecated_change_system_eacl(self, wallets, eacl_container_with_objects):
user_wallet = wallets.get_wallet()
Expand Down Expand Up @@ -490,8 +486,6 @@ def test_deprecated_change_system_eacl(self, wallets, eacl_container_with_object
with allure.step("The eACL must be empty"):
assert get_eacl(user_wallet.wallet_path, cid, self.shell, endpoint) is None

@pytest.mark.trusted_party_proved
@pytest.mark.system_eacl
@allure.title("Test case for verifying the impossible to change system extended ACL if eACL already set")
@pytest.mark.parametrize("address", [EACLRoleExtendedType.ADDRESS, None])
def test_deprecated_change_system_eacl_if_eacl_already_set(self, wallets, eacl_container_with_objects, address):
Expand Down Expand Up @@ -543,7 +537,6 @@ def test_deprecated_change_system_eacl_if_eacl_already_set(self, wallets, eacl_c
with allure.step("The eACL should not be changed"):
assert get_eacl(user_wallet.wallet_path, cid, self.shell, endpoint) == old_eacl

@pytest.mark.trusted_party_proved
@allure.title("Test case to check compliance with Check IR and STORAGE rules")
def test_compliance_ir_and_storage_rules(self, wallets, eacl_container_with_objects):
ir_wallet = wallets.get_ir_wallet()
Expand Down Expand Up @@ -679,7 +672,6 @@ def test_compliance_ir_and_storage_rules(self, wallets, eacl_container_with_obje
wallet_config=storage_wallet.config_path,
)

@pytest.mark.trusted_party_proved
@allure.title("Not owner and not trusted party can NOT set eacl")
@pytest.mark.parametrize("address", [EACLRoleExtendedType.ADDRESS, None])
def test_only_owner_can_set_eacl(
Expand Down
2 changes: 0 additions & 2 deletions pytest_tests/tests/acl/test_eacl_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
from pytest_lazy_fixtures import lf


@pytest.mark.acl
@pytest.mark.acl_filters
class TestEACLFilters(NeofsEnvTestBase):
# SPEC: https://github.com/nspcc-dev/neofs-spec/blob/master/01-arch/07-acl.md
ATTRIBUTE = {"check_key": "check_value"}
Expand Down
2 changes: 0 additions & 2 deletions pytest_tests/tests/acl/test_storagegroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@
[lf("simple_object_size"), lf("complex_object_size")],
ids=["simple object", "complex object"],
)
@pytest.mark.acl
@pytest.mark.storage_group
class TestStorageGroup(NeofsEnvTestBase):
@pytest.fixture(autouse=True)
def prepare_two_wallets(self, default_wallet):
Expand Down
4 changes: 0 additions & 4 deletions pytest_tests/tests/container/test_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,8 @@ def object_should_be_gc_marked(neofs_env: NeoFSEnv, node: StorageNode, cid: str,
assert "GC MARKED" in response.stdout, "Unexected output from control object status command"


@pytest.mark.container
@pytest.mark.container
class TestContainer(NeofsEnvTestBase):
@pytest.mark.parametrize("name", ["", "test-container"], ids=["No name", "Set particular name"])
@pytest.mark.smoke
@pytest.mark.sanity
def test_container_creation(self, default_wallet, name):
scenario_title = f"with name {name}" if name else "without name"
Expand Down Expand Up @@ -105,7 +102,6 @@ def test_container_creation(self, default_wallet, name):
self.tick_epochs_and_wait(1)
wait_for_container_deletion(wallet.path, cid, shell=self.shell, endpoint=self.neofs_env.sn_rpc)

@pytest.mark.trusted_party_proved
@allure.title("Not owner and not trusted party can NOT delete container")
def test_only_owner_can_delete_container(self, not_owner_wallet: NodeWallet, default_wallet: str):
cid = create_container(
Expand Down
1 change: 0 additions & 1 deletion pytest_tests/tests/contract/test_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from neofs_testlib.shell import Shell


@pytest.mark.additional_contracts
class TestContract(NeofsEnvTestBase):
@allure.title("Test operations with external smart contracts")
def test_contract(self, datadir, client_shell: Shell, neofs_env: NeoFSEnv):
Expand Down
2 changes: 0 additions & 2 deletions pytest_tests/tests/failovers/test_failover_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
blocked_nodes: list[StorageNode] = []


@pytest.mark.failover
@pytest.mark.failover_network
@pytest.mark.skipif(sys.platform == "darwin", reason="not supported on macos runners")
class TestFailoverNetwork(NeofsEnvTestBase):
@allure.step("Restore network")
Expand Down
3 changes: 0 additions & 3 deletions pytest_tests/tests/failovers/test_failover_part.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,8 @@ def user_container(user_wallet: NodeWallet, client_shell: Shell, neofs_env: NeoF
return StorageContainer(StorageContainerInfo(container_id, user_wallet), client_shell, neofs_env)


@pytest.mark.failover_part
class TestFailoverNodePart(NeofsEnvTestBase):
@allure.title("Enable resync metabase, delete metadata and get object")
@pytest.mark.delete_metadata
def test_enable_resync_metabase_delete_metadata(
self,
enable_metabase_resync_on_start,
Expand Down Expand Up @@ -60,7 +58,6 @@ def test_enable_resync_metabase_delete_metadata(
)

@allure.title("Delete metadata without resync metabase enabling, delete metadata try to get object")
@pytest.mark.delete_metadata
def test_delete_metadata(self, user_container: StorageContainer, simple_object_size: int):
storage_object = user_container.generate_object(simple_object_size)

Expand Down
1 change: 0 additions & 1 deletion pytest_tests/tests/failovers/test_failover_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ def return_stopped_storage_nodes(neofs_env: NeoFSEnv) -> None:
wait_all_storage_nodes_returned(neofs_env)


@pytest.mark.failover
class TestFailoverStorage(NeofsEnvTestBase):
@allure.title("Lose and return storage node's process")
@pytest.mark.parametrize("hard_restart", [True, False])
Expand Down
1 change: 0 additions & 1 deletion pytest_tests/tests/load/test_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from neofs_testlib.env.env import XK6


@pytest.mark.load
class TestLoad(NeofsEnvTestBase):
def test_custom_load(self):
xk6 = XK6(self.neofs_env)
Expand Down
1 change: 0 additions & 1 deletion pytest_tests/tests/network/test_config_changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@


@allure.title("Network configuration changes via neofs-adm")
@pytest.mark.network_config
class TestNetworkConfigChange(NeofsEnvTestBase):
@pytest.mark.parametrize(
"key, value",
Expand Down
1 change: 0 additions & 1 deletion pytest_tests/tests/network/test_homomorphic_hash.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@


@allure.title("Homomorphic hash disabling/enabling")
@pytest.mark.homo_hash
class TestHomomorphicHash(NeofsEnvTestBase):
@pytest.fixture(scope="class")
def set_homomorphic_hash_to_default(self):
Expand Down
Loading

0 comments on commit 14236d1

Please sign in to comment.