blob: 61a24348197c5e1a166168a3cd0d50d56710f172 [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"
7BE_JAVA_OPTIONS="-Xdebug -agentlib:jdwp=transport=dt_socket,address=4000,server=y,suspend=n -Xmx2g -Xms2g"
8FE_JAVA_OPTIONS="-Xdebug -agentlib:jdwp=transport=dt_socket,address=6000,server=y,suspend=n -Xmx512m -Xms512m"
9
Michael Lando451a3402017-02-19 10:28:42 +020010
Grinberg Motic3bda482017-02-23 11:24:34 +020011function usage {
Idan Amitdb3d5542017-12-07 11:33:32 +020012 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 +020013}
14
15
Grinberg Motic3bda482017-02-23 11:24:34 +020016function cleanup {
Idan Amitdb3d5542017-12-07 11:33:32 +020017 echo "performing old dockers cleanup"
Yuli Shlosberg958c32d2018-02-15 12:04:46 +020018
19 if [ "$1" == "all" ] ; then
Michael Landoa5445102018-03-04 14:53:33 +020020 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 +020021 for X in ${docker_ids}
22 do
23 docker rm -f ${X}
24 done
25 else
26 echo "performing $1 docker cleanup"
27 tmp=`docker ps -a -q --filter="name=$1"`
Yuli Shlosberg474996a2018-02-27 18:55:25 +020028 if [[ ! -z "$tmp" ]]; then
Yuli Shlosberg958c32d2018-02-15 12:04:46 +020029 docker rm -f ${tmp}
30 fi
31 fi
Grinberg Motic3bda482017-02-23 11:24:34 +020032}
33
34
35function dir_perms {
Yuli Shlosbergd1bb2e52018-01-15 11:51:21 +020036 mkdir -p ${WORKSPACE}/data/logs/BE/SDC/SDC-BE
37 mkdir -p ${WORKSPACE}/data/logs/FE/SDC/SDC-FE
Yuli Shlosbergb4deec12018-02-25 20:24:44 +020038 mkdir -p ${WORKSPACE}/data/logs/sdc-sanity/ExtentReport
39 mkdir -p ${WORKSPACE}/data/logs/sdc-sanity/target
Yuli Shlosberg23cc7f52018-02-28 13:19:42 +020040 mkdir -p ${WORKSPACE}/data/logs/docker_logs
Yuli Shlosbergd1bb2e52018-01-15 11:51:21 +020041 chmod -R 777 ${WORKSPACE}/data/logs
Grinberg Motic3bda482017-02-23 11:24:34 +020042}
Yuli Shlosberg36604c72018-02-25 16:03:45 +020043
Yuli Shlosbergb4deec12018-02-25 20:24:44 +020044function docker_logs {
45
Yuli Shlosberg23cc7f52018-02-28 13:19:42 +020046docker logs $1 > ${WORKSPACE}/data/logs/docker_logs/$1_docker.log
Yuli Shlosbergb4deec12018-02-25 20:24:44 +020047
48}
49
Yuli Shlosberg0875ce02018-01-25 13:53:36 +020050function probe_cs {
Grinberg Motic3bda482017-02-23 11:24:34 +020051
Yuli Shlosberg0875ce02018-01-25 13:53:36 +020052cs_stat=false
Yuli Shlosberg5d0f58e2018-02-26 14:18:08 +020053docker exec $1 /var/lib/ready-probe.sh > /dev/null 2>&1
Yuli Shlosberg0875ce02018-01-25 13:53:36 +020054rc=$?
55if [[ $rc == 0 ]]; then
56 echo DOCKER start finished in $2 seconds
57 cs_stat=true
58fi
59
60}
61
Yuli Shlosberg958c32d2018-02-15 12:04:46 +020062function probe_be {
63
64be_stat=false
Yuli Shlosberg5d0f58e2018-02-26 14:18:08 +020065docker exec $1 /var/lib/ready-probe.sh > /dev/null 2>&1
Yuli Shlosberg958c32d2018-02-15 12:04:46 +020066rc=$?
67if [[ $rc == 200 ]]; then
68 echo DOCKER start finished in $2 seconds
69 be_stat=true
70fi
71
72}
73
74function probe_fe {
75
76fe_stat=false
Yuli Shlosberg5d0f58e2018-02-26 14:18:08 +020077docker exec $1 /var/lib/ready-probe.sh > /dev/null 2>&1
Yuli Shlosberg958c32d2018-02-15 12:04:46 +020078rc=$?
79if [[ $rc == 200 ]]; then
80 echo DOCKER start finished in $2 seconds
81 fe_stat=true
82fi
83
84}
85
86function probe_es {
87
88es_stat=false
Yuli Shlosberg474996a2018-02-27 18:55:25 +020089health_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 +020090if [[ "$health_Check_http_code" -eq 200 ]]
91 then
92 echo DOCKER start finished in $2 seconds
93 es_stat=true
94 fi
95
96}
97
Yuli Shlosberg0875ce02018-01-25 13:53:36 +020098function probe_docker {
99
100match_result=false
101MATCH=`docker logs --tail 30 $1 | grep "DOCKER STARTED"`
102echo MATCH is -- $MATCH
103
104if [ -n "$MATCH" ]; then
105 echo DOCKER start finished in $2 seconds
106 match_result=true
107fi
108}
Michael Landoa5445102018-03-04 14:53:33 +0200109
Yuli Shlosberg5571a862017-10-03 18:18:51 +0300110function monitor_docker {
111
Idan Amitdb3d5542017-12-07 11:33:32 +0200112 echo monitor $1 Docker
113 sleep 5
114 TIME_OUT=900
115 INTERVAL=20
116 TIME=0
117 while [ "$TIME" -lt "$TIME_OUT" ]; do
Yuli Shlosberg0875ce02018-01-25 13:53:36 +0200118 if [ "$1" == "sdc-cs" ]; then
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200119 probe_cs $1 $TIME
120 if [[ $cs_stat == true ]]; then break; fi
121 elif [ "$1" == "sdc-es" ]; then
122 probe_es $1 $TIME
123 if [[ $es_stat == true ]]; then break; fi
124 elif [ "$1" == "sdc-BE" ]; then
125 probe_be $1 $TIME
126 if [[ $be_stat == true ]]; then break; fi
127 elif [ "$1" == "sdc-FE" ]; then
128 probe_fe $1 $TIME
129 if [[ $fe_stat == true ]]; then break; fi
Yuli Shlosberg0875ce02018-01-25 13:53:36 +0200130 else
131 probe_docker $1 $TIME
132 if [[ $match_result == true ]]; then break; fi
Idan Amitdb3d5542017-12-07 11:33:32 +0200133 fi
Idan Amitdb3d5542017-12-07 11:33:32 +0200134 echo Sleep: $INTERVAL seconds before testing if $1 DOCKER is up. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds
135 sleep $INTERVAL
136 TIME=$(($TIME+$INTERVAL))
137 done
Yuli Shlosberg5571a862017-10-03 18:18:51 +0300138
Yuli Shlosbergb4deec12018-02-25 20:24:44 +0200139 docker_logs $1
Yuli Shlosberg36604c72018-02-25 16:03:45 +0200140
Idan Amitdb3d5542017-12-07 11:33:32 +0200141 if [ "$TIME" -ge "$TIME_OUT" ]; then
142 echo -e "\e[1;31mTIME OUT: DOCKER was NOT fully started in $TIME_OUT seconds... Could cause problems ...\e[0m"
143 fi
Yuli Shlosberg5571a862017-10-03 18:18:51 +0300144
145}
146
Yuli Shlosbergd1bb2e52018-01-15 11:51:21 +0200147function healthCheck {
Yuli Shlosberg474996a2018-02-27 18:55:25 +0200148 curl --noproxy "*" ${IP}:9200/_cluster/health?pretty=true
Yuli Shlosbergd1bb2e52018-01-15 11:51:21 +0200149
150 echo "BE health-Check:"
Yuli Shlosberg474996a2018-02-27 18:55:25 +0200151 curl --noproxy "*" http://${IP}:8080/sdc2/rest/healthCheck
Yuli Shlosbergd1bb2e52018-01-15 11:51:21 +0200152
153 echo ""
154 echo ""
155 echo "FE health-Check:"
Yuli Shlosberg474996a2018-02-27 18:55:25 +0200156 curl --noproxy "*" http://${IP}:8181/sdc1/rest/healthCheck
Yuli Shlosbergd1bb2e52018-01-15 11:51:21 +0200157
158
159 echo ""
160 echo ""
Yuli Shlosberg474996a2018-02-27 18:55:25 +0200161 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 +0200162 if [[ ${healthCheck_http_code} != 200 ]]
163 then
164 echo "Error [${healthCheck_http_code}] while user existance check"
165 return ${healthCheck_http_code}
166 fi
167 echo "check user existance: OK"
168 return ${healthCheck_http_code}
169}
170
Grinberg Moti97246212017-02-21 19:30:31 +0200171RELEASE=latest
Idan Amitc7f57ec2017-08-31 14:26:21 +0300172LOCAL=false
Yuli Shlosberg0566f582017-11-26 19:05:23 +0200173RUNTESTS=false
Tal Gitelman8e5fc512017-10-23 13:49:06 +0300174DEBUG_PORT="--publish 4000:4000"
Tal Gitelmane224d0b2017-10-17 15:24:25 +0300175
Idan Amitdb3d5542017-12-07 11:33:32 +0200176while [ $# -gt 0 ]; do
Michael Lando451a3402017-02-19 10:28:42 +0200177 case $1 in
Idan Amitdb3d5542017-12-07 11:33:32 +0200178 # -r | --release - The specific docker version to pull and deploy
Yuli Shlosberg0566f582017-11-26 19:05:23 +0200179 -r | --release )
180 shift 1 ;
181 RELEASE=$1;
182 shift 1;;
Idan Amitdb3d5542017-12-07 11:33:32 +0200183 # -e | --environment - The environment name you want to deploy
Yuli Shlosberg0566f582017-11-26 19:05:23 +0200184 -e | --environment )
185 shift 1;
186 DEP_ENV=$1;
187 shift 1 ;;
Idan Amitdb3d5542017-12-07 11:33:32 +0200188 # -p | --port - The port from which to connect to the docker nexus
Yuli Shlosberg0566f582017-11-26 19:05:23 +0200189 -p | --port )
190 shift 1 ;
191 PORT=$1;
192 shift 1 ;;
Idan Amitdb3d5542017-12-07 11:33:32 +0200193 # -l | --local - Use this for deploying your local dockers without pulling them first
Yuli Shlosberg0566f582017-11-26 19:05:23 +0200194 -l | --local )
195 LOCAL=true;
196 shift 1;;
Idan Amitdb3d5542017-12-07 11:33:32 +0200197 # -t | --runTests - Use this for running the sanity tests docker after all other dockers have been deployed
Yuli Shlosberg0566f582017-11-26 19:05:23 +0200198 -t | --runTests )
199 RUNTESTS=true;
200 shift 1 ;;
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200201 # -d | --docker - The init specified docker
202 -d | --docker )
203 shift 1 ;
204 DOCKER=$1;
205 shift 1 ;;
Idan Amitdb3d5542017-12-07 11:33:32 +0200206 # -h | --help - Display the help message with all the available run options
Yuli Shlosberg0566f582017-11-26 19:05:23 +0200207 -h | --help )
208 usage;
209 exit 0;;
210 * )
211 usage;
212 exit 1;;
Michael Lando451a3402017-02-19 10:28:42 +0200213 esac
Michael Lando451a3402017-02-19 10:28:42 +0200214done
215
Yuli Shlosberg3301bec2017-11-08 15:31:27 +0200216
Yuli Shlosberg0875ce02018-01-25 13:53:36 +0200217[ -f /opt/config/env_name.txt ] && DEP_ENV=$(cat /opt/config/env_name.txt) || echo ${DEP_ENV}
Yuli Shlosberg316bb252017-11-14 11:47:17 +0200218[ -f /opt/config/nexus_username.txt ] && NEXUS_USERNAME=$(cat /opt/config/nexus_username.txt) || NEXUS_USERNAME=release
219[ -f /opt/config/nexus_password.txt ] && NEXUS_PASSWD=$(cat /opt/config/nexus_password.txt) || NEXUS_PASSWD=sfWU3DFVdBr7GVxB85mTYgAW
220[ -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 +0200221[ -f /opt/config/nexus_username.txt ] && docker login -u $NEXUS_USERNAME -p $NEXUS_PASSWD $NEXUS_DOCKER_REPO
222
Yuli Shlosbergd1bb2e52018-01-15 11:51:21 +0200223export IP=`ip route get 8.8.8.8 | awk '/src/{ print $7 }'`
Idan Amitdb3d5542017-12-07 11:33:32 +0200224export PREFIX=${NEXUS_DOCKER_REPO}'/onap'
Idan Amitc7f57ec2017-08-31 14:26:21 +0300225
226if [ ${LOCAL} = true ]; then
Idan Amitdb3d5542017-12-07 11:33:32 +0200227 PREFIX='onap'
Idan Amitc7f57ec2017-08-31 14:26:21 +0300228fi
Michael Lando451a3402017-02-19 10:28:42 +0200229
230echo ""
231
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200232
Michael Landoa5445102018-03-04 14:53:33 +0200233#Elastic-Search
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200234function sdc-es {
Michael Landoa5445102018-03-04 14:53:33 +0200235dir_perms
Michael Lando451a3402017-02-19 10:28:42 +0200236echo "docker run sdc-elasticsearch..."
Idan Amitc7f57ec2017-08-31 14:26:21 +0300237if [ ${LOCAL} = false ]; then
238 echo "pulling code"
239 docker pull ${PREFIX}/sdc-elasticsearch:${RELEASE}
240fi
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200241docker 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 +0200242
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200243echo "please wait while ES is starting..."
244monitor_docker sdc-es
245}
Yuli Shlosberg137cf5c2018-01-15 17:32:30 +0200246
Michael Landoa5445102018-03-04 14:53:33 +0200247
248#Init-Elastic-Search
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200249function sdc-init-es {
Michael Landoa5445102018-03-04 14:53:33 +0200250dir_perms
Tal Gitelman38211c82018-01-24 17:59:53 +0200251echo "docker run sdc-init-elasticsearch..."
252if [ ${LOCAL} = false ]; then
253 echo "pulling code"
254 docker pull ${PREFIX}/sdc-init-elasticsearch:${RELEASE}
255fi
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200256docker 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
257rc=$?
Yuli Shlosbergb4deec12018-02-25 20:24:44 +0200258docker_logs sdc-init-es
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200259if [[ $rc != 0 ]]; then exit $rc; fi
Tal Gitelmanf1927592018-01-29 17:24:56 +0200260
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200261}
Idan Amitc7f57ec2017-08-31 14:26:21 +0300262
Michael Landoa5445102018-03-04 14:53:33 +0200263#Cassandra
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200264function sdc-cs {
Michael Landoa5445102018-03-04 14:53:33 +0200265dir_perms
Idan Amitc7f57ec2017-08-31 14:26:21 +0300266echo "docker run sdc-cassandra..."
267if [ ${LOCAL} = false ]; then
268 docker pull ${PREFIX}/sdc-cassandra:${RELEASE}
269fi
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200270docker 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="2024M" --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 +0200271
Michael Lando451a3402017-02-19 10:28:42 +0200272
273echo "please wait while CS is starting..."
Yuli Shlosberg5571a862017-10-03 18:18:51 +0300274monitor_docker sdc-cs
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200275}
Michael Lando451a3402017-02-19 10:28:42 +0200276
Michael Landoa5445102018-03-04 14:53:33 +0200277#Cassandra-init
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200278function sdc-cs-init {
Yuli Shlosberg0875ce02018-01-25 13:53:36 +0200279echo "docker run sdc-cassandra-init..."
280if [ ${LOCAL} = false ]; then
281 docker pull ${PREFIX}/sdc-cassandra-init:${RELEASE}
282fi
283docker 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
284rc=$?
Yuli Shlosbergb4deec12018-02-25 20:24:44 +0200285docker_logs sdc-cs-init
Yuli Shlosberg0875ce02018-01-25 13:53:36 +0200286if [[ $rc != 0 ]]; then exit $rc; fi
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200287}
Yuli Shlosberg0875ce02018-01-25 13:53:36 +0200288
Michael Landoa5445102018-03-04 14:53:33 +0200289#Kibana
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200290function sdc-kbn {
Michael Landoa5445102018-03-04 14:53:33 +0200291dir_perms
Michael Lando451a3402017-02-19 10:28:42 +0200292echo "docker run sdc-kibana..."
Idan Amitc7f57ec2017-08-31 14:26:21 +0300293if [ ${LOCAL} = false ]; then
294 docker pull ${PREFIX}/sdc-kibana:${RELEASE}
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200295docker run --detach --name sdc-kbn --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 --publish 5601:5601 ${PREFIX}/sdc-kibana:${RELEASE}
Idan Amitc7f57ec2017-08-31 14:26:21 +0300296fi
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200297}
Yuli Shlosberg137cf5c2018-01-15 17:32:30 +0200298
Michael Landoa5445102018-03-04 14:53:33 +0200299#Back-End
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200300function sdc-BE {
Grinberg Motic3bda482017-02-23 11:24:34 +0200301dir_perms
Michael Lando451a3402017-02-19 10:28:42 +0200302echo "docker run sdc-backend..."
Idan Amitc7f57ec2017-08-31 14:26:21 +0300303if [ ${LOCAL} = false ]; then
304 docker pull ${PREFIX}/sdc-backend:${RELEASE}
Tal Gitelmane224d0b2017-10-17 15:24:25 +0300305else
Tal Gitelman8e5fc512017-10-23 13:49:06 +0300306 ADDITIONAL_ARGUMENTS=${DEBUG_PORT}
Idan Amitc7f57ec2017-08-31 14:26:21 +0300307fi
Yuli Shlosbergb4deec12018-02-25 20:24:44 +0200308docker run --detach --name sdc-BE --env HOST_IP=${IP} --env ENVNAME="${DEP_ENV}" --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 +0200309
310echo "please wait while BE is starting..."
Yuli Shlosberg5571a862017-10-03 18:18:51 +0300311monitor_docker sdc-BE
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200312}
Michael Lando451a3402017-02-19 10:28:42 +0200313
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200314# Back-End-Init
Michael Landoa5445102018-03-04 14:53:33 +0200315function sdc-BE-init {
316dir_perms
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200317echo "docker run sdc-backend-init..."
318if [ ${LOCAL} = false ]; then
319 docker pull ${PREFIX}/sdc-backend-init:${RELEASE}
320fi
321docker 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
322rc=$?
Yuli Shlosbergb4deec12018-02-25 20:24:44 +0200323docker_logs sdc-BE-init
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200324if [[ $rc != 0 ]]; then exit $rc; fi
325}
326
Michael Landoa5445102018-03-04 14:53:33 +0200327
328# Front-End
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200329function sdc-FE {
330dir_perms
Michael Lando451a3402017-02-19 10:28:42 +0200331echo "docker run sdc-frontend..."
Idan Amitc7f57ec2017-08-31 14:26:21 +0300332if [ ${LOCAL} = false ]; then
333 docker pull ${PREFIX}/sdc-frontend:${RELEASE}
334fi
Yuli Shlosbergb4deec12018-02-25 20:24:44 +0200335docker 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 +0200336
337echo "please wait while FE is starting....."
Yuli Shlosberg5571a862017-10-03 18:18:51 +0300338monitor_docker sdc-FE
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200339}
Michael Lando451a3402017-02-19 10:28:42 +0200340
ml636r0649e652017-02-20 21:10:54 +0200341
Yuli Shlosberg9dde9262017-09-12 14:11:48 +0300342# sanityDocker
Michael Landoa5445102018-03-04 14:53:33 +0200343function sdc-sanity {
Yuli Shlosbergd1bb2e52018-01-15 11:51:21 +0200344if [[ (${RUNTESTS} = true) && (${healthCheck_http_code} == 200) ]]; then
Idan Amitdb3d5542017-12-07 11:33:32 +0200345 echo "docker run sdc-sanity..."
346 echo "Triger sanity docker, please wait..."
Yuli Shlosberg0875ce02018-01-25 13:53:36 +0200347
Yuli Shlosberg9dde9262017-09-12 14:11:48 +0300348 if [ ${LOCAL} = false ]; then
Idan Amitdb3d5542017-12-07 11:33:32 +0200349 docker pull ${PREFIX}/sdc-sanity:${RELEASE}
Yuli Shlosberg9dde9262017-09-12 14:11:48 +0300350 fi
Yuli Shlosberg316bb252017-11-14 11:47:17 +0200351
Yuli Shlosbergb4deec12018-02-25 20:24:44 +0200352docker run --detach --name sdc-sanity --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/sdc-sanity/target:/var/lib/tests/target --volume ${WORKSPACE}/data/logs/sdc-sanity/ExtentReport:/var/lib/tests/ExtentReport --volume ${WORKSPACE}/data/logs/sdc-sanity/outputCsar:/var/lib/tests/outputCsar --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments --publish 9560:9560 ${PREFIX}/sdc-sanity:${RELEASE}
Yuli Shlosberg137cf5c2018-01-15 17:32:30 +0200353echo "please wait while SANITY is starting....."
Yuli Shlosbergd1bb2e52018-01-15 11:51:21 +0200354monitor_docker sdc-sanity
Yuli Shlosberg137cf5c2018-01-15 17:32:30 +0200355
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200356fi
357}
358
359if [ -z "${DOCKER}" ]; then
360 cleanup all
361 sdc-es
362 sdc-init-es
363 sdc-cs
364 sdc-cs-init
365 sdc-kbn
366 sdc-BE
367 sdc-BE-init
368 sdc-FE
Yuli Shlosberge07a5162018-02-26 10:11:10 +0200369 healthCheck
Yuli Shlosberg523a3d12018-02-25 21:10:07 +0200370 sdc-sanity
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200371else
372 cleanup ${DOCKER}
373 ${DOCKER}
Yuli Shlosberge07a5162018-02-26 10:11:10 +0200374 healthCheck
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200375fi
376