blob: db9a674a864f5f14499418385250a56e6e1ee0a7 [file] [log] [blame]
Michael Lando451a3402017-02-19 10:28:42 +02001#!/bin/bash
2
Yuli Shlosberg0875ce02018-01-25 13:53:36 +02003CS_PASSWORD="onap123#@!"
4SDC_USER="asdc_user"
5SDC_PASSWORD="Aa1234%^!"
Yuli Shlosberg958c32d2018-02-15 12:04:46 +02006JETTY_BASE="/var/lib/jetty"
Gitelman, Tal (tg851x)328388b2018-03-22 13:03:44 +02007BE_JAVA_OPTIONS="-Xdebug -agentlib:jdwp=transport=dt_socket,address=4000,server=y,suspend=n -Xmx1536m -Xms1536m"
8FE_JAVA_OPTIONS="-Xdebug -agentlib:jdwp=transport=dt_socket,address=6000,server=y,suspend=n -Xmx256m -Xms256m"
Avi Zivc175a0d2018-03-15 13:21:44 +02009ONBOARD_BE_JAVA_OPTIONS="-Xdebug -agentlib:jdwp=transport=dt_socket,address=4001,server=y,suspend=n -Xmx1g -Xms1g"
Yuli Shlosbergf59a2252018-03-21 11:14:08 +020010SIM_JAVA_OPTIONS=" -Xmx128m -Xms128m -Xss1m"
11API_TESTS_JAVA_OPTIONS="-Xmx512m -Xms512m"
12UI_TESTS_JAVA_OPTIONS="-Xmx1024m -Xms1024m"
dekstroza83520062018-05-03 16:47:08 +010013#Define this as variable, so it can be excluded in run commands on Docker for OSX, as /etc/localtime cant be mounted there.
14LOCAL_TIME_MOUNT_CMD="--volume /etc/localtime:/etc/localtime:ro"
15# If os is OSX, unset this, so /etc/localtime is not mounted, otherwise leave it be
16if [[ "$OSTYPE" == "darwin"* ]]; then
17 LOCAL_TIME_MOUNT_CMD=""
18fi
19
20
Michael Lando451a3402017-02-19 10:28:42 +020021
Grinberg Motic3bda482017-02-23 11:24:34 +020022function usage {
Idan Amitdb3d5542017-12-07 11:33:32 +020023 echo "usage: docker_run.sh [ -r|--release <RELEASE-NAME> ] [ -e|--environment <ENV-NAME> ] [ -p|--port <Docker-hub-port>] [ -l|--local <Run-without-pull>] [ -t|--runTests <Run-with-sanityDocker>] [ -h|--help ]"
Michael Lando451a3402017-02-19 10:28:42 +020024}
25
26
Grinberg Motic3bda482017-02-23 11:24:34 +020027function cleanup {
Idan Amitdb3d5542017-12-07 11:33:32 +020028 echo "performing old dockers cleanup"
Yuli Shlosberg958c32d2018-02-15 12:04:46 +020029
30 if [ "$1" == "all" ] ; then
Michael Landoa5445102018-03-04 14:53:33 +020031 docker_ids=`docker ps -a | egrep -v "onap/sdc-simulator" | egrep "ecomp-nexus:${PORT}/sdc|sdc|Exit" | awk '{print $1}'`
Yuli Shlosberg958c32d2018-02-15 12:04:46 +020032 for X in ${docker_ids}
33 do
34 docker rm -f ${X}
35 done
36 else
37 echo "performing $1 docker cleanup"
38 tmp=`docker ps -a -q --filter="name=$1"`
Yuli Shlosberg474996a2018-02-27 18:55:25 +020039 if [[ ! -z "$tmp" ]]; then
Yuli Shlosberg958c32d2018-02-15 12:04:46 +020040 docker rm -f ${tmp}
41 fi
42 fi
Grinberg Motic3bda482017-02-23 11:24:34 +020043}
44
dekstroza83520062018-05-03 16:47:08 +010045#Prefix all dirs with WORKSPACE variable, so it doesn't use absolute path if runnning outside of VM
Grinberg Motic3bda482017-02-23 11:24:34 +020046function dir_perms {
Michael Lando4b9b9472018-06-02 19:14:05 +030047 mkdir -p ${WORKSPACE}/data/logs/BE/SDC/SDC-BE
48 mkdir -p ${WORKSPACE}/data/logs/FE/SDC/SDC-FE
49 mkdir -p ${WORKSPACE}/data/logs/sdc-api-tests/ExtentReport
50 mkdir -p ${WORKSPACE}/data/logs/ONBOARD/SDC/ONBOARD-BE
Yuli Shlosbergf59a2252018-03-21 11:14:08 +020051 mkdir -p ${WORKSPACE}/data/logs/sdc-api-tests/target
52 mkdir -p ${WORKSPACE}/data/logs/sdc-ui-tests/ExtentReport
Michael Lando4b9b9472018-06-02 19:14:05 +030053 mkdir -p ${WORKSPACE}/data/logs/sdc-ui-tests/target
54 mkdir -p ${WORKSPACE}/data/logs/docker_logs
55 mkdir -p ${WORKSPACE}/data/logs/WS
56 chmod -R 777 ${WORKSPACE}/data/logs
Grinberg Motic3bda482017-02-23 11:24:34 +020057}
Yuli Shlosberg36604c72018-02-25 16:03:45 +020058
Yuli Shlosbergb4deec12018-02-25 20:24:44 +020059function docker_logs {
Michael Lando4b9b9472018-06-02 19:14:05 +030060 docker logs $1 > ${WORKSPACE}/data/logs/docker_logs/$1_docker.log
Yuli Shlosbergb4deec12018-02-25 20:24:44 +020061}
62
Yuli Shlosberg0875ce02018-01-25 13:53:36 +020063function probe_cs {
Michael Lando4b9b9472018-06-02 19:14:05 +030064 cs_stat=false
65 docker exec $1 /var/lib/ready-probe.sh > /dev/null 2>&1
66 rc=$?
67 if [[ $rc == 0 ]]; then
68 echo DOCKER start finished in $2 seconds
69 cs_stat=true
70 fi
Yuli Shlosberg0875ce02018-01-25 13:53:36 +020071}
72
Yuli Shlosberg958c32d2018-02-15 12:04:46 +020073function probe_be {
Michael Lando4b9b9472018-06-02 19:14:05 +030074 be_stat=false
75 docker exec $1 /var/lib/ready-probe.sh > /dev/null 2>&1
76 rc=$?
77 if [[ $rc == 0 ]]; then
78 echo DOCKER start finished in $2 seconds
79 be_stat=true
80 fi
Yuli Shlosberg958c32d2018-02-15 12:04:46 +020081}
82
Avi Zivc175a0d2018-03-15 13:21:44 +020083function probe_sdc_onboard_be {
Michael Lando4b9b9472018-06-02 19:14:05 +030084 sdc_onboard_be_stat=false
85 docker exec $1 /var/lib/ready-probe.sh > /dev/null 2>&1
86 rc=$?
87 if [[ $rc == 0 ]]; then
88 echo DOCKER start finished in $2 seconds
89 sdc_onboard_be_stat=true
90 fi
Avi Zivc175a0d2018-03-15 13:21:44 +020091}
92
Yuli Shlosberg958c32d2018-02-15 12:04:46 +020093function probe_fe {
Michael Lando4b9b9472018-06-02 19:14:05 +030094 fe_stat=false
95 docker exec $1 /var/lib/ready-probe.sh > /dev/null 2>&1
96 rc=$?
97 if [[ $rc == 0 ]]; then
98 echo DOCKER start finished in $2 seconds
99 fe_stat=true
100 fi
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200101}
102
103function probe_es {
Michael Lando4b9b9472018-06-02 19:14:05 +0300104 es_stat=false
105 health_Check_http_code=$(curl --noproxy "*" -o /dev/null -w '%{http_code}' http://${IP}:9200/_cluster/health?wait_for_status=yellow&timeout=120s)
106 if [[ "$health_Check_http_code" -eq 200 ]]
107 then
108 echo DOCKER start finished in $2 seconds
109 es_stat=true
110 fi
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200111}
112
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200113function probe_sim {
Michael Lando4b9b9472018-06-02 19:14:05 +0300114 if lsof -Pi :8285 -sTCP:LISTEN -t >/dev/null ; then
115 echo "running"
116 sim_stat=true
117 else
118 echo "not running"
119 sim_stat=false
120 fi
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200121}
122
Yuli Shlosberg0875ce02018-01-25 13:53:36 +0200123function probe_docker {
Michael Lando4b9b9472018-06-02 19:14:05 +0300124 match_result=false
125 MATCH=`docker logs --tail 30 $1 | grep "DOCKER STARTED"`
126 echo MATCH is -- $MATCH
Yuli Shlosberg0875ce02018-01-25 13:53:36 +0200127
Michael Lando4b9b9472018-06-02 19:14:05 +0300128 if [ -n "$MATCH" ]; then
129 echo DOCKER start finished in $2 seconds
130 match_result=true
131 fi
Yuli Shlosberg0875ce02018-01-25 13:53:36 +0200132}
Yuli Shlosberg5571a862017-10-03 18:18:51 +0300133function monitor_docker {
134
Idan Amitdb3d5542017-12-07 11:33:32 +0200135 echo monitor $1 Docker
136 sleep 5
137 TIME_OUT=900
138 INTERVAL=20
139 TIME=0
140 while [ "$TIME" -lt "$TIME_OUT" ]; do
Yuli Shlosberg0875ce02018-01-25 13:53:36 +0200141 if [ "$1" == "sdc-cs" ]; then
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200142 probe_cs $1 $TIME
143 if [[ $cs_stat == true ]]; then break; fi
144 elif [ "$1" == "sdc-es" ]; then
145 probe_es $1 $TIME
146 if [[ $es_stat == true ]]; then break; fi
147 elif [ "$1" == "sdc-BE" ]; then
148 probe_be $1 $TIME
149 if [[ $be_stat == true ]]; then break; fi
150 elif [ "$1" == "sdc-FE" ]; then
151 probe_fe $1 $TIME
152 if [[ $fe_stat == true ]]; then break; fi
Avi Zivc175a0d2018-03-15 13:21:44 +0200153 elif [ "$1" == "sdc-onboard-BE" ]; then
154 probe_sdc_onboard_be $1 $TIME
155 if [[ $sdc_onboard_be_stat == true ]]; then break; fi
156
Yuli Shlosberg0875ce02018-01-25 13:53:36 +0200157 else
158 probe_docker $1 $TIME
159 if [[ $match_result == true ]]; then break; fi
Idan Amitdb3d5542017-12-07 11:33:32 +0200160 fi
Idan Amitdb3d5542017-12-07 11:33:32 +0200161 echo Sleep: $INTERVAL seconds before testing if $1 DOCKER is up. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds
162 sleep $INTERVAL
163 TIME=$(($TIME+$INTERVAL))
164 done
Yuli Shlosberg5571a862017-10-03 18:18:51 +0300165
Yuli Shlosbergb4deec12018-02-25 20:24:44 +0200166 docker_logs $1
Yuli Shlosberg36604c72018-02-25 16:03:45 +0200167
Idan Amitdb3d5542017-12-07 11:33:32 +0200168 if [ "$TIME" -ge "$TIME_OUT" ]; then
169 echo -e "\e[1;31mTIME OUT: DOCKER was NOT fully started in $TIME_OUT seconds... Could cause problems ...\e[0m"
170 fi
Yuli Shlosberg5571a862017-10-03 18:18:51 +0300171}
172
Yuli Shlosbergd1bb2e52018-01-15 11:51:21 +0200173function healthCheck {
Yuli Shlosberg474996a2018-02-27 18:55:25 +0200174 curl --noproxy "*" ${IP}:9200/_cluster/health?pretty=true
Yuli Shlosbergd1bb2e52018-01-15 11:51:21 +0200175
176 echo "BE health-Check:"
Yuli Shlosberg474996a2018-02-27 18:55:25 +0200177 curl --noproxy "*" http://${IP}:8080/sdc2/rest/healthCheck
Yuli Shlosbergd1bb2e52018-01-15 11:51:21 +0200178
179 echo ""
180 echo ""
181 echo "FE health-Check:"
Yuli Shlosberg474996a2018-02-27 18:55:25 +0200182 curl --noproxy "*" http://${IP}:8181/sdc1/rest/healthCheck
Yuli Shlosbergd1bb2e52018-01-15 11:51:21 +0200183
184
185 echo ""
186 echo ""
Yuli Shlosberg474996a2018-02-27 18:55:25 +0200187 healthCheck_http_code=$(curl --noproxy "*" -o /dev/null -w '%{http_code}' -H "Accept: application/json" -H "Content-Type: application/json" -H "USER_ID: jh0003" http://${IP}:8080/sdc2/rest/v1/user/demo;)
Yuli Shlosbergd1bb2e52018-01-15 11:51:21 +0200188 if [[ ${healthCheck_http_code} != 200 ]]
189 then
190 echo "Error [${healthCheck_http_code}] while user existance check"
191 return ${healthCheck_http_code}
192 fi
193 echo "check user existance: OK"
194 return ${healthCheck_http_code}
195}
196
Grinberg Moti97246212017-02-21 19:30:31 +0200197RELEASE=latest
Idan Amitc7f57ec2017-08-31 14:26:21 +0300198LOCAL=false
Yuli Shlosberg0566f582017-11-26 19:05:23 +0200199RUNTESTS=false
Tal Gitelman8e5fc512017-10-23 13:49:06 +0300200DEBUG_PORT="--publish 4000:4000"
Avi Zivc175a0d2018-03-15 13:21:44 +0200201ONBOARD_DEBUG_PORT="--publish 4001:4000"
Tal Gitelmane224d0b2017-10-17 15:24:25 +0300202
Idan Amitdb3d5542017-12-07 11:33:32 +0200203while [ $# -gt 0 ]; do
Michael Lando451a3402017-02-19 10:28:42 +0200204 case $1 in
Idan Amitdb3d5542017-12-07 11:33:32 +0200205 # -r | --release - The specific docker version to pull and deploy
Yuli Shlosberg0566f582017-11-26 19:05:23 +0200206 -r | --release )
207 shift 1 ;
208 RELEASE=$1;
209 shift 1;;
Idan Amitdb3d5542017-12-07 11:33:32 +0200210 # -e | --environment - The environment name you want to deploy
Yuli Shlosberg0566f582017-11-26 19:05:23 +0200211 -e | --environment )
212 shift 1;
213 DEP_ENV=$1;
214 shift 1 ;;
Idan Amitdb3d5542017-12-07 11:33:32 +0200215 # -p | --port - The port from which to connect to the docker nexus
Yuli Shlosberg0566f582017-11-26 19:05:23 +0200216 -p | --port )
217 shift 1 ;
218 PORT=$1;
219 shift 1 ;;
Idan Amitdb3d5542017-12-07 11:33:32 +0200220 # -l | --local - Use this for deploying your local dockers without pulling them first
Yuli Shlosberg0566f582017-11-26 19:05:23 +0200221 -l | --local )
222 LOCAL=true;
223 shift 1;;
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200224 # -ta - Use this for running the APIs sanity docker after all other dockers have been deployed
225 -ta )
226 shift 1 ;
227 API_SUITE=$1;
228 RUN_API_TESTS=true;
229 shift 1 ;;
230 # -tu - Use this for running the UI sanity docker after all other dockers have been deployed
231 -tu )
232 shift 1 ;
233 UI_SUITE=$1;
234 RUN_UI_TESTS=true;
235 shift 1 ;;
236 # -tad - Use this for running the DEFAULT suite of tests in APIs sanity docker after all other dockers have been deployed
237 -tad | -t )
238 API_SUITE="onapApiSanity";
239 RUN_API_TESTS=true;
240 shift 1 ;;
241 # -tud - Use this for running the DEFAULT suite of tests in UI sanity docker after all other dockers have been deployed
242 -tud )
243 UI_SUITE="onapUiSanity";
244 RUN_UI_TESTS=true;
Yuli Shlosberg0566f582017-11-26 19:05:23 +0200245 shift 1 ;;
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200246 # -d | --docker - The init specified docker
247 -d | --docker )
248 shift 1 ;
249 DOCKER=$1;
250 shift 1 ;;
Idan Amitdb3d5542017-12-07 11:33:32 +0200251 # -h | --help - Display the help message with all the available run options
Yuli Shlosberg0566f582017-11-26 19:05:23 +0200252 -h | --help )
253 usage;
254 exit 0;;
255 * )
256 usage;
257 exit 1;;
Michael Lando451a3402017-02-19 10:28:42 +0200258 esac
Michael Lando451a3402017-02-19 10:28:42 +0200259done
260
dekstroza83520062018-05-03 16:47:08 +0100261#Prefix those with WORKSPACE so it can be set to something other then /opt
262[ -f ${WORKSPACE}/opt/config/env_name.txt ] && DEP_ENV=$(cat ${WORKSPACE}/opt/config/env_name.txt) || echo ${DEP_ENV}
263[ -f ${WORKSPACE}/opt/config/nexus_username.txt ] && NEXUS_USERNAME=$(cat ${WORKSPACE}/opt/config/nexus_username.txt) || NEXUS_USERNAME=release
264[ -f ${WORKSPACE}/opt/config/nexus_password.txt ] && NEXUS_PASSWD=$(cat ${WORKSPACE}/opt/config/nexus_password.txt) || NEXUS_PASSWD=sfWU3DFVdBr7GVxB85mTYgAW
265[ -f ${WORKSPACE}/opt/config/nexus_docker_repo.txt ] && NEXUS_DOCKER_REPO=$(cat ${WORKSPACE}/opt/config/nexus_docker_repo.txt) || NEXUS_DOCKER_REPO=nexus3.onap.org:${PORT}
266[ -f ${WORKSPACE}/opt/config/nexus_username.txt ] && docker login -u $NEXUS_USERNAME -p $NEXUS_PASSWD $NEXUS_DOCKER_REPO
Michael Lando451a3402017-02-19 10:28:42 +0200267
Yuli Shlosbergd1bb2e52018-01-15 11:51:21 +0200268export IP=`ip route get 8.8.8.8 | awk '/src/{ print $7 }'`
dekstroza83520062018-05-03 16:47:08 +0100269#If OSX, then use this to get IP
270if [[ "$OSTYPE" == "darwin"* ]]; then
271 export IP=$(ipconfig getifaddr en0)
272fi
Idan Amitdb3d5542017-12-07 11:33:32 +0200273export PREFIX=${NEXUS_DOCKER_REPO}'/onap'
Idan Amitc7f57ec2017-08-31 14:26:21 +0300274
275if [ ${LOCAL} = true ]; then
Idan Amitdb3d5542017-12-07 11:33:32 +0200276 PREFIX='onap'
Idan Amitc7f57ec2017-08-31 14:26:21 +0300277fi
Michael Lando451a3402017-02-19 10:28:42 +0200278
279echo ""
280
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200281
Michael Landoa5445102018-03-04 14:53:33 +0200282#Elastic-Search
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200283function sdc-es {
Michael Lando4b9b9472018-06-02 19:14:05 +0300284 echo "docker run sdc-elasticsearch..."
285 if [ ${LOCAL} = false ]; then
286 echo "pulling code"
287 docker pull ${PREFIX}/sdc-elasticsearch:${RELEASE}
288 fi
289 docker run -dit --name sdc-es --env ENVNAME="${DEP_ENV}" --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --env ES_JAVA_OPTS="-Xms512m -Xmx512m" --ulimit memlock=-1:-1 --ulimit nofile=4096:100000 $LOCAL_TIME_MOUNT_CMD --env ES_HEAP_SIZE=1024M --volume ${WORKSPACE}/data/ES:/usr/share/elasticsearch/data --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments --publish 9200:9200 --publish 9300:9300 ${PREFIX}/sdc-elasticsearch:${RELEASE} /bin/sh
Tal Gitelmanf1927592018-01-29 17:24:56 +0200290
Michael Lando4b9b9472018-06-02 19:14:05 +0300291 echo "please wait while ES is starting..."
292 monitor_docker sdc-es
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200293}
Yuli Shlosberg137cf5c2018-01-15 17:32:30 +0200294
Michael Landoa5445102018-03-04 14:53:33 +0200295
296#Init-Elastic-Search
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200297function sdc-init-es {
Michael Lando4b9b9472018-06-02 19:14:05 +0300298 echo "docker run sdc-init-elasticsearch..."
299 if [ ${LOCAL} = false ]; then
300 echo "pulling code"
301 docker pull ${PREFIX}/sdc-init-elasticsearch:${RELEASE}
302 fi
303 echo "Running sdc-init-es"
304 docker run --name sdc-init-es --env ENVNAME="${DEP_ENV}" --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --ulimit nofile=4096:100000 $LOCAL_TIME_MOUNT_CMD --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments ${PREFIX}/sdc-init-elasticsearch:${RELEASE} > /dev/null 2>&1
305 rc=$?
306 docker_logs sdc-init-es
307 if [[ $rc != 0 ]]; then exit $rc; fi
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200308}
Idan Amitc7f57ec2017-08-31 14:26:21 +0300309
Michael Landoa5445102018-03-04 14:53:33 +0200310#Cassandra
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200311function sdc-cs {
Michael Lando4b9b9472018-06-02 19:14:05 +0300312 echo "docker run sdc-cassandra..."
313 if [ ${LOCAL} = false ]; then
314 docker pull ${PREFIX}/sdc-cassandra:${RELEASE}
315 fi
316 docker run -dit --name sdc-cs --env RELEASE="${RELEASE}" --env CS_PASSWORD="${CS_PASSWORD}" --env ENVNAME="${DEP_ENV}" --env HOST_IP=${IP} --env MAX_HEAP_SIZE="1536M" --env HEAP_NEWSIZE="512M" --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --ulimit nofile=4096:100000 $LOCAL_TIME_MOUNT_CMD --volume ${WORKSPACE}/data/CS:/var/lib/cassandra --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments --publish 9042:9042 --publish 9160:9160 ${PREFIX}/sdc-cassandra:${RELEASE} /bin/sh
Yuli Shlosberg137cf5c2018-01-15 17:32:30 +0200317
Michael Lando451a3402017-02-19 10:28:42 +0200318
Michael Lando4b9b9472018-06-02 19:14:05 +0300319 echo "please wait while CS is starting..."
320 monitor_docker sdc-cs
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200321}
Michael Lando451a3402017-02-19 10:28:42 +0200322
Michael Landoa5445102018-03-04 14:53:33 +0200323#Cassandra-init
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200324function sdc-cs-init {
Michael Lando4b9b9472018-06-02 19:14:05 +0300325 echo "docker run sdc-cassandra-init..."
326 if [ ${LOCAL} = false ]; then
Yuli Shlosberg0875ce02018-01-25 13:53:36 +0200327 docker pull ${PREFIX}/sdc-cassandra-init:${RELEASE}
Michael Lando4b9b9472018-06-02 19:14:05 +0300328 fi
329 docker run --name sdc-cs-init --env RELEASE="${RELEASE}" --env SDC_USER="${SDC_USER}" --env SDC_PASSWORD="${SDC_PASSWORD}" --env CS_PASSWORD="${CS_PASSWORD}" --env ENVNAME="${DEP_ENV}" --env HOST_IP=${IP} --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --ulimit nofile=4096:100000 $LOCAL_TIME_MOUNT_CMD --volume ${WORKSPACE}/data/CS:/var/lib/cassandra --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments --volume ${WORKSPACE}/data/CS-Init:/root/chef-solo/cache ${PREFIX}/sdc-cassandra-init:${RELEASE} > /dev/null 2>&1
330 rc=$?
331 docker_logs sdc-cs-init
332 if [[ $rc != 0 ]]; then exit $rc; fi
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200333}
Yuli Shlosberg0875ce02018-01-25 13:53:36 +0200334
Avi Zivc175a0d2018-03-15 13:21:44 +0200335#Onboard Cassandra-init
336function sdc-cs-onboard-init {
Michael Lando4b9b9472018-06-02 19:14:05 +0300337 echo "docker run sdc-cs-onboard-init..."
338 if [ ${LOCAL} = false ]; then
339 docker pull ${PREFIX}/sdc-onboard-cassandra-init:${RELEASE}
340 fi
341 docker run --name sdc-cs-onboard-init --env RELEASE="${RELEASE}" --env CS_HOST_IP=${IP} --env SDC_USER="${SDC_USER}" --env SDC_PASSWORD="${SDC_PASSWORD}" --env CS_PASSWORD="${CS_PASSWORD}" --env ENVNAME="${DEP_ENV}" --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --ulimit nofile=4096:100000 $LOCAL_TIME_MOUNT_CMD --volume ${WORKSPACE}/data/CS:/var/lib/cassandra --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments --volume ${WORKSPACE}/data/CS-Init:/root/chef-solo/cache ${PREFIX}/sdc-onboard-cassandra-init:${RELEASE}
342 rc=$?
liboNet1ca8dbc2018-05-30 12:28:43 +0800343 docker_logs sdc-cs-onboard-init
Michael Lando4b9b9472018-06-02 19:14:05 +0300344 if [[ $rc != 0 ]]; then exit $rc; fi
Avi Zivc175a0d2018-03-15 13:21:44 +0200345}
346
Michael Landoa5445102018-03-04 14:53:33 +0200347#Kibana
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200348function sdc-kbn {
Michael Lando4b9b9472018-06-02 19:14:05 +0300349 echo "docker run sdc-kibana..."
350 if [ ${LOCAL} = false ]; then
351 docker pull ${PREFIX}/sdc-kibana:${RELEASE}
352 docker run --detach --name sdc-kbn --env ENVNAME="${DEP_ENV}" --env NODE_OPTIONS="--max-old-space-size=200" --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --ulimit nofile=4096:100000 $LOCAL_TIME_MOUNT_CMD --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments --publish 5601:5601 ${PREFIX}/sdc-kibana:${RELEASE}
353 fi
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200354}
Yuli Shlosberg137cf5c2018-01-15 17:32:30 +0200355
Michael Landoa5445102018-03-04 14:53:33 +0200356#Back-End
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200357function sdc-BE {
Michael Lando4b9b9472018-06-02 19:14:05 +0300358 echo "docker run sdc-backend..."
359 if [ ${LOCAL} = false ]; then
360 docker pull ${PREFIX}/sdc-backend:${RELEASE}
361 else
362 ADDITIONAL_ARGUMENTS=${DEBUG_PORT}
363 fi
364 docker run --detach --name sdc-BE --env HOST_IP=${IP} --env ENVNAME="${DEP_ENV}" --env cassandra_ssl_enabled="false" --env JAVA_OPTIONS="${BE_JAVA_OPTIONS}" --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --ulimit nofile=4096:100000 $LOCAL_TIME_MOUNT_CMD --volume ${WORKSPACE}/data/logs/BE/:/var/lib/jetty/logs --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments --publish 8443:8443 --publish 8080:8080 ${ADDITIONAL_ARGUMENTS} ${PREFIX}/sdc-backend:${RELEASE}
Michael Lando451a3402017-02-19 10:28:42 +0200365
Michael Lando4b9b9472018-06-02 19:14:05 +0300366 echo "please wait while BE is starting..."
367 monitor_docker sdc-BE
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200368}
Michael Lando451a3402017-02-19 10:28:42 +0200369
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200370# Back-End-Init
Michael Landoa5445102018-03-04 14:53:33 +0200371function sdc-BE-init {
Michael Lando4b9b9472018-06-02 19:14:05 +0300372 echo "docker run sdc-backend-init..."
373 if [ ${LOCAL} = false ]; then
374 docker pull ${PREFIX}/sdc-backend-init:${RELEASE}
375 fi
376 docker run --name sdc-BE-init --env HOST_IP=${IP} --env ENVNAME="${DEP_ENV}" --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --ulimit nofile=4096:100000 $LOCAL_TIME_MOUNT_CMD --volume ${WORKSPACE}/data/logs/BE/:/var/lib/jetty/logs --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments ${PREFIX}/sdc-backend-init:${RELEASE} > /dev/null 2>&1
377 rc=$?
378 docker_logs sdc-BE-init
379 if [[ $rc != 0 ]]; then exit $rc; fi
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200380}
381
Avi Zivc175a0d2018-03-15 13:21:44 +0200382# Onboard Back-End
383function sdc-onboard-BE {
384
Michael Lando4b9b9472018-06-02 19:14:05 +0300385 dir_perms
386 # Back-End
387 echo "docker run sdc-onboard-BE ..."
388 if [ ${LOCAL} = false ]; then
Avi Zivc175a0d2018-03-15 13:21:44 +0200389 docker pull ${PREFIX}/sdc-onboard-backend:${RELEASE}
Michael Lando4b9b9472018-06-02 19:14:05 +0300390 else
Avi Zivc175a0d2018-03-15 13:21:44 +0200391 ADDITIONAL_ARGUMENTS=${ONBOARD_DEBUG_PORT}
Michael Lando4b9b9472018-06-02 19:14:05 +0300392 fi
393 docker run --detach --name sdc-onboard-BE --env HOST_IP=${IP} --env ENVNAME="${DEP_ENV}" --env cassandra_ssl_enabled="false" --env SDC_CLUSTER_NAME="SDC-CS-${DEP_ENV}" --env SDC_USER="${SDC_USER}" --env SDC_PASSWORD="${SDC_PASSWORD}" --env JAVA_OPTIONS="${ONBOARD_BE_JAVA_OPTIONS}" --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --ulimit nofile=4096:100000 $LOCAL_TIME_MOUNT_CMD --volume ${WORKSPACE}/data/logs/ONBOARD:/var/lib/jetty/logs --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments --publish 8445:8445 --publish 8081:8081 ${ADDITIONAL_ARGUMENTS} ${PREFIX}/sdc-onboard-backend:${RELEASE}
Avi Zivc175a0d2018-03-15 13:21:44 +0200394
Michael Lando4b9b9472018-06-02 19:14:05 +0300395 echo "please wait while sdc-onboard-BE is starting..."
396 monitor_docker sdc-onboard-BE
Avi Zivc175a0d2018-03-15 13:21:44 +0200397}
398
Michael Landoa5445102018-03-04 14:53:33 +0200399
400# Front-End
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200401function sdc-FE {
Michael Lando4b9b9472018-06-02 19:14:05 +0300402 echo "docker run sdc-frontend..."
403 if [ ${LOCAL} = false ]; then
404 docker pull ${PREFIX}/sdc-frontend:${RELEASE}
405 fi
406 docker run --detach --name sdc-FE --env HOST_IP=${IP} --env ENVNAME="${DEP_ENV}" --env JAVA_OPTIONS="${FE_JAVA_OPTIONS}" --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --ulimit nofile=4096:100000 $LOCAL_TIME_MOUNT_CMD --volume ${WORKSPACE}/data/logs/FE/:/var/lib/jetty/logs --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments --publish 9443:9443 --publish 8181:8181 ${PREFIX}/sdc-frontend:${RELEASE}
Yuli Shlosberg137cf5c2018-01-15 17:32:30 +0200407
Michael Lando4b9b9472018-06-02 19:14:05 +0300408 echo "please wait while FE is starting....."
409 monitor_docker sdc-FE
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200410}
Michael Lando451a3402017-02-19 10:28:42 +0200411
ml636r0649e652017-02-20 21:10:54 +0200412
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200413# apis-sanity
414function sdc-api-tests {
Michael Lando4b9b9472018-06-02 19:14:05 +0300415 healthCheck
416 if [[ (${RUN_API_TESTS} = true) && (${healthCheck_http_code} == 200) ]]; then
417 echo "docker run sdc-api-tests..."
418 echo "Triger sdc-api-tests docker, please wait..."
Yuli Shlosberg0875ce02018-01-25 13:53:36 +0200419
Michael Lando4b9b9472018-06-02 19:14:05 +0300420 if [ ${LOCAL} = false ]; then
421 docker pull ${PREFIX}/sdc-api-tests:${RELEASE}
422 fi
Yuli Shlosberg316bb252017-11-14 11:47:17 +0200423
Michael Lando4b9b9472018-06-02 19:14:05 +0300424 docker run --detach --name sdc-api-tests --env HOST_IP=${IP} --env ENVNAME="${DEP_ENV}" --env JAVA_OPTIONS="${API_TESTS_JAVA_OPTIONS}" --env SUITE_NAME=${API_SUITE} --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --ulimit nofile=4096:100000 $LOCAL_TIME_MOUNT_CMD --volume ${WORKSPACE}/data/logs/sdc-api-tests/target:/var/lib/tests/target --volume ${WORKSPACE}/data/logs/sdc-api-tests/ExtentReport:/var/lib/tests/ExtentReport --volume ${WORKSPACE}/data/logs/sdc-api-tests/outputCsar:/var/lib/tests/outputCsar --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments --publish 9560:9560 ${PREFIX}/sdc-api-tests:${RELEASE} echo "please wait while SDC-API-TESTS is starting....."
425 monitor_docker sdc-api-tests
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200426
427fi
428}
429
430# ui-sanity
431function sdc-ui-tests {
Michael Lando4b9b9472018-06-02 19:14:05 +0300432 healthCheck
433 if [[ (${RUN_UI_TESTS} = true) && (${healthCheck_http_code} == 200) ]]; then
434 echo "docker run sdc-ui-tets..."
435 echo "Triger sdc-ui-tests docker, please wait..."
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200436
Michael Lando4b9b9472018-06-02 19:14:05 +0300437 if [ ${LOCAL} = false ]; then
438 docker pull ${PREFIX}/sdc-ui-tests:${RELEASE}
439 fi
440
441 sdc-sim
442 docker run --detach --name sdc-ui-tests --env HOST_IP=${IP} --env ENVNAME="${DEP_ENV}" --env JAVA_OPTIONS="${UI_TESTS_JAVA_OPTIONS}" --env SUITE_NAME=${UI_SUITE} --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --ulimit nofile=4096:100000 $LOCAL_TIME_MOUNT_CMD --volume ${WORKSPACE}/data/logs/sdc-ui-tests/target:/var/lib/tests/target --volume ${WORKSPACE}/data/logs/sdc-ui-tests/ExtentReport:/var/lib/tests/ExtentReport --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments --publish 5901:5901 --publish 6901:6901 ${PREFIX}/sdc-ui-tests:${RELEASE}
443 echo "please wait while SDC-UI-TESTS is starting....."
444 monitor_docker sdc-ui-tests
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200445 fi
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200446}
447
448
449# SDC-Simulator
450function sdc-sim {
Michael Lando4b9b9472018-06-02 19:14:05 +0300451 echo "docker run sdc-webSimulator..."
452 if [ ${LOCAL} = false ]; then
453 docker pull ${PREFIX}/sdc-simulator:${RELEASE}
454 fi
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200455
Michael Lando4b9b9472018-06-02 19:14:05 +0300456 probe_sim
457 if [ sim_stat=false ]; then
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200458
Michael Lando4b9b9472018-06-02 19:14:05 +0300459 docker run --detach --name sdc-sim --env JAVA_OPTIONS="${SIM_JAVA_OPTIONS}" --env ENVNAME="${DEP_ENV}" $LOCAL_TIME_MOUNT_CMD --volume ${WORKSPACE}/data/logs/WS/:/var/lib/jetty/logs --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments --publish 8285:8080 --publish 8286:8443 ${PREFIX}/sdc-simulator:${RELEASE}
460 echo "please wait while SDC-WEB-SIMULATOR is starting....."
461 monitor_docker sdc-sim
Yuli Shlosberg137cf5c2018-01-15 17:32:30 +0200462
Michael Lando4b9b9472018-06-02 19:14:05 +0300463 fi
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200464}
465
466if [ -z "${DOCKER}" ]; then
Michael Lando4b9b9472018-06-02 19:14:05 +0300467 cleanup all
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200468 dir_perms
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200469 sdc-es
470 sdc-init-es
471 sdc-cs
472 sdc-cs-init
Gitelman, Tal (tg851x)19c9bda2018-03-19 19:07:30 +0200473# sdc-kbn
Avi Zivc175a0d2018-03-15 13:21:44 +0200474 sdc-cs-onboard-init
475 sdc-onboard-BE
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200476 sdc-BE
477 sdc-BE-init
478 sdc-FE
Michael Lando4b9b9472018-06-02 19:14:05 +0300479 healthCheck
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200480 sdc-api-tests
dekstroza83520062018-05-03 16:47:08 +0100481 sdc-ui-tests
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200482else
483 cleanup ${DOCKER}
svishnev0b698c42018-03-08 15:50:44 +0200484 dir_perms
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200485 ${DOCKER}
Yuli Shlosberge07a5162018-02-26 10:11:10 +0200486 healthCheck
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200487fi