forked from TrueCloudLab/frostfs-testcases
Add asserts for error status codes in grpc responses
Signed-off-by: Vladimir Domnich <v.domnich@yadro.com>
This commit is contained in:
parent
b6b1644fd6
commit
a76614b40d
7 changed files with 62 additions and 31 deletions
|
@ -5,6 +5,7 @@ import allure
|
|||
import pytest
|
||||
|
||||
from epoch import tick_epoch
|
||||
from grpc_responses import CONTAINER_NOT_FOUND, error_matches_status
|
||||
from python_keywords.container import (create_container, delete_container, get_container,
|
||||
list_containers)
|
||||
from utility import placement_policy_from_container
|
||||
|
@ -23,14 +24,14 @@ def test_container_creation(prepare_wallet_and_deposit, name):
|
|||
json_wallet = json.load(file)
|
||||
|
||||
placement_rule = 'REP 2 IN X CBF 1 SELECT 2 FROM * AS X'
|
||||
options = f" --name {name}" if name else ""
|
||||
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}'
|
||||
|
||||
container_info = get_container(wallet, cid, flag='')
|
||||
container_info = container_info.lower() # To ignore case when comparing with expected values
|
||||
container_info: str = get_container(wallet, cid, flag='')
|
||||
container_info = container_info.casefold() # To ignore case when comparing with expected values
|
||||
|
||||
info_to_check = {
|
||||
f'basic ACL: {PRIVATE_ACL_F} (private)',
|
||||
|
@ -41,13 +42,13 @@ def test_container_creation(prepare_wallet_and_deposit, name):
|
|||
info_to_check.add(f'Name={name}')
|
||||
|
||||
with allure.step('Check container has correct information'):
|
||||
expected_policy = placement_rule.lower()
|
||||
expected_policy = placement_rule.casefold()
|
||||
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:
|
||||
expected_info = info.lower()
|
||||
expected_info = info.casefold()
|
||||
assert expected_info in container_info, \
|
||||
f'Expected {expected_info} in container info:\n{container_info}'
|
||||
|
||||
|
@ -66,7 +67,8 @@ def wait_for_container_deletion(wallet: str, cid: str) -> None:
|
|||
sleep(sleep_interval)
|
||||
continue
|
||||
except Exception as err:
|
||||
if 'container not found' not in str(err):
|
||||
raise AssertionError(f'Expected "container not found" in error, got\n{err}')
|
||||
return
|
||||
if error_matches_status(err, CONTAINER_NOT_FOUND):
|
||||
return
|
||||
raise AssertionError(f'Expected "{CONTAINER_NOT_FOUND}" error, got\n{err}')
|
||||
|
||||
raise AssertionError(f'Container was not deleted within {attempts * sleep_interval} sec')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue