blob: e641594fc34d2088b82351d555e2026e53759aad [file] [log] [blame]
Ashish Singhac02a0e2020-07-08 13:34:12 +05301#!/bin/bash
2
3#
4# Constants:
5#
6
7WORKSPACE="${WORKSPACE:-}"
8SUCCESS=0
9FAILURE=1
10
11CS_PASSWORD="onap123#@!"
12SDC_USER="asdc_user"
13SDC_PASSWORD="Aa1234%^!"
14
15JETTY_BASE="/var/lib/jetty"
16SDC_CERT_DIR="onap/cert"
17
18RELEASE=latest
19
20LOCAL=false
21BE_DEBUG_PORT="--publish 4000:4000"
22FE_DEBUG_PORT="--publish 6000:6000"
23ONBOARD_DEBUG_PORT="--publish 4001:4001"
24CS_PORT=${CS_PORT:-9042}
25
26
27# Java Options:
28BE_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"
30ONBOARD_BE_JAVA_OPTIONS="-Xdebug -agentlib:jdwp=transport=dt_socket,address=4001,server=y,suspend=n -Xmx1g -Xms1g"
31SIM_JAVA_OPTIONS=" -Xmx128m -Xms128m -Xss1m -Dlog4j.configuration=file:///${JETTY_BASE}/config/sdc-simulator/log4j.properties"
32API_TESTS_JAVA_OPTIONS="-Xmx512m -Xms512m"
33UI_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.
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
42#
43# Functions:
44#
45
46
47function usage {
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 "
54}
55#
56
57
58function cleanup {
59 echo "Performing old dockers cleanup"
60
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}
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"`
70 if [[ ! -z "$tmp" ]]; then
71 docker rm -f ${tmp}
72 fi
73 fi
74}
75#
76
77
78function dir_perms {
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
91}
92#
93
94
95function docker_logs {
96 docker logs $1 > ${WORKSPACE}/data/logs/docker_logs/$1_docker.log
97}
98#
99
100
101#
102# Readiness Prob
103#
104
105function ready_probe {
106 docker exec $1 /var/lib/ready-probe.sh > /dev/null 2>&1
107 rc=$?
108 if [[ ${rc} == 0 ]]; then
109 echo DOCKER $1 start finished in $2 seconds
110 return ${SUCCESS}
111 fi
112 return ${FAILURE}
113}
114#
115
116function ready_probe_jetty {
117 docker exec $1 /var/lib/jetty/ready-probe.sh > /dev/null 2>&1
118 rc=$?
119 if [[ ${rc} == 0 ]]; then
120 echo DOCKER $1 start finished in $2 seconds
121 return ${SUCCESS}
122 fi
123 return ${FAILURE}
124}
125#
126
127function probe_docker {
128 MATCH=`docker logs --tail 30 $1 | grep "DOCKER STARTED"`
129 echo MATCH is -- ${MATCH}
130
131 if [ -n "$MATCH" ] ; then
132 echo DOCKER start finished in $2 seconds
133 return ${SUCCESS}
134 fi
135 return ${FAILURE}
136}
137#
138
139function 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}
144
145 if [ -n "$MATCH" ] ; then
146 echo TEST DOCKER start finished in $2 seconds
147 return ${SUCCESS}
148 fi
149 return ${FAILURE}
150}
151#
152
153
154function probe_sim {
155 if lsof -Pi :8285 -sTCP:LISTEN -t >/dev/null ; then
156 echo "Already running"
157 return ${SUCCESS}
158 else
159 echo "Not running"
160 return ${FAILURE}
161 fi
162}
163#
164
165
166function monitor_docker {
167 DOCKER_NAME=$1
168 echo "Monitor ${DOCKER_NAME} Docker"
169 sleep 5
170 TIME_OUT=900
171 INTERVAL=20
172 TIME=0
173
174 while [ "$TIME" -lt "$TIME_OUT" ]; do
175
176 case ${DOCKER_NAME} in
177
178 sdc-cs)
179 ready_probe ${DOCKER_NAME} ${TIME} ;
180 status=$? ;
181 ;;
182 sdc-BE)
183 ready_probe_jetty ${DOCKER_NAME} ${TIME} ;
184 status=$? ;
185 ;;
186 sdc-FE)
187 ready_probe_jetty ${DOCKER_NAME} ${TIME} ;
188 status=$? ;
189 ;;
190 sdc-onboard-BE)
191 ready_probe_jetty ${DOCKER_NAME} ${TIME} ;
192 status=$? ;
193 ;;
194 sdc-api-tests)
195 probe_test_docker ${DOCKER_NAME} ${TIME};
196 status=$? ;
197 ;;
198 sdc-ui-tests)
199 probe_test_docker ${DOCKER_NAME} ${TIME};
200 status=$? ;
201 ;;
202 *)
203 probe_docker ${DOCKER_NAME} ${TIME};
204 status=$? ;
205 ;;
206
207 esac
208
209 if [[ ${status} == ${SUCCESS} ]] ; then
210 break;
211 fi
212
213 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"
214 sleep ${INTERVAL}
215 TIME=$(($TIME+$INTERVAL))
216 done
217
218 docker_logs ${DOCKER_NAME}
219
220 if [ "$TIME" -ge "$TIME_OUT" ]; then
221 echo -e "\e[1;31mTIME OUT: DOCKER was NOT fully started in $TIME_OUT seconds... Could cause problems ...\e[0m"
222 fi
223}
224#
225
226# healthCheck script used the secure connection to send request (https is always turn on)
227function healthCheck {
228
229 echo "BE Health Check:"
230 curl -k --noproxy "*" https://${IP}:8443/sdc2/rest/healthCheck
231
232 echo ""
233 echo ""
234 echo "FE Health Check:"
235 curl -k --noproxy "*" https://${IP}:9443/sdc1/rest/healthCheck
236
237
238 echo ""
239 echo ""
240 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;)
241 if [[ ${healthCheck_http_code} != 200 ]]; then
242 echo "Error [${healthCheck_http_code}] while checking existence of user"
243 return ${healthCheck_http_code}
244 fi
245 echo "check user existence: OK"
246 return ${healthCheck_http_code}
247}
248#
249
250
251function command_exit_status {
252 status=$1
253 docker=$2
254 if [ "${status}" != "0" ] ; then
255 echo "[ ERROR ] Docker ${docker} run command exit with status [${status}]"
256 fi
257}
258#
259
260
261#
262# Run Containers
263#
264
265
266#Cassandra
267function sdc-cs {
268 DOCKER_NAME="sdc-cs"
269 echo "docker run sdc-cassandra..."
270 if [ ${LOCAL} = false ]; then
271 docker pull ${PREFIX}/sdc-cassandra:${RELEASE}
272 fi
273 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
274 command_exit_status $? ${DOCKER_NAME}
275 echo "please wait while CS is starting..."
276 monitor_docker ${DOCKER_NAME}
277}
278#
279
280
281#Cassandra-init
282function sdc-cs-init {
283 DOCKER_NAME="sdc-cs-init"
284 echo "docker run sdc-cassandra-init..."
285 if [ ${LOCAL} = false ]; then
286 docker pull ${PREFIX}/sdc-cassandra-init:${RELEASE}
287 fi
288 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
289 rc=$?
290 docker_logs ${DOCKER_NAME}
291 if [[ ${rc} != 0 ]]; then exit ${rc}; fi
292}
293#
294
295
296#Onboard Cassandra-init
297function sdc-cs-onboard-init {
298 DOCKER_NAME="sdc-cs-onboard-init"
299 echo "docker run sdc-cs-onboard-init..."
300 if [ ${LOCAL} = false ]; then
301 docker pull ${PREFIX}/sdc-onboard-cassandra-init:${RELEASE}
302 fi
303 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}
304 rc=$?
305 docker_logs ${DOCKER_NAME}
306 if [[ ${rc} != 0 ]]; then exit ${rc}; fi
307}
308#
309
310
311#Back-End
312function sdc-BE {
313 DOCKER_NAME="sdc-BE"
314 echo "docker run sdc-backend..."
315 if [ ${LOCAL} = false ]; then
316 docker pull ${PREFIX}/sdc-backend:${RELEASE}
317 else
318 ADDITIONAL_ARGUMENTS=${BE_DEBUG_PORT}
319 fi
320 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}
321 command_exit_status $? ${DOCKER_NAME}
322 echo "please wait while BE is starting..."
323 monitor_docker ${DOCKER_NAME}
324}
325#
326
327
328# Back-End-Init
329function sdc-BE-init {
330 DOCKER_NAME="sdc-BE-init"
331 echo "docker run sdc-backend-init..."
332 if [ ${LOCAL} = false ]; then
333 docker pull ${PREFIX}/sdc-backend-init:${RELEASE}
334 fi
335 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
336 rc=$?
337 docker_logs ${DOCKER_NAME}
338 if [[ ${rc} != 0 ]]; then exit ${rc}; fi
339}
340#
341
342
343# Onboard Back-End
344function sdc-onboard-BE {
345 DOCKER_NAME="sdc-onboard-BE"
346 echo "docker run sdc-onboard-BE ..."
347# TODO Check the dir_perms action . do we need it here ??
348# dir_perms
349 if [ ${LOCAL} = false ]; then
350 docker pull ${PREFIX}/sdc-onboard-backend:${RELEASE}
351 else
352 ADDITIONAL_ARGUMENTS=${ONBOARD_DEBUG_PORT}
353 fi
354 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}
355 command_exit_status $? ${DOCKER_NAME}
356 echo "please wait while sdc-onboard-BE is starting..."
357 monitor_docker ${DOCKER_NAME}
358}
359#
360
361
362# Front-End
363function sdc-FE {
364 DOCKER_NAME="sdc-FE"
365 IMAGE_NAME="${PREFIX}/sdc-frontend:${RELEASE}"
366 echo "Running container '${DOCKER_NAME}' based on '${IMAGE_NAME}' image..."
367 if [ ${LOCAL} = false ]; then
368 docker pull ${PREFIX}/sdc-frontend:${RELEASE}
369 else
370 ADDITIONAL_ARGUMENTS=${FE_DEBUG_PORT}
371 fi
372
373 PLUGIN_CONFIG_FILE="${WORKSPACE}/data/environments/plugins-configuration.yaml"
374 if [[ -f ${WORKSPACE}/data/environments/plugins-configuration.yaml ]]; then
375 PLUGINS_CONF_VOLUME_MOUNT="--volume ${PLUGIN_CONFIG_FILE}:${JETTY_BASE}/config/catalog-fe/plugins-configuration.yaml"
376 else
377 echo "INFO: '${PLUGIN_CONFIG_FILE}' not provided, ignoring..."
378 fi
379
380 docker run \
381 --detach \
382 --name ${DOCKER_NAME} \
383 --env HOST_IP=${IP} \
384 --env ENVNAME="${DEP_ENV}" \
385 --env JAVA_OPTIONS="${FE_JAVA_OPTIONS}" \
386 --log-driver=json-file \
387 --log-opt max-size=100m \
388 --log-opt max-file=10 \
389 --ulimit memlock=-1:-1 \
390 --ulimit nofile=4096:100000 \
391 --volume ${WORKSPACE}/data/logs/FE/:${JETTY_BASE}/logs \
392 --volume ${WORKSPACE}/data/environments:/${JETTY_BASE}/chef-solo/environments \
393 ${LOCAL_TIME_MOUNT_CMD} \
394 ${PLUGINS_CONF_VOLUME_MOUNT} \
395 --publish 9443:9443 \
396 --publish 8181:8181 \
397 ${ADDITIONAL_ARGUMENTS} \
398 ${IMAGE_NAME}
399
400 command_exit_status $? ${DOCKER_NAME}
401 echo "Please wait while '${DOCKER_NAME}' container is starting..."
402 monitor_docker ${DOCKER_NAME}
403}
404#
405
406
407# apis-sanity
408function sdc-api-tests {
409 if [[ ${RUN_API_TESTS} = true ]] ; then
410 healthCheck
411 healthCheck_http_code=$?
412 if [[ ${healthCheck_http_code} == 200 ]] ; then
413 echo "docker run sdc-api-tests..."
414 echo "Trigger sdc-api-tests docker, please wait..."
415
416 if [ ${LOCAL} = false ]; then
417 docker pull ${PREFIX}/sdc-api-tests:${RELEASE}
418 fi
419
420 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....."
421 monitor_docker sdc-api-tests
422 fi
423 fi
424}
425#
426
427
428# ui-sanity
429function sdc-ui-tests {
430
431 if [[ ${RUN_UI_TESTS} = true ]] ; then
432 healthCheck
433 healthCheck_http_code=$?
434 if [[ ${healthCheck_http_code} == 200 ]]; then
435 echo "docker run sdc-ui-tets..."
436 echo "Trigger sdc-ui-tests docker, please wait..."
437
438 if [ ${LOCAL} = false ]; then
439 docker pull ${PREFIX}/sdc-ui-tests:${RELEASE}
440 fi
441 RUN_SIMULATOR=true;
442 sdc-sim
443 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}
444 echo "please wait while SDC-UI-TESTS is starting....."
445 monitor_docker sdc-ui-tests
446 fi
447 fi
448}
449#
450
451
452# SDC-Simulator
453function sdc-sim {
454 if [ "${RUN_SIMULATOR}" == true ]; then
455 echo "docker run sdc-webSimulator..."
456 if [ ${LOCAL} = false ]; then
457 docker pull ${PREFIX}/sdc-simulator:${RELEASE}
458 fi
459
460 probe_sim
461 sim_stat=$?
462 if [ ${sim_stat} == 1 ]; then
463 docker run \
464 --detach \
465 --name sdc-sim \
466 --env FE_URL="${FE_URL}" \
467 --env JAVA_OPTIONS="${SIM_JAVA_OPTIONS}" \
468 --env ENVNAME="${DEP_ENV}" \
469 ${LOCAL_TIME_MOUNT_CMD} \
470 --volume ${WORKSPACE}/data/logs/WS/:${JETTY_BASE}/logs \
471 --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments \
472 --publish 8285:8080 \
473 --publish 8286:8443 ${PREFIX}/sdc-simulator:${RELEASE}
474 echo "please wait while SDC-WEB-SIMULATOR is starting....."
475 monitor_docker sdc-sim
476 fi
477 fi
478}
479#
480
481
482#
483# Main
484#
485
486# Handle command line arguments
487while [ $# -gt 0 ]; do
488 case $1 in
489
490 # -r | --release - The specific docker version to pull and deploy
491 -r | --release )
492 shift 1 ;
493 RELEASE=$1;
494 shift 1;;
495
496 # -e | --environment - The environment name you want to deploy
497 -e | --environment )
498 shift 1;
499 DEP_ENV=$1;
500 shift 1 ;;
501
502 # -p | --port - The port from which to connect to the docker nexus
503 -p | --port )
504 shift 1 ;
505 PORT=$1;
506 shift 1 ;;
507
508 # -l | --local - Use this for deploying your local dockers without pulling them first
509 -l | --local )
510 LOCAL=true;
511 shift 1;;
512
513 # -ta - Use this for running the APIs sanity docker after all other dockers have been deployed
514 -ta )
515 shift 1 ;
516 API_SUITE=$1;
517 RUN_API_TESTS=true;
518 shift 1 ;;
519
520 # -tu - Use this for running the UI sanity docker after all other dockers have been deployed
521 -tu )
522 shift 1 ;
523 UI_SUITE=$1;
524 RUN_UI_TESTS=true;
525 shift 1 ;;
526
527 # -tad - Use this for running the DEFAULT suite of tests in APIs sanity docker after all other dockers have been deployed
528 -tad | -t )
529 API_SUITE="onapApiSanity";
530 RUN_API_TESTS=true;
531 shift 1 ;;
532
533 # -tud - Use this for running the DEFAULT suite of tests in UI sanity docker after all other dockers have been deployed
534 -tud )
535 UI_SUITE="onapUiSanity";
536 RUN_UI_TESTS=true;
537 shift 1 ;;
538
539 # -d | --docker - The init specified docker
540 -d | --docker )
541 shift 1 ;
542 DOCKER=$1;
543 shift 1 ;;
544 # -sim | --simulator run the simulator
545 -sim | --simulator )
546 RUN_SIMULATOR=true;
547 shift 1 ;;
548 # -sim | --simulator run the simulator
549 -u | --fe_url )
550 shift 1 ;
551 FE_URL=$1;
552 shift 1 ;;
553
554 # -h | --help - Display the help message with all the available run options
555 -h | --help )
556 usage;
557 exit ${SUCCESS};;
558
559 * )
560 usage;
561 exit ${FAILURE};;
562 esac
563done
564
565
566#Prefix those with WORKSPACE so it can be set to something other than /opt
567[ -f ${WORKSPACE}/opt/config/env_name.txt ] && DEP_ENV=$(cat ${WORKSPACE}/opt/config/env_name.txt) || echo ${DEP_ENV}
568[ -f ${WORKSPACE}/opt/config/nexus_username.txt ] && NEXUS_USERNAME=$(cat ${WORKSPACE}/opt/config/nexus_username.txt) || NEXUS_USERNAME=release
569[ -f ${WORKSPACE}/opt/config/nexus_password.txt ] && NEXUS_PASSWD=$(cat ${WORKSPACE}/opt/config/nexus_password.txt) || NEXUS_PASSWD=sfWU3DFVdBr7GVxB85mTYgAW
570[ -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}
571[ -f ${WORKSPACE}/opt/config/nexus_username.txt ] && docker login -u $NEXUS_USERNAME -p $NEXUS_PASSWD $NEXUS_DOCKER_REPO
572
573
574export IP=`ip route get 8.8.8.8 | awk '/src/{ print $7 }'`
575#If OSX, then use this to get IP
576if [[ "$OSTYPE" == "darwin"* ]]; then
577 export IP=$(ipconfig getifaddr en0)
578fi
579export PREFIX=${NEXUS_DOCKER_REPO}'/onap'
580
581if [ ${LOCAL} = true ]; then
582 PREFIX='onap'
583fi
584
585echo ""
586
587if [ -z "${DOCKER}" ]; then
588 cleanup all
589 dir_perms
590 sdc-cs
591 sdc-cs-init
592 sdc-cs-onboard-init
593 sdc-onboard-BE
594 sdc-BE
595 sdc-BE-init
596 sdc-FE
597 healthCheck
598 sdc-sim
599 sdc-api-tests
600 sdc-ui-tests
601else
602 cleanup ${DOCKER}
603 dir_perms
604 ${DOCKER}
605 healthCheck
606fi