7 WORKSPACE="${WORKSPACE:-}"
11 CS_PASSWORD="onap123#@!"
13 SDC_PASSWORD="Aa1234%^!"
15 JETTY_BASE="/var/lib/jetty"
16 SDC_CERT_DIR="onap/cert"
21 BE_DEBUG_PORT="--publish 4000:4000"
22 FE_DEBUG_PORT="--publish 6000:6000"
23 ONBOARD_DEBUG_PORT="--publish 4001:4001"
24 CS_PORT=${CS_PORT:-9042}
28 BE_JAVA_OPTIONS="-Xdebug -agentlib:jdwp=transport=dt_socket,address=4000,server=y,suspend=n -Xmx1536m -Xms1536m"
29 FE_JAVA_OPTIONS="-Xdebug -agentlib:jdwp=transport=dt_socket,address=6000,server=y,suspend=n -Xmx256m -Xms256m"
30 ONBOARD_BE_JAVA_OPTIONS="-Xdebug -agentlib:jdwp=transport=dt_socket,address=4001,server=y,suspend=n -Xmx1g -Xms1g"
31 SIM_JAVA_OPTIONS=" -Xmx128m -Xms128m -Xss1m -Dlog4j.configuration=file:///${JETTY_BASE}/config/sdc-simulator/log4j.properties"
32 API_TESTS_JAVA_OPTIONS="-Xmx512m -Xms512m"
33 UI_TESTS_JAVA_OPTIONS="-Xmx1024m -Xms1024m"
34 #Define this as variable, so it can be excluded in run commands on Docker for OSX, as /etc/localtime cant be mounted there.
35 LOCAL_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
37 if [[ "$OSTYPE" == "darwin"* ]]; then
38 LOCAL_TIME_MOUNT_CMD=""
48 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 ]"
49 echo "start dockers built locally example: docker_run.sh -l"
50 echo "start dockers built locally and simulator example: docker_run.sh -l -sim"
51 echo "start dockers, pull from onap nexus according to release and simulator example: docker_run.sh -r 1.5-STAGING-latest -sim"
52 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 "
59 echo "Performing old dockers cleanup"
61 if [ "$1" == "all" ] ; then
62 docker_ids=`docker ps -a | egrep "ecomp-nexus:${PORT}/sdc|sdc|Exit}|dcae" | awk '{print $1}'`
63 for X in ${docker_ids}
68 echo "performing $1 docker cleanup"
69 tmp=`docker ps -a -q --filter="name=$1"`
70 if [[ ! -z "$tmp" ]]; then
79 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
83 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
88 echo "Creating dir '${WORKSPACE}/data/${SDC_CERT_DIR}'"
89 mkdir -p ${WORKSPACE}/data/${SDC_CERT_DIR}
90 chmod -R 777 ${WORKSPACE}/data/logs
95 function docker_logs {
96 docker logs $1 > ${WORKSPACE}/data/logs/docker_logs/$1_docker.log
105 function ready_probe {
106 docker exec $1 /var/lib/ready-probe.sh > /dev/null 2>&1
108 if [[ ${rc} == 0 ]]; then
109 echo DOCKER $1 start finished in $2 seconds
116 function ready_probe_jetty {
117 docker exec $1 /var/lib/jetty/ready-probe.sh > /dev/null 2>&1
119 if [[ ${rc} == 0 ]]; then
120 echo DOCKER $1 start finished in $2 seconds
127 function probe_docker {
128 MATCH=`docker logs --tail 30 $1 | grep "DOCKER STARTED"`
129 echo MATCH is -- ${MATCH}
131 if [ -n "$MATCH" ] ; then
132 echo DOCKER start finished in $2 seconds
139 function probe_test_docker {
140 # This expected logging should be output by startup.sh of the
141 # respective test docker container
142 MATCH=`docker logs --tail 30 $1 | grep "Startup completed successfully"`
143 echo MATCH is -- ${MATCH}
145 if [ -n "$MATCH" ] ; then
146 echo TEST DOCKER start finished in $2 seconds
155 health_Check_http_code=$(curl --noproxy "*" -o /dev/null -w '%{http_code}' http://${IP}:9200/_cluster/health?wait_for_status=yellow&timeout=120s)
156 if [[ "$health_Check_http_code" -eq 200 ]] ; then
157 echo DOCKER start finished in $1 seconds
166 if lsof -Pi :8285 -sTCP:LISTEN -t >/dev/null ; then
167 echo "Already running"
177 function monitor_docker {
179 echo "Monitor ${DOCKER_NAME} Docker"
185 while [ "$TIME" -lt "$TIME_OUT" ]; do
187 case ${DOCKER_NAME} in
190 ready_probe ${DOCKER_NAME} ${TIME} ;
194 ready_probe_jetty ${DOCKER_NAME} ${TIME} ;
198 ready_probe_jetty ${DOCKER_NAME} ${TIME} ;
202 ready_probe_jetty ${DOCKER_NAME} ${TIME} ;
206 probe_test_docker ${DOCKER_NAME} ${TIME};
210 probe_test_docker ${DOCKER_NAME} ${TIME};
214 probe_docker ${DOCKER_NAME} ${TIME};
220 if [[ ${status} == ${SUCCESS} ]] ; then
224 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"
226 TIME=$(($TIME+$INTERVAL))
229 docker_logs ${DOCKER_NAME}
231 if [ "$TIME" -ge "$TIME_OUT" ]; then
232 echo -e "\e[1;31mTIME OUT: DOCKER was NOT fully started in $TIME_OUT seconds... Could cause problems ...\e[0m"
237 # healthCheck script used the secure connection to send request (https is always turn on)
238 function healthCheck {
239 curl --noproxy "*" ${IP}:9200/_cluster/health?pretty=true
241 echo "BE Health Check:"
242 curl -k --noproxy "*" https://${IP}:8443/sdc2/rest/healthCheck
246 echo "FE Health Check:"
247 curl -k --noproxy "*" https://${IP}:9443/sdc1/rest/healthCheck
252 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;)
253 if [[ ${healthCheck_http_code} != 200 ]]; then
254 echo "Error [${healthCheck_http_code}] while checking existence of user"
255 return ${healthCheck_http_code}
257 echo "check user existence: OK"
258 return ${healthCheck_http_code}
263 function command_exit_status {
266 if [ "${status}" != "0" ] ; then
267 echo "[ ERROR ] Docker ${docker} run command exit with status [${status}]"
281 echo "docker run sdc-cassandra..."
282 if [ ${LOCAL} = false ]; then
283 docker pull ${PREFIX}/sdc-cassandra:${RELEASE}
285 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
286 command_exit_status $? ${DOCKER_NAME}
287 echo "please wait while CS is starting..."
288 monitor_docker ${DOCKER_NAME}
294 function sdc-cs-init {
295 DOCKER_NAME="sdc-cs-init"
296 echo "docker run sdc-cassandra-init..."
297 if [ ${LOCAL} = false ]; then
298 docker pull ${PREFIX}/sdc-cassandra-init:${RELEASE}
300 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
302 docker_logs ${DOCKER_NAME}
303 if [[ ${rc} != 0 ]]; then exit ${rc}; fi
308 #Onboard Cassandra-init
309 function sdc-cs-onboard-init {
310 DOCKER_NAME="sdc-cs-onboard-init"
311 echo "docker run sdc-cs-onboard-init..."
312 if [ ${LOCAL} = false ]; then
313 docker pull ${PREFIX}/sdc-onboard-cassandra-init:${RELEASE}
315 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}
317 docker_logs ${DOCKER_NAME}
318 if [[ ${rc} != 0 ]]; then exit ${rc}; fi
326 echo "docker run sdc-backend..."
327 if [ ${LOCAL} = false ]; then
328 docker pull ${PREFIX}/sdc-backend:${RELEASE}
330 ADDITIONAL_ARGUMENTS=${BE_DEBUG_PORT}
332 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:${JETTY_BASE}/chef-solo/environments --publish 8443:8443 --publish 8080:8080 ${ADDITIONAL_ARGUMENTS} ${PREFIX}/sdc-backend:${RELEASE}
333 command_exit_status $? ${DOCKER_NAME}
334 echo "please wait while BE is starting..."
335 monitor_docker ${DOCKER_NAME}
341 function sdc-BE-init {
342 DOCKER_NAME="sdc-BE-init"
343 echo "docker run sdc-backend-init..."
344 if [ ${LOCAL} = false ]; then
345 docker pull ${PREFIX}/sdc-backend-init:${RELEASE}
347 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/sdc/chef-solo/environments ${PREFIX}/sdc-backend-init:${RELEASE} > /dev/null 2>&1
349 docker_logs ${DOCKER_NAME}
350 if [[ ${rc} != 0 ]]; then exit ${rc}; fi
356 function sdc-onboard-BE {
357 DOCKER_NAME="sdc-onboard-BE"
358 echo "docker run sdc-onboard-BE ..."
359 # TODO Check the dir_perms action . do we need it here ??
361 if [ ${LOCAL} = false ]; then
362 docker pull ${PREFIX}/sdc-onboard-backend:${RELEASE}
364 ADDITIONAL_ARGUMENTS=${ONBOARD_DEBUG_PORT}
366 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}
367 command_exit_status $? ${DOCKER_NAME}
368 echo "please wait while sdc-onboard-BE is starting..."
369 monitor_docker ${DOCKER_NAME}
377 IMAGE_NAME="${PREFIX}/sdc-frontend:${RELEASE}"
378 echo "Running container '${DOCKER_NAME}' based on '${IMAGE_NAME}' image..."
379 if [ ${LOCAL} = false ]; then
380 docker pull ${PREFIX}/sdc-frontend:${RELEASE}
382 ADDITIONAL_ARGUMENTS=${FE_DEBUG_PORT}
385 PLUGIN_CONFIG_FILE="${WORKSPACE}/data/environments/plugins-configuration.yaml"
386 if [[ -f ${WORKSPACE}/data/environments/plugins-configuration.yaml ]]; then
387 PLUGINS_CONF_VOLUME_MOUNT="--volume ${PLUGIN_CONFIG_FILE}:${JETTY_BASE}/config/catalog-fe/plugins-configuration.yaml"
389 echo "INFO: '${PLUGIN_CONFIG_FILE}' not provided, ignoring..."
394 --name ${DOCKER_NAME} \
395 --env HOST_IP=${IP} \
396 --env ENVNAME="${DEP_ENV}" \
397 --env JAVA_OPTIONS="${FE_JAVA_OPTIONS}" \
398 --log-driver=json-file \
399 --log-opt max-size=100m \
400 --log-opt max-file=10 \
401 --ulimit memlock=-1:-1 \
402 --ulimit nofile=4096:100000 \
403 --volume ${WORKSPACE}/data/logs/FE/:${JETTY_BASE}/logs \
404 --volume ${WORKSPACE}/data/environments:/${JETTY_BASE}/chef-solo/environments \
405 ${LOCAL_TIME_MOUNT_CMD} \
406 ${PLUGINS_CONF_VOLUME_MOUNT} \
407 --publish 9443:9443 \
408 --publish 8181:8181 \
409 ${ADDITIONAL_ARGUMENTS} \
412 command_exit_status $? ${DOCKER_NAME}
413 echo "Please wait while '${DOCKER_NAME}' container is starting..."
414 monitor_docker ${DOCKER_NAME}
420 function sdc-api-tests {
421 if [[ ${RUN_API_TESTS} = true ]] ; then
423 healthCheck_http_code=$?
424 if [[ ${healthCheck_http_code} == 200 ]] ; then
425 echo "docker run sdc-api-tests..."
426 echo "Trigger sdc-api-tests docker, please wait..."
428 if [ ${LOCAL} = false ]; then
429 docker pull ${PREFIX}/sdc-api-tests:${RELEASE}
432 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....."
433 monitor_docker sdc-api-tests
441 function sdc-ui-tests {
443 if [[ ${RUN_UI_TESTS} = true ]] ; then
445 healthCheck_http_code=$?
446 if [[ ${healthCheck_http_code} == 200 ]]; then
447 echo "docker run sdc-ui-tets..."
448 echo "Trigger sdc-ui-tests docker, please wait..."
450 if [ ${LOCAL} = false ]; then
451 docker pull ${PREFIX}/sdc-ui-tests:${RELEASE}
455 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}
456 echo "please wait while SDC-UI-TESTS is starting....."
457 monitor_docker sdc-ui-tests
466 if [ "${RUN_SIMULATOR}" == true ]; then
467 echo "docker run sdc-webSimulator..."
468 if [ ${LOCAL} = false ]; then
469 docker pull ${PREFIX}/sdc-simulator:${RELEASE}
474 if [ ${sim_stat} == 1 ]; then
478 --env FE_URL="${FE_URL}" \
479 --env JAVA_OPTIONS="${SIM_JAVA_OPTIONS}" \
480 --env ENVNAME="${DEP_ENV}" \
481 ${LOCAL_TIME_MOUNT_CMD} \
482 --volume ${WORKSPACE}/data/logs/WS/:${JETTY_BASE}/logs \
483 --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments \
484 --publish 8285:8080 \
485 --publish 8286:8443 ${PREFIX}/sdc-simulator:${RELEASE}
486 echo "please wait while SDC-WEB-SIMULATOR is starting....."
487 monitor_docker sdc-sim
498 # Handle command line arguments
499 while [ $# -gt 0 ]; do
502 # -r | --release - The specific docker version to pull and deploy
508 # -e | --environment - The environment name you want to deploy
514 # -p | --port - The port from which to connect to the docker nexus
520 # -l | --local - Use this for deploying your local dockers without pulling them first
525 # -ta - Use this for running the APIs sanity docker after all other dockers have been deployed
532 # -tu - Use this for running the UI sanity docker after all other dockers have been deployed
539 # -tad - Use this for running the DEFAULT suite of tests in APIs sanity docker after all other dockers have been deployed
541 API_SUITE="onapApiSanity";
545 # -tud - Use this for running the DEFAULT suite of tests in UI sanity docker after all other dockers have been deployed
547 UI_SUITE="onapUiSanity";
551 # -d | --docker - The init specified docker
556 # -sim | --simulator run the simulator
560 # -sim | --simulator run the simulator
566 # -h | --help - Display the help message with all the available run options
578 #Prefix those with WORKSPACE so it can be set to something other than /opt
579 [ -f ${WORKSPACE}/opt/config/env_name.txt ] && DEP_ENV=$(cat ${WORKSPACE}/opt/config/env_name.txt) || echo ${DEP_ENV}
580 [ -f ${WORKSPACE}/opt/config/nexus_username.txt ] && NEXUS_USERNAME=$(cat ${WORKSPACE}/opt/config/nexus_username.txt) || NEXUS_USERNAME=release
581 [ -f ${WORKSPACE}/opt/config/nexus_password.txt ] && NEXUS_PASSWD=$(cat ${WORKSPACE}/opt/config/nexus_password.txt) || NEXUS_PASSWD=sfWU3DFVdBr7GVxB85mTYgAW
582 [ -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}
583 [ -f ${WORKSPACE}/opt/config/nexus_username.txt ] && docker login -u $NEXUS_USERNAME -p $NEXUS_PASSWD $NEXUS_DOCKER_REPO
586 export IP=`ip route get 8.8.8.8 | awk '/src/{ print $7 }'`
587 #If OSX, then use this to get IP
588 if [[ "$OSTYPE" == "darwin"* ]]; then
589 export IP=$(ipconfig getifaddr en0)
591 export PREFIX=${NEXUS_DOCKER_REPO}'/onap'
593 if [ ${LOCAL} = true ]; then
599 if [ -z "${DOCKER}" ]; then