blob: 78b4ff006daf94dfabbe81a444a8bd61aefaf1b1 [file] [log] [blame]
surya-huaweid497d772017-09-22 18:58:26 +05301#!/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:
20SCRIPTS="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
21source ${WORKSPACE}/test/csit/scripts/ccsdk/script1.sh
22
23export MTU=$(/sbin/ifconfig | grep MTU | sed 's/.*MTU://' | sed 's/ .*//' | sort -n | head -1)
24export NEXUS_DOCKER_REPO="nexus3.onap.org:10001"
Stilwell, David (stilwelld)cfbb8b12017-09-27 18:08:35 +000025export NEXUS_USERNAME=docker
26export NEXUS_PASSWD=docker
27export DMAAP_TOPIC=AUTO
28export CCSDK_DOCKER_IMAGE_VERSION=0.1-STAGING-latest
29
surya-huaweid497d772017-09-22 18:58:26 +053030if [ "$MTU" == "" ]; then
31 export MTU="1450"
32fi
33
34
35# Clone CCSDK repo to get docker-compose for CCSDK
36mkdir -p $WORKSPACE/archives/ccsdk
37cd $WORKSPACE/archives
38git clone -b master --single-branch http://gerrit.onap.org/r/ccsdk/distribution.git ccsdk
39cd $WORKSPACE/archives/ccsdk
40git pull
41unset http_proxy https_proxy
42cd $WORKSPACE/archives/ccsdk/src/main/yaml
43
44sed -i "s/DMAAP_TOPIC_ENV=.*/DMAAP_TOPIC_ENV="AUTO"/g" docker-compose.yml
Stilwell, David (stilwelld)cfbb8b12017-09-27 18:08:35 +000045docker login -u $NEXUS_USERNAME -p $NEXUS_PASSWD $NEXUS_DOCKER_REPO
surya-huaweid497d772017-09-22 18:58:26 +053046
Stilwell, David (stilwelld)cfbb8b12017-09-27 18:08:35 +000047docker pull $NEXUS_DOCKER_REPO/onap/ccsdk-odl-image:$CCSDK_DOCKER_IMAGE_VERSION
48docker tag $NEXUS_DOCKER_REPO/onap/ccsdk-odl-image:$CCSDK_DOCKER_IMAGE_VERSION onap/ccsdk-odl-image:0.1-STAGING-latest
surya-huaweid497d772017-09-22 18:58:26 +053049
Stilwell, David (stilwelld)cfbb8b12017-09-27 18:08:35 +000050docker pull $NEXUS_DOCKER_REPO/onap/ccsdk-dgbuilder-image:$CCSDK_DOCKER_IMAGE_VERSION
51docker tag $NEXUS_DOCKER_REPO/onap/ccsdk-dgbuilder-image:$CCSDK_DOCKER_IMAGE_VERSION onap/ccsdk-dgbuilder-image:0.1-STAGING-latest
surya-huaweid497d772017-09-22 18:58:26 +053052
Stilwell, David (stilwelld)cfbb8b12017-09-27 18:08:35 +000053docker pull $NEXUS_DOCKER_REPO/onap/ccsdk-odlsli-image:$CCSDK_DOCKER_IMAGE_VERSION
54docker tag $NEXUS_DOCKER_REPO/onap/ccsdk-odlsli-image:$CCSDK_DOCKER_IMAGE_VERSION onap/ccsdk-odlsli-image:0.1-STAGING-latest
surya-huaweid497d772017-09-22 18:58:26 +053055
56# start CCSDK containers with docker compose and configuration from docker-compose.yml
57curl -L https://github.com/docker/compose/releases/download/1.9.0/docker-compose-`uname -s`-`uname -m` > docker-compose
58chmod +x docker-compose
59./docker-compose up -d
60
61# WAIT 5 minutes maximum and test every 5 seconds if CCSDK is up using HealthCheck API
62TIME_OUT=500
63INTERVAL=30
64TIME=0
65while [ "$TIME" -lt "$TIME_OUT" ]; do
Stilwell, David (stilwelld)cfbb8b12017-09-27 18:08:35 +000066 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" http://localhost:8383/restconf/operations/SLI-API:healthcheck ); echo $response
surya-huaweid497d772017-09-22 18:58:26 +053067
68 if [ "$response" == "200" ]; then
69 echo CCSDK started in $TIME seconds
70 break;
71 fi
72
73 echo Sleep: $INTERVAL seconds before testing if CCSDK is up. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds
74 sleep $INTERVAL
75 TIME=$(($TIME+$INTERVAL))
76done
77
78if [ "$TIME" -ge "$TIME_OUT" ]; then
79 echo TIME OUT: Docker containers not started in $TIME_OUT seconds... Could cause problems for testing activities...
80fi
81
82#sleep 800
83
84TIME_OUT=1500
85INTERVAL=60
86TIME=0
87while [ "$TIME" -lt "$TIME_OUT" ]; do
88
Stilwell, David (stilwelld)e5663252017-09-27 23:22:12 +000089response=$(docker exec ccsdk_odlsli_container /opt/opendaylight/current/bin/client -u karaf system:start-level)
90num_bundles=$(docker exec ccsdk_odlsli_container /opt/opendaylight/current/bin/client -u karaf bundle:list | tail -1 | cut -d\| -f1)
surya-huaweid497d772017-09-22 18:58:26 +053091
Stilwell, David (stilwelld)e5663252017-09-27 23:22:12 +000092 if [ "$response" == "Level 100" ] && [ "$num_bundles" -ge 333 ]; then
surya-huaweid497d772017-09-22 18:58:26 +053093 echo CCSDK karaf started in $TIME seconds
94 break;
95 fi
96
97 echo Sleep: $INTERVAL seconds before testing if CCSDK is up. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds
98 sleep $INTERVAL
99 TIME=$(($TIME+$INTERVAL))
100done
101
102if [ "$TIME" -ge "$TIME_OUT" ]; then
103 echo TIME OUT: karaf session not started in $TIME_OUT seconds... Could cause problems for testing activities...
104fi
105
Stilwell, David (stilwelld)e5663252017-09-27 23:22:12 +0000106response=$(docker exec ccsdk_odlsli_container /opt/opendaylight/current/bin/client -u karaf system:start-level)
107num_bundles=$(docker exec ccsdk_odlsli_container /opt/opendaylight/current/bin/client -u karaf bundle:list | tail -1 | cut -d\| -f1)
surya-huaweid497d772017-09-22 18:58:26 +0530108
Stilwell, David (stilwelld)e5663252017-09-27 23:22:12 +0000109 if [ "$response" == "Level 100" ] && [ "$num_bundles" -ge 333 ]; then
110 num_bundles=$(docker exec ccsdk_odlsli_container /opt/opendaylight/current/bin/client -u karaf bundle:list | tail -1 | cut -d\| -f1)
111 num_failed_bundles=$(docker exec ccsdk_odlsli_container /opt/opendaylight/current/bin/client -u karaf bundle:list | grep Failure | wc -l)
112 failed_bundles=$(docker exec ccsdk_odlsli_container /opt/opendaylight/current/bin/client -u karaf bundle:list | grep Failure)
surya-huaweid497d772017-09-22 18:58:26 +0530113 echo There is/are $num_failed_bundles failed bundles out of $num_bundles installed bundles.
114 fi
115
116if [ "$num_failed_bundles" -ge 1 ]; then
117 echo "The following bundle(s) are in a failed state: "
118 echo " $failed_bundles"
119fi
120
121# Pass any variables required by Robot test suites in ROBOT_VARIABLES
122ROBOT_VARIABLES="-v SCRIPTS:${SCRIPTS}"
123