Skip to content

Commit ff34c30

Browse files
committed
test_snapshot_ab: move metrics dimension setting into configure_vm
Move the initialization of the metrics logger dimensions into `configure_vm`, as later on there will be multiple tests having to do exactly the same sequence of configure + setup metrics. Signed-off-by: Patrick Roy <[email protected]>
1 parent 51630ca commit ff34c30

File tree

1 file changed

+15
-18
lines changed

1 file changed

+15
-18
lines changed

tests/integration_tests/performance/test_snapshot_ab.py

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,7 @@ def id(self):
4040
"""Computes a unique id for this test instance"""
4141
return "all_dev" if self.all_devices else f"{self.vcpus}vcpu_{self.mem}mb"
4242

43-
def configure_vm(
44-
self,
45-
microvm_factory,
46-
guest_kernel,
47-
rootfs,
48-
) -> Microvm:
43+
def configure_vm(self, microvm_factory, guest_kernel, rootfs, metrics) -> Microvm:
4944
"""Creates the initial snapshot that will be loaded repeatedly to sample latencies"""
5045
vm = microvm_factory.build(
5146
guest_kernel,
@@ -74,6 +69,17 @@ def configure_vm(
7469
)
7570
vm.api.vsock.put(vsock_id="vsock0", guest_cid=3, uds_path="/v.sock")
7671

72+
metrics.set_dimensions(
73+
{
74+
"performance_test": "test_restore_latency",
75+
"net_devices": str(self.nets),
76+
"block_devices": str(self.blocks),
77+
"vsock_devices": str(int(self.all_devices)),
78+
"balloon_devices": str(int(self.all_devices)),
79+
**vm.dimensions,
80+
}
81+
)
82+
7783
return vm
7884

7985
def sample_latency(self, microvm_factory, snapshot) -> List[float]:
@@ -122,19 +128,10 @@ def test_restore_latency(
122128
123129
We only test a single guest kernel, as the guest kernel does not "participate" in snapshot restore.
124130
"""
125-
vm = test_setup.configure_vm(microvm_factory, guest_kernel_linux_5_10, rootfs)
126-
vm.start()
127-
128-
metrics.set_dimensions(
129-
{
130-
"performance_test": "test_restore_latency",
131-
"net_devices": str(test_setup.nets),
132-
"block_devices": str(test_setup.blocks),
133-
"vsock_devices": str(int(test_setup.all_devices)),
134-
"balloon_devices": str(int(test_setup.all_devices)),
135-
**vm.dimensions,
136-
}
131+
vm = test_setup.configure_vm(
132+
microvm_factory, guest_kernel_linux_5_10, rootfs, metrics
137133
)
134+
vm.start()
138135

139136
snapshot = vm.snapshot_full()
140137
vm.kill()

0 commit comments

Comments
 (0)