@@ -46,11 +46,14 @@ def test_boottime_no_network(test_microvm_with_api, record_property, metrics):
46
46
vm = test_microvm_with_api
47
47
vm .jailer .extra_args .update ({"boot-timer" : None })
48
48
_ = _configure_and_run_vm (vm )
49
- boottime_us = _test_microvm_boottime (vm )
49
+ boottime_us = _get_microvm_boottime (vm )
50
50
print (f"Boot time with no network is: { boottime_us } us" )
51
51
record_property ("boottime_no_network" , f"{ boottime_us } us < { MAX_BOOT_TIME_US } us" )
52
52
metrics .set_dimensions (DIMENSIONS )
53
53
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"
54
57
55
58
56
59
# temporarily disable this test in 6.1
@@ -66,14 +69,17 @@ def test_boottime_with_network(
66
69
"""
67
70
vm = test_microvm_with_api
68
71
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 )
71
74
print (f"Boot time with network configured is: { boottime_us } us" )
72
75
record_property (
73
76
"boottime_with_network" , f"{ boottime_us } us < { MAX_BOOT_TIME_US } us"
74
77
)
75
78
metrics .set_dimensions (DIMENSIONS )
76
79
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"
77
83
78
84
79
85
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):
82
88
"""
83
89
vm = test_microvm_with_initrd
84
90
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 )
87
93
print (f"Boot time with initrd is: { boottime_us } us" )
88
94
record_property ("boottime_initrd" , f"{ boottime_us } us" )
89
95
metrics .set_dimensions (DIMENSIONS )
90
96
metrics .put_metric ("boot_time_with_initrd" , boottime_us , unit = "Microseconds" )
91
97
92
98
93
- def _test_microvm_boottime (vm , max_time_us = MAX_BOOT_TIME_US ):
99
+ def _get_microvm_boottime (vm ):
94
100
"""Auxiliary function for asserting the expected boot time."""
95
101
boot_time_us = 0
96
102
timestamps = []
@@ -103,11 +109,6 @@ def _test_microvm_boottime(vm, max_time_us=MAX_BOOT_TIME_US):
103
109
boot_time_us = int (timestamps [0 ])
104
110
105
111
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"
111
112
return boot_time_us
112
113
113
114
0 commit comments