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