3 CS_PASSWORD="onap123#@!"
5 SDC_PASSWORD="Aa1234%^!"
6 JETTY_BASE="/var/lib/jetty"
7 BE_JAVA_OPTIONS="-Xdebug -agentlib:jdwp=transport=dt_socket,address=4000,server=y,suspend=n -Xmx2g -Xms2g"
8 FE_JAVA_OPTIONS="-Xdebug -agentlib:jdwp=transport=dt_socket,address=6000,server=y,suspend=n -Xmx512m -Xms512m"
12 echo "usage: docker_run.sh [ -r|--release <RELEASE-NAME> ] [ -e|--environment <ENV-NAME> ] [ -p|--port <Docker-hub-port>] [ -l|--local <Run-without-pull>] [ -t|--runTests <Run-with-sanityDocker>] [ -h|--help ]"
17 echo "performing old dockers cleanup"
19 if [ "$1" == "all" ] ; then
20 docker_ids=`docker ps -a | egrep -v "openecomp/sdc-simulator" | egrep "ecomp-nexus:${PORT}/sdc|sdc|Exit" | awk '{print $1}'`
21 for X in ${docker_ids}
26 echo "performing $1 docker cleanup"
27 tmp=`docker ps -a -q --filter="name=$1"`
28 if [[ ! -z "$tmp" ]]; then
36 mkdir -p ${WORKSPACE}/data/logs/BE/SDC/SDC-BE
37 mkdir -p ${WORKSPACE}/data/logs/FE/SDC/SDC-FE
38 chmod -R 777 ${WORKSPACE}/data/logs
43 docker exec -it $1 /var/lib/ready-probe.sh > /dev/null 2>&1
45 if [[ $rc == 0 ]]; then
46 echo DOCKER start finished in $2 seconds
55 docker exec -it $1 /var/lib/ready-probe.sh > /dev/null 2>&1
57 if [[ $rc == 200 ]]; then
58 echo DOCKER start finished in $2 seconds
67 docker exec -it $1 /var/lib/ready-probe.sh > /dev/null 2>&1
69 if [[ $rc == 200 ]]; then
70 echo DOCKER start finished in $2 seconds
79 health_Check_http_code=$(curl -o /dev/null -w '%{http_code}' http://${IP}:9200/_cluster/health?wait_for_status=yellow&timeout=120s)
80 if [[ "$health_Check_http_code" -eq 200 ]]
82 echo DOCKER start finished in $2 seconds
88 function probe_docker {
91 MATCH=`docker logs --tail 30 $1 | grep "DOCKER STARTED"`
92 echo MATCH is -- $MATCH
94 if [ -n "$MATCH" ]; then
95 echo DOCKER start finished in $2 seconds
99 function monitor_docker {
101 echo monitor $1 Docker
106 while [ "$TIME" -lt "$TIME_OUT" ]; do
107 if [ "$1" == "sdc-cs" ]; then
109 if [[ $cs_stat == true ]]; then break; fi
110 elif [ "$1" == "sdc-es" ]; then
112 if [[ $es_stat == true ]]; then break; fi
113 elif [ "$1" == "sdc-BE" ]; then
115 if [[ $be_stat == true ]]; then break; fi
116 elif [ "$1" == "sdc-FE" ]; then
118 if [[ $fe_stat == true ]]; then break; fi
120 probe_docker $1 $TIME
121 if [[ $match_result == true ]]; then break; fi
123 echo Sleep: $INTERVAL seconds before testing if $1 DOCKER is up. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds
125 TIME=$(($TIME+$INTERVAL))
128 if [ "$TIME" -ge "$TIME_OUT" ]; then
129 echo -e "\e[1;31mTIME OUT: DOCKER was NOT fully started in $TIME_OUT seconds... Could cause problems ...\e[0m"
134 function healthCheck {
135 curl ${IP}:9200/_cluster/health?pretty=true
137 echo "BE health-Check:"
138 curl http://${IP}:8080/sdc2/rest/healthCheck
142 echo "FE health-Check:"
143 curl http://${IP}:8181/sdc1/rest/healthCheck
148 healthCheck_http_code=$(curl -o /dev/null -w '%{http_code}' -H "Accept: application/json" -H "Content-Type: application/json" -H "USER_ID: jh0003" http://${IP}:8080/sdc2/rest/v1/user/demo;)
149 if [[ ${healthCheck_http_code} != 200 ]]
151 echo "Error [${healthCheck_http_code}] while user existance check"
152 return ${healthCheck_http_code}
154 echo "check user existance: OK"
155 return ${healthCheck_http_code}
158 function elasticHealthCheck {
159 echo "Elastic Health-Check:"
162 while [ $COUNTER -lt 20 ]; do
163 echo "Waiting ES docker to start"
164 health_Check_http_code=$(curl -o /dev/null -w '%{http_code}' http://localhost:9200/_cluster/health?wait_for_status=yellow&timeout=120s)
165 if [[ "$health_Check_http_code" -eq 200 ]]
169 let COUNTER=COUNTER+1
173 healthCheck_http_code=$(curl -o /dev/null -w '%{http_code}' http://localhost:9200/_cluster/health?wait_for_status=yellow&timeout=120s)
174 if [[ "$health_Check_http_code" != 200 ]]
176 echo "Error [${healthCheck_http_code}] ES NOT started correctly"
177 exit ${healthCheck_http_code}
179 echo "ES started correctly"
180 curl ${IP}:9200/_cluster/health?pretty=true
181 return ${healthCheck_http_code}
187 DEBUG_PORT="--publish 4000:4000"
189 while [ $# -gt 0 ]; do
191 # -r | --release - The specific docker version to pull and deploy
196 # -e | --environment - The environment name you want to deploy
201 # -p | --port - The port from which to connect to the docker nexus
206 # -l | --local - Use this for deploying your local dockers without pulling them first
210 # -t | --runTests - Use this for running the sanity tests docker after all other dockers have been deployed
214 # -d | --docker - The init specified docker
219 # -h | --help - Display the help message with all the available run options
230 [ -f /opt/config/env_name.txt ] && DEP_ENV=$(cat /opt/config/env_name.txt) || echo ${DEP_ENV}
231 [ -f /opt/config/nexus_username.txt ] && NEXUS_USERNAME=$(cat /opt/config/nexus_username.txt) || NEXUS_USERNAME=release
232 [ -f /opt/config/nexus_password.txt ] && NEXUS_PASSWD=$(cat /opt/config/nexus_password.txt) || NEXUS_PASSWD=sfWU3DFVdBr7GVxB85mTYgAW
233 [ -f /opt/config/nexus_docker_repo.txt ] && NEXUS_DOCKER_REPO=$(cat /opt/config/nexus_docker_repo.txt) || NEXUS_DOCKER_REPO=nexus3.onap.org:${PORT}
234 [ -f /opt/config/nexus_username.txt ] && docker login -u $NEXUS_USERNAME -p $NEXUS_PASSWD $NEXUS_DOCKER_REPO
236 export IP=`ip route get 8.8.8.8 | awk '/src/{ print $7 }'`
237 export PREFIX=${NEXUS_DOCKER_REPO}'/onap'
239 if [ ${LOCAL} = true ]; then
250 echo "docker run sdc-elasticsearch..."
251 if [ ${LOCAL} = false ]; then
253 docker pull ${PREFIX}/sdc-elasticsearch:${RELEASE}
255 docker run -dit --name sdc-es --env ENVNAME="${DEP_ENV}" --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --env ES_JAVA_OPTS="-Xms512m -Xmx512m" --ulimit memlock=-1:-1 --ulimit nofile=4096:100000 --volume /etc/localtime:/etc/localtime:ro --env ES_HEAP_SIZE=1024M --volume ${WORKSPACE}/data/ES:/usr/share/elasticsearch/data --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments --publish 9200:9200 --publish 9300:9300 ${PREFIX}/sdc-elasticsearch:${RELEASE} /bin/sh
257 echo "please wait while ES is starting..."
258 monitor_docker sdc-es
261 function sdc-init-es {
262 # Init-Elastic-Search
263 echo "docker run sdc-init-elasticsearch..."
264 if [ ${LOCAL} = false ]; then
266 docker pull ${PREFIX}/sdc-init-elasticsearch:${RELEASE}
268 docker run --name sdc-init-es --env ENVNAME="${DEP_ENV}" --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --ulimit nofile=4096:100000 --volume /etc/localtime:/etc/localtime:ro --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments ${PREFIX}/sdc-init-elasticsearch:${RELEASE}
270 if [[ $rc != 0 ]]; then exit $rc; fi
276 echo "docker run sdc-cassandra..."
277 if [ ${LOCAL} = false ]; then
278 docker pull ${PREFIX}/sdc-cassandra:${RELEASE}
280 docker run -dit --name sdc-cs --env RELEASE="${RELEASE}" --env CS_PASSWORD="${CS_PASSWORD}" --env ENVNAME="${DEP_ENV}" --env HOST_IP=${IP} --env MAX_HEAP_SIZE="2024M" --env HEAP_NEWSIZE="512M" --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --ulimit nofile=4096:100000 --volume /etc/localtime:/etc/localtime:ro --volume ${WORKSPACE}/data/CS:/var/lib/cassandra --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments --publish 9042:9042 --publish 9160:9160 ${PREFIX}/sdc-cassandra:${RELEASE} /bin/sh
283 echo "please wait while CS is starting..."
284 monitor_docker sdc-cs
287 function sdc-cs-init {
289 echo "docker run sdc-cassandra-init..."
290 if [ ${LOCAL} = false ]; then
291 docker pull ${PREFIX}/sdc-cassandra-init:${RELEASE}
293 docker run --name sdc-cs-init --env RELEASE="${RELEASE}" --env SDC_USER="${SDC_USER}" --env SDC_PASSWORD="${SDC_PASSWORD}" --env CS_PASSWORD="${CS_PASSWORD}" --env ENVNAME="${DEP_ENV}" --env HOST_IP=${IP} --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --ulimit nofile=4096:100000 --volume /etc/localtime:/etc/localtime:ro --volume ${WORKSPACE}/data/CS:/var/lib/cassandra --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments --volume ${WORKSPACE}/data/CS-Init:/root/chef-solo/cache ${PREFIX}/sdc-cassandra-init:${RELEASE}
295 if [[ $rc != 0 ]]; then exit $rc; fi
300 echo "docker run sdc-kibana..."
301 if [ ${LOCAL} = false ]; then
302 docker pull ${PREFIX}/sdc-kibana:${RELEASE}
303 docker run --detach --name sdc-kbn --env ENVNAME="${DEP_ENV}" --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --ulimit nofile=4096:100000 --volume /etc/localtime:/etc/localtime:ro --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments --publish 5601:5601 ${PREFIX}/sdc-kibana:${RELEASE}
313 echo "docker run sdc-backend..."
314 if [ ${LOCAL} = false ]; then
315 docker pull ${PREFIX}/sdc-backend:${RELEASE}
317 ADDITIONAL_ARGUMENTS=${DEBUG_PORT}
319 docker run --detach --name sdc-BE --env HOST_IP=${IP} --env ENVNAME="${DEP_ENV}" --env http_proxy=${http_proxy} --env https_proxy=${https_proxy} --env no_proxy=${no_proxy} --env JAVA_OPTIONS="${BE_JAVA_OPTIONS}" --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --ulimit nofile=4096:100000 --volume /etc/localtime:/etc/localtime:ro --volume ${WORKSPACE}/data/logs/BE/:/var/lib/jetty/logs --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments --publish 8443:8443 --publish 8080:8080 ${ADDITIONAL_ARGUMENTS} ${PREFIX}/sdc-backend:${RELEASE}
321 echo "please wait while BE is starting..."
322 monitor_docker sdc-BE
325 function sdc-BE-init {
329 echo "docker run sdc-backend-init..."
330 if [ ${LOCAL} = false ]; then
331 docker pull ${PREFIX}/sdc-backend-init:${RELEASE}
333 docker run --name sdc-BE-init --env HOST_IP=${IP} --env ENVNAME="${DEP_ENV}" --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --ulimit nofile=4096:100000 --volume /etc/localtime:/etc/localtime:ro --volume ${WORKSPACE}/data/logs/BE/:/var/lib/jetty/logs --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments ${PREFIX}/sdc-backend-init:${RELEASE}
335 if [[ $rc != 0 ]]; then exit $rc; fi
341 echo "docker run sdc-frontend..."
342 if [ ${LOCAL} = false ]; then
343 docker pull ${PREFIX}/sdc-frontend:${RELEASE}
345 docker run --detach --name sdc-FE --env HOST_IP=${IP} --env ENVNAME="${DEP_ENV}" --env http_proxy=${http_proxy} --env https_proxy=${https_proxy} --env no_proxy=${no_proxy} --env JAVA_OPTIONS="${FE_JAVA_OPTIONS}" --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --ulimit nofile=4096:100000 --volume /etc/localtime:/etc/localtime:ro --volume ${WORKSPACE}/data/logs/FE/:/var/lib/jetty/logs --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments --publish 9443:9443 --publish 8181:8181 ${PREFIX}/sdc-frontend:${RELEASE}
347 echo "please wait while FE is starting....."
348 monitor_docker sdc-FE
353 function sdc-sanity {
355 if [[ (${RUNTESTS} = true) && (${healthCheck_http_code} == 200) ]]; then
356 echo "docker run sdc-sanity..."
357 echo "Triger sanity docker, please wait..."
359 if [ ${LOCAL} = false ]; then
360 docker pull ${PREFIX}/sdc-sanity:${RELEASE}
363 docker run --detach --name sdc-sanity --env HOST_IP=${IP} --env ENVNAME="${DEP_ENV}" --env http_proxy=${http_proxy} --env https_proxy=${https_proxy} --env no_proxy=${no_proxy} --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --ulimit nofile=4096:100000 --volume /etc/localtime:/etc/localtime:ro --volume ${WORKSPACE}/data/logs/sdc-sanity/target:/var/lib/tests/target --volume ${WORKSPACE}/data/logs/sdc-sanity/ExtentReport:/var/lib/tests/ExtentReport --volume ${WORKSPACE}/data/logs/sdc-sanity/outputCsar:/var/lib/tests/outputCsar --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments --publish 9560:9560 ${PREFIX}/sdc-sanity:${RELEASE}
364 echo "please wait while SANITY is starting....."
365 monitor_docker sdc-sanity
370 if [ -z "${DOCKER}" ]; then