Skip to content

Commit 5c9e2c0

Browse files
pb8owearyzen
authored andcommitted
test: rework boottime test to send metrics even if it fails
So that we don't see gaps in the metrics. Signed-off-by: Pablo Barbáchano <pablob@amazon.com>
1 parent 5a7d3f6 commit 5c9e2c0

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

tests/integration_tests/performance/test_boottime.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,14 @@ def test_boottime_no_network(test_microvm_with_api, record_property, metrics):
4646
vm = test_microvm_with_api
4747
vm.jailer.extra_args.update({"boot-timer": None})
4848
_ = _configure_and_run_vm(vm)
49-
boottime_us = _test_microvm_boottime(vm)
49+
boottime_us = _get_microvm_boottime(vm)
5050
print(f"Boot time with no network is: {boottime_us} us")
5151
record_property("boottime_no_network", f"{boottime_us} us < {MAX_BOOT_TIME_US} us")
5252
metrics.set_dimensions(DIMENSIONS)
5353
metrics.put_metric("boot_time", boottime_us, unit="Microseconds")
54+
assert (
55+
boottime_us < MAX_BOOT_TIME_US
56+
), f"boot time {boottime_us} cannot be greater than: {MAX_BOOT_TIME_US} us"
5457

5558

5659
# temporarily disable this test in 6.1
@@ -66,14 +69,17 @@ def test_boottime_with_network(
6669
"""
6770
vm = test_microvm_with_api
6871
vm.jailer.extra_args.update({"boot-timer": None})
69-
_tap = _configure_and_run_vm(vm, {"config": network_config, "iface_id": "1"})
70-
boottime_us = _test_microvm_boottime(vm)
72+
_configure_and_run_vm(vm, {"config": network_config, "iface_id": "1"})
73+
boottime_us = _get_microvm_boottime(vm)
7174
print(f"Boot time with network configured is: {boottime_us} us")
7275
record_property(
7376
"boottime_with_network", f"{boottime_us} us < {MAX_BOOT_TIME_US} us"
7477
)
7578
metrics.set_dimensions(DIMENSIONS)
7679
metrics.put_metric("boot_time_with_net", boottime_us, unit="Microseconds")
80+
assert (
81+
boottime_us < MAX_BOOT_TIME_US
82+
), f"boot time {boottime_us} cannot be greater than: {MAX_BOOT_TIME_US} us"
7783

7884

7985
def test_initrd_boottime(test_microvm_with_initrd, record_property, metrics):
@@ -82,15 +88,15 @@ def test_initrd_boottime(test_microvm_with_initrd, record_property, metrics):
8288
"""
8389
vm = test_microvm_with_initrd
8490
vm.jailer.extra_args.update({"boot-timer": None})
85-
_tap = _configure_and_run_vm(vm, initrd=True)
86-
boottime_us = _test_microvm_boottime(vm, max_time_us=None)
91+
_configure_and_run_vm(vm, initrd=True)
92+
boottime_us = _get_microvm_boottime(vm)
8793
print(f"Boot time with initrd is: {boottime_us} us")
8894
record_property("boottime_initrd", f"{boottime_us} us")
8995
metrics.set_dimensions(DIMENSIONS)
9096
metrics.put_metric("boot_time_with_initrd", boottime_us, unit="Microseconds")
9197

9298

93-
def _test_microvm_boottime(vm, max_time_us=MAX_BOOT_TIME_US):
99+
def _get_microvm_boottime(vm):
94100
"""Auxiliary function for asserting the expected boot time."""
95101
boot_time_us = 0
96102
timestamps = []
@@ -103,11 +109,6 @@ def _test_microvm_boottime(vm, max_time_us=MAX_BOOT_TIME_US):
103109
boot_time_us = int(timestamps[0])
104110

105111
assert boot_time_us > 0
106-
107-
if max_time_us is not None:
108-
assert (
109-
boot_time_us < max_time_us
110-
), f"boot time {boot_time_us} cannot be greater than: {max_time_us} us"
111112
return boot_time_us
112113

113114

0 commit comments

Comments
 (0)