Aaron Hay | 5a7cb08 | 2017-08-21 19:09:35 +0000 | [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: |
Aaron Hay | db1e9c5 | 2017-08-24 15:06:59 +0000 | [diff] [blame] | 20 | SCRIPTS="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" |
Aaron Hay | 5a7cb08 | 2017-08-21 19:09:35 +0000 | [diff] [blame] | 21 | source ${WORKSPACE}/test/csit/scripts/appc/script1.sh |
Aaron Hay | db1e9c5 | 2017-08-24 15:06:59 +0000 | [diff] [blame] | 22 | |
Aaron Hay | 5a7cb08 | 2017-08-21 19:09:35 +0000 | [diff] [blame] | 23 | export MTU=$(/sbin/ifconfig | grep MTU | sed 's/.*MTU://' | sed 's/ .*//' | sort -n | head -1) |
| 24 | |
Aaron Hay | 0f33e96 | 2017-09-12 14:03:37 -0400 | [diff] [blame] | 25 | if [ "$MTU" == "" ]; then |
| 26 | export MTU="1450" |
| 27 | fi |
| 28 | |
Aaron Hay | 5a7cb08 | 2017-08-21 19:09:35 +0000 | [diff] [blame] | 29 | |
| 30 | # Clone APPC repo to get docker-compose for APPC |
| 31 | mkdir -p $WORKSPACE/archives/appc |
| 32 | cd $WORKSPACE/archives |
| 33 | git clone -b master --single-branch http://gerrit.onap.org/r/appc/deployment.git appc |
| 34 | cd $WORKSPACE/archives/appc |
| 35 | git pull |
Aaron Hay | db1e9c5 | 2017-08-24 15:06:59 +0000 | [diff] [blame] | 36 | unset http_proxy https_proxy |
Aaron Hay | 5a7cb08 | 2017-08-21 19:09:35 +0000 | [diff] [blame] | 37 | cd $WORKSPACE/archives/appc/docker-compose |
| 38 | |
| 39 | sed -i "s/DMAAP_TOPIC_ENV=.*/DMAAP_TOPIC_ENV="AUTO"/g" docker-compose.yml |
| 40 | docker login -u docker -p docker nexus3.onap.org:10001 |
| 41 | |
| 42 | docker pull nexus3.onap.org:10001/openecomp/appc-image:1.1-STAGING-latest |
| 43 | docker tag nexus3.onap.org:10001/openecomp/appc-image:1.1-STAGING-latest openecomp/appc-image:latest |
| 44 | |
| 45 | docker pull nexus3.onap.org:10001/openecomp/dgbuilder-sdnc-image:1.1-STAGING-latest |
| 46 | docker tag nexus3.onap.org:10001/openecomp/dgbuilder-sdnc-image:1.1-STAGING-latest openecomp/dgbuilder-sdnc-image:latest |
| 47 | |
| 48 | # start APPC containers with docker compose and configuration from docker-compose.yml |
Aaron Hay | 0f33e96 | 2017-09-12 14:03:37 -0400 | [diff] [blame] | 49 | docker-compose up -d |
Aaron Hay | 5a7cb08 | 2017-08-21 19:09:35 +0000 | [diff] [blame] | 50 | |
| 51 | # WAIT 5 minutes maximum and test every 5 seconds if APPC is up using HealthCheck API |
Aaron Hay | db1e9c5 | 2017-08-24 15:06:59 +0000 | [diff] [blame] | 52 | TIME_OUT=500 |
| 53 | INTERVAL=30 |
Aaron Hay | 5a7cb08 | 2017-08-21 19:09:35 +0000 | [diff] [blame] | 54 | TIME=0 |
| 55 | while [ "$TIME" -lt "$TIME_OUT" ]; do |
| 56 | response=$(curl --write-out '%{http_code}' --silent --output /dev/null -H "Authorization: Basic YWRtaW46S3A4Yko0U1hzek0wV1hsaGFrM2VIbGNzZTJnQXc4NHZhb0dHbUp2VXkyVQ==" -X POST -H "X-FromAppId: csit-appc" -H "X-TransactionId: csit-appc" -H "Accept: application/json" -H "Content-Type: application/json" http://localhost:8282/restconf/operations/SLI-API:healthcheck ); echo $response |
| 57 | |
| 58 | if [ "$response" == "200" ]; then |
| 59 | echo APPC started in $TIME seconds |
| 60 | break; |
| 61 | fi |
| 62 | |
| 63 | echo Sleep: $INTERVAL seconds before testing if APPC is up. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds |
| 64 | sleep $INTERVAL |
| 65 | TIME=$(($TIME+$INTERVAL)) |
| 66 | done |
| 67 | |
| 68 | if [ "$TIME" -ge "$TIME_OUT" ]; then |
| 69 | echo TIME OUT: Docker containers not started in $TIME_OUT seconds... Could cause problems for testing activities... |
| 70 | fi |
| 71 | |
Aaron Hay | db1e9c5 | 2017-08-24 15:06:59 +0000 | [diff] [blame] | 72 | #sleep 800 |
| 73 | |
| 74 | TIME_OUT=1500 |
| 75 | INTERVAL=60 |
| 76 | TIME=0 |
| 77 | while [ "$TIME" -lt "$TIME_OUT" ]; do |
| 78 | |
| 79 | response=$(docker exec appc_controller_container /opt/opendaylight/current/bin/client -u karaf system:start-level) |
| 80 | num_bundles=$(docker exec appc_controller_container /opt/opendaylight/current/bin/client -u karaf bundle:list | tail -1 | cut -d\| -f1) |
| 81 | |
| 82 | if [ "$response" == "Level 100" ] && [ "$num_bundles" -ge 394 ]; then |
| 83 | echo APPC karaf started in $TIME seconds |
| 84 | break; |
| 85 | fi |
| 86 | |
| 87 | echo Sleep: $INTERVAL seconds before testing if APPC is up. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds |
| 88 | sleep $INTERVAL |
| 89 | TIME=$(($TIME+$INTERVAL)) |
| 90 | done |
| 91 | |
| 92 | if [ "$TIME" -ge "$TIME_OUT" ]; then |
| 93 | echo TIME OUT: karaf session not started in $TIME_OUT seconds... Could cause problems for testing activities... |
| 94 | fi |
| 95 | |
| 96 | response=$(docker exec appc_controller_container /opt/opendaylight/current/bin/client -u karaf system:start-level) |
| 97 | num_bundles=$(docker exec appc_controller_container /opt/opendaylight/current/bin/client -u karaf bundle:list | tail -1 | cut -d\| -f1) |
| 98 | |
| 99 | if [ "$response" == "Level 100" ] && [ "$num_bundles" -ge 394 ]; then |
| 100 | num_bundles=$(docker exec appc_controller_container /opt/opendaylight/current/bin/client -u karaf bundle:list | tail -1 | cut -d\| -f1) |
| 101 | num_failed_bundles=$(docker exec appc_controller_container /opt/opendaylight/current/bin/client -u karaf bundle:list | grep Failure | wc -l) |
| 102 | failed_bundles=$(docker exec appc_controller_container /opt/opendaylight/current/bin/client -u karaf bundle:list | grep Failure) |
| 103 | echo There is/are $num_failed_bundles failed bundles out of $num_bundles installed bundles. |
| 104 | fi |
| 105 | |
| 106 | if [ "$num_failed_bundles" -ge 1 ]; then |
| 107 | echo "The following bundle(s) are in a failed state: " |
| 108 | echo " $failed_bundles" |
| 109 | fi |
| 110 | |
Aaron Hay | 5a7cb08 | 2017-08-21 19:09:35 +0000 | [diff] [blame] | 111 | # Pass any variables required by Robot test suites in ROBOT_VARIABLES |
Aaron Hay | db1e9c5 | 2017-08-24 15:06:59 +0000 | [diff] [blame] | 112 | ROBOT_VARIABLES="-v SCRIPTS:${SCRIPTS}" |
Aaron Hay | 5a7cb08 | 2017-08-21 19:09:35 +0000 | [diff] [blame] | 113 | |