diff --git a/test/lima.yaml b/test/lima.yaml new file mode 100644 index 0000000..b94ece5 --- /dev/null +++ b/test/lima.yaml @@ -0,0 +1,30 @@ +images: +- location: "https://cloud-images.ubuntu.com/releases/24.04/release/ubuntu-24.04-server-cloudimg-amd64.img" + arch: "x86_64" +- location: "https://cloud-images.ubuntu.com/releases/24.04/release/ubuntu-24.04-server-cloudimg-arm64.img" + arch: "aarch64" +cpus: 2 +memory: "2g" +plain: true +networks: +- socket: /var/run/socket_vmnet +provision: +- mode: system + script: | + #!/bin/bash + set -eux -o pipefail + command -v ipref3 >/dev/null 2>&1 && exit 0 + export DEBIAN_FRONTEND=noninteractive + apt-get update + apt-get install -y iperf3 +probes: +- description: "iperf installed" + script: | + #!/bin/bash + set -eux -o pipefail + if ! timeout 30s bash -c "until command -v iperf3 >/dev/null 2>&1; do sleep 3; done"; then + echo >&2 "iperf3 is not installed yet" + exit 1 + fi + hint: | + See "/var/log/cloud-init-output.log" in the guest diff --git a/test/perf.sh b/test/perf.sh new file mode 100755 index 0000000..aa71e4d --- /dev/null +++ b/test/perf.sh @@ -0,0 +1,76 @@ +#!/bin/bash +set -e +cd "$(dirname "$0")" + +TIME=${2:-30} + +server_address() { + limactl shell server ip -j -4 addr show dev lima0 | jq -r '.[0].addr_info[0].local' +} + +create() { + limactl create --name server --tty=false lima.yaml & + limactl create --name client --tty=false lima.yaml & + wait +} + +host-to-vm() { + limactl start server + nohup limactl shell server iperf3 --server --daemon + iperf3-darwin --client $(server_address) --length 1m --time $TIME + limactl stop server +} + +host-to-vm-2() { + limactl start server & + limactl start client & + wait + nohup limactl shell server iperf3 --server --daemon + iperf3-darwin --client $(server_address) --length 1m --time $TIME + limactl stop server + limactl stop client +} + +vm-to-vm() { + limactl start server & + limactl start client & + wait + nohup limactl shell server iperf3 --server --daemon + addr=$(server_address) + limactl shell client iperf3 --client $addr --length 1m --time $TIME + limactl stop server + limactl stop client +} + +delete() { + limactl delete -f server + limactl delete -f client +} + +case $1 in +create) + create + ;; +host-to-vm) + host-to-vm + ;; +host-to-vm-2) + host-to-vm-2 + ;; +vm-to-vm) + vm-to-vm + ;; +delete) + delete + ;; +*) + echo "Usage $0 command" + echo + echo "Available commands:" + echo " create create test vms" + echo " delete delete test vms" + echo " host-to-vm [TIME] test host to vm performance" + echo " host-to-vm-2 [TIME] test host to vm performance with 1 extra vm" + echo " vm-to-vm [TIME] test vm to vm performance" + ;; +esac