Skip to content

Commit fed6a45

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 7f2fbb2 commit fed6a45

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
@@ -132,3 +132,4 @@ def __init__(self, api_usocket_full_name, *, on_error=None):
132132
self.snapshot_load = Resource(self, "/snapshot/load")
133133
self.cpu_config = Resource(self, "/cpu-config")
134134
self.entropy = Resource(self, "/entropy")
135+
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.
@@ -1209,8 +1234,13 @@ def test_get_full_config(uvm_plain):
12091234
response = test_microvm.api.vsock.put(guest_cid=15, uds_path="vsock.sock")
12101235
expected_cfg["vsock"] = {"guest_cid": 15, "uds_path": "vsock.sock"}
12111236

1212-
# TODO Add hot-pluggable memory.
1213-
expected_cfg["memory-hotplug"] = None
1237+
# Add hot-pluggable memory.
1238+
expected_cfg["memory-hotplug"] = {
1239+
"total_size_mib": 1024,
1240+
"block_size_mib": 128,
1241+
"slot_size_mib": 1024,
1242+
}
1243+
test_microvm.api.memory_hotplug.put(**expected_cfg["memory-hotplug"])
12141244

12151245
# Add a net device.
12161246
iface_id = "1"

0 commit comments

Comments
 (0)