Skip to content

Commit 565d4b6

Browse files
committed
fix(test): verify block device IO after cross-kernel snapshot restore
guest_run_fio_iteration ran fio in the background and only checked that the process launched, not that IO actually succeeded. Run fio in the foreground with JSON output and assert that bytes were read from the block device. This addresses the TODO about verifying the root device is not corrupted after snapshot restore. Signed-off-by: Jack Thomson <jackabt@amazon.com>
1 parent 3a53ff5 commit 565d4b6

2 files changed

Lines changed: 13 additions & 11 deletions

File tree

tests/framework/utils.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -555,13 +555,15 @@ def start_screen_process(screen_log, session_name, binary_path, binary_params):
555555

556556

557557
def guest_run_fio_iteration(ssh_connection, iteration):
558-
"""Start FIO workload into a microVM."""
559-
fio = """fio --filename=/dev/vda --direct=1 --rw=randread --bs=4k \
560-
--ioengine=libaio --iodepth=16 --runtime=10 --numjobs=4 --time_based \
561-
--group_reporting --name=iops-test-job --eta-newline=1 --readonly \
562-
--output /tmp/fio{} > /dev/null &""".format(iteration)
563-
exit_code, _, stderr = ssh_connection.run(fio)
564-
assert exit_code == 0, stderr
558+
"""Run FIO workload on a microVM and verify IO completed successfully."""
559+
fio = (
560+
"fio --filename=/dev/vda --direct=1 --rw=randread --bs=4k "
561+
"--ioengine=libaio --iodepth=16 --runtime=10 --numjobs=4 --time_based "
562+
"--group_reporting --name=iops-test-job --readonly --output-format=json"
563+
)
564+
_, stdout, _ = ssh_connection.check_output(fio)
565+
total_read = json.loads(stdout)["jobs"][0]["read"]["io_bytes"]
566+
assert total_read > 0, f"fio iteration {iteration}: no bytes read from block device"
565567

566568

567569
def check_filesystem(ssh_connection, disk_fmt, disk):

tests/integration_tests/functional/test_snapshot_restore_cross_kernel.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ def get_snapshot_dirs():
7272
snapshot_root_dir = Path(FC_WORKSPACE_DIR) / snapshot_root_name
7373
cpu_templates = ["None"] + get_supported_cpu_templates()
7474
for cpu_template in cpu_templates:
75-
for snapshot_dir in snapshot_root_dir.glob(f"**/*_{cpu_template}_guest_snapshot"):
75+
for snapshot_dir in snapshot_root_dir.glob(
76+
f"**/*_{cpu_template}_guest_snapshot"
77+
):
7678
assert snapshot_dir.is_dir()
7779
yield pytest.param(snapshot_dir, id=snapshot_dir.name)
7880

@@ -120,9 +122,7 @@ def test_snap_restore_from_artifacts(
120122
logger.info("Testing vsock device...")
121123
check_vsock_device(vm, bin_vsock_path, test_fc_session_root_path, vm.ssh)
122124

123-
# Run fio on the guest.
124-
# TODO: check the result of FIO or use fsck to check that the root device is
125-
# not corrupted. No obvious errors will be returned here.
125+
logger.info("Testing block device via fio...")
126126
guest_run_fio_iteration(vm.ssh, 0)
127127

128128
vm.kill()

0 commit comments

Comments
 (0)