blob: a5688579f21437c54a7bc50338eec554cd11a84e [file] [log] [blame]
Michael Lando451a3402017-02-19 10:28:42 +02001#!/bin/bash
2
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +03003#
4# Constants:
5#
6
7WORKSPACE="${WORKSPACE:-}"
8SUCCESS=0
9FAILURE=1
10
Yuli Shlosberg0875ce02018-01-25 13:53:36 +020011CS_PASSWORD="onap123#@!"
12SDC_USER="asdc_user"
13SDC_PASSWORD="Aa1234%^!"
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +030014
Yuli Shlosberg958c32d2018-02-15 12:04:46 +020015JETTY_BASE="/var/lib/jetty"
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +030016
17RELEASE=latest
18LOCAL=false
19RUNTESTS=false
20DEBUG_PORT="--publish 4000:4000"
21ONBOARD_DEBUG_PORT="--publish 4001:4000"
22
23
24# Java Options:
Gitelman, Tal (tg851x)328388b2018-03-22 13:03:44 +020025BE_JAVA_OPTIONS="-Xdebug -agentlib:jdwp=transport=dt_socket,address=4000,server=y,suspend=n -Xmx1536m -Xms1536m"
26FE_JAVA_OPTIONS="-Xdebug -agentlib:jdwp=transport=dt_socket,address=6000,server=y,suspend=n -Xmx256m -Xms256m"
Avi Zivc175a0d2018-03-15 13:21:44 +020027ONBOARD_BE_JAVA_OPTIONS="-Xdebug -agentlib:jdwp=transport=dt_socket,address=4001,server=y,suspend=n -Xmx1g -Xms1g"
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +030028DCAE_BE_JAVA_OPTIONS="-XX:MaxPermSize=256m -Xmx1024m -Dconfig.home=config -Dlog.home=/var/lib/jetty/logs/ -Dlogging.config=config/dcae-be/logback-spring.xml"
29DCAE_FE_JAVA_OPTIONS="-XX:MaxPermSize=256m -Xmx1024m -Dconfig.home=config -Dlog.home=/var/lib/jetty/logs/ -Dlogging.config=config/dcae-fe/logback-spring.xml"
Yuli Shlosbergf59a2252018-03-21 11:14:08 +020030SIM_JAVA_OPTIONS=" -Xmx128m -Xms128m -Xss1m"
31API_TESTS_JAVA_OPTIONS="-Xmx512m -Xms512m"
32UI_TESTS_JAVA_OPTIONS="-Xmx1024m -Xms1024m"
dekstroza83520062018-05-03 16:47:08 +010033#Define this as variable, so it can be excluded in run commands on Docker for OSX, as /etc/localtime cant be mounted there.
34LOCAL_TIME_MOUNT_CMD="--volume /etc/localtime:/etc/localtime:ro"
35# If os is OSX, unset this, so /etc/localtime is not mounted, otherwise leave it be
36if [[ "$OSTYPE" == "darwin"* ]]; then
37 LOCAL_TIME_MOUNT_CMD=""
38fi
39
40
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +030041#
42# Functions:
43#
44
Michael Lando451a3402017-02-19 10:28:42 +020045
Grinberg Motic3bda482017-02-23 11:24:34 +020046function usage {
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +030047 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>] [ -dcae|--dcae <Run-with-DCAE>][ -h|--help ]"
48 echo "example: sudo bash docker_run.sh -e AUTO -r 1.2-STAGING-latest -dcae"
Michael Lando451a3402017-02-19 10:28:42 +020049}
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +030050#
Michael Lando451a3402017-02-19 10:28:42 +020051
52
Grinberg Motic3bda482017-02-23 11:24:34 +020053function cleanup {
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +030054 echo "Performing old dockers cleanup"
Yuli Shlosberg958c32d2018-02-15 12:04:46 +020055
56 if [ "$1" == "all" ] ; then
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +030057 docker_ids=`docker ps -a | egrep -v "onap/sdc-simulator" | egrep "ecomp-nexus:${PORT}/sdc|sdc|Exit}|dcae" | awk '{print $1}'`
Yuli Shlosberg958c32d2018-02-15 12:04:46 +020058 for X in ${docker_ids}
59 do
60 docker rm -f ${X}
61 done
62 else
63 echo "performing $1 docker cleanup"
64 tmp=`docker ps -a -q --filter="name=$1"`
Yuli Shlosberg474996a2018-02-27 18:55:25 +020065 if [[ ! -z "$tmp" ]]; then
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +030066 docker rm -f ${tmp}
67 fi
Yuli Shlosberg958c32d2018-02-15 12:04:46 +020068 fi
Grinberg Motic3bda482017-02-23 11:24:34 +020069}
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +030070#
Grinberg Motic3bda482017-02-23 11:24:34 +020071
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +030072
Grinberg Motic3bda482017-02-23 11:24:34 +020073function dir_perms {
Michael Lando4b9b9472018-06-02 19:14:05 +030074 mkdir -p ${WORKSPACE}/data/logs/BE/SDC/SDC-BE
75 mkdir -p ${WORKSPACE}/data/logs/FE/SDC/SDC-FE
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +030076
77 mkdir -p ${WORKSPACE}/data/logs/DCAE-BE/DCAE
78 mkdir -p ${WORKSPACE}/data/logs/DCAE-FE/DCAE
79
Michael Lando4b9b9472018-06-02 19:14:05 +030080 mkdir -p ${WORKSPACE}/data/logs/sdc-api-tests/ExtentReport
81 mkdir -p ${WORKSPACE}/data/logs/ONBOARD/SDC/ONBOARD-BE
Yuli Shlosbergf59a2252018-03-21 11:14:08 +020082 mkdir -p ${WORKSPACE}/data/logs/sdc-api-tests/target
83 mkdir -p ${WORKSPACE}/data/logs/sdc-ui-tests/ExtentReport
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +030084 mkdir -p ${WORKSPACE}/data/logs/sdc-ui-tests/target
85 mkdir -p ${WORKSPACE}/data/logs/docker_logs
86 mkdir -p ${WORKSPACE}/data/logs/WS
Michael Lando4b9b9472018-06-02 19:14:05 +030087 chmod -R 777 ${WORKSPACE}/data/logs
Grinberg Motic3bda482017-02-23 11:24:34 +020088}
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +030089#
90
Yuli Shlosberg36604c72018-02-25 16:03:45 +020091
Yuli Shlosbergb4deec12018-02-25 20:24:44 +020092function docker_logs {
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +030093 docker logs $1 > ${WORKSPACE}/data/logs/docker_logs/$1_docker.log
Yuli Shlosbergb4deec12018-02-25 20:24:44 +020094}
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +030095#
Yuli Shlosbergb4deec12018-02-25 20:24:44 +020096
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +030097
98#
99# Readiness Prob
100#
101
102function ready_probe {
Michael Lando4b9b9472018-06-02 19:14:05 +0300103 docker exec $1 /var/lib/ready-probe.sh > /dev/null 2>&1
104 rc=$?
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300105 if [[ ${rc} == 0 ]]; then
106 echo DOCKER $1 start finished in $2 seconds
107 return ${SUCCESS}
Michael Lando4b9b9472018-06-02 19:14:05 +0300108 fi
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300109 return ${FAILURE}
Yuli Shlosberg0875ce02018-01-25 13:53:36 +0200110}
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300111#
Yuli Shlosberg0875ce02018-01-25 13:53:36 +0200112
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200113
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300114function probe_docker {
115 MATCH=`docker logs --tail 30 $1 | grep "DOCKER STARTED"`
116 echo MATCH is -- ${MATCH}
Avi Zivc175a0d2018-03-15 13:21:44 +0200117
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300118 if [ -n "$MATCH" ] ; then
119 echo DOCKER start finished in $2 seconds
120 return ${SUCCESS}
Michael Lando4b9b9472018-06-02 19:14:05 +0300121 fi
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300122 return ${FAILURE}
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200123}
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300124#
125
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200126
127function probe_es {
Michael Lando4b9b9472018-06-02 19:14:05 +0300128 health_Check_http_code=$(curl --noproxy "*" -o /dev/null -w '%{http_code}' http://${IP}:9200/_cluster/health?wait_for_status=yellow&timeout=120s)
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300129 if [[ "$health_Check_http_code" -eq 200 ]] ; then
130 echo DOCKER start finished in $1 seconds
131 return ${SUCCESS}
132 fi
133 return ${FAILURE}
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200134}
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300135#
136
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200137
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200138function probe_sim {
Michael Lando4b9b9472018-06-02 19:14:05 +0300139 if lsof -Pi :8285 -sTCP:LISTEN -t >/dev/null ; then
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300140 echo "Already running"
141 return ${SUCCESS}
Michael Lando4b9b9472018-06-02 19:14:05 +0300142 else
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300143 echo "Not running"
144 return ${FAILURE}
Michael Lando4b9b9472018-06-02 19:14:05 +0300145 fi
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200146}
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300147#
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200148
Yuli Shlosberg0875ce02018-01-25 13:53:36 +0200149
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300150function probe_dcae_be {
151 health_check_http_code=$(curl -i -o /dev/null -w '%{http_code}' http://${IP}:8082/dcae/conf/composition)
152 if [[ "${health_check_http_code}" -eq 200 ]] ; then
153 echo DOCKER start finished in $1 seconds
154 return ${SUCCESS}
Michael Lando4b9b9472018-06-02 19:14:05 +0300155 fi
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300156 return ${FAILURE}
Yuli Shlosberg0875ce02018-01-25 13:53:36 +0200157}
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300158#
159
160function probe_dcae_fe {
161 health_check_http_code=$(curl -i -o /dev/null -w '%{http_code}' http://${IP}:8183/dcaed/healthCheck)
162 if [[ "${health_check_http_code}" -eq 200 ]] ; then
163 echo DOCKER start finished in $1 seconds
164 return ${SUCCESS}
165 fi
166 return ${FAILURE}
167}
168#
169
170
171# Not applicable for current release. Return Success in any case
172function probe_dcae_tools {
173 health_check_http_code=$(curl -i -o /dev/null -w '%{http_code}' http://${IP}:8082/dcae/getResourcesByMonitoringTemplateCategory)
174 if [[ "${health_check_http_code}" -eq 200 ]] ; then
175 echo DOCKER start finished in $1 seconds
176 return ${SUCCESS}
177 fi
178 return ${SUCCESS}
179}
180#
181
182
Yuli Shlosberg5571a862017-10-03 18:18:51 +0300183function monitor_docker {
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300184 DOCKER_NAME=$1
185 echo "Monitor ${DOCKER_NAME} Docker"
Idan Amitdb3d5542017-12-07 11:33:32 +0200186 sleep 5
187 TIME_OUT=900
188 INTERVAL=20
189 TIME=0
Avi Zivc175a0d2018-03-15 13:21:44 +0200190
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300191 while [ "$TIME" -lt "$TIME_OUT" ]; do
192
193 case ${DOCKER_NAME} in
194
195 sdc-cs)
196 ready_probe ${DOCKER_NAME} ${TIME} ;
197 status=$? ;
198 ;;
199 sdc-es)
200 probe_es ${TIME} ;
201 status=$? ;
202 ;;
203 sdc-BE)
204 ready_probe ${DOCKER_NAME} ${TIME} ;
205 status=$? ;
206 ;;
207 sdc-FE)
208 ready_probe ${DOCKER_NAME} ${TIME} ;
209 status=$? ;
210 ;;
211 sdc-onboard-BE)
212 ready_probe ${DOCKER_NAME} ${TIME} ;
213 status=$? ;
214 ;;
215 dcae-be)
216 probe_dcae_be ${TIME} ;
217 status=$? ;
218 ;;
219 dcae-fe)
220 probe_dcae_fe ${TIME} ;
221 status=$? ;
222 ;;
223 dcae-tools)
224 probe_dcae_tools ;
225 status=$? ;
226 ;;
227 *)
228 probe_docker ${DOCKER_NAME} ${TIME};
229 status=$? ;
230 ;;
231
232 esac
233
234 if [ ${status} == ${SUCCESS} ] ; then
235 break;
Idan Amitdb3d5542017-12-07 11:33:32 +0200236 fi
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300237
238 echo "Sleep: ${INTERVAL} seconds before testing if ${DOCKER_NAME} DOCKER is up. Total wait time up now is: ${TIME} seconds. Timeout is: ${TIME_OUT} seconds"
239 sleep ${INTERVAL}
Idan Amitdb3d5542017-12-07 11:33:32 +0200240 TIME=$(($TIME+$INTERVAL))
241 done
Yuli Shlosberg5571a862017-10-03 18:18:51 +0300242
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300243 docker_logs ${DOCKER_NAME}
Yuli Shlosberg36604c72018-02-25 16:03:45 +0200244
Idan Amitdb3d5542017-12-07 11:33:32 +0200245 if [ "$TIME" -ge "$TIME_OUT" ]; then
246 echo -e "\e[1;31mTIME OUT: DOCKER was NOT fully started in $TIME_OUT seconds... Could cause problems ...\e[0m"
247 fi
Yuli Shlosberg5571a862017-10-03 18:18:51 +0300248}
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300249#
250
Yuli Shlosberg5571a862017-10-03 18:18:51 +0300251
Yuli Shlosbergd1bb2e52018-01-15 11:51:21 +0200252function healthCheck {
Yuli Shlosberg474996a2018-02-27 18:55:25 +0200253 curl --noproxy "*" ${IP}:9200/_cluster/health?pretty=true
Yuli Shlosbergd1bb2e52018-01-15 11:51:21 +0200254
255 echo "BE health-Check:"
Yuli Shlosberg474996a2018-02-27 18:55:25 +0200256 curl --noproxy "*" http://${IP}:8080/sdc2/rest/healthCheck
Yuli Shlosbergd1bb2e52018-01-15 11:51:21 +0200257
258 echo ""
259 echo ""
260 echo "FE health-Check:"
Yuli Shlosberg474996a2018-02-27 18:55:25 +0200261 curl --noproxy "*" http://${IP}:8181/sdc1/rest/healthCheck
Yuli Shlosbergd1bb2e52018-01-15 11:51:21 +0200262
263
264 echo ""
265 echo ""
Yuli Shlosberg474996a2018-02-27 18:55:25 +0200266 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;)
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300267 if [[ ${healthCheck_http_code} != 200 ]]; then
Yuli Shlosbergd1bb2e52018-01-15 11:51:21 +0200268 echo "Error [${healthCheck_http_code}] while user existance check"
269 return ${healthCheck_http_code}
270 fi
271 echo "check user existance: OK"
272 return ${healthCheck_http_code}
273}
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300274#
Yuli Shlosbergd1bb2e52018-01-15 11:51:21 +0200275
Tal Gitelmane224d0b2017-10-17 15:24:25 +0300276
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300277function command_exit_status {
278 status=$1
279 docker=$2
280 if [ "${status}" != "0" ] ; then
281 echo "[ ERROR ] Docker ${docker} run command exit with status [${status}]"
282 fi
283}
284#
285
286
287#
288# Run Containers
289#
290
291#Elastic-Search
292function sdc-es {
293 DOCKER_NAME="sdc-es"
294 echo "docker run sdc-elasticsearch..."
295 if [ ${LOCAL} = false ]; then
296 echo "pulling code"
297 docker pull ${PREFIX}/sdc-elasticsearch:${RELEASE}
298 fi
299 docker run -dit --name ${DOCKER_NAME} --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
300 command_exit_status $? ${DOCKER_NAME}
301 echo "please wait while ES is starting..."
302 monitor_docker ${DOCKER_NAME}
303}
304#
305
306
307#Init-Elastic-Search
308function sdc-init-es {
309 DOCKER_NAME="sdc-init-es"
310 echo "docker run sdc-init-elasticsearch..."
311 if [ ${LOCAL} = false ]; then
312 echo "pulling code"
313 docker pull ${PREFIX}/sdc-init-elasticsearch:${RELEASE}
314 fi
315 echo "Running sdc-init-es"
316 docker run --name ${DOCKER_NAME} --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
317 rc=$?
318 docker_logs ${DOCKER_NAME}
319 if [[ ${rc} != 0 ]]; then exit ${rc}; fi
320}
321#
322
323
324#Cassandra
325function sdc-cs {
326 DOCKER_NAME="sdc-cs"
327 echo "docker run sdc-cassandra..."
328 if [ ${LOCAL} = false ]; then
329 docker pull ${PREFIX}/sdc-cassandra:${RELEASE}
330 fi
331 docker run -dit --name ${DOCKER_NAME} --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
332 command_exit_status $? ${DOCKER_NAME}
333 echo "please wait while CS is starting..."
334 monitor_docker ${DOCKER_NAME}
335}
336#
337
338
339#Cassandra-init
340function sdc-cs-init {
341 DOCKER_NAME="sdc-cs-init"
342 echo "docker run sdc-cassandra-init..."
343 if [ ${LOCAL} = false ]; then
344 docker pull ${PREFIX}/sdc-cassandra-init:${RELEASE}
345 fi
346 docker run --name ${DOCKER_NAME} --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
347 rc=$?
348 docker_logs ${DOCKER_NAME}
349 if [[ ${rc} != 0 ]]; then exit ${rc}; fi
350}
351#
352
353
354#Onboard Cassandra-init
355function sdc-cs-onboard-init {
356 DOCKER_NAME="sdc-cs-onboard-init"
357 echo "docker run sdc-cs-onboard-init..."
358 if [ ${LOCAL} = false ]; then
359 docker pull ${PREFIX}/sdc-onboard-cassandra-init:${RELEASE}
360 fi
361 docker run --name ${DOCKER_NAME} --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}
362 rc=$?
363 docker_logs ${DOCKER_NAME}
364 if [[ ${rc} != 0 ]]; then exit ${rc}; fi
365}
366#
367
368
369#Kibana
370function sdc-kbn {
371 DOCKER_NAME="sdc-kbn"
372 echo "docker run sdc-kibana..."
373 if [ ${LOCAL} = false ]; then
374 docker pull ${PREFIX}/sdc-kibana:${RELEASE}
375 docker run --detach --name ${DOCKER_NAME} --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}
376 command_exit_status $? ${DOCKER_NAME}
377 fi
378}
379#
380
381
382#Back-End
383function sdc-BE {
384 DOCKER_NAME="sdc-BE"
385 echo "docker run sdc-backend..."
386 if [ ${LOCAL} = false ]; then
387 docker pull ${PREFIX}/sdc-backend:${RELEASE}
388 else
389 ADDITIONAL_ARGUMENTS=${DEBUG_PORT}
390 fi
391 docker run --detach --name ${DOCKER_NAME} --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}
392 command_exit_status $? ${DOCKER_NAME}
393 echo "please wait while BE is starting..."
394 monitor_docker ${DOCKER_NAME}
395}
396#
397
398
399# Back-End-Init
400function sdc-BE-init {
401 DOCKER_NAME="sdc-BE-init"
402 echo "docker run sdc-backend-init..."
403 if [ ${LOCAL} = false ]; then
404 docker pull ${PREFIX}/sdc-backend-init:${RELEASE}
405 fi
406 docker run --name ${DOCKER_NAME} --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
407 rc=$?
408 docker_logs ${DOCKER_NAME}
409 if [[ ${rc} != 0 ]]; then exit ${rc}; fi
410}
411#
412
413
414# Onboard Back-End
415function sdc-onboard-BE {
416 DOCKER_NAME="sdc-onboard-BE"
417 echo "docker run sdc-onboard-BE ..."
418# TODO Check the dir_perms action . do we need it here ??
419# dir_perms
420 if [ ${LOCAL} = false ]; then
421 docker pull ${PREFIX}/sdc-onboard-backend:${RELEASE}
422 else
423 ADDITIONAL_ARGUMENTS=${ONBOARD_DEBUG_PORT}
424 fi
425 docker run --detach --name ${DOCKER_NAME} --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}
426 command_exit_status $? ${DOCKER_NAME}
427 echo "please wait while sdc-onboard-BE is starting..."
428 monitor_docker ${DOCKER_NAME}
429}
430#
431
432
433# Front-End
434function sdc-FE {
435 DOCKER_NAME="sdc-FE"
436 echo "docker run sdc-frontend..."
437 if [ ${LOCAL} = false ]; then
438 docker pull ${PREFIX}/sdc-frontend:${RELEASE}
439 fi
440 docker run --detach --name ${DOCKER_NAME} --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}
441 command_exit_status $? ${DOCKER_NAME}
442 echo "please wait while FE is starting....."
443 monitor_docker ${DOCKER_NAME}
444}
445#
446
447
448# DCAE BackEnd
449function dcae-be {
450 if [ ! ${DCAE_ENABLE} ] ; then
451 return
452 fi
453 DOCKER_NAME="dcae-be"
454 echo "docker run ${DOCKER_NAME}..."
455 if [ ${LOCAL} = false ]; then
456 docker pull ${PREFIX}/${DOCKER_NAME}:${RELEASE}
457 fi
458 docker run --detach --name ${DOCKER_NAME} --env HOST_IP=${IP} --env ENVNAME="${DEP_ENV}" --env JAVA_OPTIONS="${DCAE_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/DCAE-BE/:/var/lib/jetty/logs --volume ${WORKSPACE}/data/environments:/var/opt/dcae-be/chef-solo/environments --publish 8444:8444 --publish 8082:8082 ${PREFIX}/${DOCKER_NAME}:${RELEASE}
459 command_exit_status $? ${DOCKER_NAME}
460 echo "please wait while ${DOCKER_NAME^^} is starting....."
461 monitor_docker ${DOCKER_NAME}
462}
463#
464
465
466# DCAE Configuration
467function dcae-tools {
468 if [ ! ${DCAE_ENABLE} ] ; then
469 return
470 fi
471 DOCKER_NAME="dcae-tools"
472 echo "docker run ${DOCKER_NAME}..."
473 if [ ${LOCAL} = false ]; then
474 docker pull ${PREFIX}/${DOCKER_NAME}:${RELEASE}
475 fi
476 docker run --detach --name ${DOCKER_NAME} --env HOST_IP=${IP} --env ENVNAME="${DEP_ENV}" ${LOCAL_TIME_MOUNT_CMD} --volume ${WORKSPACE}/data/logs/BE/:/var/lib/jetty/logs --volume ${WORKSPACE}/data/environments:/var/opt/dcae-tools/chef-solo/environments ${PREFIX}/${DOCKER_NAME}:${RELEASE}
477 command_exit_status $? ${DOCKER_NAME}
478 echo "please wait while ${DOCKER_NAME^^} is starting....."
479 monitor_docker ${DOCKER_NAME}
480
481}
482#
483
484
485# DCAE FrontEnd
486function dcae-fe {
487 if [ ! ${DCAE_ENABLE} ] ; then
488 return
489 fi
490 DOCKER_NAME="dcae-fe"
491 echo "docker run ${DOCKER_NAME}..."
492 if [ ${LOCAL} = false ]; then
493 docker pull ${PREFIX}/${DOCKER_NAME}:${RELEASE}
494 fi
495 docker run --detach --name ${DOCKER_NAME} --env HOST_IP=${IP} --env ENVNAME="${DEP_ENV}" --env JAVA_OPTIONS="${DCAE_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/DCAE-FE/:/var/lib/jetty/logs --volume ${WORKSPACE}/data/environments:/var/opt/dcae-fe/chef-solo/environments/ --publish 9444:9444 --publish 8183:8183 ${PREFIX}/${DOCKER_NAME}:${RELEASE}
496 command_exit_status $? ${DOCKER_NAME}
497 echo "please wait while ${DOCKER_NAME^^} is starting....."
498 monitor_docker ${DOCKER_NAME}
499
500}
501#
502
503
504# apis-sanity
505function sdc-api-tests {
506 if [[ ${RUN_API_TESTS} = true ]] ; then
Yuli Shlosbergd0eaeca2018-07-19 17:54:15 +0300507 healthCheck
508 healthCheck_http_code=$?
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300509 if [[ ${healthCheck_http_code} == 200 ]] ; then
510 echo "docker run sdc-api-tests..."
511 echo "Trigger sdc-api-tests docker, please wait..."
512
513 if [ ${LOCAL} = false ]; then
514 docker pull ${PREFIX}/sdc-api-tests:${RELEASE}
515 fi
516
517 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....."
518 monitor_docker sdc-api-tests
519 fi
520 fi
521}
522#
523
524
525# ui-sanity
526function sdc-ui-tests {
527
528 if [[ ${RUN_UI_TESTS} = true ]] ; then
Yuli Shlosbergd0eaeca2018-07-19 17:54:15 +0300529 healthCheck
530 healthCheck_http_code=$?
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300531 if [[ ${healthCheck_http_code} == 200 ]]; then
532 echo "docker run sdc-ui-tets..."
533 echo "Trigger sdc-ui-tests docker, please wait..."
534
535 if [ ${LOCAL} = false ]; then
536 docker pull ${PREFIX}/sdc-ui-tests:${RELEASE}
537 fi
538
539 sdc-sim
540 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}
541 echo "please wait while SDC-UI-TESTS is starting....."
542 monitor_docker sdc-ui-tests
543 fi
544 fi
545}
546#
547
548
549# SDC-Simulator
550function sdc-sim {
551 echo "docker run sdc-webSimulator..."
552 if [ ${LOCAL} = false ]; then
553 docker pull ${PREFIX}/sdc-simulator:${RELEASE}
554 fi
555
556 probe_sim
557 if [ sim_stat=false ]; then
558 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}
559 echo "please wait while SDC-WEB-SIMULATOR is starting....."
560 monitor_docker sdc-sim
561 fi
562}
563#
564
565
566#
567# Main
568#
569
570# Handle command line arguments
Idan Amitdb3d5542017-12-07 11:33:32 +0200571while [ $# -gt 0 ]; do
Michael Lando451a3402017-02-19 10:28:42 +0200572 case $1 in
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300573
Idan Amitdb3d5542017-12-07 11:33:32 +0200574 # -r | --release - The specific docker version to pull and deploy
Yuli Shlosberg0566f582017-11-26 19:05:23 +0200575 -r | --release )
576 shift 1 ;
577 RELEASE=$1;
578 shift 1;;
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300579
Idan Amitdb3d5542017-12-07 11:33:32 +0200580 # -e | --environment - The environment name you want to deploy
Yuli Shlosberg0566f582017-11-26 19:05:23 +0200581 -e | --environment )
582 shift 1;
583 DEP_ENV=$1;
584 shift 1 ;;
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300585
Idan Amitdb3d5542017-12-07 11:33:32 +0200586 # -p | --port - The port from which to connect to the docker nexus
Yuli Shlosberg0566f582017-11-26 19:05:23 +0200587 -p | --port )
588 shift 1 ;
589 PORT=$1;
590 shift 1 ;;
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300591
Idan Amitdb3d5542017-12-07 11:33:32 +0200592 # -l | --local - Use this for deploying your local dockers without pulling them first
Yuli Shlosberg0566f582017-11-26 19:05:23 +0200593 -l | --local )
594 LOCAL=true;
595 shift 1;;
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300596
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200597 # -ta - Use this for running the APIs sanity docker after all other dockers have been deployed
598 -ta )
599 shift 1 ;
600 API_SUITE=$1;
601 RUN_API_TESTS=true;
602 shift 1 ;;
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300603
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200604 # -tu - Use this for running the UI sanity docker after all other dockers have been deployed
605 -tu )
606 shift 1 ;
607 UI_SUITE=$1;
608 RUN_UI_TESTS=true;
609 shift 1 ;;
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300610
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200611 # -tad - Use this for running the DEFAULT suite of tests in APIs sanity docker after all other dockers have been deployed
612 -tad | -t )
613 API_SUITE="onapApiSanity";
614 RUN_API_TESTS=true;
615 shift 1 ;;
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300616
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200617 # -tud - Use this for running the DEFAULT suite of tests in UI sanity docker after all other dockers have been deployed
618 -tud )
619 UI_SUITE="onapUiSanity";
620 RUN_UI_TESTS=true;
Yuli Shlosberg0566f582017-11-26 19:05:23 +0200621 shift 1 ;;
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300622
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200623 # -d | --docker - The init specified docker
624 -d | --docker )
625 shift 1 ;
626 DOCKER=$1;
627 shift 1 ;;
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300628
629 # -dcae | --dcae - Use this to deploy DCAE upon SDC
630 -dcae | --dcae )
631 shift 1 ;
632 DCAE_ENABLE='True';;
633
Idan Amitdb3d5542017-12-07 11:33:32 +0200634 # -h | --help - Display the help message with all the available run options
Yuli Shlosberg0566f582017-11-26 19:05:23 +0200635 -h | --help )
636 usage;
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300637 exit ${SUCCESS};;
638
Yuli Shlosberg0566f582017-11-26 19:05:23 +0200639 * )
640 usage;
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300641 exit ${FAILURE};;
Michael Lando451a3402017-02-19 10:28:42 +0200642 esac
Michael Lando451a3402017-02-19 10:28:42 +0200643done
644
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300645
dekstroza83520062018-05-03 16:47:08 +0100646#Prefix those with WORKSPACE so it can be set to something other then /opt
647[ -f ${WORKSPACE}/opt/config/env_name.txt ] && DEP_ENV=$(cat ${WORKSPACE}/opt/config/env_name.txt) || echo ${DEP_ENV}
648[ -f ${WORKSPACE}/opt/config/nexus_username.txt ] && NEXUS_USERNAME=$(cat ${WORKSPACE}/opt/config/nexus_username.txt) || NEXUS_USERNAME=release
649[ -f ${WORKSPACE}/opt/config/nexus_password.txt ] && NEXUS_PASSWD=$(cat ${WORKSPACE}/opt/config/nexus_password.txt) || NEXUS_PASSWD=sfWU3DFVdBr7GVxB85mTYgAW
650[ -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}
651[ -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 +0200652
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300653
Yuli Shlosbergd1bb2e52018-01-15 11:51:21 +0200654export IP=`ip route get 8.8.8.8 | awk '/src/{ print $7 }'`
dekstroza83520062018-05-03 16:47:08 +0100655#If OSX, then use this to get IP
656if [[ "$OSTYPE" == "darwin"* ]]; then
657 export IP=$(ipconfig getifaddr en0)
658fi
Idan Amitdb3d5542017-12-07 11:33:32 +0200659export PREFIX=${NEXUS_DOCKER_REPO}'/onap'
Idan Amitc7f57ec2017-08-31 14:26:21 +0300660
661if [ ${LOCAL} = true ]; then
Idan Amitdb3d5542017-12-07 11:33:32 +0200662 PREFIX='onap'
Idan Amitc7f57ec2017-08-31 14:26:21 +0300663fi
Michael Lando451a3402017-02-19 10:28:42 +0200664
665echo ""
666
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200667if [ -z "${DOCKER}" ]; then
Michael Lando4b9b9472018-06-02 19:14:05 +0300668 cleanup all
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200669 dir_perms
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200670 sdc-es
671 sdc-init-es
672 sdc-cs
673 sdc-cs-init
Gitelman, Tal (tg851x)19c9bda2018-03-19 19:07:30 +0200674# sdc-kbn
Avi Zivc175a0d2018-03-15 13:21:44 +0200675 sdc-cs-onboard-init
676 sdc-onboard-BE
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200677 sdc-BE
678 sdc-BE-init
679 sdc-FE
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300680 dcae-be
681 dcae-tools
682 dcae-fe
683 healthCheck
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200684 sdc-api-tests
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300685 sdc-ui-tests
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200686else
687 cleanup ${DOCKER}
svishnev0b698c42018-03-08 15:50:44 +0200688 dir_perms
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200689 ${DOCKER}
Yuli Shlosberge07a5162018-02-26 10:11:10 +0200690 healthCheck
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200691fi