1111import pandas
1212import pytest
1313
14- from framework .utils_iperf import IPerf3Test , emit_iperf3_metrics
14+ from framework .utils_cpuid import check_guest_cpuid_output
15+
16+ # from framework.utils_iperf import IPerf3Test, emit_iperf3_metrics
1517from host_tools .cargo_build import gcc_compile
16- from host_tools .fcmetrics import FCMetricsMonitor
18+
19+ # from host_tools.fcmetrics import FCMetricsMonitor
1720
1821
1922@pytest .mark .skipif (
@@ -28,7 +31,7 @@ def test_custom_udev_rule_latency(
2831 """Test the latency for hotplugging and booting CPUs in the guest"""
2932 gcc_compile (Path ("./host_tools/hotplug_time.c" ), Path ("host_tools/hotplug_time.o" ))
3033 data = []
31- for i in range (50 ):
34+ for _ in range (20 ):
3235 uvm_hotplug = microvm_factory .build (guest_kernel_linux_acpi_only , rootfs_rw )
3336 uvm_hotplug .jailer .extra_args .update ({"boot-timer" : None , "no-seccomp" : None })
3437 uvm_hotplug .help .enable_console ()
@@ -51,7 +54,7 @@ def test_custom_udev_rule_latency(
5154 )
5255
5356 uvm_hotplug .api .hotplug .put (Vcpu = {"add" : vcpu_count })
54- time .sleep (2 )
57+ time .sleep (5 )
5558
5659 # Extract API call duration
5760 api_duration = (
@@ -73,10 +76,24 @@ def test_custom_udev_rule_latency(
7376 / 1000
7477 )
7578 except IndexError :
76- timestamp = None
79+ uvm_hotplug .kill ()
80+ data .append ({"vcpus" : vcpu_count , "api" : api_duration , "onlining" : None })
81+ continue
7782
7883 data .append ({"vcpus" : vcpu_count , "api" : api_duration , "onlining" : timestamp })
7984
85+ check_guest_cpuid_output (
86+ uvm_hotplug ,
87+ "lscpu" ,
88+ None ,
89+ ":" ,
90+ {
91+ "CPU(s)" : str (1 + vcpu_count ),
92+ "On-line CPU(s) list" : f"0-{ vcpu_count } " ,
93+ },
94+ )
95+ uvm_hotplug .kill ()
96+
8097 output_file = results_dir / f"hotplug-{ vcpu_count } .csv"
8198
8299 csv_data = pandas .DataFrame .from_dict (data ).to_csv (
@@ -99,7 +116,7 @@ def test_manual_latency(
99116 """Test the latency for hotplugging and booting CPUs in the guest"""
100117 gcc_compile (Path ("./host_tools/hotplug_time.c" ), Path ("host_tools/hotplug_time.o" ))
101118 data = []
102- for _ in range (50 ):
119+ for _ in range (20 ):
103120 uvm_hotplug = microvm_factory .build (guest_kernel_linux_acpi_only , rootfs_rw )
104121 uvm_hotplug .jailer .extra_args .update ({"boot-timer" : None , "no-seccomp" : None })
105122 uvm_hotplug .help .enable_console ()
@@ -113,11 +130,13 @@ def test_manual_latency(
113130 uvm_hotplug .ssh .scp_put (
114131 Path ("./host_tools/hotplug_time.o" ), Path ("/home/hotplug_time.o" )
115132 )
116- uvm_hotplug .ssh .run ("tmux new-session -d /bin/bash /home/hotplug.sh" )
133+ uvm_hotplug .ssh .run (
134+ f"tmux new-session -d /bin/bash /home/hotplug.sh { vcpu_count } "
135+ )
117136
118137 uvm_hotplug .api .hotplug .put (Vcpu = {"add" : vcpu_count })
119138
120- time .sleep (1. 5 )
139+ time .sleep (5 )
121140 # Extract API call duration
122141 api_duration = (
123142 float (
@@ -139,10 +158,24 @@ def test_manual_latency(
139158 )
140159 except IndexError :
141160 data .append ({"vcpus" : vcpu_count , "api" : api_duration , "onlining" : None })
161+ uvm_hotplug .kill ()
142162 continue
143163
144164 data .append ({"vcpus" : vcpu_count , "api" : api_duration , "onlining" : timestamp })
145165
166+ check_guest_cpuid_output (
167+ uvm_hotplug ,
168+ "lscpu" ,
169+ None ,
170+ ":" ,
171+ {
172+ "CPU(s)" : str (1 + vcpu_count ),
173+ "On-line CPU(s) list" : f"0-{ vcpu_count } " ,
174+ },
175+ )
176+
177+ uvm_hotplug .kill ()
178+
146179 output_file = results_dir / f"hotplug-{ vcpu_count } .csv"
147180
148181 csv_data = pandas .DataFrame .from_dict (data ).to_csv (
0 commit comments