blob: 759c4699d5393f13795268f549f5b456c7e52ea3 [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"
shrek20000594c412020-01-30 14:52:49 +020024CS_PORT=${CS_PORT:-9042}
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +030025
26
27# Java Options:
Gitelman, Tal (tg851x)328388b2018-03-22 13:03:44 +020028BE_JAVA_OPTIONS="-Xdebug -agentlib:jdwp=transport=dt_socket,address=4000,server=y,suspend=n -Xmx1536m -Xms1536m"
29FE_JAVA_OPTIONS="-Xdebug -agentlib:jdwp=transport=dt_socket,address=6000,server=y,suspend=n -Xmx256m -Xms256m"
Avi Zivc175a0d2018-03-15 13:21:44 +020030ONBOARD_BE_JAVA_OPTIONS="-Xdebug -agentlib:jdwp=transport=dt_socket,address=4001,server=y,suspend=n -Xmx1g -Xms1g"
Yuli Shlosbergaf70a202018-09-25 17:16:48 +030031SIM_JAVA_OPTIONS=" -Xmx128m -Xms128m -Xss1m -Dlog4j.configuration=file:///${JETTY_BASE}/config/sdc-simulator/log4j.properties"
Yuli Shlosbergf59a2252018-03-21 11:14:08 +020032API_TESTS_JAVA_OPTIONS="-Xmx512m -Xms512m"
33UI_TESTS_JAVA_OPTIONS="-Xmx1024m -Xms1024m"
dekstroza83520062018-05-03 16:47:08 +010034#Define this as variable, so it can be excluded in run commands on Docker for OSX, as /etc/localtime cant be mounted there.
35LOCAL_TIME_MOUNT_CMD="--volume /etc/localtime:/etc/localtime:ro"
36# If os is OSX, unset this, so /etc/localtime is not mounted, otherwise leave it be
37if [[ "$OSTYPE" == "darwin"* ]]; then
38 LOCAL_TIME_MOUNT_CMD=""
39fi
40
41
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +030042#
43# Functions:
44#
45
Michael Lando451a3402017-02-19 10:28:42 +020046
Grinberg Motic3bda482017-02-23 11:24:34 +020047function usage {
kaihlavi900985e2019-06-06 14:52:02 +030048 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 +030049 echo "start dockers built locally example: docker_run.sh -l"
50 echo "start dockers built locally and simulator example: docker_run.sh -l -sim"
kaihlavib2372712019-05-27 16:28:23 +030051 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 +030052 echo "start dockers built locally and run api tests docker example: docker_run.sh -l -tad"
53 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 +020054}
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +030055#
Michael Lando451a3402017-02-19 10:28:42 +020056
57
Grinberg Motic3bda482017-02-23 11:24:34 +020058function cleanup {
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +030059 echo "Performing old dockers cleanup"
Yuli Shlosberg958c32d2018-02-15 12:04:46 +020060
61 if [ "$1" == "all" ] ; then
k.kedron3643cc52019-08-28 15:01:51 +020062 docker_ids=`docker ps -a | egrep "ecomp-nexus:${PORT}/sdc|sdc|Exit}|dcae" | awk '{print $1}'`
Yuli Shlosberg958c32d2018-02-15 12:04:46 +020063 for X in ${docker_ids}
64 do
65 docker rm -f ${X}
66 done
67 else
68 echo "performing $1 docker cleanup"
69 tmp=`docker ps -a -q --filter="name=$1"`
Yuli Shlosberg474996a2018-02-27 18:55:25 +020070 if [[ ! -z "$tmp" ]]; then
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +030071 docker rm -f ${tmp}
72 fi
Yuli Shlosberg958c32d2018-02-15 12:04:46 +020073 fi
Grinberg Motic3bda482017-02-23 11:24:34 +020074}
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +030075#
Grinberg Motic3bda482017-02-23 11:24:34 +020076
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +030077
Grinberg Motic3bda482017-02-23 11:24:34 +020078function dir_perms {
Michael Lando4b9b9472018-06-02 19:14:05 +030079 mkdir -p ${WORKSPACE}/data/logs/BE/SDC/SDC-BE
80 mkdir -p ${WORKSPACE}/data/logs/FE/SDC/SDC-FE
81 mkdir -p ${WORKSPACE}/data/logs/sdc-api-tests/ExtentReport
82 mkdir -p ${WORKSPACE}/data/logs/ONBOARD/SDC/ONBOARD-BE
kaihlavi900985e2019-06-06 14:52:02 +030083 mkdir -p ${WORKSPACE}/data/logs/sdc-api-tests/target
84 mkdir -p ${WORKSPACE}/data/logs/sdc-ui-tests/ExtentReport
85 mkdir -p ${WORKSPACE}/data/logs/sdc-ui-tests/target
86 mkdir -p ${WORKSPACE}/data/logs/docker_logs
87 mkdir -p ${WORKSPACE}/data/logs/WS
andre.schmidfa1db432019-10-29 17:18:22 +000088 echo "Creating dir '${WORKSPACE}/data/${SDC_CERT_DIR}'"
kaihlavi900985e2019-06-06 14:52:02 +030089 mkdir -p ${WORKSPACE}/data/${SDC_CERT_DIR}
Michael Lando4b9b9472018-06-02 19:14:05 +030090 chmod -R 777 ${WORKSPACE}/data/logs
Grinberg Motic3bda482017-02-23 11:24:34 +020091}
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +030092#
93
Yuli Shlosberg36604c72018-02-25 16:03:45 +020094
Yuli Shlosbergb4deec12018-02-25 20:24:44 +020095function docker_logs {
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +030096 docker logs $1 > ${WORKSPACE}/data/logs/docker_logs/$1_docker.log
Yuli Shlosbergb4deec12018-02-25 20:24:44 +020097}
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +030098#
Yuli Shlosbergb4deec12018-02-25 20:24:44 +020099
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300100
101#
102# Readiness Prob
103#
104
105function ready_probe {
Michael Lando4b9b9472018-06-02 19:14:05 +0300106 docker exec $1 /var/lib/ready-probe.sh > /dev/null 2>&1
107 rc=$?
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300108 if [[ ${rc} == 0 ]]; then
109 echo DOCKER $1 start finished in $2 seconds
110 return ${SUCCESS}
Michael Lando4b9b9472018-06-02 19:14:05 +0300111 fi
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300112 return ${FAILURE}
Yuli Shlosberg0875ce02018-01-25 13:53:36 +0200113}
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300114#
Yuli Shlosberg0875ce02018-01-25 13:53:36 +0200115
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200116
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300117function probe_docker {
118 MATCH=`docker logs --tail 30 $1 | grep "DOCKER STARTED"`
119 echo MATCH is -- ${MATCH}
Avi Zivc175a0d2018-03-15 13:21:44 +0200120
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300121 if [ -n "$MATCH" ] ; then
122 echo DOCKER start finished in $2 seconds
123 return ${SUCCESS}
Michael Lando4b9b9472018-06-02 19:14:05 +0300124 fi
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300125 return ${FAILURE}
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200126}
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300127#
128
kaihlavi02f48802019-07-30 19:23:52 +0300129function probe_test_docker {
130 # This expected logging should be output by startup.sh of the
131 # respective test docker container
132 MATCH=`docker logs --tail 30 $1 | grep "Startup completed successfully"`
133 echo MATCH is -- ${MATCH}
134
135 if [ -n "$MATCH" ] ; then
136 echo TEST DOCKER start finished in $2 seconds
137 return ${SUCCESS}
138 fi
139 return ${FAILURE}
140}
141#
142
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200143
144function probe_es {
Michael Lando4b9b9472018-06-02 19:14:05 +0300145 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 +0300146 if [[ "$health_Check_http_code" -eq 200 ]] ; then
147 echo DOCKER start finished in $1 seconds
148 return ${SUCCESS}
149 fi
150 return ${FAILURE}
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200151}
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300152#
153
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200154
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200155function probe_sim {
Michael Lando4b9b9472018-06-02 19:14:05 +0300156 if lsof -Pi :8285 -sTCP:LISTEN -t >/dev/null ; then
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300157 echo "Already running"
158 return ${SUCCESS}
Michael Lando4b9b9472018-06-02 19:14:05 +0300159 else
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300160 echo "Not running"
161 return ${FAILURE}
Michael Lando4b9b9472018-06-02 19:14:05 +0300162 fi
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200163}
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300164#
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200165
Yuli Shlosberg0875ce02018-01-25 13:53:36 +0200166
Yuli Shlosberg5571a862017-10-03 18:18:51 +0300167function monitor_docker {
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300168 DOCKER_NAME=$1
169 echo "Monitor ${DOCKER_NAME} Docker"
Idan Amitdb3d5542017-12-07 11:33:32 +0200170 sleep 5
171 TIME_OUT=900
172 INTERVAL=20
173 TIME=0
Avi Zivc175a0d2018-03-15 13:21:44 +0200174
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300175 while [ "$TIME" -lt "$TIME_OUT" ]; do
176
177 case ${DOCKER_NAME} in
178
179 sdc-cs)
180 ready_probe ${DOCKER_NAME} ${TIME} ;
181 status=$? ;
182 ;;
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300183 sdc-BE)
kaihlavi02f48802019-07-30 19:23:52 +0300184 ready_probe ${DOCKER_NAME} ${TIME} ;
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300185 status=$? ;
186 ;;
187 sdc-FE)
188 ready_probe ${DOCKER_NAME} ${TIME} ;
189 status=$? ;
190 ;;
191 sdc-onboard-BE)
192 ready_probe ${DOCKER_NAME} ${TIME} ;
193 status=$? ;
194 ;;
kaihlavi02f48802019-07-30 19:23:52 +0300195 sdc-api-tests)
196 probe_test_docker ${DOCKER_NAME} ${TIME};
197 status=$? ;
198 ;;
199 sdc-ui-tests)
200 probe_test_docker ${DOCKER_NAME} ${TIME};
201 status=$? ;
202 ;;
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300203 *)
204 probe_docker ${DOCKER_NAME} ${TIME};
205 status=$? ;
206 ;;
207
208 esac
209
k.kedron3643cc52019-08-28 15:01:51 +0200210 if [[ ${status} == ${SUCCESS} ]] ; then
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300211 break;
Idan Amitdb3d5542017-12-07 11:33:32 +0200212 fi
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300213
214 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"
215 sleep ${INTERVAL}
Idan Amitdb3d5542017-12-07 11:33:32 +0200216 TIME=$(($TIME+$INTERVAL))
217 done
Yuli Shlosberg5571a862017-10-03 18:18:51 +0300218
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300219 docker_logs ${DOCKER_NAME}
Yuli Shlosberg36604c72018-02-25 16:03:45 +0200220
Idan Amitdb3d5542017-12-07 11:33:32 +0200221 if [ "$TIME" -ge "$TIME_OUT" ]; then
222 echo -e "\e[1;31mTIME OUT: DOCKER was NOT fully started in $TIME_OUT seconds... Could cause problems ...\e[0m"
223 fi
Yuli Shlosberg5571a862017-10-03 18:18:51 +0300224}
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300225#
226
k.kedron3643cc52019-08-28 15:01:51 +0200227# healthCheck script used the secure connection to send request (https is always turn on)
Yuli Shlosbergd1bb2e52018-01-15 11:51:21 +0200228function healthCheck {
Yuli Shlosberg474996a2018-02-27 18:55:25 +0200229 curl --noproxy "*" ${IP}:9200/_cluster/health?pretty=true
Yuli Shlosbergd1bb2e52018-01-15 11:51:21 +0200230
kaihlavi900985e2019-06-06 14:52:02 +0300231 echo "BE Health Check:"
k.kedron3643cc52019-08-28 15:01:51 +0200232 curl -k --noproxy "*" https://${IP}:8443/sdc2/rest/healthCheck
Yuli Shlosbergd1bb2e52018-01-15 11:51:21 +0200233
234 echo ""
235 echo ""
kaihlavi900985e2019-06-06 14:52:02 +0300236 echo "FE Health Check:"
k.kedron3643cc52019-08-28 15:01:51 +0200237 curl -k --noproxy "*" https://${IP}:9443/sdc1/rest/healthCheck
Yuli Shlosbergd1bb2e52018-01-15 11:51:21 +0200238
239
240 echo ""
241 echo ""
k.kedron3643cc52019-08-28 15:01:51 +0200242 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 +0300243 if [[ ${healthCheck_http_code} != 200 ]]; then
kaihlavi900985e2019-06-06 14:52:02 +0300244 echo "Error [${healthCheck_http_code}] while checking existence of user"
Yuli Shlosbergd1bb2e52018-01-15 11:51:21 +0200245 return ${healthCheck_http_code}
246 fi
kaihlavi900985e2019-06-06 14:52:02 +0300247 echo "check user existence: OK"
Yuli Shlosbergd1bb2e52018-01-15 11:51:21 +0200248 return ${healthCheck_http_code}
249}
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300250#
Yuli Shlosbergd1bb2e52018-01-15 11:51:21 +0200251
Tal Gitelmane224d0b2017-10-17 15:24:25 +0300252
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300253function command_exit_status {
254 status=$1
255 docker=$2
256 if [ "${status}" != "0" ] ; then
257 echo "[ ERROR ] Docker ${docker} run command exit with status [${status}]"
258 fi
259}
260#
261
262
263#
264# Run Containers
265#
266
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300267
268#Cassandra
269function sdc-cs {
270 DOCKER_NAME="sdc-cs"
271 echo "docker run sdc-cassandra..."
272 if [ ${LOCAL} = false ]; then
273 docker pull ${PREFIX}/sdc-cassandra:${RELEASE}
274 fi
shrek20000594c412020-01-30 14:52:49 +0200275 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 ${CS_PORT}:${CS_PORT} ${PREFIX}/sdc-cassandra:${RELEASE} /bin/sh
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300276 command_exit_status $? ${DOCKER_NAME}
277 echo "please wait while CS is starting..."
278 monitor_docker ${DOCKER_NAME}
279}
280#
281
282
283#Cassandra-init
284function sdc-cs-init {
285 DOCKER_NAME="sdc-cs-init"
286 echo "docker run sdc-cassandra-init..."
287 if [ ${LOCAL} = false ]; then
288 docker pull ${PREFIX}/sdc-cassandra-init:${RELEASE}
289 fi
290 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
291 rc=$?
292 docker_logs ${DOCKER_NAME}
293 if [[ ${rc} != 0 ]]; then exit ${rc}; fi
294}
295#
296
297
298#Onboard Cassandra-init
299function sdc-cs-onboard-init {
300 DOCKER_NAME="sdc-cs-onboard-init"
301 echo "docker run sdc-cs-onboard-init..."
302 if [ ${LOCAL} = false ]; then
303 docker pull ${PREFIX}/sdc-onboard-cassandra-init:${RELEASE}
304 fi
shrek20000594c412020-01-30 14:52:49 +0200305 docker run --name ${DOCKER_NAME} --env RELEASE="${RELEASE}" --env CS_HOST_IP=${IP} --env CS_HOST_PORT=${CS_PORT} --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}
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300306 rc=$?
307 docker_logs ${DOCKER_NAME}
308 if [[ ${rc} != 0 ]]; then exit ${rc}; fi
309}
310#
311
312
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300313#Back-End
314function sdc-BE {
315 DOCKER_NAME="sdc-BE"
316 echo "docker run sdc-backend..."
317 if [ ${LOCAL} = false ]; then
318 docker pull ${PREFIX}/sdc-backend:${RELEASE}
319 else
Tal Gitelmanef4b94e2018-08-02 17:11:25 +0300320 ADDITIONAL_ARGUMENTS=${BE_DEBUG_PORT}
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300321 fi
andre.schmidfa1db432019-10-29 17:18:22 +0000322 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 +0300323 command_exit_status $? ${DOCKER_NAME}
324 echo "please wait while BE is starting..."
325 monitor_docker ${DOCKER_NAME}
326}
327#
328
329
330# Back-End-Init
331function sdc-BE-init {
332 DOCKER_NAME="sdc-BE-init"
333 echo "docker run sdc-backend-init..."
334 if [ ${LOCAL} = false ]; then
335 docker pull ${PREFIX}/sdc-backend-init:${RELEASE}
336 fi
andre.schmidfa1db432019-10-29 17:18:22 +0000337 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 +0300338 rc=$?
339 docker_logs ${DOCKER_NAME}
340 if [[ ${rc} != 0 ]]; then exit ${rc}; fi
341}
342#
343
344
345# Onboard Back-End
346function sdc-onboard-BE {
347 DOCKER_NAME="sdc-onboard-BE"
348 echo "docker run sdc-onboard-BE ..."
349# TODO Check the dir_perms action . do we need it here ??
350# dir_perms
351 if [ ${LOCAL} = false ]; then
352 docker pull ${PREFIX}/sdc-onboard-backend:${RELEASE}
353 else
354 ADDITIONAL_ARGUMENTS=${ONBOARD_DEBUG_PORT}
355 fi
andre.schmidfa1db432019-10-29 17:18:22 +0000356 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 +0300357 command_exit_status $? ${DOCKER_NAME}
358 echo "please wait while sdc-onboard-BE is starting..."
359 monitor_docker ${DOCKER_NAME}
360}
361#
362
363
364# Front-End
365function sdc-FE {
366 DOCKER_NAME="sdc-FE"
367 echo "docker run sdc-frontend..."
368 if [ ${LOCAL} = false ]; then
369 docker pull ${PREFIX}/sdc-frontend:${RELEASE}
Tal Gitelmanef4b94e2018-08-02 17:11:25 +0300370 else
371 ADDITIONAL_ARGUMENTS=${FE_DEBUG_PORT}
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300372 fi
andre.schmidfa1db432019-10-29 17:18:22 +0000373 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 +0300374 command_exit_status $? ${DOCKER_NAME}
375 echo "please wait while FE is starting....."
376 monitor_docker ${DOCKER_NAME}
377}
378#
379
380
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300381# apis-sanity
382function sdc-api-tests {
383 if [[ ${RUN_API_TESTS} = true ]] ; then
Yuli Shlosbergd0eaeca2018-07-19 17:54:15 +0300384 healthCheck
385 healthCheck_http_code=$?
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300386 if [[ ${healthCheck_http_code} == 200 ]] ; then
387 echo "docker run sdc-api-tests..."
388 echo "Trigger sdc-api-tests docker, please wait..."
389
390 if [ ${LOCAL} = false ]; then
391 docker pull ${PREFIX}/sdc-api-tests:${RELEASE}
392 fi
393
AndyWalshec1835f32019-04-25 11:20:38 +0000394 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 +0300395 monitor_docker sdc-api-tests
396 fi
397 fi
398}
399#
400
401
402# ui-sanity
403function sdc-ui-tests {
404
405 if [[ ${RUN_UI_TESTS} = true ]] ; then
Yuli Shlosbergd0eaeca2018-07-19 17:54:15 +0300406 healthCheck
407 healthCheck_http_code=$?
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300408 if [[ ${healthCheck_http_code} == 200 ]]; then
409 echo "docker run sdc-ui-tets..."
410 echo "Trigger sdc-ui-tests docker, please wait..."
411
412 if [ ${LOCAL} = false ]; then
413 docker pull ${PREFIX}/sdc-ui-tests:${RELEASE}
414 fi
Michael Landodc856bb2018-08-13 13:27:52 +0300415 RUN_SIMULATOR=true;
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300416 sdc-sim
417 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}
418 echo "please wait while SDC-UI-TESTS is starting....."
419 monitor_docker sdc-ui-tests
420 fi
421 fi
422}
423#
424
425
426# SDC-Simulator
427function sdc-sim {
Lianhao Lu26166842018-09-07 10:42:10 +0800428 if [ "${RUN_SIMULATOR}" == true ]; then
Michael Landodc856bb2018-08-13 13:27:52 +0300429 echo "docker run sdc-webSimulator..."
430 if [ ${LOCAL} = false ]; then
431 docker pull ${PREFIX}/sdc-simulator:${RELEASE}
432 fi
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300433
Michael Landodc856bb2018-08-13 13:27:52 +0300434 probe_sim
435 sim_stat=$?
Michael Landob751c962018-08-20 11:34:04 +0300436 if [ ${sim_stat} == 1 ]; then
Michael Landodc856bb2018-08-13 13:27:52 +0300437 docker run \
438 --detach \
439 --name sdc-sim \
440 --env FE_URL="${FE_URL}" \
441 --env JAVA_OPTIONS="${SIM_JAVA_OPTIONS}" \
442 --env ENVNAME="${DEP_ENV}" \
443 ${LOCAL_TIME_MOUNT_CMD} \
andre.schmidfa1db432019-10-29 17:18:22 +0000444 --volume ${WORKSPACE}/data/logs/WS/:${JETTY_BASE}/logs \
Michael Landodc856bb2018-08-13 13:27:52 +0300445 --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments \
446 --publish 8285:8080 \
447 --publish 8286:8443 ${PREFIX}/sdc-simulator:${RELEASE}
448 echo "please wait while SDC-WEB-SIMULATOR is starting....."
449 monitor_docker sdc-sim
450 fi
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300451 fi
452}
453#
454
455
456#
457# Main
458#
459
460# Handle command line arguments
Idan Amitdb3d5542017-12-07 11:33:32 +0200461while [ $# -gt 0 ]; do
Michael Lando451a3402017-02-19 10:28:42 +0200462 case $1 in
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300463
Idan Amitdb3d5542017-12-07 11:33:32 +0200464 # -r | --release - The specific docker version to pull and deploy
Yuli Shlosberg0566f582017-11-26 19:05:23 +0200465 -r | --release )
466 shift 1 ;
467 RELEASE=$1;
468 shift 1;;
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300469
Idan Amitdb3d5542017-12-07 11:33:32 +0200470 # -e | --environment - The environment name you want to deploy
Yuli Shlosberg0566f582017-11-26 19:05:23 +0200471 -e | --environment )
472 shift 1;
473 DEP_ENV=$1;
474 shift 1 ;;
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300475
Idan Amitdb3d5542017-12-07 11:33:32 +0200476 # -p | --port - The port from which to connect to the docker nexus
Yuli Shlosberg0566f582017-11-26 19:05:23 +0200477 -p | --port )
478 shift 1 ;
479 PORT=$1;
480 shift 1 ;;
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300481
Idan Amitdb3d5542017-12-07 11:33:32 +0200482 # -l | --local - Use this for deploying your local dockers without pulling them first
Yuli Shlosberg0566f582017-11-26 19:05:23 +0200483 -l | --local )
484 LOCAL=true;
485 shift 1;;
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300486
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200487 # -ta - Use this for running the APIs sanity docker after all other dockers have been deployed
488 -ta )
489 shift 1 ;
490 API_SUITE=$1;
491 RUN_API_TESTS=true;
492 shift 1 ;;
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300493
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200494 # -tu - Use this for running the UI sanity docker after all other dockers have been deployed
495 -tu )
496 shift 1 ;
497 UI_SUITE=$1;
498 RUN_UI_TESTS=true;
499 shift 1 ;;
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300500
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200501 # -tad - Use this for running the DEFAULT suite of tests in APIs sanity docker after all other dockers have been deployed
502 -tad | -t )
503 API_SUITE="onapApiSanity";
504 RUN_API_TESTS=true;
505 shift 1 ;;
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300506
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200507 # -tud - Use this for running the DEFAULT suite of tests in UI sanity docker after all other dockers have been deployed
508 -tud )
509 UI_SUITE="onapUiSanity";
510 RUN_UI_TESTS=true;
Yuli Shlosberg0566f582017-11-26 19:05:23 +0200511 shift 1 ;;
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300512
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200513 # -d | --docker - The init specified docker
514 -d | --docker )
515 shift 1 ;
516 DOCKER=$1;
517 shift 1 ;;
Michael Landodc856bb2018-08-13 13:27:52 +0300518 # -sim | --simulator run the simulator
519 -sim | --simulator )
kaihlavib2372712019-05-27 16:28:23 +0300520 RUN_SIMULATOR=true;
521 shift 1 ;;
Michael Landodc856bb2018-08-13 13:27:52 +0300522 # -sim | --simulator run the simulator
523 -u | --fe_url )
kaihlavib2372712019-05-27 16:28:23 +0300524 shift 1 ;
525 FE_URL=$1;
526 shift 1 ;;
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300527
Idan Amitdb3d5542017-12-07 11:33:32 +0200528 # -h | --help - Display the help message with all the available run options
Yuli Shlosberg0566f582017-11-26 19:05:23 +0200529 -h | --help )
530 usage;
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300531 exit ${SUCCESS};;
532
Yuli Shlosberg0566f582017-11-26 19:05:23 +0200533 * )
534 usage;
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300535 exit ${FAILURE};;
Michael Lando451a3402017-02-19 10:28:42 +0200536 esac
Michael Lando451a3402017-02-19 10:28:42 +0200537done
538
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300539
liang dingd73c2872018-09-27 19:07:02 -0700540#Prefix those with WORKSPACE so it can be set to something other than /opt
dekstroza83520062018-05-03 16:47:08 +0100541[ -f ${WORKSPACE}/opt/config/env_name.txt ] && DEP_ENV=$(cat ${WORKSPACE}/opt/config/env_name.txt) || echo ${DEP_ENV}
542[ -f ${WORKSPACE}/opt/config/nexus_username.txt ] && NEXUS_USERNAME=$(cat ${WORKSPACE}/opt/config/nexus_username.txt) || NEXUS_USERNAME=release
543[ -f ${WORKSPACE}/opt/config/nexus_password.txt ] && NEXUS_PASSWD=$(cat ${WORKSPACE}/opt/config/nexus_password.txt) || NEXUS_PASSWD=sfWU3DFVdBr7GVxB85mTYgAW
544[ -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}
545[ -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 +0200546
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300547
Yuli Shlosbergd1bb2e52018-01-15 11:51:21 +0200548export IP=`ip route get 8.8.8.8 | awk '/src/{ print $7 }'`
dekstroza83520062018-05-03 16:47:08 +0100549#If OSX, then use this to get IP
550if [[ "$OSTYPE" == "darwin"* ]]; then
551 export IP=$(ipconfig getifaddr en0)
552fi
Idan Amitdb3d5542017-12-07 11:33:32 +0200553export PREFIX=${NEXUS_DOCKER_REPO}'/onap'
Idan Amitc7f57ec2017-08-31 14:26:21 +0300554
555if [ ${LOCAL} = true ]; then
Idan Amitdb3d5542017-12-07 11:33:32 +0200556 PREFIX='onap'
Idan Amitc7f57ec2017-08-31 14:26:21 +0300557fi
Michael Lando451a3402017-02-19 10:28:42 +0200558
559echo ""
560
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200561if [ -z "${DOCKER}" ]; then
k.kedron3643cc52019-08-28 15:01:51 +0200562 cleanup all
563 dir_perms
k.kedron3643cc52019-08-28 15:01:51 +0200564 sdc-cs
565 sdc-cs-init
k.kedron3643cc52019-08-28 15:01:51 +0200566 sdc-cs-onboard-init
567 sdc-onboard-BE
568 sdc-BE
569 sdc-BE-init
570 sdc-FE
571 healthCheck
572 sdc-sim
573 sdc-api-tests
574 sdc-ui-tests
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200575else
k.kedron3643cc52019-08-28 15:01:51 +0200576 cleanup ${DOCKER}
577 dir_perms
578 ${DOCKER}
579 healthCheck
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200580fi