Refactor container tests

Use wellknown ACL constants.
Remove 0x prefix from ACL, because neofs CLI changed formatting.
Remove redundant comments.

Signed-off-by: Vladimir Domnich <v.domnich@yadro.com>
This commit is contained in:
Vladimir Domnich 2022-08-12 10:23:23 +03:00 committed by Vladimir Domnich
parent 186091640f
commit f9ba463d2e
5 changed files with 38 additions and 35 deletions

View file

@ -183,10 +183,6 @@ class RemoteDevEnvStorageServiceHelper(LocalDevEnvStorageServiceHelper):
client = docker.APIClient(base_url=f"tcp://{host}:2375")
return client
def run_control_command(self, node_name: str, command: str) -> str:
# On remote devenv it works same way as in cloud
return CloudVmStorageServiceHelper().run_control_command(node_name, command)
def delete_node_data(self, node_name: str) -> None:
volume_name = _get_storage_volume_name(node_name)

View file

@ -69,7 +69,7 @@ def placement_policy_from_container(container_info: str) -> str:
container ID: j7k4auNHRmiPMSmnH2qENLECD2au2y675fvTX6csDwd
version: 2.12
owner ID: NQ8HUxE5qEj7UUvADj7z9Z7pcvJdjtPwuw
basic ACL: 0x0fbfbfff (eacl-public-read-write)
basic ACL: 0fbfbfff (eacl-public-read-write)
attribute: Timestamp=1656340345 (2022-06-27 17:32:25 +0300 MSK)
nonce: 1c511e88-efd7-4004-8dbf-14391a5d375a
placement policy:

View file

@ -5,43 +5,51 @@ import allure
import pytest
from epoch import tick_epoch
from python_keywords.container import create_container, get_container, list_containers, delete_container
from python_keywords.container import (create_container, delete_container, get_container,
list_containers)
from utility import placement_policy_from_container
from wellknown_acl import PRIVATE_ACL_F
@pytest.mark.parametrize('name', ['', 'test-container'], ids=['No name', 'Set particular name'])
@pytest.mark.sanity
@pytest.mark.container
def test_container_creation(prepare_wallet_and_deposit, name):
wallet = prepare_wallet_and_deposit
msg = f'with name {name}' if name else 'without name'
allure.dynamic.title(f'User can create container {msg}')
scenario_title = f'with name {name}' if name else 'without name'
allure.dynamic.title(f'User can create container {scenario_title}')
with open(wallet) as fp:
json_wallet = json.load(fp)
wallet = prepare_wallet_and_deposit
with open(wallet) as file:
json_wallet = json.load(file)
placement_rule = 'REP 2 IN X CBF 1 SELECT 2 FROM * AS X'
info_to_check = {'basic ACL: 1c8c8ccc (private)',
f'owner ID: {json_wallet.get("accounts")[0].get("address")}'}
if name:
info_to_check.add(f'Name={name}')
name = f' --name {name}'
cid = create_container(wallet, rule=placement_rule, options=name)
info_to_check.add(f'container ID: {cid}')
options = f" --name {name}" if name else ""
cid = create_container(wallet, rule=placement_rule, options=options)
containers = list_containers(wallet)
assert cid in containers, f'Expected container {cid} in containers: {containers}'
get_output = get_container(wallet, cid, flag='')
container_info = get_container(wallet, cid, flag='')
container_info = container_info.lower() # To ignore case when comparing with expected values
info_to_check = {
f'basic ACL: {PRIVATE_ACL_F} (private)',
f'owner ID: {json_wallet.get("accounts")[0].get("address")}',
f'container ID: {cid}',
}
if name:
info_to_check.add(f'Name={name}')
with allure.step('Check container has correct information'):
got_policy = placement_policy_from_container(get_output)
assert got_policy == placement_rule.replace('\'', ''), \
f'Expected \n{placement_rule} and got policy \n{got_policy} are the same'
expected_policy = placement_rule.lower()
actual_policy = placement_policy_from_container(container_info)
assert actual_policy == expected_policy, \
f'Expected policy\n{expected_policy} but got policy\n{actual_policy}'
for info in info_to_check:
assert info in get_output, f'Expected info {info} in output:\n{get_output}'
expected_info = info.lower()
assert expected_info in container_info, \
f'Expected {expected_info} in container info:\n{container_info}'
with allure.step('Delete container and check it was deleted'):
delete_container(wallet, cid)
@ -50,7 +58,7 @@ def test_container_creation(prepare_wallet_and_deposit, name):
@allure.step('Wait for container deletion')
def wait_for_container_deletion(wallet: str, cid: str):
def wait_for_container_deletion(wallet: str, cid: str) -> None:
attempts, sleep_interval = 10, 5
for _ in range(attempts):
try:
@ -61,4 +69,4 @@ def wait_for_container_deletion(wallet: str, cid: str):
if 'container not found' not in str(err):
raise AssertionError(f'Expected "container not found" in error, got\n{err}')
return
raise AssertionError(f'Expected container deleted during {attempts * sleep_interval} sec.')
raise AssertionError(f'Container was not deleted within {attempts * sleep_interval} sec')

View file

@ -68,7 +68,6 @@ def _encode_cid_for_eacl(cid: str) -> str:
@keyword('Create eACL')
def create_eacl(cid: str, rules_list: list) -> str:
table_file_path = f"{os.getcwd()}/{ASSETS_DIR}/eacl_table_{str(uuid.uuid4())}.json"
# TODO: check if $Object: is still necessary for filtering in the newest releases
rules = " ".join(f"--rule '{rule}'" for rule in rules_list)
cmd = f"{NEOFS_CLI_EXEC} acl extended create --cid {cid} {rules} --out {table_file_path}"

View file

@ -1,9 +1,9 @@
# ACLs with set F flag
PUBLIC_ACL_F = "0x1FBFBFFF"
PRIVATE_ACL_F = "0x1C8C8CCC"
READONLY_ACL_F = "0x1FBF8CFF"
# ACLs with final flag
PUBLIC_ACL_F = "1FBFBFFF"
PRIVATE_ACL_F = "1C8C8CCC"
READONLY_ACL_F = "1FBF8CFF"
# ACLs without F flag set
PUBLIC_ACL = "0x0FBFBFFF"
INACCESSIBLE_ACL = "0x40000000"
STICKYBIT_PUB_ACL = "0x3FFFFFFF"
# ACLs without final flag set
PUBLIC_ACL = "0FBFBFFF"
INACCESSIBLE_ACL = "40000000"
STICKYBIT_PUB_ACL = "3FFFFFFF"