Fix I/O benchmark graph uploads

Addresses issue #22
This commit is contained in:
2Shirt 2022-10-08 22:07:05 -07:00
parent d733790c1a
commit 26022f6011
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C
2 changed files with 32 additions and 4 deletions

View file

@ -100,7 +100,7 @@ def calc_io_dd_values(dev_size, test_mode=False) -> dict[str, int]:
}
def check_io_results(test_obj, rate_list, graph_width) -> None:
def check_io_results(state, test_obj, rate_list, graph_width) -> None:
"""Check I/O restuls and generate report using rate_list."""
avg_read = sum(rate_list) / len(rate_list)
min_read = min(rate_list)
@ -144,8 +144,36 @@ def check_io_results(test_obj, rate_list, graph_width) -> None:
else:
test_obj.set_status('Unknown')
# Export and upload graphs
export_and_upload_graphs(state, test_obj, rate_list)
def run_io_test(test_obj, log_path, test_mode=False) -> None:
def export_and_upload_graphs(state, test_obj, rate_list):
"""Export and upload graphs."""
image_path = None
try:
image_path = graph.export_io_graph(test_obj.dev, state.log_dir, rate_list)
except RuntimeError:
# Failed to export PNG, skip uploads below
test_obj.report.append('Failed to export graph')
return
# Upload PNG
if not state.ost.disabled and state.ost.ticket_id:
try:
imgur_url = graph.upload_to_imgur(image_path)
nextcloud_url = graph.upload_to_nextcloud(
image_path, state.ost.ticket_id, test_obj.dev.path.name)
test_obj.report.append(f'Imgur: {imgur_url}')
test_obj.report.append(f'Nextcloud: {nextcloud_url}')
except Exception as err: # pylint: disable=broad-except
LOG.error('%s', err)
LOG.error('Failed to upload graph')
test_obj.report.append('Failed to upload graph')
def run_io_test(state, test_obj, log_path, test_mode=False) -> None:
#pylint: disable=too-many-locals
"""Run I/O benchmark and handle exceptions."""
dev_path = test_obj.dev.path
if PLATFORM == 'Darwin':
@ -214,7 +242,7 @@ def run_io_test(test_obj, log_path, test_mode=False) -> None:
offset += dd_values['Read Blocks'] + skip
# Check results
check_io_results(test_obj, read_rates, IO_GRAPH_WIDTH)
check_io_results(state, test_obj, read_rates, IO_GRAPH_WIDTH)

View file

@ -610,7 +610,7 @@ def disk_io_benchmark(
)
state.update_progress_pane()
try:
hw_benchmark.run_io_test(test, test_log, test_mode=test_mode)
hw_benchmark.run_io_test(state, test, test_log, test_mode=test_mode)
except KeyboardInterrupt:
aborted = True
except (subprocess.CalledProcessError, TypeError, ValueError) as err: