From bb88b14315f07d21052969b39fe5b98d5e106926 Mon Sep 17 00:00:00 2001 From: Nikita Kalyazin Date: Thu, 3 Jul 2025 11:16:11 +0000 Subject: [PATCH 1/2] test(microvm): add no_netns_reuse in build_n_from_snapshot This is to be able to disable netns reuse to get consistent performance results. Signed-off-by: Nikita Kalyazin --- tests/framework/microvm.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/framework/microvm.py b/tests/framework/microvm.py index a6582515491..b6646e758f6 100644 --- a/tests/framework/microvm.py +++ b/tests/framework/microvm.py @@ -1206,13 +1206,20 @@ def build_n_from_snapshot( uffd_handler_name=None, incremental=False, use_snapshot_editor=True, + no_netns_reuse=False, ): """A generator of `n` microvms restored, either all restored from the same given snapshot (incremental=False), or created by taking successive snapshots of restored VMs """ last_snapshot = None for _ in range(nr_vms): - microvm = self.build() + microvm = self.build( + **( + {"netns": net_tools.NetNs(str(uuid.uuid4()))} + if no_netns_reuse + else {} + ) + ) microvm.spawn() snapshot_copy = microvm.restore_from_snapshot( From faf0b0193473da3bf1c0ad76673c21634bd60348 Mon Sep 17 00:00:00 2001 From: Nikita Kalyazin Date: Thu, 3 Jul 2025 11:18:07 +0000 Subject: [PATCH 2/2] test(snapshot_latency): do not reuse netns This is because with netns reuse, the first test variant spends time on initialising netns, while the subsequent test variants do not. Disable netns reuse to make the performance data consistent. Signed-off-by: Nikita Kalyazin --- tests/integration_tests/performance/test_snapshot.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/integration_tests/performance/test_snapshot.py b/tests/integration_tests/performance/test_snapshot.py index 6c885a6a723..99307c76d24 100644 --- a/tests/integration_tests/performance/test_snapshot.py +++ b/tests/integration_tests/performance/test_snapshot.py @@ -122,7 +122,9 @@ def test_restore_latency( snapshot = vm.snapshot_full() vm.kill() - for microvm in microvm_factory.build_n_from_snapshot(snapshot, ITERATIONS): + for microvm in microvm_factory.build_n_from_snapshot( + snapshot, ITERATIONS, no_netns_reuse=True + ): value = 0 # Parse all metric data points in search of load_snapshot time. microvm.flush_metrics()