Skip to content

Commit d12aa49

Browse files
committed
test(snapshot-perf): Consolidate tests into realistic scenarios
Change the test to resemble realistic microVM configurations that customers actually use in production: - Scale memory and vcpus at the same time - add a few block/net devices Keep the test about doing a snapshot with one of each device, so that we cover less-used devices as well. Signed-off-by: Patrick Roy <[email protected]>
1 parent 975aa79 commit d12aa49

File tree

1 file changed

+36
-88
lines changed

1 file changed

+36
-88
lines changed

tests/integration_tests/performance/test_snapshot_restore_performance.py

Lines changed: 36 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ def get_snap_restore_latency(
9090
rootfs,
9191
vcpus,
9292
mem_size,
93-
nets=1,
94-
blocks=1,
93+
nets=3,
94+
blocks=3,
9595
all_devices=False,
9696
iterations=10,
9797
):
@@ -186,94 +186,35 @@ def consume_output(cons, result):
186186

187187

188188
@pytest.mark.nonci
189-
@pytest.mark.parametrize("vcpu_count", [1, 2, 4, 8, 10])
190-
def test_snapshot_scaling_vcpus(
191-
bin_cloner_path, microvm_factory, rootfs, guest_kernel, vcpu_count, st_core
189+
@pytest.mark.parametrize(
190+
"mem, vcpus",
191+
[
192+
(128, 1),
193+
(1024, 1),
194+
(2048, 2),
195+
(4096, 3),
196+
(6144, 4),
197+
(8192, 5),
198+
(10240, 6),
199+
(12288, 7),
200+
],
201+
)
202+
def test_snapshot_scaling(
203+
bin_cloner_path, microvm_factory, rootfs, guest_kernel, st_core, mem, vcpus
192204
):
193-
"""Restore snapshots with variable vcpu count."""
194-
guest_config = f"{vcpu_count}vcpu_{BASE_MEM_SIZE_MIB}mb"
195-
env_id = f"{guest_kernel.name()}/{rootfs.name()}/{guest_config}"
196-
st_prod = st.producer.LambdaProducer(
197-
func=get_snap_restore_latency,
198-
func_kwargs={
199-
"vm_builder": MicrovmBuilder(bin_cloner_path),
200-
"microvm_factory": microvm_factory,
201-
"guest_kernel": guest_kernel,
202-
"rootfs": rootfs,
203-
"vcpus": vcpu_count,
204-
"mem_size": BASE_MEM_SIZE_MIB,
205-
},
206-
)
207-
st_cons = default_lambda_consumer(env_id, WORKLOAD)
208-
st_core.add_pipe(st_prod, st_cons, f"{env_id}/{WORKLOAD}")
209-
st_core.name = TEST_ID
210-
st_core.custom["guest_config"] = guest_config
211-
st_core.run_exercise()
205+
"""
206+
Restores snapshots with vcpu/memory configuration, roughly scaling according to mem = (vcpus - 1) * 2048MB,
207+
which resembles firecracker production setups.
212208
213209
214-
# mem_exponent=7 takes around 100s
215-
@pytest.mark.nonci
216-
@pytest.mark.timeout(10 * 60)
217-
@pytest.mark.parametrize("mem_exponent", range(1, 8))
218-
def test_snapshot_scaling_mem(
219-
bin_cloner_path, microvm_factory, rootfs, guest_kernel, mem_exponent, st_core
220-
):
221-
"""Restore snapshots with variable memory size."""
222-
mem_mib = BASE_MEM_SIZE_MIB * (2**mem_exponent)
223-
guest_config = f"{BASE_VCPU_COUNT}vcpu_{mem_mib}mb"
224-
env_id = f"{guest_kernel.name()}/{rootfs.name()}/{guest_config}"
225-
st_prod = st.producer.LambdaProducer(
226-
func=get_snap_restore_latency,
227-
func_kwargs={
228-
"vm_builder": MicrovmBuilder(bin_cloner_path),
229-
"microvm_factory": microvm_factory,
230-
"guest_kernel": guest_kernel,
231-
"rootfs": rootfs,
232-
"vcpus": BASE_VCPU_COUNT,
233-
"mem_size": mem_mib,
234-
},
235-
)
236-
st_cons = default_lambda_consumer(env_id, WORKLOAD)
237-
st_core.add_pipe(st_prod, st_cons, f"{env_id}/{WORKLOAD}")
238-
st_core.name = TEST_ID
239-
st_core.custom["guest_config"] = guest_config
240-
st_core.run_exercise()
241-
242-
243-
@pytest.mark.nonci
244-
@pytest.mark.parametrize("net_count", range(1, 4))
245-
def test_snapshot_scaling_net(
246-
bin_cloner_path, microvm_factory, rootfs, guest_kernel, st_core, net_count
247-
):
248-
"""Restore snapshots with variable net device count."""
249-
guest_config = f"{BASE_NET_COUNT + net_count}net_dev"
250-
env_id = f"{guest_kernel.name()}/{rootfs.name()}/{guest_config}"
251-
st_prod = st.producer.LambdaProducer(
252-
func=get_snap_restore_latency,
253-
func_kwargs={
254-
"vm_builder": MicrovmBuilder(bin_cloner_path),
255-
"microvm_factory": microvm_factory,
256-
"guest_kernel": guest_kernel,
257-
"rootfs": rootfs,
258-
"vcpus": BASE_VCPU_COUNT,
259-
"mem_size": BASE_MEM_SIZE_MIB,
260-
"nets": BASE_NET_COUNT + net_count,
261-
},
262-
)
263-
st_cons = default_lambda_consumer(env_id, WORKLOAD)
264-
st_core.add_pipe(st_prod, st_cons, f"{env_id}/{WORKLOAD}")
265-
st_core.name = TEST_ID
266-
st_core.custom["guest_config"] = guest_config
267-
st_core.run_exercise()
210+
"""
268211

212+
# The guest kernel does not "participate" in snapshot restore, so just pick some
213+
# arbitrary one
214+
if "4.14" not in guest_kernel.name():
215+
pytest.skip()
269216

270-
@pytest.mark.nonci
271-
@pytest.mark.parametrize("block_count", range(1, 4))
272-
def test_snapshot_scaling_block(
273-
bin_cloner_path, microvm_factory, rootfs, guest_kernel, st_core, block_count
274-
):
275-
"""Restore snapshots with variable block device count."""
276-
guest_config = f"{BASE_BLOCK_COUNT + block_count}block_dev"
217+
guest_config = f"{vcpus}vcpu_{mem}mb"
277218
env_id = f"{guest_kernel.name()}/{rootfs.name()}/{guest_config}"
278219
st_prod = st.producer.LambdaProducer(
279220
func=get_snap_restore_latency,
@@ -282,9 +223,8 @@ def test_snapshot_scaling_block(
282223
"microvm_factory": microvm_factory,
283224
"guest_kernel": guest_kernel,
284225
"rootfs": rootfs,
285-
"vcpus": BASE_VCPU_COUNT,
286-
"mem_size": BASE_MEM_SIZE_MIB,
287-
"blocks": BASE_BLOCK_COUNT + block_count,
226+
"vcpus": vcpus,
227+
"mem_size": mem,
288228
},
289229
)
290230
st_cons = default_lambda_consumer(env_id, WORKLOAD)
@@ -299,6 +239,12 @@ def test_snapshot_all_devices(
299239
bin_cloner_path, microvm_factory, rootfs, guest_kernel, st_core
300240
):
301241
"""Restore snapshots with one of each devices."""
242+
243+
# The guest kernel does not "participate" in snapshot restore, so just pick some
244+
# arbitrary one
245+
if "4.14" not in guest_kernel.name():
246+
pytest.skip()
247+
302248
guest_config = "all_dev"
303249
env_id = f"{guest_kernel.name()}/{rootfs.name()}/{guest_config}"
304250
st_prod = st.producer.LambdaProducer(
@@ -308,6 +254,8 @@ def test_snapshot_all_devices(
308254
"microvm_factory": microvm_factory,
309255
"guest_kernel": guest_kernel,
310256
"rootfs": rootfs,
257+
"nets": 1,
258+
"blocks": 1,
311259
"vcpus": BASE_VCPU_COUNT,
312260
"mem_size": BASE_MEM_SIZE_MIB,
313261
"all_devices": True,

0 commit comments

Comments
 (0)