blob: 2c12fffd7dcd678e9945596991a4155a8e48c4ae [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"
Michael Lando451a3402017-02-19 10:28:42 +020013
Grinberg Motic3bda482017-02-23 11:24:34 +020014function usage {
Idan Amitdb3d5542017-12-07 11:33:32 +020015 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 +020016}
17
18
Grinberg Motic3bda482017-02-23 11:24:34 +020019function cleanup {
Idan Amitdb3d5542017-12-07 11:33:32 +020020 echo "performing old dockers cleanup"
Yuli Shlosberg958c32d2018-02-15 12:04:46 +020021
22 if [ "$1" == "all" ] ; then
Michael Landoa5445102018-03-04 14:53:33 +020023 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 +020024 for X in ${docker_ids}
25 do
26 docker rm -f ${X}
27 done
28 else
29 echo "performing $1 docker cleanup"
30 tmp=`docker ps -a -q --filter="name=$1"`
Yuli Shlosberg474996a2018-02-27 18:55:25 +020031 if [[ ! -z "$tmp" ]]; then
Yuli Shlosberg958c32d2018-02-15 12:04:46 +020032 docker rm -f ${tmp}
33 fi
34 fi
Grinberg Motic3bda482017-02-23 11:24:34 +020035}
36
37
38function dir_perms {
Yuli Shlosbergd1bb2e52018-01-15 11:51:21 +020039 mkdir -p ${WORKSPACE}/data/logs/BE/SDC/SDC-BE
40 mkdir -p ${WORKSPACE}/data/logs/FE/SDC/SDC-FE
Yuli Shlosbergf59a2252018-03-21 11:14:08 +020041 mkdir -p ${WORKSPACE}/data/logs/sdc-api-tests/ExtentReport
Avi Zivc175a0d2018-03-15 13:21:44 +020042 mkdir -p ${WORKSPACE}/data/logs/ONBOARD/SDC/ONBOARD-BE
Yuli Shlosbergf59a2252018-03-21 11:14:08 +020043 mkdir -p ${WORKSPACE}/data/logs/sdc-api-tests/target
44 mkdir -p ${WORKSPACE}/data/logs/sdc-ui-tests/ExtentReport
45 mkdir -p ${WORKSPACE}/data/logs/sdc-ui-tests/target
Yuli Shlosberg23cc7f52018-02-28 13:19:42 +020046 mkdir -p ${WORKSPACE}/data/logs/docker_logs
Yuli Shlosberge2eef602018-04-10 23:05:13 +030047 mkdir -p ${WORKSPACE}/data/logs/WS
Yuli Shlosbergd1bb2e52018-01-15 11:51:21 +020048 chmod -R 777 ${WORKSPACE}/data/logs
Grinberg Motic3bda482017-02-23 11:24:34 +020049}
Yuli Shlosberg36604c72018-02-25 16:03:45 +020050
Yuli Shlosbergb4deec12018-02-25 20:24:44 +020051function docker_logs {
52
Yuli Shlosberg23cc7f52018-02-28 13:19:42 +020053docker logs $1 > ${WORKSPACE}/data/logs/docker_logs/$1_docker.log
Yuli Shlosbergb4deec12018-02-25 20:24:44 +020054
55}
56
Yuli Shlosberg0875ce02018-01-25 13:53:36 +020057function probe_cs {
Grinberg Motic3bda482017-02-23 11:24:34 +020058
Yuli Shlosberg0875ce02018-01-25 13:53:36 +020059cs_stat=false
Yuli Shlosberg5d0f58e2018-02-26 14:18:08 +020060docker exec $1 /var/lib/ready-probe.sh > /dev/null 2>&1
Yuli Shlosberg0875ce02018-01-25 13:53:36 +020061rc=$?
62if [[ $rc == 0 ]]; then
63 echo DOCKER start finished in $2 seconds
64 cs_stat=true
65fi
66
67}
68
Yuli Shlosberg958c32d2018-02-15 12:04:46 +020069function probe_be {
70
71be_stat=false
Yuli Shlosberg5d0f58e2018-02-26 14:18:08 +020072docker exec $1 /var/lib/ready-probe.sh > /dev/null 2>&1
Yuli Shlosberg958c32d2018-02-15 12:04:46 +020073rc=$?
Avi Zivc175a0d2018-03-15 13:21:44 +020074if [[ $rc == 0 ]]; then
Yuli Shlosberg958c32d2018-02-15 12:04:46 +020075 echo DOCKER start finished in $2 seconds
76 be_stat=true
77fi
78
79}
80
Avi Zivc175a0d2018-03-15 13:21:44 +020081function probe_sdc_onboard_be {
82
83sdc_onboard_be_stat=false
84docker exec $1 /var/lib/ready-probe.sh > /dev/null 2>&1
85rc=$?
86if [[ $rc == 0 ]]; then
87 echo DOCKER start finished in $2 seconds
88 sdc_onboard_be_stat=true
89fi
90
91}
92
Yuli Shlosberg958c32d2018-02-15 12:04:46 +020093function probe_fe {
94
95fe_stat=false
Yuli Shlosberg5d0f58e2018-02-26 14:18:08 +020096docker exec $1 /var/lib/ready-probe.sh > /dev/null 2>&1
Yuli Shlosberg958c32d2018-02-15 12:04:46 +020097rc=$?
Avi Zivc175a0d2018-03-15 13:21:44 +020098if [[ $rc == 0 ]]; then
Yuli Shlosberg958c32d2018-02-15 12:04:46 +020099 echo DOCKER start finished in $2 seconds
100 fe_stat=true
101fi
102
103}
104
105function probe_es {
106
107es_stat=false
Yuli Shlosberg474996a2018-02-27 18:55:25 +0200108health_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 +0200109if [[ "$health_Check_http_code" -eq 200 ]]
110 then
111 echo DOCKER start finished in $2 seconds
112 es_stat=true
113 fi
114
115}
116
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200117function probe_sim {
118
119if lsof -Pi :8285 -sTCP:LISTEN -t >/dev/null ; then
120 echo "running"
121 sim_stat=true
122else
123 echo "not running"
124 sim_stat=false
125fi
126
127
128}
129
Yuli Shlosberg0875ce02018-01-25 13:53:36 +0200130function probe_docker {
131
132match_result=false
133MATCH=`docker logs --tail 30 $1 | grep "DOCKER STARTED"`
134echo MATCH is -- $MATCH
135
136if [ -n "$MATCH" ]; then
137 echo DOCKER start finished in $2 seconds
138 match_result=true
139fi
140}
Yuli Shlosberg5571a862017-10-03 18:18:51 +0300141function monitor_docker {
142
Idan Amitdb3d5542017-12-07 11:33:32 +0200143 echo monitor $1 Docker
144 sleep 5
145 TIME_OUT=900
146 INTERVAL=20
147 TIME=0
148 while [ "$TIME" -lt "$TIME_OUT" ]; do
Yuli Shlosberg0875ce02018-01-25 13:53:36 +0200149 if [ "$1" == "sdc-cs" ]; then
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200150 probe_cs $1 $TIME
151 if [[ $cs_stat == true ]]; then break; fi
152 elif [ "$1" == "sdc-es" ]; then
153 probe_es $1 $TIME
154 if [[ $es_stat == true ]]; then break; fi
155 elif [ "$1" == "sdc-BE" ]; then
156 probe_be $1 $TIME
157 if [[ $be_stat == true ]]; then break; fi
158 elif [ "$1" == "sdc-FE" ]; then
159 probe_fe $1 $TIME
160 if [[ $fe_stat == true ]]; then break; fi
Avi Zivc175a0d2018-03-15 13:21:44 +0200161 elif [ "$1" == "sdc-onboard-BE" ]; then
162 probe_sdc_onboard_be $1 $TIME
163 if [[ $sdc_onboard_be_stat == true ]]; then break; fi
164
Yuli Shlosberg0875ce02018-01-25 13:53:36 +0200165 else
166 probe_docker $1 $TIME
167 if [[ $match_result == true ]]; then break; fi
Idan Amitdb3d5542017-12-07 11:33:32 +0200168 fi
Idan Amitdb3d5542017-12-07 11:33:32 +0200169 echo Sleep: $INTERVAL seconds before testing if $1 DOCKER is up. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds
170 sleep $INTERVAL
171 TIME=$(($TIME+$INTERVAL))
172 done
Yuli Shlosberg5571a862017-10-03 18:18:51 +0300173
Yuli Shlosbergb4deec12018-02-25 20:24:44 +0200174 docker_logs $1
Yuli Shlosberg36604c72018-02-25 16:03:45 +0200175
Idan Amitdb3d5542017-12-07 11:33:32 +0200176 if [ "$TIME" -ge "$TIME_OUT" ]; then
177 echo -e "\e[1;31mTIME OUT: DOCKER was NOT fully started in $TIME_OUT seconds... Could cause problems ...\e[0m"
178 fi
Yuli Shlosberg5571a862017-10-03 18:18:51 +0300179
180}
181
Yuli Shlosbergd1bb2e52018-01-15 11:51:21 +0200182function healthCheck {
Yuli Shlosberg474996a2018-02-27 18:55:25 +0200183 curl --noproxy "*" ${IP}:9200/_cluster/health?pretty=true
Yuli Shlosbergd1bb2e52018-01-15 11:51:21 +0200184
185 echo "BE health-Check:"
Yuli Shlosberg474996a2018-02-27 18:55:25 +0200186 curl --noproxy "*" http://${IP}:8080/sdc2/rest/healthCheck
Yuli Shlosbergd1bb2e52018-01-15 11:51:21 +0200187
188 echo ""
189 echo ""
190 echo "FE health-Check:"
Yuli Shlosberg474996a2018-02-27 18:55:25 +0200191 curl --noproxy "*" http://${IP}:8181/sdc1/rest/healthCheck
Yuli Shlosbergd1bb2e52018-01-15 11:51:21 +0200192
193
194 echo ""
195 echo ""
Yuli Shlosberg474996a2018-02-27 18:55:25 +0200196 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 +0200197 if [[ ${healthCheck_http_code} != 200 ]]
198 then
199 echo "Error [${healthCheck_http_code}] while user existance check"
200 return ${healthCheck_http_code}
201 fi
202 echo "check user existance: OK"
203 return ${healthCheck_http_code}
204}
205
Grinberg Moti97246212017-02-21 19:30:31 +0200206RELEASE=latest
Idan Amitc7f57ec2017-08-31 14:26:21 +0300207LOCAL=false
Yuli Shlosberg0566f582017-11-26 19:05:23 +0200208RUNTESTS=false
Tal Gitelman8e5fc512017-10-23 13:49:06 +0300209DEBUG_PORT="--publish 4000:4000"
Avi Zivc175a0d2018-03-15 13:21:44 +0200210ONBOARD_DEBUG_PORT="--publish 4001:4000"
Tal Gitelmane224d0b2017-10-17 15:24:25 +0300211
Idan Amitdb3d5542017-12-07 11:33:32 +0200212while [ $# -gt 0 ]; do
Michael Lando451a3402017-02-19 10:28:42 +0200213 case $1 in
Idan Amitdb3d5542017-12-07 11:33:32 +0200214 # -r | --release - The specific docker version to pull and deploy
Yuli Shlosberg0566f582017-11-26 19:05:23 +0200215 -r | --release )
216 shift 1 ;
217 RELEASE=$1;
218 shift 1;;
Idan Amitdb3d5542017-12-07 11:33:32 +0200219 # -e | --environment - The environment name you want to deploy
Yuli Shlosberg0566f582017-11-26 19:05:23 +0200220 -e | --environment )
221 shift 1;
222 DEP_ENV=$1;
223 shift 1 ;;
Idan Amitdb3d5542017-12-07 11:33:32 +0200224 # -p | --port - The port from which to connect to the docker nexus
Yuli Shlosberg0566f582017-11-26 19:05:23 +0200225 -p | --port )
226 shift 1 ;
227 PORT=$1;
228 shift 1 ;;
Idan Amitdb3d5542017-12-07 11:33:32 +0200229 # -l | --local - Use this for deploying your local dockers without pulling them first
Yuli Shlosberg0566f582017-11-26 19:05:23 +0200230 -l | --local )
231 LOCAL=true;
232 shift 1;;
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200233 # -ta - Use this for running the APIs sanity docker after all other dockers have been deployed
234 -ta )
235 shift 1 ;
236 API_SUITE=$1;
237 RUN_API_TESTS=true;
238 shift 1 ;;
239 # -tu - Use this for running the UI sanity docker after all other dockers have been deployed
240 -tu )
241 shift 1 ;
242 UI_SUITE=$1;
243 RUN_UI_TESTS=true;
244 shift 1 ;;
245 # -tad - Use this for running the DEFAULT suite of tests in APIs sanity docker after all other dockers have been deployed
246 -tad | -t )
247 API_SUITE="onapApiSanity";
248 RUN_API_TESTS=true;
249 shift 1 ;;
250 # -tud - Use this for running the DEFAULT suite of tests in UI sanity docker after all other dockers have been deployed
251 -tud )
252 UI_SUITE="onapUiSanity";
253 RUN_UI_TESTS=true;
Yuli Shlosberg0566f582017-11-26 19:05:23 +0200254 shift 1 ;;
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200255 # -d | --docker - The init specified docker
256 -d | --docker )
257 shift 1 ;
258 DOCKER=$1;
259 shift 1 ;;
Idan Amitdb3d5542017-12-07 11:33:32 +0200260 # -h | --help - Display the help message with all the available run options
Yuli Shlosberg0566f582017-11-26 19:05:23 +0200261 -h | --help )
262 usage;
263 exit 0;;
264 * )
265 usage;
266 exit 1;;
Michael Lando451a3402017-02-19 10:28:42 +0200267 esac
Michael Lando451a3402017-02-19 10:28:42 +0200268done
269
Yuli Shlosberg3301bec2017-11-08 15:31:27 +0200270
Yuli Shlosberg0875ce02018-01-25 13:53:36 +0200271[ -f /opt/config/env_name.txt ] && DEP_ENV=$(cat /opt/config/env_name.txt) || echo ${DEP_ENV}
Yuli Shlosberg316bb252017-11-14 11:47:17 +0200272[ -f /opt/config/nexus_username.txt ] && NEXUS_USERNAME=$(cat /opt/config/nexus_username.txt) || NEXUS_USERNAME=release
273[ -f /opt/config/nexus_password.txt ] && NEXUS_PASSWD=$(cat /opt/config/nexus_password.txt) || NEXUS_PASSWD=sfWU3DFVdBr7GVxB85mTYgAW
274[ -f /opt/config/nexus_docker_repo.txt ] && NEXUS_DOCKER_REPO=$(cat /opt/config/nexus_docker_repo.txt) || NEXUS_DOCKER_REPO=nexus3.onap.org:${PORT}
Michael Lando451a3402017-02-19 10:28:42 +0200275[ -f /opt/config/nexus_username.txt ] && docker login -u $NEXUS_USERNAME -p $NEXUS_PASSWD $NEXUS_DOCKER_REPO
276
Yuli Shlosbergd1bb2e52018-01-15 11:51:21 +0200277export IP=`ip route get 8.8.8.8 | awk '/src/{ print $7 }'`
Idan Amitdb3d5542017-12-07 11:33:32 +0200278export PREFIX=${NEXUS_DOCKER_REPO}'/onap'
Idan Amitc7f57ec2017-08-31 14:26:21 +0300279
280if [ ${LOCAL} = true ]; then
Idan Amitdb3d5542017-12-07 11:33:32 +0200281 PREFIX='onap'
Idan Amitc7f57ec2017-08-31 14:26:21 +0300282fi
Michael Lando451a3402017-02-19 10:28:42 +0200283
284echo ""
285
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200286
Michael Landoa5445102018-03-04 14:53:33 +0200287#Elastic-Search
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200288function sdc-es {
Michael Lando451a3402017-02-19 10:28:42 +0200289echo "docker run sdc-elasticsearch..."
Idan Amitc7f57ec2017-08-31 14:26:21 +0300290if [ ${LOCAL} = false ]; then
291 echo "pulling code"
292 docker pull ${PREFIX}/sdc-elasticsearch:${RELEASE}
293fi
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200294docker 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 --volume /etc/localtime:/etc/localtime:ro --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 +0200295
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200296echo "please wait while ES is starting..."
297monitor_docker sdc-es
298}
Yuli Shlosberg137cf5c2018-01-15 17:32:30 +0200299
Michael Landoa5445102018-03-04 14:53:33 +0200300
301#Init-Elastic-Search
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200302function sdc-init-es {
Tal Gitelman38211c82018-01-24 17:59:53 +0200303echo "docker run sdc-init-elasticsearch..."
304if [ ${LOCAL} = false ]; then
305 echo "pulling code"
306 docker pull ${PREFIX}/sdc-init-elasticsearch:${RELEASE}
307fi
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200308echo "Running sdc-init-es"
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200309docker 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 --volume /etc/localtime:/etc/localtime:ro --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments ${PREFIX}/sdc-init-elasticsearch:${RELEASE} > /dev/null 2>&1
310rc=$?
Yuli Shlosbergb4deec12018-02-25 20:24:44 +0200311docker_logs sdc-init-es
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200312if [[ $rc != 0 ]]; then exit $rc; fi
Tal Gitelmanf1927592018-01-29 17:24:56 +0200313
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200314}
Idan Amitc7f57ec2017-08-31 14:26:21 +0300315
Michael Landoa5445102018-03-04 14:53:33 +0200316#Cassandra
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200317function sdc-cs {
Idan Amitc7f57ec2017-08-31 14:26:21 +0300318echo "docker run sdc-cassandra..."
319if [ ${LOCAL} = false ]; then
320 docker pull ${PREFIX}/sdc-cassandra:${RELEASE}
321fi
Gitelman, Tal (tg851x)328388b2018-03-22 13:03:44 +0200322docker 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 --volume /etc/localtime:/etc/localtime:ro --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 +0200323
Michael Lando451a3402017-02-19 10:28:42 +0200324
325echo "please wait while CS is starting..."
Yuli Shlosberg5571a862017-10-03 18:18:51 +0300326monitor_docker sdc-cs
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200327}
Michael Lando451a3402017-02-19 10:28:42 +0200328
Michael Landoa5445102018-03-04 14:53:33 +0200329#Cassandra-init
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200330function sdc-cs-init {
Yuli Shlosberg0875ce02018-01-25 13:53:36 +0200331echo "docker run sdc-cassandra-init..."
332if [ ${LOCAL} = false ]; then
333 docker pull ${PREFIX}/sdc-cassandra-init:${RELEASE}
334fi
335docker 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 --volume /etc/localtime:/etc/localtime:ro --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
336rc=$?
Yuli Shlosbergb4deec12018-02-25 20:24:44 +0200337docker_logs sdc-cs-init
Yuli Shlosberg0875ce02018-01-25 13:53:36 +0200338if [[ $rc != 0 ]]; then exit $rc; fi
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200339}
Yuli Shlosberg0875ce02018-01-25 13:53:36 +0200340
Avi Zivc175a0d2018-03-15 13:21:44 +0200341#Onboard Cassandra-init
342function sdc-cs-onboard-init {
343echo "docker run sdc-cs-onboard-init..."
344if [ ${LOCAL} = false ]; then
345 docker pull ${PREFIX}/sdc-onboard-cassandra-init:${RELEASE}
346fi
347docker 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 --volume /etc/localtime:/etc/localtime:ro --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}
348rc=$?
349docker_logs sdc-onboard-cs-init
350if [[ $rc != 0 ]]; then exit $rc; fi
351}
352
Michael Landoa5445102018-03-04 14:53:33 +0200353#Kibana
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200354function sdc-kbn {
Michael Lando451a3402017-02-19 10:28:42 +0200355echo "docker run sdc-kibana..."
Idan Amitc7f57ec2017-08-31 14:26:21 +0300356if [ ${LOCAL} = false ]; then
357 docker pull ${PREFIX}/sdc-kibana:${RELEASE}
Gitelman, Tal (tg851x)6a1b82a2018-03-21 17:42:47 +0200358docker 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 --volume /etc/localtime:/etc/localtime:ro --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments --publish 5601:5601 ${PREFIX}/sdc-kibana:${RELEASE}
Idan Amitc7f57ec2017-08-31 14:26:21 +0300359fi
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200360
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200361}
Yuli Shlosberg137cf5c2018-01-15 17:32:30 +0200362
Michael Landoa5445102018-03-04 14:53:33 +0200363#Back-End
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200364function sdc-BE {
Michael Lando451a3402017-02-19 10:28:42 +0200365echo "docker run sdc-backend..."
Idan Amitc7f57ec2017-08-31 14:26:21 +0300366if [ ${LOCAL} = false ]; then
367 docker pull ${PREFIX}/sdc-backend:${RELEASE}
Tal Gitelmane224d0b2017-10-17 15:24:25 +0300368else
Tal Gitelman8e5fc512017-10-23 13:49:06 +0300369 ADDITIONAL_ARGUMENTS=${DEBUG_PORT}
Idan Amitc7f57ec2017-08-31 14:26:21 +0300370fi
Areli, Fuss (af732p)9d525f52018-04-09 18:15:42 +0300371docker 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 --volume /etc/localtime:/etc/localtime:ro --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 +0200372
373echo "please wait while BE is starting..."
Yuli Shlosberg5571a862017-10-03 18:18:51 +0300374monitor_docker sdc-BE
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200375}
Michael Lando451a3402017-02-19 10:28:42 +0200376
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200377# Back-End-Init
Michael Landoa5445102018-03-04 14:53:33 +0200378function sdc-BE-init {
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200379echo "docker run sdc-backend-init..."
380if [ ${LOCAL} = false ]; then
381 docker pull ${PREFIX}/sdc-backend-init:${RELEASE}
382fi
383docker 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 --volume /etc/localtime:/etc/localtime:ro --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
384rc=$?
Yuli Shlosbergb4deec12018-02-25 20:24:44 +0200385docker_logs sdc-BE-init
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200386if [[ $rc != 0 ]]; then exit $rc; fi
387}
388
Avi Zivc175a0d2018-03-15 13:21:44 +0200389# Onboard Back-End
390function sdc-onboard-BE {
391
392dir_perms
393# Back-End
394echo "docker run sdc-onboard-BE ..."
395if [ ${LOCAL} = false ]; then
396 docker pull ${PREFIX}/sdc-onboard-backend:${RELEASE}
397else
398 ADDITIONAL_ARGUMENTS=${ONBOARD_DEBUG_PORT}
399fi
400docker 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 --volume /etc/localtime:/etc/localtime:ro --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}
401
402echo "please wait while sdc-onboard-BE is starting..."
403monitor_docker sdc-onboard-BE
404}
405
Michael Landoa5445102018-03-04 14:53:33 +0200406
407# Front-End
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200408function sdc-FE {
Michael Lando451a3402017-02-19 10:28:42 +0200409echo "docker run sdc-frontend..."
Idan Amitc7f57ec2017-08-31 14:26:21 +0300410if [ ${LOCAL} = false ]; then
411 docker pull ${PREFIX}/sdc-frontend:${RELEASE}
412fi
Yuli Shlosbergb4deec12018-02-25 20:24:44 +0200413docker 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 --volume /etc/localtime:/etc/localtime:ro --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 +0200414
415echo "please wait while FE is starting....."
Yuli Shlosberg5571a862017-10-03 18:18:51 +0300416monitor_docker sdc-FE
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200417}
Michael Lando451a3402017-02-19 10:28:42 +0200418
ml636r0649e652017-02-20 21:10:54 +0200419
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200420# apis-sanity
421function sdc-api-tests {
422healthCheck
423if [[ (${RUN_API_TESTS} = true) && (${healthCheck_http_code} == 200) ]]; then
424 echo "docker run sdc-api-tests..."
425 echo "Triger sdc-api-tests docker, please wait..."
Yuli Shlosberg0875ce02018-01-25 13:53:36 +0200426
Yuli Shlosberg9dde9262017-09-12 14:11:48 +0300427 if [ ${LOCAL} = false ]; then
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200428 docker pull ${PREFIX}/sdc-api-tests:${RELEASE}
Yuli Shlosberg9dde9262017-09-12 14:11:48 +0300429 fi
Yuli Shlosberg316bb252017-11-14 11:47:17 +0200430
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200431docker 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 --volume /etc/localtime:/etc/localtime:ro --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....."
432monitor_docker sdc-api-tests
433
434fi
435}
436
437# ui-sanity
438function sdc-ui-tests {
439healthCheck
440if [[ (${RUN_UI_TESTS} = true) && (${healthCheck_http_code} == 200) ]]; then
441 echo "docker run sdc-ui-tets..."
442 echo "Triger sdc-ui-tests docker, please wait..."
443
444 if [ ${LOCAL} = false ]; then
445 docker pull ${PREFIX}/sdc-ui-tests:${RELEASE}
446 fi
447
448sdc-sim
449docker 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 --volume /etc/localtime:/etc/localtime:ro --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}
450echo "please wait while SDC-UI-TESTS is starting....."
451monitor_docker sdc-ui-tests
452
453fi
454}
455
456
457# SDC-Simulator
458function sdc-sim {
459echo "docker run sdc-webSimulator..."
460if [ ${LOCAL} = false ]; then
Yuli Shlosberg98369b12018-04-10 19:36:24 +0300461 docker pull ${PREFIX}/sdc-simulator:${RELEASE}
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200462fi
463
464probe_sim
465if [ sim_stat=false ]; then
466
Yuli Shlosberge2eef602018-04-10 23:05:13 +0300467docker run --detach --name sdc-sim --env JAVA_OPTIONS="${SIM_JAVA_OPTIONS}" --env ENVNAME="${DEP_ENV}" --volume /etc/localtime:/etc/localtime:ro --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 +0200468echo "please wait while SDC-WEB-SIMULATOR is starting....."
469monitor_docker sdc-sim
Yuli Shlosberg137cf5c2018-01-15 17:32:30 +0200470
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200471fi
472}
473
474if [ -z "${DOCKER}" ]; then
475 cleanup all
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200476 dir_perms
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200477 sdc-es
478 sdc-init-es
479 sdc-cs
480 sdc-cs-init
Gitelman, Tal (tg851x)19c9bda2018-03-19 19:07:30 +0200481# sdc-kbn
Avi Zivc175a0d2018-03-15 13:21:44 +0200482 sdc-cs-onboard-init
483 sdc-onboard-BE
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200484 sdc-BE
485 sdc-BE-init
486 sdc-FE
Yuli Shlosberge07a5162018-02-26 10:11:10 +0200487 healthCheck
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200488 sdc-api-tests
489 sdc-ui-tests
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200490else
491 cleanup ${DOCKER}
svishnev0b698c42018-03-08 15:50:44 +0200492 dir_perms
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200493 ${DOCKER}
Yuli Shlosberge07a5162018-02-26 10:11:10 +0200494 healthCheck
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200495fi