| 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | set -euxo pipefail |
| 7 | |
| 8 | INSTANCE=plain-static-port-forward |
| 9 | TEMPLATE="$(dirname "$0")/test-templates/test-misc.yaml" |
| 10 | |
| 11 | limactl delete -f "$INSTANCE" || true |
| 12 | |
| 13 | limactl start --name="$INSTANCE" --plain=true --tty=false "$TEMPLATE" |
| 14 | |
| 15 | limactl shell "$INSTANCE" -- bash -c 'until systemctl is-active --quiet nginx; do sleep 1; done' |
| 16 | |
| 17 | if ! curl -sSf http://127.0.0.1:9090 | grep -i 'nginx'; then |
| 18 | echo 'ERROR: Static port forwarding (9090) does not work in plain mode!' |
| 19 | exit 1 |
| 20 | fi |
| 21 | echo 'Static port forwarding (9090) works in plain mode!' |
| 22 | |
| 23 | if curl -sSf http://127.0.0.1:29080 2>/dev/null; then |
| 24 | echo 'ERROR: Dynamic port 29080 should not be forwarded in plain mode!' |
| 25 | exit 1 |
| 26 | else |
| 27 | echo 'Dynamic port 29080 is correctly NOT forwarded in plain mode.' |
| 28 | fi |
| 29 | |
| 30 | if curl -sSf http://127.0.0.1:29070 2>/dev/null; then |
| 31 | echo 'ERROR: Dynamic port 29070 should not be forwarded in plain mode!' |
| 32 | exit 1 |
| 33 | else |
| 34 | echo 'Dynamic port 29070 is correctly NOT forwarded in plain mode.' |
| 35 | fi |
| 36 | |
| 37 | limactl delete -f "$INSTANCE" |
| 38 | echo "All tests passed for plain mode - only static ports work!" |
| 39 | |