Skip to content

Commit d145cdd

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 a657044 commit d145cdd

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
@@ -373,8 +373,6 @@ def cpu_template_any(request, record_property):
373373
@pytest.fixture(params=["Sync", "Async"])
374374
def io_engine(request):
375375
"""All supported io_engines"""
376-
if request.param == "Async" and not utils.is_io_uring_supported():
377-
pytest.skip("io_uring not supported in this kernel")
378376
return request.param
379377

380378

tests/framework/defs.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@
3333
/ "release"
3434
)
3535

36-
# The minimum required host kernel version for which io_uring is supported in
37-
# Firecracker.
38-
MIN_KERNEL_VERSION_FOR_IO_URING = "5.10.51"
39-
4036
SUPPORTED_HOST_KERNELS = ["5.10", "6.1"]
4137

4238
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
@@ -28,8 +28,6 @@
2828
wait_fixed,
2929
)
3030

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

457455

458-
def is_io_uring_supported():
459-
"""
460-
Return whether Firecracker supports io_uring for the running kernel ...
461-
462-
...version.
463-
"""
464-
kv = packaging.version.parse(get_kernel_version())
465-
min_kv = packaging.version.parse(MIN_KERNEL_VERSION_FOR_IO_URING)
466-
return kv >= min_kv
467-
468-
469456
def generate_mmds_session_token(ssh_connection, ipv4_address, token_ttl):
470457
"""Generate session token used for MMDS V2 requests."""
471458
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, 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

@@ -46,7 +46,7 @@ def test_api_happy_start(uvm_plain):
4646
assert "Kernel loaded using PVH boot protocol" in test_microvm.log_data
4747

4848

49-
def test_drive_io_engine(uvm_plain):
49+
def test_drive_io_engine(uvm_plain, io_engine):
5050
"""
5151
Test io_engine configuration.
5252
@@ -59,35 +59,20 @@ def test_drive_io_engine(uvm_plain):
5959
test_microvm.basic_config(add_root_device=False)
6060
test_microvm.add_net_iface()
6161

62-
supports_io_uring = is_io_uring_supported()
63-
6462
kwargs = {
6563
"drive_id": "rootfs",
6664
"path_on_host": test_microvm.create_jailed_resource(test_microvm.rootfs_file),
6765
"is_root_device": True,
6866
"is_read_only": True,
6967
}
7068

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

8871
test_microvm.start()
8972

90-
assert test_microvm.api.vm_config.get().json()["drives"][0]["io_engine"] == "Sync"
73+
assert (
74+
test_microvm.api.vm_config.get().json()["drives"][0]["io_engine"] == io_engine
75+
)
9176

9277

9378
def test_api_put_update_pre_boot(uvm_plain, io_engine):
@@ -735,7 +720,7 @@ def test_negative_api_patch_post_boot(uvm_plain, io_engine):
735720
test_microvm.api.logger.patch(level="Error")
736721

737722

738-
def test_drive_patch(uvm_plain):
723+
def test_drive_patch(uvm_plain, io_engine):
739724
"""
740725
Extensively test drive PATCH scenarios before and after boot.
741726
"""
@@ -752,7 +737,7 @@ def test_drive_patch(uvm_plain):
752737
path_on_host=fs.path,
753738
is_root_device=False,
754739
is_read_only=False,
755-
io_engine="Async" if is_io_uring_supported() else "Sync",
740+
io_engine=io_engine,
756741
)
757742

758743
fs_vub = drive_tools.FilesystemFile(
@@ -766,7 +751,7 @@ def test_drive_patch(uvm_plain):
766751

767752
test_microvm.start()
768753

769-
_drive_patch(test_microvm)
754+
_drive_patch(test_microvm, io_engine)
770755

771756

772757
@pytest.mark.skipif(
@@ -802,7 +787,7 @@ def test_send_ctrl_alt_del(uvm_plain):
802787
pass
803788

804789

805-
def _drive_patch(test_microvm):
790+
def _drive_patch(test_microvm, io_engine):
806791
"""Exercise drive patch test scenarios."""
807792
# Patches without mandatory fields for virtio block are not allowed.
808793
expected_msg = "Unable to patch the block device: Device manager error: Running method expected different backend. Please verify the request arguments"
@@ -912,7 +897,7 @@ def _drive_patch(test_microvm):
912897
"bandwidth": {"size": 5000, "one_time_burst": None, "refill_time": 100},
913898
"ops": {"size": 500, "one_time_burst": None, "refill_time": 100},
914899
},
915-
"io_engine": "Async" if is_io_uring_supported() else "Sync",
900+
"io_engine": io_engine,
916901
"socket": None,
917902
},
918903
{

0 commit comments

Comments
 (0)