Load benchmark results as JSON
Load the JSON at the API side instead of client side, because that's what the API doc says it is and it just makes more sense.
This commit is contained in:
parent
23977b04fc
commit
ce06e4d81b
|
@ -78,6 +78,8 @@ def close_database(conn, cur, failed=False):
|
|||
|
||||
|
||||
def list_benchmarks(job=None):
|
||||
from json import loads
|
||||
|
||||
if job is not None:
|
||||
query = "SELECT * FROM {} WHERE job = %s;".format('storage_benchmarks')
|
||||
args = (job, )
|
||||
|
@ -93,7 +95,7 @@ def list_benchmarks(job=None):
|
|||
benchmark_data = dict()
|
||||
benchmark_data['id'] = benchmark['id']
|
||||
benchmark_data['job'] = benchmark['job']
|
||||
benchmark_data['benchmark_result'] = benchmark['result']
|
||||
benchmark_data['benchmark_result'] = loads(benchmark['result'])
|
||||
# Append the new data to our actual output structure
|
||||
data.append(benchmark_data)
|
||||
close_database(conn, cur)
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#
|
||||
###############################################################################
|
||||
|
||||
import json
|
||||
import math
|
||||
|
||||
from requests_toolbelt.multipart.encoder import MultipartEncoder, MultipartEncoderMonitor
|
||||
|
@ -1479,12 +1478,12 @@ def format_list_benchmark(config, benchmark_information):
|
|||
if benchmark['benchmark_result'] == 'Running':
|
||||
continue
|
||||
|
||||
benchmark_data = json.loads(benchmark['benchmark_result'])
|
||||
benchmark_data = benchmark['benchmark_result']
|
||||
|
||||
benchmark_bandwidth = dict()
|
||||
benchmark_iops = dict()
|
||||
for test in ["seq_read", "seq_write", "rand_read_4K", "rand_write_4K"]:
|
||||
benchmark_data = json.loads(benchmark['benchmark_result'])
|
||||
benchmark_data = benchmark['benchmark_result']
|
||||
benchmark_bandwidth[test] = format_bytes_tohuman(int(benchmark_data[test]['overall']['bandwidth']) * 1024)
|
||||
benchmark_iops[test] = format_ops_tohuman(int(benchmark_data[test]['overall']['iops']))
|
||||
|
||||
|
@ -1558,7 +1557,7 @@ def format_list_benchmark(config, benchmark_information):
|
|||
benchmark_bandwidth = dict()
|
||||
benchmark_iops = dict()
|
||||
for test in ["seq_read", "seq_write", "rand_read_4K", "rand_write_4K"]:
|
||||
benchmark_data = json.loads(benchmark['benchmark_result'])
|
||||
benchmark_data = benchmark['benchmark_result']
|
||||
benchmark_bandwidth[test] = format_bytes_tohuman(int(benchmark_data[test]['overall']['bandwidth']) * 1024)
|
||||
benchmark_iops[test] = format_ops_tohuman(int(benchmark_data[test]['overall']['iops']))
|
||||
|
||||
|
@ -1595,7 +1594,7 @@ def format_info_benchmark(config, benchmark_information):
|
|||
if benchmark_information[0]['benchmark_result'] == "Running":
|
||||
return "Benchmark test is still running."
|
||||
|
||||
benchmark_details = json.loads(benchmark_information[0]['benchmark_result'])
|
||||
benchmark_details = benchmark_information[0]['benchmark_result']
|
||||
|
||||
# Format a nice output; do this line-by-line then concat the elements at the end
|
||||
ainformation = []
|
||||
|
|
Loading…
Reference in New Issue