eh552t | 9c0b468 | 2017-08-21 11:10:11 +0200 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # Copyright 2016-2017 Huawei Technologies Co., Ltd. |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | # |
| 17 | # Modifications copyright (c) 2017 AT&T Intellectual Property |
| 18 | # |
| 19 | # Place the scripts in run order: |
| 20 | source ${WORKSPACE}/test/csit/scripts/clamp/script1.sh |
| 21 | |
| 22 | # Clone Clamp repo to get extra folder that has all needed to run docker with docker-compose to start DB and Clamp |
| 23 | mkdir -p $WORKSPACE/archives/clamp-clone |
| 24 | cd $WORKSPACE/archives/clamp-clone |
| 25 | git clone --depth 1 http://gerrit.onap.org/r/clamp -b master |
| 26 | cd clamp/extra/docker/clamp/ |
| 27 | |
| 28 | # start Clamp and MariaDB containers with docker compose and configuration from clamp/extra/docker/clamp/docker-compose.yml |
| 29 | docker-compose up -d |
| 30 | |
| 31 | # WAIT 5 minutes maximum and test every 5 seconds if Clamp up using HealthCheck API |
| 32 | TIME_OUT=300 |
| 33 | INTERVAL=5 |
| 34 | TIME=0 |
| 35 | while [ "$TIME" -lt "$TIME_OUT" ]; do |
| 36 | response=$(curl --write-out '%{http_code}' --silent --output /dev/null http://localhost:8080/restservices/clds/v1/clds/healthcheck); echo $response |
| 37 | |
| 38 | if [ "$response" == "200" ]; then |
| 39 | echo Clamp and its database well started in $TIME seconds |
| 40 | break; |
| 41 | fi |
| 42 | |
| 43 | echo Sleep: $INTERVAL seconds before testing if Clamp is up. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds |
| 44 | sleep $INTERVAL |
| 45 | TIME=$(($TIME+$INTERVAL)) |
| 46 | done |
| 47 | |
| 48 | if [ "$TIME" -ge "$TIME_OUT" ]; then |
| 49 | echo TIME OUT: Docker containers not started in $TIME_OUT seconds... Could cause problems for tests... |
| 50 | fi |
| 51 | |
| 52 | # Pass any variables required by Robot test suites in ROBOT_VARIABLES |
| 53 | #ROBOT_VARIABLES="-v TEST:${TEST}" |
| 54 | |