Skip to content

Commit bf763f9

Browse files
committed
Update test to write results to S3 bucket
Only manual test being used now, due to udev rules being too slow. Change the manual test to save results to s3 bucket, so that the results can more easily be processed Signed-off-by: James Curtis <[email protected]>
1 parent 2c96f8e commit bf763f9

File tree

3 files changed

+131
-125
lines changed

3 files changed

+131
-125
lines changed

tests/conftest.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,10 @@ def rootfs_fxt(request, record_property):
362362
guest_kernel_fxt, params=kernel_params("vmlinux-5.10*")
363363
)
364364
guest_kernel_linux_acpi_only = pytest.fixture(
365-
guest_kernel_fxt, params=kernel_params("vmlinux-5.10.221")
365+
guest_kernel_fxt, params=kernel_params("vmlinux-5.10.219")
366+
)
367+
guest_kernel_linux_6_5 = pytest.fixture(
368+
guest_kernel_fxt, params=kernel_params("vmlinux-6.5.*", select=kernels_unfiltered)
366369
)
367370
# Use the unfiltered selector, since we don't officially support 6.1 yet.
368371
# TODO: switch to default selector once we add full 6.1 support.

tests/host_tools/hotplug.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ done
99
readarray -t offline_cpus < <(lscpu -p=cpu --offline | sed '/^#/d')
1010

1111
for cpu_idx in ${offline_cpus[@]}; do
12-
echo 1 >/sys/devices/system/cpu/cpu$cpu_idx/online
12+
echo 1 | tee cpu*/online
1313
done
1414

1515
/home/hotplug_time.o

tests/integration_tests/performance/test_vcpu_hotplug.py

+126-123
Original file line numberDiff line numberDiff line change
@@ -12,133 +12,133 @@
1212

1313
from host_tools.cargo_build import gcc_compile
1414

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

136136

137137
@pytest.mark.parametrize(
138138
"vcpu_count", [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]
139139
)
140140
def test_manual_latency(
141-
microvm_factory, guest_kernel_linux_acpi_only, rootfs_rw, vcpu_count
141+
microvm_factory, guest_kernel_linux_acpi_only, rootfs_rw, vcpu_count, results_dir
142142
):
143143
"""Test the latency for hotplugging and booting CPUs in the guest"""
144144
gcc_compile(Path("./host_tools/hotplug_time.c"), Path("host_tools/hotplug_time.o"))
@@ -189,8 +189,11 @@ def test_manual_latency(
189189
# Extract onlining timings
190190
data.append({"vcpus": vcpu_count, "api": api_duration, "onlining": timestamp})
191191

192-
df = pandas.DataFrame.from_dict(data).to_csv(
193-
f"../test_results/manual-hotplug_{vcpu_count}.csv",
192+
output_file = results_dir / f"hotplug-{vcpu_count}.csv"
193+
194+
csv_data = pandas.DataFrame.from_dict(data).to_csv(
194195
index=False,
195196
float_format="%.3f",
196197
)
198+
199+
output_file.write_text(csv_data)

0 commit comments

Comments
 (0)