forked from TrueCloudLab/frostfs-testcases
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:
parent
186091640f
commit
f9ba463d2e
5 changed files with 38 additions and 35 deletions
|
@ -183,10 +183,6 @@ class RemoteDevEnvStorageServiceHelper(LocalDevEnvStorageServiceHelper):
|
||||||
client = docker.APIClient(base_url=f"tcp://{host}:2375")
|
client = docker.APIClient(base_url=f"tcp://{host}:2375")
|
||||||
return client
|
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:
|
def delete_node_data(self, node_name: str) -> None:
|
||||||
volume_name = _get_storage_volume_name(node_name)
|
volume_name = _get_storage_volume_name(node_name)
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ def placement_policy_from_container(container_info: str) -> str:
|
||||||
container ID: j7k4auNHRmiPMSmnH2qENLECD2au2y675fvTX6csDwd
|
container ID: j7k4auNHRmiPMSmnH2qENLECD2au2y675fvTX6csDwd
|
||||||
version: 2.12
|
version: 2.12
|
||||||
owner ID: NQ8HUxE5qEj7UUvADj7z9Z7pcvJdjtPwuw
|
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)
|
attribute: Timestamp=1656340345 (2022-06-27 17:32:25 +0300 MSK)
|
||||||
nonce: 1c511e88-efd7-4004-8dbf-14391a5d375a
|
nonce: 1c511e88-efd7-4004-8dbf-14391a5d375a
|
||||||
placement policy:
|
placement policy:
|
||||||
|
|
|
@ -5,43 +5,51 @@ import allure
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from epoch import tick_epoch
|
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 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.parametrize('name', ['', 'test-container'], ids=['No name', 'Set particular name'])
|
||||||
@pytest.mark.sanity
|
@pytest.mark.sanity
|
||||||
@pytest.mark.container
|
@pytest.mark.container
|
||||||
def test_container_creation(prepare_wallet_and_deposit, name):
|
def test_container_creation(prepare_wallet_and_deposit, name):
|
||||||
wallet = prepare_wallet_and_deposit
|
scenario_title = f'with name {name}' if name else 'without name'
|
||||||
msg = f'with name {name}' if name else 'without name'
|
allure.dynamic.title(f'User can create container {scenario_title}')
|
||||||
allure.dynamic.title(f'User can create container {msg}')
|
|
||||||
|
|
||||||
with open(wallet) as fp:
|
wallet = prepare_wallet_and_deposit
|
||||||
json_wallet = json.load(fp)
|
with open(wallet) as file:
|
||||||
|
json_wallet = json.load(file)
|
||||||
|
|
||||||
placement_rule = 'REP 2 IN X CBF 1 SELECT 2 FROM * AS X'
|
placement_rule = 'REP 2 IN X CBF 1 SELECT 2 FROM * AS X'
|
||||||
info_to_check = {'basic ACL: 1c8c8ccc (private)',
|
options = f" --name {name}" if name else ""
|
||||||
f'owner ID: {json_wallet.get("accounts")[0].get("address")}'}
|
cid = create_container(wallet, rule=placement_rule, options=options)
|
||||||
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}')
|
|
||||||
|
|
||||||
containers = list_containers(wallet)
|
containers = list_containers(wallet)
|
||||||
assert cid in containers, f'Expected container {cid} in containers: {containers}'
|
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'):
|
with allure.step('Check container has correct information'):
|
||||||
got_policy = placement_policy_from_container(get_output)
|
expected_policy = placement_rule.lower()
|
||||||
assert got_policy == placement_rule.replace('\'', ''), \
|
actual_policy = placement_policy_from_container(container_info)
|
||||||
f'Expected \n{placement_rule} and got policy \n{got_policy} are the same'
|
assert actual_policy == expected_policy, \
|
||||||
|
f'Expected policy\n{expected_policy} but got policy\n{actual_policy}'
|
||||||
|
|
||||||
for info in info_to_check:
|
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'):
|
with allure.step('Delete container and check it was deleted'):
|
||||||
delete_container(wallet, cid)
|
delete_container(wallet, cid)
|
||||||
|
@ -50,7 +58,7 @@ def test_container_creation(prepare_wallet_and_deposit, name):
|
||||||
|
|
||||||
|
|
||||||
@allure.step('Wait for container deletion')
|
@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
|
attempts, sleep_interval = 10, 5
|
||||||
for _ in range(attempts):
|
for _ in range(attempts):
|
||||||
try:
|
try:
|
||||||
|
@ -61,4 +69,4 @@ def wait_for_container_deletion(wallet: str, cid: str):
|
||||||
if 'container not found' not in str(err):
|
if 'container not found' not in str(err):
|
||||||
raise AssertionError(f'Expected "container not found" in error, got\n{err}')
|
raise AssertionError(f'Expected "container not found" in error, got\n{err}')
|
||||||
return
|
return
|
||||||
raise AssertionError(f'Expected container deleted during {attempts * sleep_interval} sec.')
|
raise AssertionError(f'Container was not deleted within {attempts * sleep_interval} sec')
|
||||||
|
|
|
@ -68,7 +68,6 @@ def _encode_cid_for_eacl(cid: str) -> str:
|
||||||
@keyword('Create eACL')
|
@keyword('Create eACL')
|
||||||
def create_eacl(cid: str, rules_list: list) -> str:
|
def create_eacl(cid: str, rules_list: list) -> str:
|
||||||
table_file_path = f"{os.getcwd()}/{ASSETS_DIR}/eacl_table_{str(uuid.uuid4())}.json"
|
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)
|
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}"
|
cmd = f"{NEOFS_CLI_EXEC} acl extended create --cid {cid} {rules} --out {table_file_path}"
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
# ACLs with set F flag
|
# ACLs with final flag
|
||||||
PUBLIC_ACL_F = "0x1FBFBFFF"
|
PUBLIC_ACL_F = "1FBFBFFF"
|
||||||
PRIVATE_ACL_F = "0x1C8C8CCC"
|
PRIVATE_ACL_F = "1C8C8CCC"
|
||||||
READONLY_ACL_F = "0x1FBF8CFF"
|
READONLY_ACL_F = "1FBF8CFF"
|
||||||
|
|
||||||
# ACLs without F flag set
|
# ACLs without final flag set
|
||||||
PUBLIC_ACL = "0x0FBFBFFF"
|
PUBLIC_ACL = "0FBFBFFF"
|
||||||
INACCESSIBLE_ACL = "0x40000000"
|
INACCESSIBLE_ACL = "40000000"
|
||||||
STICKYBIT_PUB_ACL = "0x3FFFFFFF"
|
STICKYBIT_PUB_ACL = "3FFFFFFF"
|
||||||
|
|
Loading…
Reference in a new issue