Skip to content

Commit 3fe6e90

Browse files
committed
test(virtio-mem): add tests for PUT API
Test the freshly added PUT API to /hotplug/memory. Signed-off-by: Riccardo Mancini <[email protected]>
1 parent e3726ed commit 3fe6e90

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

tests/framework/http_api.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,4 @@ def __init__(self, api_usocket_full_name, *, on_error=None):
133133
self.cpu_config = Resource(self, "/cpu-config")
134134
self.entropy = Resource(self, "/entropy")
135135
self.serial = Resource(self, "/serial")
136+
self.memory_hotplug = Resource(self, "/hotplug/memory")

tests/integration_tests/functional/test_api.py

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -981,6 +981,31 @@ def test_api_entropy(uvm_plain):
981981
test_microvm.api.entropy.put()
982982

983983

984+
def test_api_memory_hotplug(uvm_plain):
985+
"""
986+
Test hotplug related API commands.
987+
"""
988+
test_microvm = uvm_plain
989+
test_microvm.spawn()
990+
test_microvm.basic_config()
991+
992+
# Adding hotplug memory region should be OK.
993+
test_microvm.api.memory_hotplug.put(
994+
total_size_mib=1024, block_size_mib=128, slot_size_mib=1024
995+
)
996+
997+
# Overwriting an existing should be OK.
998+
# Omitting optional values should be ok
999+
test_microvm.api.memory_hotplug.put(total_size_mib=1024)
1000+
1001+
# Start the microvm
1002+
test_microvm.start()
1003+
1004+
# API should be rejected after boot
1005+
with pytest.raises(RuntimeError):
1006+
test_microvm.api.memory_hotplug.put(total_size_mib=1024)
1007+
1008+
9841009
def test_api_balloon(uvm_nano):
9851010
"""
9861011
Test balloon related API commands.
@@ -1211,8 +1236,13 @@ def test_get_full_config(uvm_plain):
12111236
response = test_microvm.api.vsock.put(guest_cid=15, uds_path="vsock.sock")
12121237
expected_cfg["vsock"] = {"guest_cid": 15, "uds_path": "vsock.sock"}
12131238

1214-
# TODO Add hot-pluggable memory.
1215-
expected_cfg["memory-hotplug"] = None
1239+
# Add hot-pluggable memory.
1240+
expected_cfg["memory-hotplug"] = {
1241+
"total_size_mib": 1024,
1242+
"block_size_mib": 128,
1243+
"slot_size_mib": 1024,
1244+
}
1245+
test_microvm.api.memory_hotplug.put(**expected_cfg["memory-hotplug"])
12161246

12171247
# Add a net device.
12181248
iface_id = "1"

0 commit comments

Comments
 (0)