Yuli Shlosberg | e120970 | 2017-09-24 17:43:28 +0300 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # ============LICENSE_START======================================================= |
| 4 | # ONAP CLAMP |
| 5 | # ================================================================================ |
| 6 | # Copyright (C) 2017 AT&T Intellectual Property. All rights |
| 7 | # reserved. |
| 8 | # ================================================================================ |
| 9 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 10 | # you may not use this file except in compliance with the License. |
| 11 | # You may obtain a copy of the License at |
| 12 | # |
| 13 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 14 | # |
| 15 | # Unless required by applicable law or agreed to in writing, software |
| 16 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 18 | # See the License for the specific language governing permissions and |
| 19 | # limitations under the License. |
| 20 | # ============LICENSE_END============================================ |
| 21 | # =================================================================== |
| 22 | # ECOMP is a trademark and service mark of AT&T Intellectual Property. |
| 23 | # |
| 24 | |
| 25 | echo "This is ${WORKSPACE}/test/csit/scripts/vid/start_vid_containers.sh" |
| 26 | |
| 27 | |
Sonsino, Ofir (os0695) | 57c02a6 | 2018-08-06 16:47:32 +0300 | [diff] [blame] | 28 | RELEASE=vid:latest |
Yuli Shlosberg | e120970 | 2017-09-24 17:43:28 +0300 | [diff] [blame] | 29 | CONFIG_PATH=${WORKSPACE}/data/clone/vid/lf_config |
| 30 | |
| 31 | export IP=`ifconfig eth0 | awk -F: '/inet addr/ {gsub(/ .*/,"",$2); print $2}'` |
Sonsino, Ofir (os0695) | 57c02a6 | 2018-08-06 16:47:32 +0300 | [diff] [blame] | 32 | export PREFIX='nexus3.onap.org:10001/onap' |
Yuli Shlosberg | e120970 | 2017-09-24 17:43:28 +0300 | [diff] [blame] | 33 | |
| 34 | #start Maria-DB |
| 35 | docker run --name vid-mariadb -e MYSQL_DATABASE=vid_openecomp_epsdk -e MYSQL_USER=vidadmin -e MYSQL_PASSWORD=Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U -e MYSQL_ROOT_PASSWORD=LF+tp_1WqgSY -v ${CONFIG_PATH}/vid-my.cnf:/etc/mysql/my.cnf -v ${CONFIG_PATH}/vid-pre-init.sql:/docker-entrypoint-initdb.d/vid-pre-init.sql -v /var/lib/mysql -d mariadb:10 |
| 36 | |
| 37 | #start VID server |
| 38 | |
Sonsino, Ofir (os0695) | 57c02a6 | 2018-08-06 16:47:32 +0300 | [diff] [blame] | 39 | docker run -e VID_MYSQL_DBNAME=vid_openecomp_epsdk -e VID_MYSQL_PASS=Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U --name vid-server -p 8080:8080 --link vid-mariadb:vid-mariadb-docker-instance -d nexus3.onap.org:10001/onap/${RELEASE} |
Yuli Shlosberg | e120970 | 2017-09-24 17:43:28 +0300 | [diff] [blame] | 40 | |
| 41 | # WAIT 5 minutes maximum and test every 5 seconds if VID up using HealthCheck API |
| 42 | |
| 43 | TIME_OUT=1200 |
| 44 | INTERVAL=5 |
| 45 | TIME=0 |
| 46 | while [ "$TIME" -lt "$TIME_OUT" ]; do |
| 47 | response=$(curl --write-out '%{http_code}' --silent --output /dev/null http://localhost:8080/vid/healthCheck); echo $response |
| 48 | |
| 49 | if [ "$response" == "200" ]; then |
| 50 | echo VID and its database well started in $TIME seconds |
| 51 | break; |
| 52 | fi |
| 53 | |
| 54 | echo Sleep: $INTERVAL seconds before testing if VID is up. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds |
| 55 | sleep $INTERVAL |
| 56 | TIME=$(($TIME+$INTERVAL)) |
| 57 | done |
| 58 | |
| 59 | if [ "$TIME" -ge "$TIME_OUT" ]; then |
| 60 | echo TIME OUT: Docker containers not started in $TIME_OUT seconds... Could cause problems for tests... |
| 61 | fi |