Skip to content

Commit 26bb489

Browse files
committed
fix(test): Fix io_engine related tests
Ensure all io_engine related tests run with both the sync and the async io_engine. Prior to 4.14 deprecation, some tests used the following logic to determine whether the Async engine or the Sync engine should be tested: If io_uring is supported (e.g. host_kernel != 4.14) then use Async Else use Sync This meant we were running with the Async engine on 5.10 and 6.1, and with the Sync engine on 4.14. However, once 4.14 went out of support, this meant that tests employing this logic only ever tested the Async engine anymore. Fix this by having all these tests always run with both Sync and Async engines, independently of host kernel version. Also remove all logic around checking whether io_uring is supported, because it definitely is supported on all currently supported host kernels. Signed-off-by: Patrick Roy <[email protected]>
1 parent 2aaea37 commit 26bb489

File tree

4 files changed

+11
-45
lines changed

4 files changed

+11
-45
lines changed

tests/conftest.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,8 +386,6 @@ def cpu_template_any(request, record_property):
386386
@pytest.fixture(params=["Sync", "Async"])
387387
def io_engine(request):
388388
"""All supported io_engines"""
389-
if request.param == "Async" and not utils.is_io_uring_supported():
390-
pytest.skip("io_uring not supported in this kernel")
391389
return request.param
392390

393391

tests/framework/defs.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@
2626
# Absolute path to the test results folder
2727
TEST_RESULTS_DIR = FC_WORKSPACE_DIR / "test_results"
2828

29-
# The minimum required host kernel version for which io_uring is supported in
30-
# Firecracker.
31-
MIN_KERNEL_VERSION_FOR_IO_URING = "5.10.51"
32-
3329
SUPPORTED_HOST_KERNELS = ["5.10", "6.1"]
3430

3531
IMG_DIR = Path(DEFAULT_TEST_SESSION_ROOT_PATH) / "img"

tests/framework/utils.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929
wait_fixed,
3030
)
3131

32-
from framework.defs import MIN_KERNEL_VERSION_FOR_IO_URING
33-
3432
FLUSH_CMD = 'screen -S {session} -X colon "logfile flush 0^M"'
3533
CommandReturn = namedtuple("CommandReturn", "returncode stdout stderr")
3634
CMDLOG = logging.getLogger("commands")
@@ -519,17 +517,6 @@ def get_kernel_version(level=2):
519517
return linux_version
520518

521519

522-
def is_io_uring_supported():
523-
"""
524-
Return whether Firecracker supports io_uring for the running kernel ...
525-
526-
...version.
527-
"""
528-
kv = packaging.version.parse(get_kernel_version())
529-
min_kv = packaging.version.parse(MIN_KERNEL_VERSION_FOR_IO_URING)
530-
return kv >= min_kv
531-
532-
533520
def generate_mmds_session_token(ssh_connection, ipv4_address, token_ttl):
534521
"""Generate session token used for MMDS V2 requests."""
535522
cmd = "curl -m 2 -s"

tests/integration_tests/functional/test_api.py

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import host_tools.drive as drive_tools
1818
import host_tools.network as net_tools
1919
from framework import utils_cpuid
20-
from framework.utils import get_firecracker_version_from_toml, is_io_uring_supported
20+
from framework.utils import get_firecracker_version_from_toml
2121

2222
MEM_LIMIT = 1000000000
2323

@@ -43,7 +43,7 @@ def test_api_happy_start(uvm_plain):
4343
test_microvm.start()
4444

4545

46-
def test_drive_io_engine(uvm_plain):
46+
def test_drive_io_engine(uvm_plain, io_engine):
4747
"""
4848
Test io_engine configuration.
4949
@@ -56,35 +56,20 @@ def test_drive_io_engine(uvm_plain):
5656
test_microvm.basic_config(add_root_device=False)
5757
test_microvm.add_net_iface()
5858

59-
supports_io_uring = is_io_uring_supported()
60-
6159
kwargs = {
6260
"drive_id": "rootfs",
6361
"path_on_host": test_microvm.create_jailed_resource(test_microvm.rootfs_file),
6462
"is_root_device": True,
6563
"is_read_only": True,
6664
}
6765

68-
# Test the opposite of the default backend type.
69-
if supports_io_uring:
70-
test_microvm.api.drive.put(io_engine="Sync", **kwargs)
71-
72-
if not supports_io_uring:
73-
with pytest.raises(RuntimeError):
74-
test_microvm.api.drive.put(io_engine="Async", **kwargs)
75-
# The Async engine is not supported for older kernels.
76-
test_microvm.check_log_message(
77-
"Received Error. Status code: 400 Bad Request. Message: Drive config error: "
78-
"Unable to create the virtio block device: Virtio backend error: "
79-
"Error coming from the IO engine: Unsupported engine type: Async"
80-
)
81-
82-
# Now configure the default engine type and check that it works.
83-
test_microvm.api.drive.put(**kwargs)
66+
test_microvm.api.drive.put(io_engine=io_engine, **kwargs)
8467

8568
test_microvm.start()
8669

87-
assert test_microvm.api.vm_config.get().json()["drives"][0]["io_engine"] == "Sync"
70+
assert (
71+
test_microvm.api.vm_config.get().json()["drives"][0]["io_engine"] == io_engine
72+
)
8873

8974

9075
def test_api_put_update_pre_boot(uvm_plain, io_engine):
@@ -732,7 +717,7 @@ def test_negative_api_patch_post_boot(uvm_plain, io_engine):
732717
test_microvm.api.logger.patch(level="Error")
733718

734719

735-
def test_drive_patch(uvm_plain):
720+
def test_drive_patch(uvm_plain, io_engine):
736721
"""
737722
Extensively test drive PATCH scenarios before and after boot.
738723
"""
@@ -749,7 +734,7 @@ def test_drive_patch(uvm_plain):
749734
path_on_host=fs.path,
750735
is_root_device=False,
751736
is_read_only=False,
752-
io_engine="Async" if is_io_uring_supported() else "Sync",
737+
io_engine=io_engine,
753738
)
754739

755740
fs_vub = drive_tools.FilesystemFile(
@@ -763,7 +748,7 @@ def test_drive_patch(uvm_plain):
763748

764749
test_microvm.start()
765750

766-
_drive_patch(test_microvm)
751+
_drive_patch(test_microvm, io_engine)
767752

768753

769754
@pytest.mark.skipif(
@@ -789,7 +774,7 @@ def test_send_ctrl_alt_del(uvm_plain):
789774
test_microvm.mark_killed()
790775

791776

792-
def _drive_patch(test_microvm):
777+
def _drive_patch(test_microvm, io_engine):
793778
"""Exercise drive patch test scenarios."""
794779
# Patches without mandatory fields for virtio block are not allowed.
795780
expected_msg = "Unable to patch the block device: Device manager error: Running method expected different backend. Please verify the request arguments"
@@ -899,7 +884,7 @@ def _drive_patch(test_microvm):
899884
"bandwidth": {"size": 5000, "one_time_burst": None, "refill_time": 100},
900885
"ops": {"size": 500, "one_time_burst": None, "refill_time": 100},
901886
},
902-
"io_engine": "Async" if is_io_uring_supported() else "Sync",
887+
"io_engine": io_engine,
903888
"socket": None,
904889
},
905890
{

0 commit comments

Comments
 (0)