Skip to content

Commit 5c3ff08

Browse files
committed
test: use fio instead of dd for performance tests
In test_drive_rate_limiter, use `fio` for measuring latencies of writing a fixed number of bytes to a block device, instead of `dd` (which the test itself notes is unreliable). Should fix intermitted failures we're been seeing in this test, hopefully. Signed-off-by: Patrick Roy <[email protected]>
1 parent 1709e4f commit 5c3ff08

File tree

1 file changed

+11
-17
lines changed

1 file changed

+11
-17
lines changed

tests/integration_tests/performance/test_drive_rate_limiter.py

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
"""Tests for checking the rate limiter on /drives resources."""
5-
5+
import json
66
import os
77

88
import host_tools.drive as drive_tools
@@ -12,28 +12,22 @@
1212

1313
def check_iops_limit(ssh_connection, block_size, count, min_time, max_time):
1414
"""Verify if the rate limiter throttles block iops using dd."""
15-
obs = block_size
15+
1616
byte_count = block_size * count
17-
dd = "dd if=/dev/zero of=/dev/vdb ibs={} obs={} count={} oflag=direct".format(
18-
block_size, obs, count
19-
)
20-
print("Running cmd {}".format(dd))
21-
# Check write iops (writing with oflag=direct is more reliable).
22-
_, _, stderr = ssh_connection.check_output(dd)
2317

24-
# "dd" writes to stderr by design. We drop first lines
25-
lines = stderr.split("\n")
26-
dd_result = lines[2].strip()
18+
fio = f"fio --name=fixed-job --direct=1 --rw=write --blocksize={block_size} --size={byte_count} --filename=/dev/vdb --zero_buffers --output-format=json"
19+
20+
_, stdout, _ = ssh_connection.check_output(fio)
2721

28-
# Interesting output looks like this:
29-
# 4194304 bytes (4.2 MB, 4.0 MiB) copied, 0.0528524 s, 79.4 MB/s
30-
tokens = dd_result.split()
22+
data = json.loads(stdout)
23+
runtime_ms = data["jobs"][0]["write"]["runtime"]
24+
io_bytes = data["jobs"][0]["write"]["io_bytes"]
3125

3226
# Check total read bytes.
33-
assert int(tokens[0]) == byte_count
27+
assert io_bytes == byte_count
3428
# Check duration.
35-
assert float(tokens[7]) > min_time
36-
assert float(tokens[7]) < max_time
29+
assert runtime_ms > min_time * 1000
30+
assert runtime_ms < max_time * 1000
3731

3832

3933
def test_patch_drive_limiter(uvm_plain):

0 commit comments

Comments
 (0)