(#84) try-catch for --ttl 1
Signed-off-by: Elizaveta Chichindaeva <elizaveta@nspcc.ru>
This commit is contained in:
parent
b95f6bd7c8
commit
f3f3f00d4a
1 changed files with 67 additions and 51 deletions
|
@ -326,18 +326,20 @@ def get_component_objects(private_key: str, cid: str, oid: str):
|
||||||
split_id = ""
|
split_id = ""
|
||||||
nodes = _get_storage_nodes()
|
nodes = _get_storage_nodes()
|
||||||
for node in nodes:
|
for node in nodes:
|
||||||
header_virtual = head_object(private_key, cid, oid, '', '', '--raw --ttl 1', node, True)
|
try:
|
||||||
if header_virtual:
|
header_virtual = head_object(private_key, cid, oid, '', '', '--raw --ttl 1', node, True)
|
||||||
parsed_header_virtual = parse_object_virtual_raw_header(header_virtual)
|
if header_virtual:
|
||||||
|
parsed_header_virtual = parse_object_virtual_raw_header(header_virtual)
|
||||||
|
|
||||||
if 'Linking object' in parsed_header_virtual.keys():
|
if 'Linking object' in parsed_header_virtual.keys():
|
||||||
return _collect_split_objects_from_header(private_key, cid, parsed_header_virtual)
|
return _collect_split_objects_from_header(private_key, cid, parsed_header_virtual)
|
||||||
|
|
||||||
elif 'Split ID' in parsed_header_virtual.keys():
|
elif 'Split ID' in parsed_header_virtual.keys():
|
||||||
logger.info(f"parsed_header_virtual: !@ {parsed_header_virtual}" )
|
logger.info(f"parsed_header_virtual: !@ {parsed_header_virtual}" )
|
||||||
split_id = parsed_header_virtual['Split ID']
|
split_id = parsed_header_virtual['Split ID']
|
||||||
|
|
||||||
logger.warn("Linking object has not been found.")
|
except:
|
||||||
|
logger.warn("Linking object has not been found.")
|
||||||
|
|
||||||
# Get all existing objects
|
# Get all existing objects
|
||||||
full_obj_list = search_object(private_key, cid, None, None, None, None, '--phy')
|
full_obj_list = search_object(private_key, cid, None, None, None, None, '--phy')
|
||||||
|
@ -373,59 +375,69 @@ def verify_split_chain(private_key: str, cid: str, oid: str):
|
||||||
logger.info("Collect Split objects information and verify chain of the objects.")
|
logger.info("Collect Split objects information and verify chain of the objects.")
|
||||||
nodes = _get_storage_nodes()
|
nodes = _get_storage_nodes()
|
||||||
for node in nodes:
|
for node in nodes:
|
||||||
header_virtual = head_object(private_key, cid, oid, '', '', '--raw --ttl 1', node, True)
|
try:
|
||||||
parsed_header_virtual = parse_object_virtual_raw_header(header_virtual)
|
header_virtual = head_object(private_key, cid, oid, '', '', '--raw --ttl 1', node, True)
|
||||||
|
parsed_header_virtual = parse_object_virtual_raw_header(header_virtual)
|
||||||
|
|
||||||
if 'Last object' in parsed_header_virtual.keys():
|
if 'Last object' in parsed_header_virtual.keys():
|
||||||
header_last = head_object(private_key, cid, parsed_header_virtual['Last object'], '', '', '--raw')
|
header_last = head_object(private_key, cid,
|
||||||
header_last_parsed = _get_raw_split_information(header_last)
|
parsed_header_virtual['Last object'],
|
||||||
marker_last_obj = 1
|
'', '', '--raw')
|
||||||
|
header_last_parsed = _get_raw_split_information(header_last)
|
||||||
|
marker_last_obj = 1
|
||||||
|
|
||||||
# Recursive chain validation up to the first object
|
# Recursive chain validation up to the first object
|
||||||
final_verif_data = _verify_child_link(private_key, cid, oid, header_last_parsed, final_verif_data)
|
final_verif_data = _verify_child_link(private_key, cid, oid, header_last_parsed, final_verif_data)
|
||||||
break
|
break
|
||||||
|
|
||||||
if marker_last_obj == 0:
|
except:
|
||||||
raise Exception("Latest object has not been found.")
|
if marker_last_obj == 0:
|
||||||
|
raise Exception("Latest object has not been found.")
|
||||||
|
|
||||||
# Get Linking object
|
# Get Linking object
|
||||||
logger.info("Compare Split objects result information with Linking object.")
|
logger.info("Compare Split objects result information with Linking object.")
|
||||||
for node in nodes:
|
for node in nodes:
|
||||||
|
try:
|
||||||
|
header_virtual = head_object(private_key, cid, oid, '', '', '--raw --ttl 1', node, True)
|
||||||
|
parsed_header_virtual = parse_object_virtual_raw_header(header_virtual)
|
||||||
|
if 'Linking object' in parsed_header_virtual.keys():
|
||||||
|
|
||||||
header_virtual = head_object(private_key, cid, oid, '', '', '--raw --ttl 1', node, True)
|
header_link = head_object(private_key, cid,
|
||||||
parsed_header_virtual = parse_object_virtual_raw_header(header_virtual)
|
parsed_header_virtual['Linking object'],
|
||||||
if 'Linking object' in parsed_header_virtual.keys():
|
'', '', '--raw')
|
||||||
|
header_link_parsed = _get_raw_split_information(header_link)
|
||||||
|
marker_link_obj = 1
|
||||||
|
|
||||||
header_link = head_object(private_key, cid, parsed_header_virtual['Linking object'], '', '', '--raw')
|
reversed_list = final_verif_data['ID List'][::-1]
|
||||||
header_link_parsed = _get_raw_split_information(header_link)
|
|
||||||
marker_link_obj = 1
|
|
||||||
|
|
||||||
reversed_list = final_verif_data['ID List'][::-1]
|
if header_link_parsed['Split ChildID'] == reversed_list:
|
||||||
|
logger.info(f"Split objects list from Linked Object is equal to expected "
|
||||||
|
f"{', '.join(header_link_parsed['Split ChildID'])}")
|
||||||
|
else:
|
||||||
|
raise Exception(f"Split objects list from Linking Object "
|
||||||
|
f"({', '.join(header_link_parsed['Split ChildID'])}) "
|
||||||
|
f"is not equal to expected ({', '.join(reversed_list)})")
|
||||||
|
|
||||||
if header_link_parsed['Split ChildID'] == reversed_list:
|
if int(header_link_parsed['PayloadLength']) == 0:
|
||||||
logger.info(f"Split objects list from Linked Object is equal to expected {', '.join(header_link_parsed['Split ChildID'])}")
|
logger.info("Linking object Payload is equal to expected - zero size.")
|
||||||
else:
|
else:
|
||||||
raise Exception(f"Split objects list from Linking Object ({', '.join(header_link_parsed['Split ChildID'])}) is not equal to expected ({', '.join(reversed_list)})")
|
raise Exception("Linking object Payload is not equal to expected. Should be zero.")
|
||||||
|
|
||||||
if int(header_link_parsed['PayloadLength']) == 0:
|
if header_link_parsed['Type'] == 'regular':
|
||||||
logger.info("Linking object Payload is equal to expected - zero size.")
|
logger.info("Linking Object Type is 'regular' as expected.")
|
||||||
else:
|
else:
|
||||||
raise Exception("Linking object Payload is not equal to expected. Should be zero.")
|
raise Exception("Object Type is not 'regular'.")
|
||||||
|
|
||||||
if header_link_parsed['Type'] == 'regular':
|
if header_link_parsed['Split ID'] == final_verif_data['Split ID']:
|
||||||
logger.info("Linking Object Type is 'regular' as expected.")
|
logger.info(f"Linking Object Split ID is equal to expected {final_verif_data['Split ID']}.")
|
||||||
else:
|
else:
|
||||||
raise Exception("Object Type is not 'regular'.")
|
raise Exception(f"Split ID from Linking Object ({header_link_parsed['Split ID']}) "
|
||||||
|
f"is not equal to expected ({final_verif_data['Split ID']})")
|
||||||
|
|
||||||
if header_link_parsed['Split ID'] == final_verif_data['Split ID']:
|
break
|
||||||
logger.info(f"Linking Object Split ID is equal to expected {final_verif_data['Split ID']}.")
|
except:
|
||||||
else:
|
if marker_link_obj == 0:
|
||||||
raise Exception(f"Split ID from Linking Object ({header_link_parsed['Split ID']}) is not equal to expected ({final_verif_data['Split ID']})")
|
raise Exception("Linked object has not been found.")
|
||||||
|
|
||||||
break
|
|
||||||
|
|
||||||
if marker_link_obj == 0:
|
|
||||||
raise Exception("Linked object has not been found.")
|
|
||||||
|
|
||||||
|
|
||||||
logger.info("Compare Split objects result information with Virtual object.")
|
logger.info("Compare Split objects result information with Virtual object.")
|
||||||
|
@ -434,9 +446,12 @@ def verify_split_chain(private_key: str, cid: str, oid: str):
|
||||||
header_virtual_parsed = _get_raw_split_information(header_virtual)
|
header_virtual_parsed = _get_raw_split_information(header_virtual)
|
||||||
|
|
||||||
if int(header_virtual_parsed['PayloadLength']) == int(final_verif_data['PayloadLength']):
|
if int(header_virtual_parsed['PayloadLength']) == int(final_verif_data['PayloadLength']):
|
||||||
logger.info(f"Split objects PayloadLength are equal to Virtual Object Payload {header_virtual_parsed['PayloadLength']}")
|
logger.info(f"Split objects PayloadLength are equal to Virtual Object Payload "
|
||||||
|
f"{header_virtual_parsed['PayloadLength']}")
|
||||||
else:
|
else:
|
||||||
raise Exception(f"Split objects PayloadLength from Virtual Object ({header_virtual_parsed['PayloadLength']}) is not equal to expected ({final_verif_data['PayloadLength']})")
|
raise Exception(f"Split objects PayloadLength from Virtual Object "
|
||||||
|
f"({header_virtual_parsed['PayloadLength']}) is not equal "
|
||||||
|
f"to expected ({final_verif_data['PayloadLength']})")
|
||||||
|
|
||||||
if header_link_parsed['Type'] == 'regular':
|
if header_link_parsed['Type'] == 'regular':
|
||||||
logger.info("Virtual Object Type is 'regular' as expected.")
|
logger.info("Virtual Object Type is 'regular' as expected.")
|
||||||
|
@ -613,7 +628,8 @@ def get_container_attributes(private_key: str, cid: str, endpoint: str="", json_
|
||||||
endpoint = NEOFS_ENDPOINT
|
endpoint = NEOFS_ENDPOINT
|
||||||
|
|
||||||
container_cmd = (
|
container_cmd = (
|
||||||
f'{NEOFS_CLI_EXEC} --rpc-endpoint {endpoint} --wif {private_key} --cid {cid} container get {"--json" if json_output else ""}'
|
f'{NEOFS_CLI_EXEC} --rpc-endpoint {endpoint} --wif {private_key} '
|
||||||
|
f'--cid {cid} container get {"--json" if json_output else ""}'
|
||||||
)
|
)
|
||||||
logger.info(f"Cmd: {container_cmd}")
|
logger.info(f"Cmd: {container_cmd}")
|
||||||
output = _cmd_run(container_cmd)
|
output = _cmd_run(container_cmd)
|
||||||
|
|
Loading…
Reference in a new issue