Skip to content

Commit

Permalink
test: use fio instead of dd for performance tests
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
roypat committed Dec 16, 2024
1 parent 1709e4f commit 5c3ff08
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions tests/integration_tests/performance/test_drive_rate_limiter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# SPDX-License-Identifier: Apache-2.0

"""Tests for checking the rate limiter on /drives resources."""

import json
import os

import host_tools.drive as drive_tools
Expand All @@ -12,28 +12,22 @@

def check_iops_limit(ssh_connection, block_size, count, min_time, max_time):
"""Verify if the rate limiter throttles block iops using dd."""
obs = block_size

byte_count = block_size * count
dd = "dd if=/dev/zero of=/dev/vdb ibs={} obs={} count={} oflag=direct".format(
block_size, obs, count
)
print("Running cmd {}".format(dd))
# Check write iops (writing with oflag=direct is more reliable).
_, _, stderr = ssh_connection.check_output(dd)

# "dd" writes to stderr by design. We drop first lines
lines = stderr.split("\n")
dd_result = lines[2].strip()
fio = f"fio --name=fixed-job --direct=1 --rw=write --blocksize={block_size} --size={byte_count} --filename=/dev/vdb --zero_buffers --output-format=json"

_, stdout, _ = ssh_connection.check_output(fio)

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

# Check total read bytes.
assert int(tokens[0]) == byte_count
assert io_bytes == byte_count
# Check duration.
assert float(tokens[7]) > min_time
assert float(tokens[7]) < max_time
assert runtime_ms > min_time * 1000
assert runtime_ms < max_time * 1000


def test_patch_drive_limiter(uvm_plain):
Expand Down

0 comments on commit 5c3ff08

Please sign in to comment.