Skip to content

Commit f7a9835

Browse files
committed
Add performance test using lima and iperf3
% test/perf.sh Usage test/perf.sh command Available commands: create create test vms delete delete test vms host-to-vm [TIME] test host to vm performance host-to-vm-2 [TIME] test host to vm performance with 1 extra vm vm-to-vm [TIME] test vm to vm performance Signed-off-by: Nir Soffer <[email protected]>
1 parent f486d47 commit f7a9835

File tree

2 files changed

+106
-0
lines changed

2 files changed

+106
-0
lines changed

test/lima.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
images:
2+
- location: "https://cloud-images.ubuntu.com/releases/24.04/release/ubuntu-24.04-server-cloudimg-amd64.img"
3+
arch: "x86_64"
4+
- location: "https://cloud-images.ubuntu.com/releases/24.04/release/ubuntu-24.04-server-cloudimg-arm64.img"
5+
arch: "aarch64"
6+
cpus: 2
7+
memory: "2g"
8+
plain: true
9+
networks:
10+
- socket: /var/run/socket_vmnet
11+
provision:
12+
- mode: system
13+
script: |
14+
#!/bin/bash
15+
set -eux -o pipefail
16+
command -v ipref3 >/dev/null 2>&1 && exit 0
17+
export DEBIAN_FRONTEND=noninteractive
18+
apt-get update
19+
apt-get install -y iperf3
20+
probes:
21+
- description: "iperf installed"
22+
script: |
23+
#!/bin/bash
24+
set -eux -o pipefail
25+
if ! timeout 30s bash -c "until command -v iperf3 >/dev/null 2>&1; do sleep 3; done"; then
26+
echo >&2 "iperf3 is not installed yet"
27+
exit 1
28+
fi
29+
hint: |
30+
See "/var/log/cloud-init-output.log" in the guest

test/perf.sh

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#!/bin/bash
2+
set -e
3+
cd "$(dirname "$0")"
4+
5+
TIME=${2:-30}
6+
7+
server_address() {
8+
limactl shell server ip -j -4 addr show dev lima0 | jq -r '.[0].addr_info[0].local'
9+
}
10+
11+
create() {
12+
limactl create --name server --tty=false lima.yaml &
13+
limactl create --name client --tty=false lima.yaml &
14+
wait
15+
}
16+
17+
host-to-vm() {
18+
limactl start server
19+
nohup limactl shell server iperf3 --server --daemon
20+
iperf3-darwin --client $(server_address) --length 1m --time $TIME
21+
limactl stop server
22+
}
23+
24+
host-to-vm-2() {
25+
limactl start server &
26+
limactl start client &
27+
wait
28+
nohup limactl shell server iperf3 --server --daemon
29+
iperf3-darwin --client $(server_address) --length 1m --time $TIME
30+
limactl stop server
31+
limactl stop client
32+
}
33+
34+
vm-to-vm() {
35+
limactl start server &
36+
limactl start client &
37+
wait
38+
nohup limactl shell server iperf3 --server --daemon
39+
addr=$(server_address)
40+
limactl shell client iperf3 --client $addr --length 1m --time $TIME
41+
limactl stop server
42+
limactl stop client
43+
}
44+
45+
delete() {
46+
limactl delete -f server
47+
limactl delete -f client
48+
}
49+
50+
case $1 in
51+
create)
52+
create
53+
;;
54+
host-to-vm)
55+
host-to-vm
56+
;;
57+
host-to-vm-2)
58+
host-to-vm-2
59+
;;
60+
vm-to-vm)
61+
vm-to-vm
62+
;;
63+
delete)
64+
delete
65+
;;
66+
*)
67+
echo "Usage $0 command"
68+
echo
69+
echo "Available commands:"
70+
echo " create create test vms"
71+
echo " delete delete test vms"
72+
echo " host-to-vm [TIME] test host to vm performance"
73+
echo " host-to-vm-2 [TIME] test host to vm performance with 1 extra vm"
74+
echo " vm-to-vm [TIME] test vm to vm performance"
75+
;;
76+
esac

0 commit comments

Comments
 (0)