forked from TrueCloudLab/frostfs-testcases
Fix parsing of CLI output
Formatting has been changed in CLI tools in version v0.30 and it required us to change logic in tests: - Fix authmate output parsing. - Fix format of container name in assert. Signed-off-by: Vladimir Domnich <v.domnich@yadro.com>
This commit is contained in:
parent
cccfc41409
commit
d8911f2490
2 changed files with 21 additions and 14 deletions
|
@ -21,10 +21,10 @@ def test_container_creation(prepare_wallet_and_deposit, name):
|
||||||
json_wallet = json.load(fp)
|
json_wallet = json.load(fp)
|
||||||
|
|
||||||
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: 0x1c8c8ccc (private)',
|
info_to_check = {'basic ACL: 1c8c8ccc (private)',
|
||||||
f'owner ID: {json_wallet.get("accounts")[0].get("address")}'}
|
f'owner ID: {json_wallet.get("accounts")[0].get("address")}'}
|
||||||
if name:
|
if name:
|
||||||
info_to_check.add(f'attribute: Name={name}')
|
info_to_check.add(f'Name={name}')
|
||||||
name = f' --name {name}'
|
name = f' --name {name}'
|
||||||
|
|
||||||
cid = create_container(wallet, rule=placement_rule, options=name)
|
cid = create_container(wallet, rule=placement_rule, options=name)
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
import uuid
|
import uuid
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
@ -52,19 +53,25 @@ def init_s3_credentials(wallet_path, s3_bearer_rules_file: str = None):
|
||||||
try:
|
try:
|
||||||
output = _run_with_passwd(cmd)
|
output = _run_with_passwd(cmd)
|
||||||
logger.info(f'Command completed with output: {output}')
|
logger.info(f'Command completed with output: {output}')
|
||||||
# first five string are log output, cutting them off and parse
|
|
||||||
# the rest of the output as JSON
|
# output contains some debug info and then several JSON structures, so we find each
|
||||||
output = '\n'.join(output.split('\n')[5:])
|
# JSON structure by curly brackets (naive approach, but works while JSON is not nested)
|
||||||
|
# and then we take JSON containing secret_access_key
|
||||||
|
json_blocks = re.findall(r'\{.*?\}', output, re.DOTALL)
|
||||||
|
for json_block in json_blocks:
|
||||||
try:
|
try:
|
||||||
output_dict = json.loads(output)
|
parsed_json_block = json.loads(json_block)
|
||||||
|
if 'secret_access_key' in parsed_json_block:
|
||||||
|
return (
|
||||||
|
parsed_json_block['container_id'],
|
||||||
|
bucket,
|
||||||
|
parsed_json_block['access_key_id'],
|
||||||
|
parsed_json_block['secret_access_key'],
|
||||||
|
parsed_json_block['owner_private_key']
|
||||||
|
)
|
||||||
except json.JSONDecodeError:
|
except json.JSONDecodeError:
|
||||||
raise AssertionError(f'Could not parse info from output\n{output}')
|
raise AssertionError(f'Could not parse info from output\n{output}')
|
||||||
|
raise AssertionError(f'Could not find AWS credentials in output:\n{output}')
|
||||||
return (output_dict['container_id'],
|
|
||||||
bucket,
|
|
||||||
output_dict['access_key_id'],
|
|
||||||
output_dict['secret_access_key'],
|
|
||||||
output_dict['owner_private_key'])
|
|
||||||
|
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
raise RuntimeError(f'Failed to init s3 credentials because of error\n{exc}') from exc
|
raise RuntimeError(f'Failed to init s3 credentials because of error\n{exc}') from exc
|
||||||
|
|
Loading…
Reference in a new issue