Skip to content

Commit 8c42b99

Browse files
committed
Format printed results
1 parent d318318 commit 8c42b99

File tree

1 file changed

+30
-6
lines changed
  • python/perftest/models/v1alpha1

1 file changed

+30
-6
lines changed

python/perftest/models/v1alpha1/fio.py

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
from ...config import settings
1111
from ...errors import PodLogFormatError, PodResultsIncompleteError
12+
from ...utils import format_amount
1213

1314
from . import base
1415

@@ -160,6 +161,22 @@ class FioStatus(base.BenchmarkStatus):
160161
None,
161162
description = "The result of the benchmark."
162163
)
164+
read_bw_result: t.Optional[schema.IntOrString] = Field(
165+
None,
166+
description = "The summary result for read bw, used for display."
167+
)
168+
write_bw_result: t.Optional[schema.IntOrString] = Field(
169+
None,
170+
description = "The summary result for write bw, used for display."
171+
)
172+
read_iops_result: t.Optional[schema.confloat(ge = 0)] = Field(
173+
None,
174+
description = "The summary result for read IOPs, used for display."
175+
)
176+
write_iops_result: t.Optional[schema.confloat(ge = 0)] = Field(
177+
None,
178+
description = "The summary result for write IOPs, used for display."
179+
)
163180
master_pod: t.Optional[base.PodInfo] = Field(
164181
None,
165182
description = "Pod information for the Fio master pod."
@@ -224,23 +241,23 @@ class Fio(
224241
},
225242
{
226243
"name": "Read Bandwidth",
227-
"type": "number",
228-
"jsonPath": ".status.result.readBw",
244+
"type": "string",
245+
"jsonPath": ".status.readBwResult",
229246
},
230247
{
231248
"name": "Read IOPS",
232249
"type": "number",
233-
"jsonPath": ".status.result.readIops",
250+
"jsonPath": ".status.readIopsResult",
234251
},
235252
{
236253
"name": "Write Bandwidth",
237-
"type": "number",
238-
"jsonPath": ".status.result.writeBw",
254+
"type": "string",
255+
"jsonPath": ".status.writeBwResult",
239256
},
240257
{
241258
"name": "Write IOPS",
242259
"type": "number",
243-
"jsonPath": ".status.result.writeIops",
260+
"jsonPath": ".status.writeIopsResult",
244261
}
245262
]
246263
):
@@ -288,6 +305,13 @@ def summarise(self):
288305
else:
289306
aggregate_data = [i for i in fio_json['client_stats'] if i['jobname'] == 'All clients'][0]
290307

308+
# Format results nicely for printing
309+
self.status.read_bw_result = "{0} {1}B/s".format(*format_amount(aggregate_data['read']['bw'], "K"))
310+
self.status.write_bw_result = "{0} {1}B/s".format(*format_amount(aggregate_data['write']['bw'], "K"))
311+
self.status.write_iops_result = round(aggregate_data['write']['iops'], 2)
312+
self.status.read_iops_result = round(aggregate_data['read']['iops'], 2)
313+
314+
# Use unformatted data for full fioresult
291315
self.status.result = FioResult(
292316
read_bw = aggregate_data['read']['bw'],
293317
read_iops = aggregate_data['read']['iops'],

0 commit comments

Comments
 (0)