Skip to content

Commit 5eeb56d

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 1a74fc6 commit 5eeb56d

File tree

3 files changed

+131
-125
lines changed

3 files changed

+131
-125
lines changed

tests/conftest.py

Lines changed: 4 additions & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 126 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -13,126 +13,126 @@
1313

1414
from host_tools.cargo_build import gcc_compile
1515

16-
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")
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")
135+
#
136136

137137

138138
@pytest.mark.skipif(
@@ -142,7 +142,7 @@ def test_default_udev_rule_latency(
142142
"vcpu_count", [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]
143143
)
144144
def test_manual_latency(
145-
microvm_factory, guest_kernel_linux_acpi_only, rootfs_rw, vcpu_count
145+
microvm_factory, guest_kernel_linux_acpi_only, rootfs_rw, vcpu_count, results_dir
146146
):
147147
"""Test the latency for hotplugging and booting CPUs in the guest"""
148148
gcc_compile(Path("./host_tools/hotplug_time.c"), Path("host_tools/hotplug_time.o"))
@@ -193,8 +193,11 @@ def test_manual_latency(
193193
# Extract onlining timings
194194
data.append({"vcpus": vcpu_count, "api": api_duration, "onlining": timestamp})
195195

196-
df = pandas.DataFrame.from_dict(data).to_csv(
197-
f"../test_results/manual-hotplug_{vcpu_count}.csv",
196+
output_file = results_dir / f"hotplug-{vcpu_count}.csv"
197+
198+
csv_data = pandas.DataFrame.from_dict(data).to_csv(
198199
index=False,
199200
float_format="%.3f",
200201
)
202+
203+
output_file.write_text(csv_data)

0 commit comments

Comments
 (0)