blob: bd11c15855ddec00d16a720eb6719b99969e5419 [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 {
dekstroza83520062018-05-03 16:47:08 +010047 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
53 mkdir -p ${WORKSPACE}/data/logs/sdc-ui-tests/target
Yuli Shlosberg23cc7f52018-02-28 13:19:42 +020054 mkdir -p ${WORKSPACE}/data/logs/docker_logs
Yuli Shlosberge2eef602018-04-10 23:05:13 +030055 mkdir -p ${WORKSPACE}/data/logs/WS
dekstroza83520062018-05-03 16:47:08 +010056 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 {
60
Yuli Shlosberg23cc7f52018-02-28 13:19:42 +020061docker logs $1 > ${WORKSPACE}/data/logs/docker_logs/$1_docker.log
Yuli Shlosbergb4deec12018-02-25 20:24:44 +020062
63}
64
Yuli Shlosberg0875ce02018-01-25 13:53:36 +020065function probe_cs {
Grinberg Motic3bda482017-02-23 11:24:34 +020066
Yuli Shlosberg0875ce02018-01-25 13:53:36 +020067cs_stat=false
Yuli Shlosberg5d0f58e2018-02-26 14:18:08 +020068docker exec $1 /var/lib/ready-probe.sh > /dev/null 2>&1
Yuli Shlosberg0875ce02018-01-25 13:53:36 +020069rc=$?
70if [[ $rc == 0 ]]; then
71 echo DOCKER start finished in $2 seconds
72 cs_stat=true
73fi
74
75}
76
Yuli Shlosberg958c32d2018-02-15 12:04:46 +020077function probe_be {
78
79be_stat=false
Yuli Shlosberg5d0f58e2018-02-26 14:18:08 +020080docker exec $1 /var/lib/ready-probe.sh > /dev/null 2>&1
Yuli Shlosberg958c32d2018-02-15 12:04:46 +020081rc=$?
Avi Zivc175a0d2018-03-15 13:21:44 +020082if [[ $rc == 0 ]]; then
Yuli Shlosberg958c32d2018-02-15 12:04:46 +020083 echo DOCKER start finished in $2 seconds
84 be_stat=true
85fi
86
87}
88
Avi Zivc175a0d2018-03-15 13:21:44 +020089function probe_sdc_onboard_be {
90
91sdc_onboard_be_stat=false
92docker exec $1 /var/lib/ready-probe.sh > /dev/null 2>&1
93rc=$?
94if [[ $rc == 0 ]]; then
95 echo DOCKER start finished in $2 seconds
96 sdc_onboard_be_stat=true
97fi
98
99}
100
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200101function probe_fe {
102
103fe_stat=false
Yuli Shlosberg5d0f58e2018-02-26 14:18:08 +0200104docker exec $1 /var/lib/ready-probe.sh > /dev/null 2>&1
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200105rc=$?
Avi Zivc175a0d2018-03-15 13:21:44 +0200106if [[ $rc == 0 ]]; then
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200107 echo DOCKER start finished in $2 seconds
108 fe_stat=true
109fi
110
111}
112
113function probe_es {
114
115es_stat=false
Yuli Shlosberg474996a2018-02-27 18:55:25 +0200116health_Check_http_code=$(curl --noproxy "*" -o /dev/null -w '%{http_code}' http://${IP}:9200/_cluster/health?wait_for_status=yellow&timeout=120s)
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200117if [[ "$health_Check_http_code" -eq 200 ]]
118 then
119 echo DOCKER start finished in $2 seconds
120 es_stat=true
121 fi
122
123}
124
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200125function probe_sim {
126
127if lsof -Pi :8285 -sTCP:LISTEN -t >/dev/null ; then
128 echo "running"
129 sim_stat=true
130else
131 echo "not running"
132 sim_stat=false
133fi
134
135
136}
137
Yuli Shlosberg0875ce02018-01-25 13:53:36 +0200138function probe_docker {
139
140match_result=false
141MATCH=`docker logs --tail 30 $1 | grep "DOCKER STARTED"`
142echo MATCH is -- $MATCH
143
144if [ -n "$MATCH" ]; then
145 echo DOCKER start finished in $2 seconds
146 match_result=true
147fi
148}
Yuli Shlosberg5571a862017-10-03 18:18:51 +0300149function monitor_docker {
150
Idan Amitdb3d5542017-12-07 11:33:32 +0200151 echo monitor $1 Docker
152 sleep 5
153 TIME_OUT=900
154 INTERVAL=20
155 TIME=0
156 while [ "$TIME" -lt "$TIME_OUT" ]; do
Yuli Shlosberg0875ce02018-01-25 13:53:36 +0200157 if [ "$1" == "sdc-cs" ]; then
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200158 probe_cs $1 $TIME
159 if [[ $cs_stat == true ]]; then break; fi
160 elif [ "$1" == "sdc-es" ]; then
161 probe_es $1 $TIME
162 if [[ $es_stat == true ]]; then break; fi
163 elif [ "$1" == "sdc-BE" ]; then
164 probe_be $1 $TIME
165 if [[ $be_stat == true ]]; then break; fi
166 elif [ "$1" == "sdc-FE" ]; then
167 probe_fe $1 $TIME
168 if [[ $fe_stat == true ]]; then break; fi
Avi Zivc175a0d2018-03-15 13:21:44 +0200169 elif [ "$1" == "sdc-onboard-BE" ]; then
170 probe_sdc_onboard_be $1 $TIME
171 if [[ $sdc_onboard_be_stat == true ]]; then break; fi
172
Yuli Shlosberg0875ce02018-01-25 13:53:36 +0200173 else
174 probe_docker $1 $TIME
175 if [[ $match_result == true ]]; then break; fi
Idan Amitdb3d5542017-12-07 11:33:32 +0200176 fi
Idan Amitdb3d5542017-12-07 11:33:32 +0200177 echo Sleep: $INTERVAL seconds before testing if $1 DOCKER is up. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds
178 sleep $INTERVAL
179 TIME=$(($TIME+$INTERVAL))
180 done
Yuli Shlosberg5571a862017-10-03 18:18:51 +0300181
Yuli Shlosbergb4deec12018-02-25 20:24:44 +0200182 docker_logs $1
Yuli Shlosberg36604c72018-02-25 16:03:45 +0200183
Idan Amitdb3d5542017-12-07 11:33:32 +0200184 if [ "$TIME" -ge "$TIME_OUT" ]; then
185 echo -e "\e[1;31mTIME OUT: DOCKER was NOT fully started in $TIME_OUT seconds... Could cause problems ...\e[0m"
186 fi
Yuli Shlosberg5571a862017-10-03 18:18:51 +0300187
188}
189
Yuli Shlosbergd1bb2e52018-01-15 11:51:21 +0200190function healthCheck {
Yuli Shlosberg474996a2018-02-27 18:55:25 +0200191 curl --noproxy "*" ${IP}:9200/_cluster/health?pretty=true
Yuli Shlosbergd1bb2e52018-01-15 11:51:21 +0200192
193 echo "BE health-Check:"
Yuli Shlosberg474996a2018-02-27 18:55:25 +0200194 curl --noproxy "*" http://${IP}:8080/sdc2/rest/healthCheck
Yuli Shlosbergd1bb2e52018-01-15 11:51:21 +0200195
196 echo ""
197 echo ""
198 echo "FE health-Check:"
Yuli Shlosberg474996a2018-02-27 18:55:25 +0200199 curl --noproxy "*" http://${IP}:8181/sdc1/rest/healthCheck
Yuli Shlosbergd1bb2e52018-01-15 11:51:21 +0200200
201
202 echo ""
203 echo ""
Yuli Shlosberg474996a2018-02-27 18:55:25 +0200204 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 +0200205 if [[ ${healthCheck_http_code} != 200 ]]
206 then
207 echo "Error [${healthCheck_http_code}] while user existance check"
208 return ${healthCheck_http_code}
209 fi
210 echo "check user existance: OK"
211 return ${healthCheck_http_code}
212}
213
Grinberg Moti97246212017-02-21 19:30:31 +0200214RELEASE=latest
Idan Amitc7f57ec2017-08-31 14:26:21 +0300215LOCAL=false
Yuli Shlosberg0566f582017-11-26 19:05:23 +0200216RUNTESTS=false
Tal Gitelman8e5fc512017-10-23 13:49:06 +0300217DEBUG_PORT="--publish 4000:4000"
Avi Zivc175a0d2018-03-15 13:21:44 +0200218ONBOARD_DEBUG_PORT="--publish 4001:4000"
Tal Gitelmane224d0b2017-10-17 15:24:25 +0300219
Idan Amitdb3d5542017-12-07 11:33:32 +0200220while [ $# -gt 0 ]; do
Michael Lando451a3402017-02-19 10:28:42 +0200221 case $1 in
Idan Amitdb3d5542017-12-07 11:33:32 +0200222 # -r | --release - The specific docker version to pull and deploy
Yuli Shlosberg0566f582017-11-26 19:05:23 +0200223 -r | --release )
224 shift 1 ;
225 RELEASE=$1;
226 shift 1;;
Idan Amitdb3d5542017-12-07 11:33:32 +0200227 # -e | --environment - The environment name you want to deploy
Yuli Shlosberg0566f582017-11-26 19:05:23 +0200228 -e | --environment )
229 shift 1;
230 DEP_ENV=$1;
231 shift 1 ;;
Idan Amitdb3d5542017-12-07 11:33:32 +0200232 # -p | --port - The port from which to connect to the docker nexus
Yuli Shlosberg0566f582017-11-26 19:05:23 +0200233 -p | --port )
234 shift 1 ;
235 PORT=$1;
236 shift 1 ;;
Idan Amitdb3d5542017-12-07 11:33:32 +0200237 # -l | --local - Use this for deploying your local dockers without pulling them first
Yuli Shlosberg0566f582017-11-26 19:05:23 +0200238 -l | --local )
239 LOCAL=true;
240 shift 1;;
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200241 # -ta - Use this for running the APIs sanity docker after all other dockers have been deployed
242 -ta )
243 shift 1 ;
244 API_SUITE=$1;
245 RUN_API_TESTS=true;
246 shift 1 ;;
247 # -tu - Use this for running the UI sanity docker after all other dockers have been deployed
248 -tu )
249 shift 1 ;
250 UI_SUITE=$1;
251 RUN_UI_TESTS=true;
252 shift 1 ;;
253 # -tad - Use this for running the DEFAULT suite of tests in APIs sanity docker after all other dockers have been deployed
254 -tad | -t )
255 API_SUITE="onapApiSanity";
256 RUN_API_TESTS=true;
257 shift 1 ;;
258 # -tud - Use this for running the DEFAULT suite of tests in UI sanity docker after all other dockers have been deployed
259 -tud )
260 UI_SUITE="onapUiSanity";
261 RUN_UI_TESTS=true;
Yuli Shlosberg0566f582017-11-26 19:05:23 +0200262 shift 1 ;;
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200263 # -d | --docker - The init specified docker
264 -d | --docker )
265 shift 1 ;
266 DOCKER=$1;
267 shift 1 ;;
Idan Amitdb3d5542017-12-07 11:33:32 +0200268 # -h | --help - Display the help message with all the available run options
Yuli Shlosberg0566f582017-11-26 19:05:23 +0200269 -h | --help )
270 usage;
271 exit 0;;
272 * )
273 usage;
274 exit 1;;
Michael Lando451a3402017-02-19 10:28:42 +0200275 esac
Michael Lando451a3402017-02-19 10:28:42 +0200276done
277
dekstroza83520062018-05-03 16:47:08 +0100278#Prefix those with WORKSPACE so it can be set to something other then /opt
279[ -f ${WORKSPACE}/opt/config/env_name.txt ] && DEP_ENV=$(cat ${WORKSPACE}/opt/config/env_name.txt) || echo ${DEP_ENV}
280[ -f ${WORKSPACE}/opt/config/nexus_username.txt ] && NEXUS_USERNAME=$(cat ${WORKSPACE}/opt/config/nexus_username.txt) || NEXUS_USERNAME=release
281[ -f ${WORKSPACE}/opt/config/nexus_password.txt ] && NEXUS_PASSWD=$(cat ${WORKSPACE}/opt/config/nexus_password.txt) || NEXUS_PASSWD=sfWU3DFVdBr7GVxB85mTYgAW
282[ -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}
283[ -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 +0200284
Yuli Shlosbergd1bb2e52018-01-15 11:51:21 +0200285export IP=`ip route get 8.8.8.8 | awk '/src/{ print $7 }'`
dekstroza83520062018-05-03 16:47:08 +0100286#If OSX, then use this to get IP
287if [[ "$OSTYPE" == "darwin"* ]]; then
288 export IP=$(ipconfig getifaddr en0)
289fi
Idan Amitdb3d5542017-12-07 11:33:32 +0200290export PREFIX=${NEXUS_DOCKER_REPO}'/onap'
Idan Amitc7f57ec2017-08-31 14:26:21 +0300291
292if [ ${LOCAL} = true ]; then
Idan Amitdb3d5542017-12-07 11:33:32 +0200293 PREFIX='onap'
Idan Amitc7f57ec2017-08-31 14:26:21 +0300294fi
Michael Lando451a3402017-02-19 10:28:42 +0200295
296echo ""
297
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200298
Michael Landoa5445102018-03-04 14:53:33 +0200299#Elastic-Search
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200300function sdc-es {
Michael Lando451a3402017-02-19 10:28:42 +0200301echo "docker run sdc-elasticsearch..."
Idan Amitc7f57ec2017-08-31 14:26:21 +0300302if [ ${LOCAL} = false ]; then
303 echo "pulling code"
304 docker pull ${PREFIX}/sdc-elasticsearch:${RELEASE}
305fi
dekstroza83520062018-05-03 16:47:08 +0100306docker 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 +0200307
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200308echo "please wait while ES is starting..."
309monitor_docker sdc-es
310}
Yuli Shlosberg137cf5c2018-01-15 17:32:30 +0200311
Michael Landoa5445102018-03-04 14:53:33 +0200312
313#Init-Elastic-Search
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200314function sdc-init-es {
Tal Gitelman38211c82018-01-24 17:59:53 +0200315echo "docker run sdc-init-elasticsearch..."
316if [ ${LOCAL} = false ]; then
317 echo "pulling code"
318 docker pull ${PREFIX}/sdc-init-elasticsearch:${RELEASE}
319fi
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200320echo "Running sdc-init-es"
dekstroza83520062018-05-03 16:47:08 +0100321docker 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
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200322rc=$?
Yuli Shlosbergb4deec12018-02-25 20:24:44 +0200323docker_logs sdc-init-es
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200324if [[ $rc != 0 ]]; then exit $rc; fi
Tal Gitelmanf1927592018-01-29 17:24:56 +0200325
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200326}
Idan Amitc7f57ec2017-08-31 14:26:21 +0300327
Michael Landoa5445102018-03-04 14:53:33 +0200328#Cassandra
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200329function sdc-cs {
Idan Amitc7f57ec2017-08-31 14:26:21 +0300330echo "docker run sdc-cassandra..."
331if [ ${LOCAL} = false ]; then
332 docker pull ${PREFIX}/sdc-cassandra:${RELEASE}
333fi
dekstroza83520062018-05-03 16:47:08 +0100334docker 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 +0200335
Michael Lando451a3402017-02-19 10:28:42 +0200336
337echo "please wait while CS is starting..."
Yuli Shlosberg5571a862017-10-03 18:18:51 +0300338monitor_docker sdc-cs
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200339}
Michael Lando451a3402017-02-19 10:28:42 +0200340
Michael Landoa5445102018-03-04 14:53:33 +0200341#Cassandra-init
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200342function sdc-cs-init {
Yuli Shlosberg0875ce02018-01-25 13:53:36 +0200343echo "docker run sdc-cassandra-init..."
344if [ ${LOCAL} = false ]; then
345 docker pull ${PREFIX}/sdc-cassandra-init:${RELEASE}
346fi
dekstroza83520062018-05-03 16:47:08 +0100347docker 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
Yuli Shlosberg0875ce02018-01-25 13:53:36 +0200348rc=$?
Yuli Shlosbergb4deec12018-02-25 20:24:44 +0200349docker_logs sdc-cs-init
Yuli Shlosberg0875ce02018-01-25 13:53:36 +0200350if [[ $rc != 0 ]]; then exit $rc; fi
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200351}
Yuli Shlosberg0875ce02018-01-25 13:53:36 +0200352
Avi Zivc175a0d2018-03-15 13:21:44 +0200353#Onboard Cassandra-init
354function sdc-cs-onboard-init {
355echo "docker run sdc-cs-onboard-init..."
356if [ ${LOCAL} = false ]; then
357 docker pull ${PREFIX}/sdc-onboard-cassandra-init:${RELEASE}
358fi
dekstroza83520062018-05-03 16:47:08 +0100359docker 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}
Avi Zivc175a0d2018-03-15 13:21:44 +0200360rc=$?
361docker_logs sdc-onboard-cs-init
362if [[ $rc != 0 ]]; then exit $rc; fi
363}
364
Michael Landoa5445102018-03-04 14:53:33 +0200365#Kibana
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200366function sdc-kbn {
Michael Lando451a3402017-02-19 10:28:42 +0200367echo "docker run sdc-kibana..."
Idan Amitc7f57ec2017-08-31 14:26:21 +0300368if [ ${LOCAL} = false ]; then
369 docker pull ${PREFIX}/sdc-kibana:${RELEASE}
dekstroza83520062018-05-03 16:47:08 +0100370docker 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}
Idan Amitc7f57ec2017-08-31 14:26:21 +0300371fi
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200372
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200373}
Yuli Shlosberg137cf5c2018-01-15 17:32:30 +0200374
Michael Landoa5445102018-03-04 14:53:33 +0200375#Back-End
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200376function sdc-BE {
Michael Lando451a3402017-02-19 10:28:42 +0200377echo "docker run sdc-backend..."
Idan Amitc7f57ec2017-08-31 14:26:21 +0300378if [ ${LOCAL} = false ]; then
379 docker pull ${PREFIX}/sdc-backend:${RELEASE}
Tal Gitelmane224d0b2017-10-17 15:24:25 +0300380else
Tal Gitelman8e5fc512017-10-23 13:49:06 +0300381 ADDITIONAL_ARGUMENTS=${DEBUG_PORT}
Idan Amitc7f57ec2017-08-31 14:26:21 +0300382fi
dekstroza83520062018-05-03 16:47:08 +0100383docker 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 +0200384
385echo "please wait while BE is starting..."
Yuli Shlosberg5571a862017-10-03 18:18:51 +0300386monitor_docker sdc-BE
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200387}
Michael Lando451a3402017-02-19 10:28:42 +0200388
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200389# Back-End-Init
Michael Landoa5445102018-03-04 14:53:33 +0200390function sdc-BE-init {
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200391echo "docker run sdc-backend-init..."
392if [ ${LOCAL} = false ]; then
393 docker pull ${PREFIX}/sdc-backend-init:${RELEASE}
394fi
dekstroza83520062018-05-03 16:47:08 +0100395docker 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
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200396rc=$?
Yuli Shlosbergb4deec12018-02-25 20:24:44 +0200397docker_logs sdc-BE-init
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200398if [[ $rc != 0 ]]; then exit $rc; fi
399}
400
Avi Zivc175a0d2018-03-15 13:21:44 +0200401# Onboard Back-End
402function sdc-onboard-BE {
403
404dir_perms
405# Back-End
406echo "docker run sdc-onboard-BE ..."
407if [ ${LOCAL} = false ]; then
408 docker pull ${PREFIX}/sdc-onboard-backend:${RELEASE}
409else
410 ADDITIONAL_ARGUMENTS=${ONBOARD_DEBUG_PORT}
411fi
dekstroza83520062018-05-03 16:47:08 +0100412docker 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 +0200413
414echo "please wait while sdc-onboard-BE is starting..."
415monitor_docker sdc-onboard-BE
416}
417
Michael Landoa5445102018-03-04 14:53:33 +0200418
419# Front-End
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200420function sdc-FE {
Michael Lando451a3402017-02-19 10:28:42 +0200421echo "docker run sdc-frontend..."
Idan Amitc7f57ec2017-08-31 14:26:21 +0300422if [ ${LOCAL} = false ]; then
423 docker pull ${PREFIX}/sdc-frontend:${RELEASE}
424fi
dekstroza83520062018-05-03 16:47:08 +0100425docker 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 +0200426
427echo "please wait while FE is starting....."
Yuli Shlosberg5571a862017-10-03 18:18:51 +0300428monitor_docker sdc-FE
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200429}
Michael Lando451a3402017-02-19 10:28:42 +0200430
ml636r0649e652017-02-20 21:10:54 +0200431
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200432# apis-sanity
433function sdc-api-tests {
434healthCheck
435if [[ (${RUN_API_TESTS} = true) && (${healthCheck_http_code} == 200) ]]; then
436 echo "docker run sdc-api-tests..."
437 echo "Triger sdc-api-tests docker, please wait..."
Yuli Shlosberg0875ce02018-01-25 13:53:36 +0200438
Yuli Shlosberg9dde9262017-09-12 14:11:48 +0300439 if [ ${LOCAL} = false ]; then
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200440 docker pull ${PREFIX}/sdc-api-tests:${RELEASE}
Yuli Shlosberg9dde9262017-09-12 14:11:48 +0300441 fi
Yuli Shlosberg316bb252017-11-14 11:47:17 +0200442
dekstroza83520062018-05-03 16:47:08 +0100443docker 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....."
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200444monitor_docker sdc-api-tests
445
446fi
447}
448
449# ui-sanity
450function sdc-ui-tests {
451healthCheck
452if [[ (${RUN_UI_TESTS} = true) && (${healthCheck_http_code} == 200) ]]; then
453 echo "docker run sdc-ui-tets..."
454 echo "Triger sdc-ui-tests docker, please wait..."
455
456 if [ ${LOCAL} = false ]; then
457 docker pull ${PREFIX}/sdc-ui-tests:${RELEASE}
458 fi
459
460sdc-sim
dekstroza83520062018-05-03 16:47:08 +0100461docker 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}
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200462echo "please wait while SDC-UI-TESTS is starting....."
463monitor_docker sdc-ui-tests
464
465fi
466}
467
468
469# SDC-Simulator
470function sdc-sim {
471echo "docker run sdc-webSimulator..."
472if [ ${LOCAL} = false ]; then
Yuli Shlosberg98369b12018-04-10 19:36:24 +0300473 docker pull ${PREFIX}/sdc-simulator:${RELEASE}
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200474fi
475
476probe_sim
477if [ sim_stat=false ]; then
478
dekstroza83520062018-05-03 16:47:08 +0100479docker 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}
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200480echo "please wait while SDC-WEB-SIMULATOR is starting....."
481monitor_docker sdc-sim
Yuli Shlosberg137cf5c2018-01-15 17:32:30 +0200482
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200483fi
484}
485
486if [ -z "${DOCKER}" ]; then
dekstroza83520062018-05-03 16:47:08 +0100487 cleanup all
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200488 dir_perms
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200489 sdc-es
490 sdc-init-es
491 sdc-cs
492 sdc-cs-init
Gitelman, Tal (tg851x)19c9bda2018-03-19 19:07:30 +0200493# sdc-kbn
Avi Zivc175a0d2018-03-15 13:21:44 +0200494 sdc-cs-onboard-init
495 sdc-onboard-BE
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200496 sdc-BE
497 sdc-BE-init
498 sdc-FE
dekstroza83520062018-05-03 16:47:08 +0100499 healthCheck
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200500 sdc-api-tests
dekstroza83520062018-05-03 16:47:08 +0100501 sdc-ui-tests
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200502else
503 cleanup ${DOCKER}
svishnev0b698c42018-03-08 15:50:44 +0200504 dir_perms
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200505 ${DOCKER}
Yuli Shlosberge07a5162018-02-26 10:11:10 +0200506 healthCheck
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200507fi