|
14 | 14 | from framework.utils_cpuid import check_guest_cpuid_output |
15 | 15 | from host_tools.cargo_build import gcc_compile |
16 | 16 |
|
17 | | - |
18 | | -@pytest.mark.parametrize( |
19 | | - "vcpu_count", [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30] |
20 | | -) |
21 | | -def test_custom_udev_rule_latency( |
22 | | - microvm_factory, guest_kernel_linux_acpi_only, rootfs_rw, vcpu_count |
23 | | -): |
24 | | - """Test the latency for hotplugging and booting CPUs in the guest""" |
25 | | - api_durations = [] |
26 | | - onlining_durations = [] |
27 | | - print(f"Vcpu count: {vcpu_count}") |
28 | | - for i in range(5): |
29 | | - uvm_hotplug = microvm_factory.build(guest_kernel_linux_acpi_only, rootfs_rw) |
30 | | - uvm_hotplug.jailer.extra_args.update({"no-seccomp": None}) |
31 | | - uvm_hotplug.help.enable_console() |
32 | | - uvm_hotplug.spawn() |
33 | | - uvm_hotplug.basic_config(vcpu_count=1, mem_size_mib=128) |
34 | | - uvm_hotplug.add_net_iface() |
35 | | - uvm_hotplug.start() |
36 | | - uvm_hotplug.ssh.run("rm /usr/lib/udev/rules.d/40-vm-hotadd.rules") |
37 | | - uvm_hotplug.ssh.scp_put( |
38 | | - Path("./host_tools/1-cpu-hotplug.rules"), |
39 | | - Path("/usr/lib/udev/rules.d/1-cpu-hotplug.rules"), |
40 | | - ) |
41 | | - |
42 | | - time.sleep(0.25) |
43 | | - |
44 | | - uvm_hotplug.api.hotplug.put(Vcpu={"add": vcpu_count}) |
45 | | - time.sleep(0.25) |
46 | | - _, stdout, _ = uvm_hotplug.ssh.run("dmesg") |
47 | | - |
48 | | - # Extract API call duration |
49 | | - api_duration = ( |
50 | | - float( |
51 | | - re.findall( |
52 | | - r"Total previous API call duration: (\d+) us\.", |
53 | | - uvm_hotplug.log_data, |
54 | | - )[-1] |
55 | | - ) |
56 | | - / 1000 |
57 | | - ) |
58 | | - |
59 | | - # Extract onlining timings |
60 | | - start = float( |
61 | | - re.findall(r"\[\s+(\d+\.\d+)\] CPU1 has been hot-added\n", stdout)[0] |
62 | | - ) |
63 | | - end = float(re.findall(r"\[\s+(\d+\.\d+)\] \w+", stdout)[-1]) |
64 | | - elapsed_time = (end - start) * 1000 |
65 | | - print(f"Api call duration: {api_duration} ms") |
66 | | - print(f"Onlining duration: {elapsed_time} ms") |
67 | | - api_durations.append(api_duration) |
68 | | - onlining_durations.append(elapsed_time) |
69 | | - uvm_hotplug.kill() |
70 | | - time.sleep(1) |
71 | | - |
72 | | - avg_api_duration = sum(api_durations) / 5 |
73 | | - avg_onlining_duration = sum(onlining_durations) / 5 |
74 | | - print(f"Averages for {vcpu_count} hotplugged vcpus:") |
75 | | - print(f"\tAverage API call duration: {avg_api_duration} ms") |
76 | | - print(f"\tAverage onliing duration: {avg_onlining_duration} ms") |
77 | | - |
78 | | - |
79 | | -@pytest.mark.parametrize( |
80 | | - "vcpu_count", [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30] |
81 | | -) |
82 | | -def test_default_udev_rule_latency( |
83 | | - microvm_factory, guest_kernel_linux_acpi_only, rootfs_rw, vcpu_count |
84 | | -): |
85 | | - """Test the latency for hotplugging and booting CPUs in the guest""" |
86 | | - api_durations = [] |
87 | | - onlining_durations = [] |
88 | | - print(f"Vcpu count: {vcpu_count}") |
89 | | - for i in range(5): |
90 | | - uvm_hotplug = microvm_factory.build(guest_kernel_linux_acpi_only, rootfs_rw) |
91 | | - uvm_hotplug.jailer.extra_args.update({"no-seccomp": None}) |
92 | | - uvm_hotplug.help.enable_console() |
93 | | - uvm_hotplug.spawn() |
94 | | - uvm_hotplug.basic_config(vcpu_count=1, mem_size_mib=128) |
95 | | - uvm_hotplug.add_net_iface() |
96 | | - uvm_hotplug.start() |
97 | | - |
98 | | - time.sleep(0.25) |
99 | | - |
100 | | - _, stdout, _ = uvm_hotplug.ssh.run("ls /usr/lib/udev/rules.d") |
101 | | - default_rule = re.search(r"40-vm-hotadd\.rules", stdout) |
102 | | - assert default_rule is not None |
103 | | - |
104 | | - uvm_hotplug.api.hotplug.put(Vcpu={"add": vcpu_count}) |
105 | | - time.sleep(0.25) |
106 | | - _, stdout, _ = uvm_hotplug.ssh.run("dmesg") |
107 | | - |
108 | | - # Extract API call duration |
109 | | - api_duration = ( |
110 | | - float( |
111 | | - re.findall( |
112 | | - r"Total previous API call duration: (\d+) us\.", |
113 | | - uvm_hotplug.log_data, |
114 | | - )[-1] |
115 | | - ) |
116 | | - / 1000 |
117 | | - ) |
118 | | - |
119 | | - # Extract onlining timings |
120 | | - start = float( |
121 | | - re.findall(r"\[\s+(\d+\.\d+)\] CPU1 has been hot-added\n", stdout)[0] |
122 | | - ) |
123 | | - end = float(re.findall(r"\[\s+(\d+\.\d+)\] \w+", stdout)[-1]) |
124 | | - elapsed_time = (end - start) * 1000 |
125 | | - print(f"Api call duration: {api_duration} ms") |
126 | | - print(f"Onlining duration: {elapsed_time} ms") |
127 | | - api_durations.append(api_duration) |
128 | | - onlining_durations.append(elapsed_time) |
129 | | - uvm_hotplug.kill() |
130 | | - time.sleep(1) |
131 | | - |
132 | | - avg_api_duration = sum(api_durations) / 5 |
133 | | - avg_onlining_duration = sum(onlining_durations) / 5 |
134 | | - print(f"Averages for {vcpu_count} hotplugged vcpus:") |
135 | | - print(f"\tAverage API call duration: {avg_api_duration} ms") |
136 | | - print(f"\tAverage onliing duration: {avg_onlining_duration} ms") |
| 17 | +# @pytest.mark.parametrize( |
| 18 | +# "vcpu_count", [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30] |
| 19 | +# ) |
| 20 | +# def test_custom_udev_rule_latency( |
| 21 | +# microvm_factory, guest_kernel_linux_acpi_only, rootfs_rw, vcpu_count |
| 22 | +# ): |
| 23 | +# """Test the latency for hotplugging and booting CPUs in the guest""" |
| 24 | +# api_durations = [] |
| 25 | +# onlining_durations = [] |
| 26 | +# print(f"Vcpu count: {vcpu_count}") |
| 27 | +# for i in range(5): |
| 28 | +# uvm_hotplug = microvm_factory.build(guest_kernel_linux_acpi_only, rootfs_rw) |
| 29 | +# uvm_hotplug.jailer.extra_args.update({"no-seccomp": None}) |
| 30 | +# uvm_hotplug.help.enable_console() |
| 31 | +# uvm_hotplug.spawn() |
| 32 | +# uvm_hotplug.basic_config(vcpu_count=1, mem_size_mib=128) |
| 33 | +# uvm_hotplug.add_net_iface() |
| 34 | +# uvm_hotplug.start() |
| 35 | +# uvm_hotplug.ssh.run("rm /usr/lib/udev/rules.d/40-vm-hotadd.rules") |
| 36 | +# uvm_hotplug.ssh.scp_put( |
| 37 | +# Path("./host_tools/1-cpu-hotplug.rules"), |
| 38 | +# Path("/usr/lib/udev/rules.d/1-cpu-hotplug.rules"), |
| 39 | +# ) |
| 40 | +# |
| 41 | +# time.sleep(0.25) |
| 42 | +# |
| 43 | +# uvm_hotplug.api.hotplug.put(Vcpu={"add": vcpu_count}) |
| 44 | +# time.sleep(0.25) |
| 45 | +# _, stdout, _ = uvm_hotplug.ssh.run("dmesg") |
| 46 | +# |
| 47 | +# # Extract API call duration |
| 48 | +# api_duration = ( |
| 49 | +# float( |
| 50 | +# re.findall( |
| 51 | +# r"Total previous API call duration: (\d+) us\.", |
| 52 | +# uvm_hotplug.log_data, |
| 53 | +# )[-1] |
| 54 | +# ) |
| 55 | +# / 1000 |
| 56 | +# ) |
| 57 | +# |
| 58 | +# # Extract onlining timings |
| 59 | +# start = float( |
| 60 | +# re.findall(r"\[\s+(\d+\.\d+)\] CPU1 has been hot-added\n", stdout)[0] |
| 61 | +# ) |
| 62 | +# end = float(re.findall(r"\[\s+(\d+\.\d+)\] \w+", stdout)[-1]) |
| 63 | +# elapsed_time = (end - start) * 1000 |
| 64 | +# print(f"Api call duration: {api_duration} ms") |
| 65 | +# print(f"Onlining duration: {elapsed_time} ms") |
| 66 | +# api_durations.append(api_duration) |
| 67 | +# onlining_durations.append(elapsed_time) |
| 68 | +# uvm_hotplug.kill() |
| 69 | +# time.sleep(1) |
| 70 | +# |
| 71 | +# avg_api_duration = sum(api_durations) / 5 |
| 72 | +# avg_onlining_duration = sum(onlining_durations) / 5 |
| 73 | +# print(f"Averages for {vcpu_count} hotplugged vcpus:") |
| 74 | +# print(f"\tAverage API call duration: {avg_api_duration} ms") |
| 75 | +# print(f"\tAverage onliing duration: {avg_onlining_duration} ms") |
| 76 | +# |
| 77 | +# |
| 78 | +# @pytest.mark.parametrize( |
| 79 | +# "vcpu_count", [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30] |
| 80 | +# ) |
| 81 | +# def test_default_udev_rule_latency( |
| 82 | +# microvm_factory, guest_kernel_linux_acpi_only, rootfs_rw, vcpu_count |
| 83 | +# ): |
| 84 | +# """Test the latency for hotplugging and booting CPUs in the guest""" |
| 85 | +# api_durations = [] |
| 86 | +# onlining_durations = [] |
| 87 | +# print(f"Vcpu count: {vcpu_count}") |
| 88 | +# for i in range(5): |
| 89 | +# uvm_hotplug = microvm_factory.build(guest_kernel_linux_acpi_only, rootfs_rw) |
| 90 | +# uvm_hotplug.jailer.extra_args.update({"no-seccomp": None}) |
| 91 | +# uvm_hotplug.help.enable_console() |
| 92 | +# uvm_hotplug.spawn() |
| 93 | +# uvm_hotplug.basic_config(vcpu_count=1, mem_size_mib=128) |
| 94 | +# uvm_hotplug.add_net_iface() |
| 95 | +# uvm_hotplug.start() |
| 96 | +# |
| 97 | +# time.sleep(0.25) |
| 98 | +# |
| 99 | +# _, stdout, _ = uvm_hotplug.ssh.run("ls /usr/lib/udev/rules.d") |
| 100 | +# default_rule = re.search(r"40-vm-hotadd\.rules", stdout) |
| 101 | +# assert default_rule is not None |
| 102 | +# |
| 103 | +# uvm_hotplug.api.hotplug.put(Vcpu={"add": vcpu_count}) |
| 104 | +# time.sleep(0.25) |
| 105 | +# _, stdout, _ = uvm_hotplug.ssh.run("dmesg") |
| 106 | +# |
| 107 | +# # Extract API call duration |
| 108 | +# api_duration = ( |
| 109 | +# float( |
| 110 | +# re.findall( |
| 111 | +# r"Total previous API call duration: (\d+) us\.", |
| 112 | +# uvm_hotplug.log_data, |
| 113 | +# )[-1] |
| 114 | +# ) |
| 115 | +# / 1000 |
| 116 | +# ) |
| 117 | +# |
| 118 | +# # Extract onlining timings |
| 119 | +# start = float( |
| 120 | +# re.findall(r"\[\s+(\d+\.\d+)\] CPU1 has been hot-added\n", stdout)[0] |
| 121 | +# ) |
| 122 | +# end = float(re.findall(r"\[\s+(\d+\.\d+)\] \w+", stdout)[-1]) |
| 123 | +# elapsed_time = (end - start) * 1000 |
| 124 | +# print(f"Api call duration: {api_duration} ms") |
| 125 | +# print(f"Onlining duration: {elapsed_time} ms") |
| 126 | +# api_durations.append(api_duration) |
| 127 | +# onlining_durations.append(elapsed_time) |
| 128 | +# uvm_hotplug.kill() |
| 129 | +# time.sleep(1) |
| 130 | +# |
| 131 | +# avg_api_duration = sum(api_durations) / 5 |
| 132 | +# avg_onlining_duration = sum(onlining_durations) / 5 |
| 133 | +# print(f"Averages for {vcpu_count} hotplugged vcpus:") |
| 134 | +# print(f"\tAverage API call duration: {avg_api_duration} ms") |
| 135 | +# print(f"\tAverage onliing duration: {avg_onlining_duration} ms") |
| 136 | +# |
137 | 137 |
|
138 | 138 |
|
139 | 139 | @pytest.mark.parametrize( |
140 | 140 | "vcpu_count", [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30] |
141 | 141 | ) |
142 | 142 | def test_manual_latency( |
143 | | - microvm_factory, guest_kernel_linux_acpi_only, rootfs_rw, vcpu_count |
| 143 | + microvm_factory, guest_kernel_linux_acpi_only, rootfs_rw, vcpu_count, results_dir |
144 | 144 | ): |
145 | 145 | """Test the latency for hotplugging and booting CPUs in the guest""" |
146 | 146 | gcc_compile(Path("./host_tools/hotplug_time.c"), Path("host_tools/hotplug_time.o")) |
@@ -191,8 +191,11 @@ def test_manual_latency( |
191 | 191 | # Extract onlining timings |
192 | 192 | data.append({"vcpus": vcpu_count, "api": api_duration, "onlining": timestamp}) |
193 | 193 |
|
194 | | - df = pandas.DataFrame.from_dict(data).to_csv( |
195 | | - f"../test_results/manual-hotplug_{vcpu_count}.csv", |
| 194 | + output_file = results_dir / f"hotplug-{vcpu_count}.csv" |
| 195 | + |
| 196 | + csv_data = pandas.DataFrame.from_dict(data).to_csv( |
196 | 197 | index=False, |
197 | 198 | float_format="%.3f", |
198 | 199 | ) |
| 200 | + |
| 201 | + output_file.write_text(csv_data) |
0 commit comments