-
Notifications
You must be signed in to change notification settings - Fork 82
/
07-run-generated-app-sample.sh
108 lines (89 loc) · 2.86 KB
/
07-run-generated-app-sample.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/bin/sh
set -e
RED='\033[0;31m'
GREEN='\033[0;32m'
#-------------------------------------------------------------------------------
# functions
#-------------------------------------------------------------------------------
launchCurlOrProtractor() {
if [ "$1" = "build" ]; then
sleep 10
else
sleep 150
fi
retryCount=1
maxRetry=10
httpUrl="http://localhost:8081/management/info"
rep=$(curl -v "$httpUrl")
status=$?
while [ "$status" -ne 0 ] && [ "$retryCount" -le "$maxRetry" ]; do
echo "*** [$(date)] Application not reachable yet. Sleep and retry - retryCount =" $retryCount "/" $maxRetry
retryCount=$((retryCount+1))
sleep 15
rep=$(curl -v "$httpUrl")
status=$?
done
if [ "$status" -ne 0 ]; then
echo "***${RED}[$(date)] Not connected after" $retryCount " retries."
return 1
fi
if [ "$1" = "oauth2" ] || [ "$1" = "jwt" ]; then
retryCount=0
maxRetry=1
until [ "$retryCount" -ge "$maxRetry" ]
do
result=0
echo "***${GREEN}run protractor e2e test in client for : "$1
node node_modules/webdriver-manager/bin/webdriver-manager update --gecko false && JHI_E2E_HEADLESS=true npm run e2e
result=$?
[ $result -eq 0 ] && break
retryCount=$((retryCount+1))
echo "***${RED}e2e tests failed... retryCount =" $retryCount "/" $maxRetry
sleep 15
done
return $result
else
return 0
fi
}
runOnlyServerApp() {
echo "***${GREEN}node env : "$1
BACKEND_ENV=$1 node dist/main.js &
echo $! > .pidRunApp
}
runApp() {
echo "***${GREEN}node env : "$1
BACKEND_ENV=$1 npm run start:app &
echo $! > .pidRunApp
}
#-------------------------------------------------------------------------------
# Change in template directory
#-------------------------------------------------------------------------------
cd test-integration/samples/$1
echo "***${GREEN}changed directory in : test-integration/samples/"$1
#-------------------------------------------------------------------------------
# Run and test app
#-------------------------------------------------------------------------------
ENV_BUILD="dev"
if [ "$1" = "monolith-client-database-prod-template-jdl" ]; then
echo "***${GREEN}set prod build environment"
ENV_BUILD="prod"
fi
if [ "$2" = "build" ]; then
echo "***${GREEN}only server build in : "$1
cd server
npm run build
echo "***${GREEN}run server main app in dist : "$1
runOnlyServerApp $ENV_BUILD
else
echo "***${GREEN}run full app in : "$1
runApp $ENV_BUILD
fi
launchCurlOrProtractor $2
resultRunApp=$?
#-------------------------------------------------------------------------------
# Kill app
#-------------------------------------------------------------------------------
echo "***${GREEN}kill app : "$1
kill $(cat .pidRunApp)
exit $((resultRunApp))