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