blob: 51e552e975324712c185ad83455c577ba38a2333 [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"
kooperb087a8b2019-04-04 14:03:36 +000016SDC_CERT_DIR="onap/cert"
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +030017
18RELEASE=latest
kaihlavi900985e2019-06-06 14:52:02 +030019
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +030020LOCAL=false
Tal Gitelmanef4b94e2018-08-02 17:11:25 +030021BE_DEBUG_PORT="--publish 4000:4000"
22FE_DEBUG_PORT="--publish 6000:6000"
Tal Gitelmanc4d387d2019-03-28 11:00:54 +020023ONBOARD_DEBUG_PORT="--publish 4001:4001"
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +030024
25
26# Java Options:
Gitelman, Tal (tg851x)328388b2018-03-22 13:03:44 +020027BE_JAVA_OPTIONS="-Xdebug -agentlib:jdwp=transport=dt_socket,address=4000,server=y,suspend=n -Xmx1536m -Xms1536m"
28FE_JAVA_OPTIONS="-Xdebug -agentlib:jdwp=transport=dt_socket,address=6000,server=y,suspend=n -Xmx256m -Xms256m"
Avi Zivc175a0d2018-03-15 13:21:44 +020029ONBOARD_BE_JAVA_OPTIONS="-Xdebug -agentlib:jdwp=transport=dt_socket,address=4001,server=y,suspend=n -Xmx1g -Xms1g"
Yuli Shlosbergaf70a202018-09-25 17:16:48 +030030SIM_JAVA_OPTIONS=" -Xmx128m -Xms128m -Xss1m -Dlog4j.configuration=file:///${JETTY_BASE}/config/sdc-simulator/log4j.properties"
Yuli Shlosbergf59a2252018-03-21 11:14:08 +020031API_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 {
kaihlavi900985e2019-06-06 14:52:02 +030047 echo "usage: docker_run.sh [ -r|--release <RELEASE-NAME> ] [ -e|--environment <ENV-NAME> ] [ -p|--port <Docker-hub-port>] [ -l|--local <Run-without-pull>] [ -sim|--simulator <Run-with-simulator>] [ -ta <run api tests with the supplied test suit>] [ -tu <run ui tests with the supplied test suit>] [ -ta <run api tests with the supplied test suit>] [ -tu <run ui tests with the supplied test suit>] [ -tad <run api tests with the default test suit>] [ -tu <run ui tests with the default test suit>] [ -h|--help ]"
Michael Landodc856bb2018-08-13 13:27:52 +030048 echo "start dockers built locally example: docker_run.sh -l"
49 echo "start dockers built locally and simulator example: docker_run.sh -l -sim"
kaihlavib2372712019-05-27 16:28:23 +030050 echo "start dockers, pull from onap nexus according to release and simulator example: docker_run.sh -r 1.5-STAGING-latest -sim"
Michael Landodc856bb2018-08-13 13:27:52 +030051 echo "start dockers built locally and run api tests docker example: docker_run.sh -l -tad"
52 echo "start dockers built locally and run only the catalog be example: docker_run.sh -l -d sdc-BE "
Michael Lando451a3402017-02-19 10:28:42 +020053}
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +030054#
Michael Lando451a3402017-02-19 10:28:42 +020055
56
Grinberg Motic3bda482017-02-23 11:24:34 +020057function cleanup {
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +030058 echo "Performing old dockers cleanup"
Yuli Shlosberg958c32d2018-02-15 12:04:46 +020059
60 if [ "$1" == "all" ] ; then
k.kedron3643cc52019-08-28 15:01:51 +020061 docker_ids=`docker ps -a | egrep "ecomp-nexus:${PORT}/sdc|sdc|Exit}|dcae" | awk '{print $1}'`
Yuli Shlosberg958c32d2018-02-15 12:04:46 +020062 for X in ${docker_ids}
63 do
64 docker rm -f ${X}
65 done
66 else
67 echo "performing $1 docker cleanup"
68 tmp=`docker ps -a -q --filter="name=$1"`
Yuli Shlosberg474996a2018-02-27 18:55:25 +020069 if [[ ! -z "$tmp" ]]; then
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +030070 docker rm -f ${tmp}
71 fi
Yuli Shlosberg958c32d2018-02-15 12:04:46 +020072 fi
Grinberg Motic3bda482017-02-23 11:24:34 +020073}
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +030074#
Grinberg Motic3bda482017-02-23 11:24:34 +020075
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +030076
Grinberg Motic3bda482017-02-23 11:24:34 +020077function dir_perms {
Michael Lando4b9b9472018-06-02 19:14:05 +030078 mkdir -p ${WORKSPACE}/data/logs/BE/SDC/SDC-BE
79 mkdir -p ${WORKSPACE}/data/logs/FE/SDC/SDC-FE
80 mkdir -p ${WORKSPACE}/data/logs/sdc-api-tests/ExtentReport
81 mkdir -p ${WORKSPACE}/data/logs/ONBOARD/SDC/ONBOARD-BE
kaihlavi900985e2019-06-06 14:52:02 +030082 mkdir -p ${WORKSPACE}/data/logs/sdc-api-tests/target
83 mkdir -p ${WORKSPACE}/data/logs/sdc-ui-tests/ExtentReport
84 mkdir -p ${WORKSPACE}/data/logs/sdc-ui-tests/target
85 mkdir -p ${WORKSPACE}/data/logs/docker_logs
86 mkdir -p ${WORKSPACE}/data/logs/WS
andre.schmidfa1db432019-10-29 17:18:22 +000087 echo "Creating dir '${WORKSPACE}/data/${SDC_CERT_DIR}'"
kaihlavi900985e2019-06-06 14:52:02 +030088 mkdir -p ${WORKSPACE}/data/${SDC_CERT_DIR}
Michael Lando4b9b9472018-06-02 19:14:05 +030089 chmod -R 777 ${WORKSPACE}/data/logs
Grinberg Motic3bda482017-02-23 11:24:34 +020090}
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +030091#
92
Yuli Shlosberg36604c72018-02-25 16:03:45 +020093
Yuli Shlosbergb4deec12018-02-25 20:24:44 +020094function docker_logs {
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +030095 docker logs $1 > ${WORKSPACE}/data/logs/docker_logs/$1_docker.log
Yuli Shlosbergb4deec12018-02-25 20:24:44 +020096}
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +030097#
Yuli Shlosbergb4deec12018-02-25 20:24:44 +020098
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +030099
100#
101# Readiness Prob
102#
103
104function ready_probe {
Michael Lando4b9b9472018-06-02 19:14:05 +0300105 docker exec $1 /var/lib/ready-probe.sh > /dev/null 2>&1
106 rc=$?
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300107 if [[ ${rc} == 0 ]]; then
108 echo DOCKER $1 start finished in $2 seconds
109 return ${SUCCESS}
Michael Lando4b9b9472018-06-02 19:14:05 +0300110 fi
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300111 return ${FAILURE}
Yuli Shlosberg0875ce02018-01-25 13:53:36 +0200112}
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300113#
Yuli Shlosberg0875ce02018-01-25 13:53:36 +0200114
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200115
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300116function probe_docker {
117 MATCH=`docker logs --tail 30 $1 | grep "DOCKER STARTED"`
118 echo MATCH is -- ${MATCH}
Avi Zivc175a0d2018-03-15 13:21:44 +0200119
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300120 if [ -n "$MATCH" ] ; then
121 echo DOCKER start finished in $2 seconds
122 return ${SUCCESS}
Michael Lando4b9b9472018-06-02 19:14:05 +0300123 fi
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300124 return ${FAILURE}
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200125}
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300126#
127
kaihlavi02f48802019-07-30 19:23:52 +0300128function probe_test_docker {
129 # This expected logging should be output by startup.sh of the
130 # respective test docker container
131 MATCH=`docker logs --tail 30 $1 | grep "Startup completed successfully"`
132 echo MATCH is -- ${MATCH}
133
134 if [ -n "$MATCH" ] ; then
135 echo TEST DOCKER start finished in $2 seconds
136 return ${SUCCESS}
137 fi
138 return ${FAILURE}
139}
140#
141
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200142
143function probe_es {
Michael Lando4b9b9472018-06-02 19:14:05 +0300144 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 +0300145 if [[ "$health_Check_http_code" -eq 200 ]] ; then
146 echo DOCKER start finished in $1 seconds
147 return ${SUCCESS}
148 fi
149 return ${FAILURE}
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200150}
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300151#
152
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200153
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200154function probe_sim {
Michael Lando4b9b9472018-06-02 19:14:05 +0300155 if lsof -Pi :8285 -sTCP:LISTEN -t >/dev/null ; then
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300156 echo "Already running"
157 return ${SUCCESS}
Michael Lando4b9b9472018-06-02 19:14:05 +0300158 else
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300159 echo "Not running"
160 return ${FAILURE}
Michael Lando4b9b9472018-06-02 19:14:05 +0300161 fi
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200162}
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300163#
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200164
Yuli Shlosberg0875ce02018-01-25 13:53:36 +0200165
Yuli Shlosberg5571a862017-10-03 18:18:51 +0300166function monitor_docker {
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300167 DOCKER_NAME=$1
168 echo "Monitor ${DOCKER_NAME} Docker"
Idan Amitdb3d5542017-12-07 11:33:32 +0200169 sleep 5
170 TIME_OUT=900
171 INTERVAL=20
172 TIME=0
Avi Zivc175a0d2018-03-15 13:21:44 +0200173
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300174 while [ "$TIME" -lt "$TIME_OUT" ]; do
175
176 case ${DOCKER_NAME} in
177
178 sdc-cs)
179 ready_probe ${DOCKER_NAME} ${TIME} ;
180 status=$? ;
181 ;;
182 sdc-es)
183 probe_es ${TIME} ;
184 status=$? ;
185 ;;
186 sdc-BE)
kaihlavi02f48802019-07-30 19:23:52 +0300187 ready_probe ${DOCKER_NAME} ${TIME} ;
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300188 status=$? ;
189 ;;
190 sdc-FE)
191 ready_probe ${DOCKER_NAME} ${TIME} ;
192 status=$? ;
193 ;;
194 sdc-onboard-BE)
195 ready_probe ${DOCKER_NAME} ${TIME} ;
196 status=$? ;
197 ;;
kaihlavi02f48802019-07-30 19:23:52 +0300198 sdc-api-tests)
199 probe_test_docker ${DOCKER_NAME} ${TIME};
200 status=$? ;
201 ;;
202 sdc-ui-tests)
203 probe_test_docker ${DOCKER_NAME} ${TIME};
204 status=$? ;
205 ;;
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300206 *)
207 probe_docker ${DOCKER_NAME} ${TIME};
208 status=$? ;
209 ;;
210
211 esac
212
k.kedron3643cc52019-08-28 15:01:51 +0200213 if [[ ${status} == ${SUCCESS} ]] ; then
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300214 break;
Idan Amitdb3d5542017-12-07 11:33:32 +0200215 fi
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300216
217 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"
218 sleep ${INTERVAL}
Idan Amitdb3d5542017-12-07 11:33:32 +0200219 TIME=$(($TIME+$INTERVAL))
220 done
Yuli Shlosberg5571a862017-10-03 18:18:51 +0300221
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300222 docker_logs ${DOCKER_NAME}
Yuli Shlosberg36604c72018-02-25 16:03:45 +0200223
Idan Amitdb3d5542017-12-07 11:33:32 +0200224 if [ "$TIME" -ge "$TIME_OUT" ]; then
225 echo -e "\e[1;31mTIME OUT: DOCKER was NOT fully started in $TIME_OUT seconds... Could cause problems ...\e[0m"
226 fi
Yuli Shlosberg5571a862017-10-03 18:18:51 +0300227}
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300228#
229
k.kedron3643cc52019-08-28 15:01:51 +0200230# healthCheck script used the secure connection to send request (https is always turn on)
Yuli Shlosbergd1bb2e52018-01-15 11:51:21 +0200231function healthCheck {
Yuli Shlosberg474996a2018-02-27 18:55:25 +0200232 curl --noproxy "*" ${IP}:9200/_cluster/health?pretty=true
Yuli Shlosbergd1bb2e52018-01-15 11:51:21 +0200233
kaihlavi900985e2019-06-06 14:52:02 +0300234 echo "BE Health Check:"
k.kedron3643cc52019-08-28 15:01:51 +0200235 curl -k --noproxy "*" https://${IP}:8443/sdc2/rest/healthCheck
Yuli Shlosbergd1bb2e52018-01-15 11:51:21 +0200236
237 echo ""
238 echo ""
kaihlavi900985e2019-06-06 14:52:02 +0300239 echo "FE Health Check:"
k.kedron3643cc52019-08-28 15:01:51 +0200240 curl -k --noproxy "*" https://${IP}:9443/sdc1/rest/healthCheck
Yuli Shlosbergd1bb2e52018-01-15 11:51:21 +0200241
242
243 echo ""
244 echo ""
k.kedron3643cc52019-08-28 15:01:51 +0200245 healthCheck_http_code=$(curl -k --noproxy "*" -o /dev/null -w '%{http_code}' -H "Accept: application/json" -H "Content-Type: application/json" -H "USER_ID: jh0003" https://${IP}:8443/sdc2/rest/v1/user/demo;)
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300246 if [[ ${healthCheck_http_code} != 200 ]]; then
kaihlavi900985e2019-06-06 14:52:02 +0300247 echo "Error [${healthCheck_http_code}] while checking existence of user"
Yuli Shlosbergd1bb2e52018-01-15 11:51:21 +0200248 return ${healthCheck_http_code}
249 fi
kaihlavi900985e2019-06-06 14:52:02 +0300250 echo "check user existence: OK"
Yuli Shlosbergd1bb2e52018-01-15 11:51:21 +0200251 return ${healthCheck_http_code}
252}
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300253#
Yuli Shlosbergd1bb2e52018-01-15 11:51:21 +0200254
Tal Gitelmane224d0b2017-10-17 15:24:25 +0300255
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300256function command_exit_status {
257 status=$1
258 docker=$2
259 if [ "${status}" != "0" ] ; then
260 echo "[ ERROR ] Docker ${docker} run command exit with status [${status}]"
261 fi
262}
263#
264
265
266#
267# Run Containers
268#
269
270#Elastic-Search
271function sdc-es {
272 DOCKER_NAME="sdc-es"
273 echo "docker run sdc-elasticsearch..."
274 if [ ${LOCAL} = false ]; then
275 echo "pulling code"
276 docker pull ${PREFIX}/sdc-elasticsearch:${RELEASE}
277 fi
278 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
279 command_exit_status $? ${DOCKER_NAME}
280 echo "please wait while ES is starting..."
281 monitor_docker ${DOCKER_NAME}
282}
283#
284
285
286#Init-Elastic-Search
287function sdc-init-es {
288 DOCKER_NAME="sdc-init-es"
289 echo "docker run sdc-init-elasticsearch..."
290 if [ ${LOCAL} = false ]; then
291 echo "pulling code"
292 docker pull ${PREFIX}/sdc-init-elasticsearch:${RELEASE}
293 fi
294 echo "Running sdc-init-es"
295 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
296 rc=$?
297 docker_logs ${DOCKER_NAME}
298 if [[ ${rc} != 0 ]]; then exit ${rc}; fi
299}
300#
301
302
303#Cassandra
304function sdc-cs {
305 DOCKER_NAME="sdc-cs"
306 echo "docker run sdc-cassandra..."
307 if [ ${LOCAL} = false ]; then
308 docker pull ${PREFIX}/sdc-cassandra:${RELEASE}
309 fi
310 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
311 command_exit_status $? ${DOCKER_NAME}
312 echo "please wait while CS is starting..."
313 monitor_docker ${DOCKER_NAME}
314}
315#
316
317
318#Cassandra-init
319function sdc-cs-init {
320 DOCKER_NAME="sdc-cs-init"
321 echo "docker run sdc-cassandra-init..."
322 if [ ${LOCAL} = false ]; then
323 docker pull ${PREFIX}/sdc-cassandra-init:${RELEASE}
324 fi
325 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
326 rc=$?
327 docker_logs ${DOCKER_NAME}
328 if [[ ${rc} != 0 ]]; then exit ${rc}; fi
329}
330#
331
332
333#Onboard Cassandra-init
334function sdc-cs-onboard-init {
335 DOCKER_NAME="sdc-cs-onboard-init"
336 echo "docker run sdc-cs-onboard-init..."
337 if [ ${LOCAL} = false ]; then
338 docker pull ${PREFIX}/sdc-onboard-cassandra-init:${RELEASE}
339 fi
340 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}
341 rc=$?
342 docker_logs ${DOCKER_NAME}
343 if [[ ${rc} != 0 ]]; then exit ${rc}; fi
344}
345#
346
347
348#Kibana
349function sdc-kbn {
350 DOCKER_NAME="sdc-kbn"
351 echo "docker run sdc-kibana..."
352 if [ ${LOCAL} = false ]; then
353 docker pull ${PREFIX}/sdc-kibana:${RELEASE}
354 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}
355 command_exit_status $? ${DOCKER_NAME}
356 fi
357}
358#
359
360
361#Back-End
362function sdc-BE {
363 DOCKER_NAME="sdc-BE"
364 echo "docker run sdc-backend..."
365 if [ ${LOCAL} = false ]; then
366 docker pull ${PREFIX}/sdc-backend:${RELEASE}
367 else
Tal Gitelmanef4b94e2018-08-02 17:11:25 +0300368 ADDITIONAL_ARGUMENTS=${BE_DEBUG_PORT}
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300369 fi
andre.schmidfa1db432019-10-29 17:18:22 +0000370 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/:${JETTY_BASE}/logs --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments --publish 8443:8443 --publish 8080:8080 ${ADDITIONAL_ARGUMENTS} ${PREFIX}/sdc-backend:${RELEASE}
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300371 command_exit_status $? ${DOCKER_NAME}
372 echo "please wait while BE is starting..."
373 monitor_docker ${DOCKER_NAME}
374}
375#
376
377
378# Back-End-Init
379function sdc-BE-init {
380 DOCKER_NAME="sdc-BE-init"
381 echo "docker run sdc-backend-init..."
382 if [ ${LOCAL} = false ]; then
383 docker pull ${PREFIX}/sdc-backend-init:${RELEASE}
384 fi
andre.schmidfa1db432019-10-29 17:18:22 +0000385 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/:${JETTY_BASE}/logs --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments ${PREFIX}/sdc-backend-init:${RELEASE} > /dev/null 2>&1
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300386 rc=$?
387 docker_logs ${DOCKER_NAME}
388 if [[ ${rc} != 0 ]]; then exit ${rc}; fi
389}
390#
391
392
393# Onboard Back-End
394function sdc-onboard-BE {
395 DOCKER_NAME="sdc-onboard-BE"
396 echo "docker run sdc-onboard-BE ..."
397# TODO Check the dir_perms action . do we need it here ??
398# dir_perms
399 if [ ${LOCAL} = false ]; then
400 docker pull ${PREFIX}/sdc-onboard-backend:${RELEASE}
401 else
402 ADDITIONAL_ARGUMENTS=${ONBOARD_DEBUG_PORT}
403 fi
andre.schmidfa1db432019-10-29 17:18:22 +0000404 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 SDC_CERT_DIR="${SDC_CERT_DIR}" --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/${SDC_CERT_DIR}:${JETTY_BASE}/onap/cert --volume ${WORKSPACE}/data/logs/ONBOARD:${JETTY_BASE}/logs --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments --publish 8445:8445 --publish 8081:8081 ${ADDITIONAL_ARGUMENTS} ${PREFIX}/sdc-onboard-backend:${RELEASE}
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300405 command_exit_status $? ${DOCKER_NAME}
406 echo "please wait while sdc-onboard-BE is starting..."
407 monitor_docker ${DOCKER_NAME}
408}
409#
410
411
412# Front-End
413function sdc-FE {
414 DOCKER_NAME="sdc-FE"
415 echo "docker run sdc-frontend..."
416 if [ ${LOCAL} = false ]; then
417 docker pull ${PREFIX}/sdc-frontend:${RELEASE}
Tal Gitelmanef4b94e2018-08-02 17:11:25 +0300418 else
419 ADDITIONAL_ARGUMENTS=${FE_DEBUG_PORT}
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300420 fi
andre.schmidfa1db432019-10-29 17:18:22 +0000421 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/:${JETTY_BASE}/logs --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments --volume ${WORKSPACE}/data/environments/plugins-configuration.yaml:${JETTY_BASE}/config/catalog-fe/plugins-configuration.yaml --publish 9443:9443 --publish 8181:8181 ${ADDITIONAL_ARGUMENTS} ${PREFIX}/sdc-frontend:${RELEASE}
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300422 command_exit_status $? ${DOCKER_NAME}
423 echo "please wait while FE is starting....."
424 monitor_docker ${DOCKER_NAME}
425}
426#
427
428
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300429# apis-sanity
430function sdc-api-tests {
431 if [[ ${RUN_API_TESTS} = true ]] ; then
Yuli Shlosbergd0eaeca2018-07-19 17:54:15 +0300432 healthCheck
433 healthCheck_http_code=$?
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300434 if [[ ${healthCheck_http_code} == 200 ]] ; then
435 echo "docker run sdc-api-tests..."
436 echo "Trigger sdc-api-tests docker, please wait..."
437
438 if [ ${LOCAL} = false ]; then
439 docker pull ${PREFIX}/sdc-api-tests:${RELEASE}
440 fi
441
AndyWalshec1835f32019-04-25 11:20:38 +0000442 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 --volume ${WORKSPACE}/data/${SDC_CERT_DIR}:/var/lib/tests/cert --publish 9560:9560 ${PREFIX}/sdc-api-tests:${RELEASE} echo "please wait while SDC-API-TESTS is starting....."
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300443 monitor_docker sdc-api-tests
444 fi
445 fi
446}
447#
448
449
450# ui-sanity
451function sdc-ui-tests {
452
453 if [[ ${RUN_UI_TESTS} = true ]] ; then
Yuli Shlosbergd0eaeca2018-07-19 17:54:15 +0300454 healthCheck
455 healthCheck_http_code=$?
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300456 if [[ ${healthCheck_http_code} == 200 ]]; then
457 echo "docker run sdc-ui-tets..."
458 echo "Trigger sdc-ui-tests docker, please wait..."
459
460 if [ ${LOCAL} = false ]; then
461 docker pull ${PREFIX}/sdc-ui-tests:${RELEASE}
462 fi
Michael Landodc856bb2018-08-13 13:27:52 +0300463 RUN_SIMULATOR=true;
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300464 sdc-sim
465 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}
466 echo "please wait while SDC-UI-TESTS is starting....."
467 monitor_docker sdc-ui-tests
468 fi
469 fi
470}
471#
472
473
474# SDC-Simulator
475function sdc-sim {
Lianhao Lu26166842018-09-07 10:42:10 +0800476 if [ "${RUN_SIMULATOR}" == true ]; then
Michael Landodc856bb2018-08-13 13:27:52 +0300477 echo "docker run sdc-webSimulator..."
478 if [ ${LOCAL} = false ]; then
479 docker pull ${PREFIX}/sdc-simulator:${RELEASE}
480 fi
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300481
Michael Landodc856bb2018-08-13 13:27:52 +0300482 probe_sim
483 sim_stat=$?
Michael Landob751c962018-08-20 11:34:04 +0300484 if [ ${sim_stat} == 1 ]; then
Michael Landodc856bb2018-08-13 13:27:52 +0300485 docker run \
486 --detach \
487 --name sdc-sim \
488 --env FE_URL="${FE_URL}" \
489 --env JAVA_OPTIONS="${SIM_JAVA_OPTIONS}" \
490 --env ENVNAME="${DEP_ENV}" \
491 ${LOCAL_TIME_MOUNT_CMD} \
andre.schmidfa1db432019-10-29 17:18:22 +0000492 --volume ${WORKSPACE}/data/logs/WS/:${JETTY_BASE}/logs \
Michael Landodc856bb2018-08-13 13:27:52 +0300493 --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments \
494 --publish 8285:8080 \
495 --publish 8286:8443 ${PREFIX}/sdc-simulator:${RELEASE}
496 echo "please wait while SDC-WEB-SIMULATOR is starting....."
497 monitor_docker sdc-sim
498 fi
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300499 fi
500}
501#
502
503
504#
505# Main
506#
507
508# Handle command line arguments
Idan Amitdb3d5542017-12-07 11:33:32 +0200509while [ $# -gt 0 ]; do
Michael Lando451a3402017-02-19 10:28:42 +0200510 case $1 in
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300511
Idan Amitdb3d5542017-12-07 11:33:32 +0200512 # -r | --release - The specific docker version to pull and deploy
Yuli Shlosberg0566f582017-11-26 19:05:23 +0200513 -r | --release )
514 shift 1 ;
515 RELEASE=$1;
516 shift 1;;
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300517
Idan Amitdb3d5542017-12-07 11:33:32 +0200518 # -e | --environment - The environment name you want to deploy
Yuli Shlosberg0566f582017-11-26 19:05:23 +0200519 -e | --environment )
520 shift 1;
521 DEP_ENV=$1;
522 shift 1 ;;
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300523
Idan Amitdb3d5542017-12-07 11:33:32 +0200524 # -p | --port - The port from which to connect to the docker nexus
Yuli Shlosberg0566f582017-11-26 19:05:23 +0200525 -p | --port )
526 shift 1 ;
527 PORT=$1;
528 shift 1 ;;
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300529
Idan Amitdb3d5542017-12-07 11:33:32 +0200530 # -l | --local - Use this for deploying your local dockers without pulling them first
Yuli Shlosberg0566f582017-11-26 19:05:23 +0200531 -l | --local )
532 LOCAL=true;
533 shift 1;;
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300534
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200535 # -ta - Use this for running the APIs sanity docker after all other dockers have been deployed
536 -ta )
537 shift 1 ;
538 API_SUITE=$1;
539 RUN_API_TESTS=true;
540 shift 1 ;;
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300541
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200542 # -tu - Use this for running the UI sanity docker after all other dockers have been deployed
543 -tu )
544 shift 1 ;
545 UI_SUITE=$1;
546 RUN_UI_TESTS=true;
547 shift 1 ;;
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300548
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200549 # -tad - Use this for running the DEFAULT suite of tests in APIs sanity docker after all other dockers have been deployed
550 -tad | -t )
551 API_SUITE="onapApiSanity";
552 RUN_API_TESTS=true;
553 shift 1 ;;
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300554
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200555 # -tud - Use this for running the DEFAULT suite of tests in UI sanity docker after all other dockers have been deployed
556 -tud )
557 UI_SUITE="onapUiSanity";
558 RUN_UI_TESTS=true;
Yuli Shlosberg0566f582017-11-26 19:05:23 +0200559 shift 1 ;;
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300560
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200561 # -d | --docker - The init specified docker
562 -d | --docker )
563 shift 1 ;
564 DOCKER=$1;
565 shift 1 ;;
Michael Landodc856bb2018-08-13 13:27:52 +0300566 # -sim | --simulator run the simulator
567 -sim | --simulator )
kaihlavib2372712019-05-27 16:28:23 +0300568 RUN_SIMULATOR=true;
569 shift 1 ;;
Michael Landodc856bb2018-08-13 13:27:52 +0300570 # -sim | --simulator run the simulator
571 -u | --fe_url )
kaihlavib2372712019-05-27 16:28:23 +0300572 shift 1 ;
573 FE_URL=$1;
574 shift 1 ;;
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300575
Idan Amitdb3d5542017-12-07 11:33:32 +0200576 # -h | --help - Display the help message with all the available run options
Yuli Shlosberg0566f582017-11-26 19:05:23 +0200577 -h | --help )
578 usage;
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300579 exit ${SUCCESS};;
580
Yuli Shlosberg0566f582017-11-26 19:05:23 +0200581 * )
582 usage;
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300583 exit ${FAILURE};;
Michael Lando451a3402017-02-19 10:28:42 +0200584 esac
Michael Lando451a3402017-02-19 10:28:42 +0200585done
586
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300587
liang dingd73c2872018-09-27 19:07:02 -0700588#Prefix those with WORKSPACE so it can be set to something other than /opt
dekstroza83520062018-05-03 16:47:08 +0100589[ -f ${WORKSPACE}/opt/config/env_name.txt ] && DEP_ENV=$(cat ${WORKSPACE}/opt/config/env_name.txt) || echo ${DEP_ENV}
590[ -f ${WORKSPACE}/opt/config/nexus_username.txt ] && NEXUS_USERNAME=$(cat ${WORKSPACE}/opt/config/nexus_username.txt) || NEXUS_USERNAME=release
591[ -f ${WORKSPACE}/opt/config/nexus_password.txt ] && NEXUS_PASSWD=$(cat ${WORKSPACE}/opt/config/nexus_password.txt) || NEXUS_PASSWD=sfWU3DFVdBr7GVxB85mTYgAW
592[ -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}
593[ -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 +0200594
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300595
Yuli Shlosbergd1bb2e52018-01-15 11:51:21 +0200596export IP=`ip route get 8.8.8.8 | awk '/src/{ print $7 }'`
dekstroza83520062018-05-03 16:47:08 +0100597#If OSX, then use this to get IP
598if [[ "$OSTYPE" == "darwin"* ]]; then
599 export IP=$(ipconfig getifaddr en0)
600fi
Idan Amitdb3d5542017-12-07 11:33:32 +0200601export PREFIX=${NEXUS_DOCKER_REPO}'/onap'
Idan Amitc7f57ec2017-08-31 14:26:21 +0300602
603if [ ${LOCAL} = true ]; then
Idan Amitdb3d5542017-12-07 11:33:32 +0200604 PREFIX='onap'
Idan Amitc7f57ec2017-08-31 14:26:21 +0300605fi
Michael Lando451a3402017-02-19 10:28:42 +0200606
607echo ""
608
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200609if [ -z "${DOCKER}" ]; then
k.kedron3643cc52019-08-28 15:01:51 +0200610 cleanup all
611 dir_perms
612 sdc-es
613 sdc-init-es
614 sdc-cs
615 sdc-cs-init
616# sdc-kbn
617 sdc-cs-onboard-init
618 sdc-onboard-BE
619 sdc-BE
620 sdc-BE-init
621 sdc-FE
622 healthCheck
623 sdc-sim
624 sdc-api-tests
625 sdc-ui-tests
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200626else
k.kedron3643cc52019-08-28 15:01:51 +0200627 cleanup ${DOCKER}
628 dir_perms
629 ${DOCKER}
630 healthCheck
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200631fi