Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [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. |
koblosz | 2ac270a | 2018-10-23 07:32:30 +0200 | [diff] [blame] | 20 | # |
| 21 | # Modifications copyright (c) 2018 Nokia Intellectual Property |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 22 | # ============LICENSE_END============================================ |
| 23 | # =================================================================== |
| 24 | # ECOMP is a trademark and service mark of AT&T Intellectual Property. |
| 25 | |
Gary Wu | 13111e9 | 2018-09-27 11:31:33 -0700 | [diff] [blame] | 26 | echo "This is ${WORKSPACE}/scripts/vid/start_vid_containers.sh" |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 27 | |
| 28 | export IP=`ifconfig eth0 | awk -F: '/inet addr/ {gsub(/ .*/,"",$2); print $2}'` |
| 29 | |
Gary Wu | 13111e9 | 2018-09-27 11:31:33 -0700 | [diff] [blame] | 30 | cd ${WORKSPACE}/tests/vid/resources |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 31 | docker-compose up -d --build |
| 32 | |
| 33 | # WAIT 5 minutes maximum and test every 5 seconds if VID up using HealthCheck API |
| 34 | |
| 35 | TIME_OUT=1200 |
| 36 | INTERVAL=5 |
| 37 | TIME=0 |
koblosz | 2ac270a | 2018-10-23 07:32:30 +0200 | [diff] [blame] | 38 | |
| 39 | for i in {1..10}; do |
| 40 | if [ $(docker inspect -f '{{ .State.Running }}' vid-server) ] |
| 41 | then |
| 42 | echo "VID service is running" |
| 43 | VID_DOCKER_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' vid-server) |
| 44 | break |
| 45 | else |
| 46 | echo "Waiting for vid-server docker initialization... $i" |
| 47 | sleep $i |
| 48 | fi |
| 49 | done |
| 50 | |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 51 | while [ "$TIME" -lt "$TIME_OUT" ]; do |
koblosz | 2ac270a | 2018-10-23 07:32:30 +0200 | [diff] [blame] | 52 | response=$(curl --write-out '%{http_code}' --silent --output /dev/null http://"$VID_DOCKER_IP":8080/vid/healthCheck); echo $response |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 53 | |
| 54 | if [ "$response" == "200" ]; then |
| 55 | echo VID and its database well started in $TIME seconds |
| 56 | break; |
| 57 | fi |
| 58 | |
| 59 | echo Sleep: $INTERVAL seconds before testing if VID is up. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds |
| 60 | sleep $INTERVAL |
| 61 | TIME=$(($TIME+$INTERVAL)) |
| 62 | done |
| 63 | |
| 64 | if [ "$TIME" -ge "$TIME_OUT" ]; then |
| 65 | echo TIME OUT: Docker containers not started in $TIME_OUT seconds... Could cause problems for tests... |
| 66 | fi |