-
Notifications
You must be signed in to change notification settings - Fork 1
/
create.sh
executable file
·74 lines (60 loc) · 2.03 KB
/
create.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash
set -euo pipefail
# destroy the existing environment.
./destroy.sh
# build the environment.
docker compose --progress plain build
# start the environment in background.
docker compose up --detach
# wait for the services to exit.
function wait-for-service {
echo "Waiting for the $1 service to complete..."
while true; do
local result="$(docker compose ps --status exited --format json $1)"
if [ -n "$result" ] && [ "$result" != 'null' ]; then
local exit_code="$(jq -r '.ExitCode' <<<"$result")"
break
fi
sleep 3
done
docker compose logs $1
return $exit_code
}
wait-for-service init
# wait for the example-go service to be available.
function wait-for-http-200 {
local url="$1"
local timeout=300 # NB 300s is 5m.
local start_time="$(date +%s)"
echo "Waiting for the $url URL to be available..."
while true; do
local status_code="$(curl -o /dev/null -s -w "%{http_code}" "$url")"
local current_time="$(date +%s)"
local elapsed_time="$((current_time - start_time))"
if [ "$status_code" -eq 200 ]; then
echo "Waited $elapsed_time seconds for the $url URL to be available."
return 0
fi
if [ "$elapsed_time" -ge "$timeout" ]; then
echo "Timeout reached. URL did not return 200 status code within $timeout seconds."
return 1
fi
sleep 5
done
}
wait-for-http-200 http://wso2am.test:8280/example-go/1.0.0/
# show how to use the system.
cat <<'EOF'
#### Manual tests
example-go service:
http://example-go.test:8000
http://wso2am.test:8280/example-go/1.0.0/
https://wso2am.test:8243/example-go/1.0.0/
wso2am:
http://wso2am.test:8280/ (WSO2AM Gateway)
https://wso2am.test:8243/ (WSO2AM Gateway)
https://wso2am.test:9443/carbon/ (WSO2AM Carbon Management Console; login as `admin`:`admin`)
https://wso2am.test:9443/admin/ (WSO2AM Admin Portal; login as `admin`:`admin`)
https://wso2am.test:9443/publisher/ (WSO2AM Publisher; login as `admin`:`admin`)
https://wso2am.test:9443/devportal/ (WSO2AM Developer Portal; login as `admin`:`admin`)
EOF