blob: d3de8039b4505f6eeb8e513b15fd76e878d91a0b [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
k.kedroncb30f3a2020-03-05 13:12:27 +010026OS_USER="onap"
27
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +030028
29# Java Options:
vasrazb08ac292021-10-21 17:32:16 +010030BE_JAVA_OPTIONS="-Xdebug -agentlib:jdwp=transport=dt_socket,address=*:4000,server=y,suspend=n -Xmx1536m -Xms1536m"
31FE_JAVA_OPTIONS="-Xdebug -agentlib:jdwp=transport=dt_socket,address=*:6000,server=y,suspend=n -Xmx256m -Xms256m"
32ONBOARD_BE_JAVA_OPTIONS="-Xdebug -agentlib:jdwp=transport=dt_socket,address=*:4001,server=y,suspend=n -Xmx1g -Xms1g"
amohamad9ee60942020-06-26 12:40:11 -040033SIM_JAVA_OPTIONS=" -Xmx128m -Xms128m -Xss1m -Dlog4j.configuration=file:///${JETTY_BASE}/config/sdc-simulator/log4j2.properties"
Yuli Shlosbergf59a2252018-03-21 11:14:08 +020034API_TESTS_JAVA_OPTIONS="-Xmx512m -Xms512m"
35UI_TESTS_JAVA_OPTIONS="-Xmx1024m -Xms1024m"
dekstroza83520062018-05-03 16:47:08 +010036#Define this as variable, so it can be excluded in run commands on Docker for OSX, as /etc/localtime cant be mounted there.
37LOCAL_TIME_MOUNT_CMD="--volume /etc/localtime:/etc/localtime:ro"
38# If os is OSX, unset this, so /etc/localtime is not mounted, otherwise leave it be
39if [[ "$OSTYPE" == "darwin"* ]]; then
40 LOCAL_TIME_MOUNT_CMD=""
41fi
42
43
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +030044#
45# Functions:
46#
47
Michael Lando451a3402017-02-19 10:28:42 +020048
Grinberg Motic3bda482017-02-23 11:24:34 +020049function usage {
kaihlavi900985e2019-06-06 14:52:02 +030050 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 +030051 echo "start dockers built locally example: docker_run.sh -l"
52 echo "start dockers built locally and simulator example: docker_run.sh -l -sim"
kaihlavib2372712019-05-27 16:28:23 +030053 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 +030054 echo "start dockers built locally and run api tests docker example: docker_run.sh -l -tad"
55 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 +020056}
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +030057#
Michael Lando451a3402017-02-19 10:28:42 +020058
59
Grinberg Motic3bda482017-02-23 11:24:34 +020060function cleanup {
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +030061 echo "Performing old dockers cleanup"
Yuli Shlosberg958c32d2018-02-15 12:04:46 +020062
63 if [ "$1" == "all" ] ; then
k.kedron3643cc52019-08-28 15:01:51 +020064 docker_ids=`docker ps -a | egrep "ecomp-nexus:${PORT}/sdc|sdc|Exit}|dcae" | awk '{print $1}'`
Yuli Shlosberg958c32d2018-02-15 12:04:46 +020065 for X in ${docker_ids}
66 do
67 docker rm -f ${X}
68 done
69 else
70 echo "performing $1 docker cleanup"
71 tmp=`docker ps -a -q --filter="name=$1"`
Yuli Shlosberg474996a2018-02-27 18:55:25 +020072 if [[ ! -z "$tmp" ]]; then
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +030073 docker rm -f ${tmp}
74 fi
Yuli Shlosberg958c32d2018-02-15 12:04:46 +020075 fi
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 +020078
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +030079
Grinberg Motic3bda482017-02-23 11:24:34 +020080function dir_perms {
Michael Lando4b9b9472018-06-02 19:14:05 +030081 mkdir -p ${WORKSPACE}/data/logs/BE/SDC/SDC-BE
82 mkdir -p ${WORKSPACE}/data/logs/FE/SDC/SDC-FE
83 mkdir -p ${WORKSPACE}/data/logs/sdc-api-tests/ExtentReport
84 mkdir -p ${WORKSPACE}/data/logs/ONBOARD/SDC/ONBOARD-BE
kaihlavi900985e2019-06-06 14:52:02 +030085 mkdir -p ${WORKSPACE}/data/logs/sdc-api-tests/target
86 mkdir -p ${WORKSPACE}/data/logs/sdc-ui-tests/ExtentReport
87 mkdir -p ${WORKSPACE}/data/logs/sdc-ui-tests/target
88 mkdir -p ${WORKSPACE}/data/logs/docker_logs
89 mkdir -p ${WORKSPACE}/data/logs/WS
andre.schmidfa1db432019-10-29 17:18:22 +000090 echo "Creating dir '${WORKSPACE}/data/${SDC_CERT_DIR}'"
kaihlavi900985e2019-06-06 14:52:02 +030091 mkdir -p ${WORKSPACE}/data/${SDC_CERT_DIR}
Michael Lando4b9b9472018-06-02 19:14:05 +030092 chmod -R 777 ${WORKSPACE}/data/logs
Grinberg Motic3bda482017-02-23 11:24:34 +020093}
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +030094#
95
Yuli Shlosberg36604c72018-02-25 16:03:45 +020096
Yuli Shlosbergb4deec12018-02-25 20:24:44 +020097function docker_logs {
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +030098 docker logs $1 > ${WORKSPACE}/data/logs/docker_logs/$1_docker.log
Yuli Shlosbergb4deec12018-02-25 20:24:44 +020099}
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300100#
Yuli Shlosbergb4deec12018-02-25 20:24:44 +0200101
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300102
103#
104# Readiness Prob
105#
106
107function ready_probe {
Michael Lando4b9b9472018-06-02 19:14:05 +0300108 docker exec $1 /var/lib/ready-probe.sh > /dev/null 2>&1
109 rc=$?
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300110 if [[ ${rc} == 0 ]]; then
111 echo DOCKER $1 start finished in $2 seconds
112 return ${SUCCESS}
Michael Lando4b9b9472018-06-02 19:14:05 +0300113 fi
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300114 return ${FAILURE}
Yuli Shlosberg0875ce02018-01-25 13:53:36 +0200115}
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300116#
Yuli Shlosberg0875ce02018-01-25 13:53:36 +0200117
MichaelMorrisa2abf6e2020-03-10 12:37:48 +0000118function ready_probe_jetty {
119 docker exec $1 /var/lib/jetty/ready-probe.sh > /dev/null 2>&1
120 rc=$?
121 if [[ ${rc} == 0 ]]; then
122 echo DOCKER $1 start finished in $2 seconds
123 return ${SUCCESS}
124 fi
125 return ${FAILURE}
126}
127#
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200128
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300129function probe_docker {
130 MATCH=`docker logs --tail 30 $1 | grep "DOCKER STARTED"`
131 echo MATCH is -- ${MATCH}
Avi Zivc175a0d2018-03-15 13:21:44 +0200132
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300133 if [ -n "$MATCH" ] ; then
134 echo DOCKER start finished in $2 seconds
135 return ${SUCCESS}
Michael Lando4b9b9472018-06-02 19:14:05 +0300136 fi
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300137 return ${FAILURE}
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200138}
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300139#
140
kaihlavi02f48802019-07-30 19:23:52 +0300141function probe_test_docker {
142 # This expected logging should be output by startup.sh of the
143 # respective test docker container
144 MATCH=`docker logs --tail 30 $1 | grep "Startup completed successfully"`
145 echo MATCH is -- ${MATCH}
146
147 if [ -n "$MATCH" ] ; then
148 echo TEST DOCKER start finished in $2 seconds
149 return ${SUCCESS}
150 fi
151 return ${FAILURE}
152}
153#
154
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200155
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200156function probe_sim {
Michael Lando4b9b9472018-06-02 19:14:05 +0300157 if lsof -Pi :8285 -sTCP:LISTEN -t >/dev/null ; then
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300158 echo "Already running"
159 return ${SUCCESS}
Michael Lando4b9b9472018-06-02 19:14:05 +0300160 else
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300161 echo "Not running"
162 return ${FAILURE}
Michael Lando4b9b9472018-06-02 19:14:05 +0300163 fi
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200164}
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300165#
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200166
Yuli Shlosberg0875ce02018-01-25 13:53:36 +0200167
Yuli Shlosberg5571a862017-10-03 18:18:51 +0300168function monitor_docker {
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300169 DOCKER_NAME=$1
170 echo "Monitor ${DOCKER_NAME} Docker"
Idan Amitdb3d5542017-12-07 11:33:32 +0200171 sleep 5
172 TIME_OUT=900
173 INTERVAL=20
174 TIME=0
Avi Zivc175a0d2018-03-15 13:21:44 +0200175
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300176 while [ "$TIME" -lt "$TIME_OUT" ]; do
177
178 case ${DOCKER_NAME} in
179
180 sdc-cs)
181 ready_probe ${DOCKER_NAME} ${TIME} ;
182 status=$? ;
183 ;;
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300184 sdc-BE)
MichaelMorrisa2abf6e2020-03-10 12:37:48 +0000185 ready_probe_jetty ${DOCKER_NAME} ${TIME} ;
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300186 status=$? ;
187 ;;
188 sdc-FE)
MichaelMorrisa2abf6e2020-03-10 12:37:48 +0000189 ready_probe_jetty ${DOCKER_NAME} ${TIME} ;
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300190 status=$? ;
191 ;;
192 sdc-onboard-BE)
MichaelMorrisa2abf6e2020-03-10 12:37:48 +0000193 ready_probe_jetty ${DOCKER_NAME} ${TIME} ;
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300194 status=$? ;
195 ;;
kaihlavi02f48802019-07-30 19:23:52 +0300196 sdc-api-tests)
197 probe_test_docker ${DOCKER_NAME} ${TIME};
198 status=$? ;
199 ;;
200 sdc-ui-tests)
201 probe_test_docker ${DOCKER_NAME} ${TIME};
202 status=$? ;
203 ;;
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300204 *)
205 probe_docker ${DOCKER_NAME} ${TIME};
206 status=$? ;
207 ;;
208
209 esac
210
k.kedron3643cc52019-08-28 15:01:51 +0200211 if [[ ${status} == ${SUCCESS} ]] ; then
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300212 break;
Idan Amitdb3d5542017-12-07 11:33:32 +0200213 fi
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300214
215 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"
216 sleep ${INTERVAL}
Idan Amitdb3d5542017-12-07 11:33:32 +0200217 TIME=$(($TIME+$INTERVAL))
218 done
Yuli Shlosberg5571a862017-10-03 18:18:51 +0300219
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300220 docker_logs ${DOCKER_NAME}
Yuli Shlosberg36604c72018-02-25 16:03:45 +0200221
Idan Amitdb3d5542017-12-07 11:33:32 +0200222 if [ "$TIME" -ge "$TIME_OUT" ]; then
223 echo -e "\e[1;31mTIME OUT: DOCKER was NOT fully started in $TIME_OUT seconds... Could cause problems ...\e[0m"
224 fi
Yuli Shlosberg5571a862017-10-03 18:18:51 +0300225}
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300226#
227
k.kedron3643cc52019-08-28 15:01:51 +0200228# healthCheck script used the secure connection to send request (https is always turn on)
Yuli Shlosbergd1bb2e52018-01-15 11:51:21 +0200229function healthCheck {
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
MichaelMorrisa2abf6e2020-03-10 12:37:48 +0000290 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:/home/sdc/chef-solo/environments --volume ${WORKSPACE}/data/CS-Init:/root/chef-solo/cache ${PREFIX}/sdc-cassandra-init:${RELEASE} > /dev/null 2>&1
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300291 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
MichaelMorrisa2abf6e2020-03-10 12:37:48 +0000305 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:/home/sdc/chef-solo/environments --volume ${WORKSPACE}/data/CS-Init:/home/sdc/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"
andre.schmid662fcba2020-08-21 11:31:47 +0100316 IMAGE_NAME="sdc-backend"
317 IMAGE_FULL_NAME="$PREFIX/$IMAGE_NAME:$RELEASE"
318 echo "Running container '$DOCKER_NAME' based on image '$IMAGE_FULL_NAME'..."
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300319 if [ ${LOCAL} = false ]; then
andre.schmid662fcba2020-08-21 11:31:47 +0100320 docker pull "$IMAGE_FULL_NAME"
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300321 else
andre.schmid662fcba2020-08-21 11:31:47 +0100322 ADDITIONAL_ARGUMENTS=${BE_DEBUG_PORT}
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300323 fi
andre.schmid662fcba2020-08-21 11:31:47 +0100324
325 docker run --detach --name ${DOCKER_NAME} --env HOST_IP=${IP} \
326 --env ENVNAME="${DEP_ENV}" --env cassandra_ssl_enabled="false" --env JAVA_OPTIONS="${BE_JAVA_OPTIONS}" \
327 --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 \
328 --ulimit memlock=-1:-1 --ulimit nofile=4096:100000 ${LOCAL_TIME_MOUNT_CMD} \
329 --volume ${WORKSPACE}/data/logs/BE/:${JETTY_BASE}/logs \
330 --volume ${WORKSPACE}/data/environments:${JETTY_BASE}/chef-solo/environments \
331 --volume "${WORKSPACE}/data/sdc-backend/plugins":${JETTY_BASE}/plugins \
332 --publish 8443:8443 --publish 8080:8080 \
333 ${ADDITIONAL_ARGUMENTS} \
334 "$IMAGE_FULL_NAME"
335
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300336 command_exit_status $? ${DOCKER_NAME}
andre.schmid662fcba2020-08-21 11:31:47 +0100337 echo "please wait while $DOCKER_NAME is starting..."
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300338 monitor_docker ${DOCKER_NAME}
339}
340#
341
342
343# Back-End-Init
344function sdc-BE-init {
345 DOCKER_NAME="sdc-BE-init"
346 echo "docker run sdc-backend-init..."
347 if [ ${LOCAL} = false ]; then
348 docker pull ${PREFIX}/sdc-backend-init:${RELEASE}
349 fi
k.kedroncb30f3a2020-03-05 13:12:27 +0100350 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:/home/${OS_USER}/chef-solo/environments ${PREFIX}/sdc-backend-init:${RELEASE} > /dev/null 2>&1
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300351 rc=$?
352 docker_logs ${DOCKER_NAME}
353 if [[ ${rc} != 0 ]]; then exit ${rc}; fi
354}
355#
356
357
358# Onboard Back-End
359function sdc-onboard-BE {
360 DOCKER_NAME="sdc-onboard-BE"
361 echo "docker run sdc-onboard-BE ..."
362# TODO Check the dir_perms action . do we need it here ??
363# dir_perms
364 if [ ${LOCAL} = false ]; then
365 docker pull ${PREFIX}/sdc-onboard-backend:${RELEASE}
366 else
367 ADDITIONAL_ARGUMENTS=${ONBOARD_DEBUG_PORT}
368 fi
MichaelMorrisa2abf6e2020-03-10 12:37:48 +0000369 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:/${JETTY_BASE}/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 +0300370 command_exit_status $? ${DOCKER_NAME}
371 echo "please wait while sdc-onboard-BE is starting..."
372 monitor_docker ${DOCKER_NAME}
373}
374#
375
376
377# Front-End
378function sdc-FE {
379 DOCKER_NAME="sdc-FE"
Dmitry Puzikov0574f882020-03-05 18:03:15 +0100380 IMAGE_NAME="${PREFIX}/sdc-frontend:${RELEASE}"
381 echo "Running container '${DOCKER_NAME}' based on '${IMAGE_NAME}' image..."
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300382 if [ ${LOCAL} = false ]; then
383 docker pull ${PREFIX}/sdc-frontend:${RELEASE}
Tal Gitelmanef4b94e2018-08-02 17:11:25 +0300384 else
385 ADDITIONAL_ARGUMENTS=${FE_DEBUG_PORT}
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300386 fi
Dmitry Puzikov0574f882020-03-05 18:03:15 +0100387
388 PLUGIN_CONFIG_FILE="${WORKSPACE}/data/environments/plugins-configuration.yaml"
389 if [[ -f ${WORKSPACE}/data/environments/plugins-configuration.yaml ]]; then
390 PLUGINS_CONF_VOLUME_MOUNT="--volume ${PLUGIN_CONFIG_FILE}:${JETTY_BASE}/config/catalog-fe/plugins-configuration.yaml"
391 else
392 echo "INFO: '${PLUGIN_CONFIG_FILE}' not provided, ignoring..."
393 fi
394
395 docker run \
396 --detach \
397 --name ${DOCKER_NAME} \
398 --env HOST_IP=${IP} \
399 --env ENVNAME="${DEP_ENV}" \
400 --env JAVA_OPTIONS="${FE_JAVA_OPTIONS}" \
401 --log-driver=json-file \
402 --log-opt max-size=100m \
403 --log-opt max-file=10 \
404 --ulimit memlock=-1:-1 \
405 --ulimit nofile=4096:100000 \
406 --volume ${WORKSPACE}/data/logs/FE/:${JETTY_BASE}/logs \
MichaelMorrisa2abf6e2020-03-10 12:37:48 +0000407 --volume ${WORKSPACE}/data/environments:/${JETTY_BASE}/chef-solo/environments \
Dmitry Puzikov0574f882020-03-05 18:03:15 +0100408 ${LOCAL_TIME_MOUNT_CMD} \
409 ${PLUGINS_CONF_VOLUME_MOUNT} \
410 --publish 9443:9443 \
411 --publish 8181:8181 \
412 ${ADDITIONAL_ARGUMENTS} \
413 ${IMAGE_NAME}
414
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300415 command_exit_status $? ${DOCKER_NAME}
Dmitry Puzikov0574f882020-03-05 18:03:15 +0100416 echo "Please wait while '${DOCKER_NAME}' container is starting..."
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300417 monitor_docker ${DOCKER_NAME}
418}
419#
420
421
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300422# apis-sanity
423function sdc-api-tests {
424 if [[ ${RUN_API_TESTS} = true ]] ; then
Yuli Shlosbergd0eaeca2018-07-19 17:54:15 +0300425 healthCheck
426 healthCheck_http_code=$?
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300427 if [[ ${healthCheck_http_code} == 200 ]] ; then
428 echo "docker run sdc-api-tests..."
429 echo "Trigger sdc-api-tests docker, please wait..."
430
431 if [ ${LOCAL} = false ]; then
432 docker pull ${PREFIX}/sdc-api-tests:${RELEASE}
433 fi
434
AndyWalshec1835f32019-04-25 11:20:38 +0000435 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 +0300436 monitor_docker sdc-api-tests
437 fi
438 fi
439}
440#
441
442
443# ui-sanity
444function sdc-ui-tests {
445
446 if [[ ${RUN_UI_TESTS} = true ]] ; then
Yuli Shlosbergd0eaeca2018-07-19 17:54:15 +0300447 healthCheck
448 healthCheck_http_code=$?
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300449 if [[ ${healthCheck_http_code} == 200 ]]; then
450 echo "docker run sdc-ui-tets..."
451 echo "Trigger sdc-ui-tests docker, please wait..."
452
453 if [ ${LOCAL} = false ]; then
454 docker pull ${PREFIX}/sdc-ui-tests:${RELEASE}
455 fi
Michael Landodc856bb2018-08-13 13:27:52 +0300456 RUN_SIMULATOR=true;
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300457 sdc-sim
458 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}
459 echo "please wait while SDC-UI-TESTS is starting....."
460 monitor_docker sdc-ui-tests
461 fi
462 fi
463}
464#
465
466
467# SDC-Simulator
468function sdc-sim {
Lianhao Lu26166842018-09-07 10:42:10 +0800469 if [ "${RUN_SIMULATOR}" == true ]; then
Michael Landodc856bb2018-08-13 13:27:52 +0300470 echo "docker run sdc-webSimulator..."
471 if [ ${LOCAL} = false ]; then
472 docker pull ${PREFIX}/sdc-simulator:${RELEASE}
473 fi
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300474
Michael Landodc856bb2018-08-13 13:27:52 +0300475 probe_sim
476 sim_stat=$?
Michael Landob751c962018-08-20 11:34:04 +0300477 if [ ${sim_stat} == 1 ]; then
Michael Landodc856bb2018-08-13 13:27:52 +0300478 docker run \
479 --detach \
480 --name sdc-sim \
481 --env FE_URL="${FE_URL}" \
482 --env JAVA_OPTIONS="${SIM_JAVA_OPTIONS}" \
483 --env ENVNAME="${DEP_ENV}" \
484 ${LOCAL_TIME_MOUNT_CMD} \
andre.schmidfa1db432019-10-29 17:18:22 +0000485 --volume ${WORKSPACE}/data/logs/WS/:${JETTY_BASE}/logs \
Michael Landodc856bb2018-08-13 13:27:52 +0300486 --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments \
487 --publish 8285:8080 \
488 --publish 8286:8443 ${PREFIX}/sdc-simulator:${RELEASE}
489 echo "please wait while SDC-WEB-SIMULATOR is starting....."
490 monitor_docker sdc-sim
491 fi
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300492 fi
493}
494#
495
496
497#
498# Main
499#
500
501# Handle command line arguments
Idan Amitdb3d5542017-12-07 11:33:32 +0200502while [ $# -gt 0 ]; do
Michael Lando451a3402017-02-19 10:28:42 +0200503 case $1 in
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300504
Idan Amitdb3d5542017-12-07 11:33:32 +0200505 # -r | --release - The specific docker version to pull and deploy
Yuli Shlosberg0566f582017-11-26 19:05:23 +0200506 -r | --release )
507 shift 1 ;
508 RELEASE=$1;
509 shift 1;;
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300510
Idan Amitdb3d5542017-12-07 11:33:32 +0200511 # -e | --environment - The environment name you want to deploy
Yuli Shlosberg0566f582017-11-26 19:05:23 +0200512 -e | --environment )
513 shift 1;
514 DEP_ENV=$1;
515 shift 1 ;;
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300516
Idan Amitdb3d5542017-12-07 11:33:32 +0200517 # -p | --port - The port from which to connect to the docker nexus
Yuli Shlosberg0566f582017-11-26 19:05:23 +0200518 -p | --port )
519 shift 1 ;
520 PORT=$1;
521 shift 1 ;;
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300522
Idan Amitdb3d5542017-12-07 11:33:32 +0200523 # -l | --local - Use this for deploying your local dockers without pulling them first
Yuli Shlosberg0566f582017-11-26 19:05:23 +0200524 -l | --local )
525 LOCAL=true;
526 shift 1;;
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300527
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200528 # -ta - Use this for running the APIs sanity docker after all other dockers have been deployed
529 -ta )
530 shift 1 ;
531 API_SUITE=$1;
532 RUN_API_TESTS=true;
533 shift 1 ;;
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300534
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200535 # -tu - Use this for running the UI sanity docker after all other dockers have been deployed
536 -tu )
537 shift 1 ;
538 UI_SUITE=$1;
539 RUN_UI_TESTS=true;
540 shift 1 ;;
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300541
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200542 # -tad - Use this for running the DEFAULT suite of tests in APIs sanity docker after all other dockers have been deployed
543 -tad | -t )
544 API_SUITE="onapApiSanity";
545 RUN_API_TESTS=true;
546 shift 1 ;;
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300547
Yuli Shlosbergf59a2252018-03-21 11:14:08 +0200548 # -tud - Use this for running the DEFAULT suite of tests in UI sanity docker after all other dockers have been deployed
549 -tud )
550 UI_SUITE="onapUiSanity";
551 RUN_UI_TESTS=true;
Yuli Shlosberg0566f582017-11-26 19:05:23 +0200552 shift 1 ;;
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300553
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200554 # -d | --docker - The init specified docker
555 -d | --docker )
556 shift 1 ;
557 DOCKER=$1;
558 shift 1 ;;
Michael Landodc856bb2018-08-13 13:27:52 +0300559 # -sim | --simulator run the simulator
560 -sim | --simulator )
kaihlavib2372712019-05-27 16:28:23 +0300561 RUN_SIMULATOR=true;
562 shift 1 ;;
Michael Landodc856bb2018-08-13 13:27:52 +0300563 # -sim | --simulator run the simulator
564 -u | --fe_url )
kaihlavib2372712019-05-27 16:28:23 +0300565 shift 1 ;
566 FE_URL=$1;
567 shift 1 ;;
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300568
Idan Amitdb3d5542017-12-07 11:33:32 +0200569 # -h | --help - Display the help message with all the available run options
Yuli Shlosberg0566f582017-11-26 19:05:23 +0200570 -h | --help )
571 usage;
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300572 exit ${SUCCESS};;
573
Yuli Shlosberg0566f582017-11-26 19:05:23 +0200574 * )
575 usage;
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300576 exit ${FAILURE};;
Michael Lando451a3402017-02-19 10:28:42 +0200577 esac
Michael Lando451a3402017-02-19 10:28:42 +0200578done
579
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300580
liang dingd73c2872018-09-27 19:07:02 -0700581#Prefix those with WORKSPACE so it can be set to something other than /opt
dekstroza83520062018-05-03 16:47:08 +0100582[ -f ${WORKSPACE}/opt/config/env_name.txt ] && DEP_ENV=$(cat ${WORKSPACE}/opt/config/env_name.txt) || echo ${DEP_ENV}
583[ -f ${WORKSPACE}/opt/config/nexus_username.txt ] && NEXUS_USERNAME=$(cat ${WORKSPACE}/opt/config/nexus_username.txt) || NEXUS_USERNAME=release
584[ -f ${WORKSPACE}/opt/config/nexus_password.txt ] && NEXUS_PASSWD=$(cat ${WORKSPACE}/opt/config/nexus_password.txt) || NEXUS_PASSWD=sfWU3DFVdBr7GVxB85mTYgAW
585[ -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}
586[ -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 +0200587
Areli, Fuss (af732p)062d4c12018-06-03 18:49:19 +0300588
Yuli Shlosbergd1bb2e52018-01-15 11:51:21 +0200589export IP=`ip route get 8.8.8.8 | awk '/src/{ print $7 }'`
dekstroza83520062018-05-03 16:47:08 +0100590#If OSX, then use this to get IP
591if [[ "$OSTYPE" == "darwin"* ]]; then
592 export IP=$(ipconfig getifaddr en0)
593fi
Idan Amitdb3d5542017-12-07 11:33:32 +0200594export PREFIX=${NEXUS_DOCKER_REPO}'/onap'
Idan Amitc7f57ec2017-08-31 14:26:21 +0300595
596if [ ${LOCAL} = true ]; then
Idan Amitdb3d5542017-12-07 11:33:32 +0200597 PREFIX='onap'
Idan Amitc7f57ec2017-08-31 14:26:21 +0300598fi
Michael Lando451a3402017-02-19 10:28:42 +0200599
600echo ""
601
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200602if [ -z "${DOCKER}" ]; then
k.kedron3643cc52019-08-28 15:01:51 +0200603 cleanup all
604 dir_perms
k.kedron3643cc52019-08-28 15:01:51 +0200605 sdc-cs
606 sdc-cs-init
k.kedron3643cc52019-08-28 15:01:51 +0200607 sdc-cs-onboard-init
608 sdc-onboard-BE
609 sdc-BE
610 sdc-BE-init
611 sdc-FE
612 healthCheck
613 sdc-sim
614 sdc-api-tests
615 sdc-ui-tests
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200616else
k.kedron3643cc52019-08-28 15:01:51 +0200617 cleanup ${DOCKER}
618 dir_perms
619 ${DOCKER}
620 healthCheck
Yuli Shlosberg958c32d2018-02-15 12:04:46 +0200621fi