Skip to content

Commit 31470aa

Browse files
committed
test(virtio-mem): add API tests for PATCH
Test that the new PATCH API behaves as expected. Also updates expected metrics and fixes memory monitor to account for hotplugging. Signed-off-by: Riccardo Mancini <[email protected]>
1 parent 1c2c99c commit 31470aa

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

tests/host_tools/fcmetrics.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@ def validate_fc_metrics(metrics):
202202
"machine_cfg_fails",
203203
"mmds_count",
204204
"mmds_fails",
205+
"hotplug_memory_count",
206+
"hotplug_memory_fails",
205207
],
206208
"put_api_requests": [
207209
"actions_count",

tests/host_tools/memory.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def is_guest_mem_x86(self, size, guest_mem_bytes):
9999
Checks if a region is a guest memory region based on
100100
x86_64 physical memory layout
101101
"""
102-
return size in (
102+
return size >= guest_mem_bytes or size in (
103103
# memory fits before the first gap
104104
guest_mem_bytes,
105105
# guest memory spans at least two regions & memory fits before the second gap
@@ -121,7 +121,7 @@ def is_guest_mem_arch64(self, size, guest_mem_bytes):
121121
Checks if a region is a guest memory region based on
122122
ARM64 physical memory layout
123123
"""
124-
return size in (
124+
return size >= guest_mem_bytes or size in (
125125
# guest memory fits before the gap
126126
guest_mem_bytes,
127127
# guest memory fills the space before the gap

tests/integration_tests/functional/test_api.py

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

983983

984-
def test_api_memory_hotplug(uvm_plain):
984+
def test_api_memory_hotplug(uvm_plain_6_1):
985985
"""
986986
Test hotplug related API commands.
987987
"""
988-
test_microvm = uvm_plain
988+
test_microvm = uvm_plain_6_1
989989
test_microvm.spawn()
990990
test_microvm.basic_config()
991+
test_microvm.add_net_iface()
991992

992993
# Adding hotplug memory region should be OK.
993994
test_microvm.api.memory_hotplug.put(
@@ -1002,6 +1003,10 @@ def test_api_memory_hotplug(uvm_plain):
10021003
with pytest.raises(AssertionError):
10031004
test_microvm.api.memory_hotplug.get()
10041005

1006+
# Patch API should be rejected before boot
1007+
with pytest.raises(RuntimeError, match=NOT_SUPPORTED_BEFORE_START):
1008+
test_microvm.api.memory_hotplug.patch(requested_size_mib=512)
1009+
10051010
# Start the microvm
10061011
test_microvm.start()
10071012

@@ -1013,6 +1018,11 @@ def test_api_memory_hotplug(uvm_plain):
10131018
status = test_microvm.api.memory_hotplug.get().json()
10141019
assert status["total_size_mib"] == 1024
10151020

1021+
# Patch API should work after boot
1022+
test_microvm.api.memory_hotplug.patch(requested_size_mib=512)
1023+
status = test_microvm.api.memory_hotplug.get().json()
1024+
assert status["requested_size_mib"] == 512
1025+
10161026

10171027
def test_api_balloon(uvm_nano):
10181028
"""

0 commit comments

Comments
 (0)