From 5c3ff0881f0cdf7ad82326408c9f10cee6b3c1c8 Mon Sep 17 00:00:00 2001 From: Patrick Roy Date: Mon, 16 Dec 2024 13:10:42 +0000 Subject: [PATCH] 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 --- .../performance/test_drive_rate_limiter.py | 28 ++++++++----------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/tests/integration_tests/performance/test_drive_rate_limiter.py b/tests/integration_tests/performance/test_drive_rate_limiter.py index adeb0c25123..dbb1bfb310c 100644 --- a/tests/integration_tests/performance/test_drive_rate_limiter.py +++ b/tests/integration_tests/performance/test_drive_rate_limiter.py @@ -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 @@ -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):