Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
lima-vm
GitHub Repository: lima-vm/lima
Path: blob/master/hack/test-plain-static-port-forward.sh
1637 views
1
#!/usr/bin/env bash
2
3
# SPDX-FileCopyrightText: Copyright The Lima Authors
4
# SPDX-License-Identifier: Apache-2.0
5
6
set -euxo pipefail
7
8
INSTANCE=plain-static-port-forward
9
TEMPLATE=hack/test-templates/static-port-forward.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 [ -e /run/nginx.pid ]; do sleep 1; done'
16
17
curl -sSf http://127.0.0.1:9090 | grep -i 'nginx' && echo 'Static port forwarding (9090) works in plain mode!'
18
19
if curl -sSf http://127.0.0.1:9080 2>/dev/null; then
20
echo 'ERROR: Dynamic port 9080 should not be forwarded in plain mode!'
21
exit 1
22
else
23
echo 'Dynamic port 9080 is correctly NOT forwarded in plain mode.'
24
fi
25
26
if curl -sSf http://127.0.0.1:9070 2>/dev/null; then
27
echo 'ERROR: Dynamic port 9070 should not be forwarded in plain mode!'
28
exit 1
29
else
30
echo 'Dynamic port 9070 is correctly NOT forwarded in plain mode.'
31
fi
32
33
limactl delete -f $INSTANCE
34
echo "All tests passed for plain mode - only static ports work!"
35
# EOF
36
37