eh552t | b21b56a | 2017-08-23 13:44:54 +0200 | [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/clamp/start_clamp_containers.sh" |
| 26 | |
| 27 | # start Clamp and MariaDB containers with docker compose and configuration from clamp/extra/docker/clamp/docker-compose.yml |
| 28 | docker-compose up -d |
| 29 | |
| 30 | # WAIT 5 minutes maximum and test every 5 seconds if Clamp up using HealthCheck API |
eh552t | bc1d800 | 2018-07-04 14:43:49 +0200 | [diff] [blame] | 31 | TIME_OUT=600 |
eh552t | b21b56a | 2017-08-23 13:44:54 +0200 | [diff] [blame] | 32 | INTERVAL=5 |
| 33 | TIME=0 |
| 34 | while [ "$TIME" -lt "$TIME_OUT" ]; do |
eh552t | 7edf080 | 2018-07-30 12:48:48 +0200 | [diff] [blame] | 35 | response=$(curl --write-out '%{http_code}' --silent --output /dev/null -vk --key config/org.onap.clamp.keyfile https://localhost:8443/restservices/clds/v1/healthcheck); echo $response |
eh552t | b21b56a | 2017-08-23 13:44:54 +0200 | [diff] [blame] | 36 | |
| 37 | if [ "$response" == "200" ]; then |
| 38 | echo Clamp and its database well started in $TIME seconds |
| 39 | break; |
| 40 | fi |
| 41 | |
| 42 | echo Sleep: $INTERVAL seconds before testing if Clamp is up. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds |
| 43 | sleep $INTERVAL |
| 44 | TIME=$(($TIME+$INTERVAL)) |
| 45 | done |
| 46 | |
| 47 | if [ "$TIME" -ge "$TIME_OUT" ]; then |
| 48 | echo TIME OUT: Docker containers not started in $TIME_OUT seconds... Could cause problems for tests... |
eh552t | bc1d800 | 2018-07-04 14:43:49 +0200 | [diff] [blame] | 49 | exit 1; |
eh552t | b21b56a | 2017-08-23 13:44:54 +0200 | [diff] [blame] | 50 | fi |
| 51 | |
ehautot | af8aad2 | 2018-02-23 12:36:37 +0100 | [diff] [blame] | 52 | # To avoid some problem because templates not yet read |
| 53 | TIME=0 |
| 54 | while [ "$TIME" -lt "$TIME_OUT" ]; do |
eh552t | bc1d800 | 2018-07-04 14:43:49 +0200 | [diff] [blame] | 55 | response=$(curl --write-out '%{http_code}' --silent --output /dev/null -u admin:password -vk --key config/org.onap.clamp.keyfile https://localhost:8443/restservices/clds/v1/cldsTempate/template-names); echo $response |
ehautot | af8aad2 | 2018-02-23 12:36:37 +0100 | [diff] [blame] | 56 | |
| 57 | if [ "$response" == "200" ]; then |
| 58 | echo Templates well available |
| 59 | break; |
| 60 | fi |
| 61 | |
| 62 | echo Sleep: $INTERVAL seconds before testing if templates available. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds |
| 63 | sleep $INTERVAL |
| 64 | TIME=$(($TIME+$INTERVAL)) |
| 65 | done |
| 66 | |
| 67 | if [ "$TIME" -ge "$TIME_OUT" ]; then |
| 68 | echo TIME OUT: Templates not available in $TIME_OUT seconds... Could cause problems for tests... |
eh552t | bc1d800 | 2018-07-04 14:43:49 +0200 | [diff] [blame] | 69 | exit 1; |
ehautot | af8aad2 | 2018-02-23 12:36:37 +0100 | [diff] [blame] | 70 | fi |