blob: eaf488a657d8d9480bfe1b69aa7c7a11211e5837 [file] [log] [blame]
Aaron Hay5a7cb082017-08-21 19:09:35 +00001#!/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 Haydb1e9c52017-08-24 15:06:59 +000020SCRIPTS="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
Aaron Hay5a7cb082017-08-21 19:09:35 +000021source ${WORKSPACE}/test/csit/scripts/appc/script1.sh
Aaron Haydb1e9c52017-08-24 15:06:59 +000022
Aaron Hay0e795a72017-09-20 03:14:04 +000023export NEXUS_USERNAME=docker
24export NEXUS_PASSWD=docker
25export NEXUS_DOCKER_REPO=nexus3.onap.org:10001
26export DMAAP_TOPIC=AUTO
27export DOCKER_IMAGE_VERSION=1.1.0-SNAPSHOT-latest
28
Aaron Hay5a7cb082017-08-21 19:09:35 +000029export MTU=$(/sbin/ifconfig | grep MTU | sed 's/.*MTU://' | sed 's/ .*//' | sort -n | head -1)
30
Aaron Hay0f33e962017-09-12 14:03:37 -040031if [ "$MTU" == "" ]; then
32 export MTU="1450"
33fi
34
Aaron Hay5a7cb082017-08-21 19:09:35 +000035
36# Clone APPC repo to get docker-compose for APPC
37mkdir -p $WORKSPACE/archives/appc
38cd $WORKSPACE/archives
39git clone -b master --single-branch http://gerrit.onap.org/r/appc/deployment.git appc
40cd $WORKSPACE/archives/appc
41git pull
Aaron Haydb1e9c52017-08-24 15:06:59 +000042unset http_proxy https_proxy
Aaron Hay5a7cb082017-08-21 19:09:35 +000043cd $WORKSPACE/archives/appc/docker-compose
44
Aaron Hay0e795a72017-09-20 03:14:04 +000045sed -i "s/DMAAP_TOPIC_ENV=.*/DMAAP_TOPIC_ENV="$DMAAP_TOPIC"/g" docker-compose.yml
46docker login -u $NEXUS_USERNAME -p $NEXUS_PASSWD $NEXUS_DOCKER_REPO
Aaron Hay5a7cb082017-08-21 19:09:35 +000047
Aaron Hay0e795a72017-09-20 03:14:04 +000048docker pull $NEXUS_DOCKER_REPO/openecomp/appc-image:$DOCKER_IMAGE_VERSION
49docker tag $NEXUS_DOCKER_REPO/openecomp/appc-image:$DOCKER_IMAGE_VERSION openecomp/appc-image:latest
Aaron Hay5a7cb082017-08-21 19:09:35 +000050
Aaron Hay0e795a72017-09-20 03:14:04 +000051docker pull $NEXUS_DOCKER_REPO/onap/ccsdk-dgbuilder-image:latest
52docker tag $NEXUS_DOCKER_REPO/onap/ccsdk-dgbuilder-image:latest onap/ccsdk-dgbuilder-image:latest
Aaron Hay5a7cb082017-08-21 19:09:35 +000053
54# start APPC containers with docker compose and configuration from docker-compose.yml
Aaron Hay0f33e962017-09-12 14:03:37 -040055docker-compose up -d
Aaron Hay5a7cb082017-08-21 19:09:35 +000056
57# WAIT 5 minutes maximum and test every 5 seconds if APPC is up using HealthCheck API
Aaron Haydb1e9c52017-08-24 15:06:59 +000058TIME_OUT=500
59INTERVAL=30
Aaron Hay5a7cb082017-08-21 19:09:35 +000060TIME=0
61while [ "$TIME" -lt "$TIME_OUT" ]; do
62 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
63
64 if [ "$response" == "200" ]; then
65 echo APPC started in $TIME seconds
66 break;
67 fi
68
69 echo Sleep: $INTERVAL seconds before testing if APPC is up. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds
70 sleep $INTERVAL
71 TIME=$(($TIME+$INTERVAL))
72done
73
74if [ "$TIME" -ge "$TIME_OUT" ]; then
75 echo TIME OUT: Docker containers not started in $TIME_OUT seconds... Could cause problems for testing activities...
76fi
77
Aaron Haydb1e9c52017-08-24 15:06:59 +000078#sleep 800
79
Aaron Hay0e795a72017-09-20 03:14:04 +000080TIME_OUT=1000
Aaron Haydb1e9c52017-08-24 15:06:59 +000081INTERVAL=60
82TIME=0
83while [ "$TIME" -lt "$TIME_OUT" ]; do
84
85response=$(docker exec appc_controller_container /opt/opendaylight/current/bin/client -u karaf system:start-level)
86num_bundles=$(docker exec appc_controller_container /opt/opendaylight/current/bin/client -u karaf bundle:list | tail -1 | cut -d\| -f1)
87
Aaron Hay0e795a72017-09-20 03:14:04 +000088 if [ "$response" == "Level 100" ] && [ "$num_bundles" -ge 400 ]; then
Aaron Haydb1e9c52017-08-24 15:06:59 +000089 echo APPC karaf started in $TIME seconds
90 break;
91 fi
92
93 echo Sleep: $INTERVAL seconds before testing if APPC is up. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds
94 sleep $INTERVAL
95 TIME=$(($TIME+$INTERVAL))
96done
97
98if [ "$TIME" -ge "$TIME_OUT" ]; then
99 echo TIME OUT: karaf session not started in $TIME_OUT seconds... Could cause problems for testing activities...
100fi
101
102response=$(docker exec appc_controller_container /opt/opendaylight/current/bin/client -u karaf system:start-level)
103num_bundles=$(docker exec appc_controller_container /opt/opendaylight/current/bin/client -u karaf bundle:list | tail -1 | cut -d\| -f1)
104
Aaron Hay0e795a72017-09-20 03:14:04 +0000105 if [ "$response" == "Level 100" ] && [ "$num_bundles" -ge 400 ]; then
Aaron Haydb1e9c52017-08-24 15:06:59 +0000106 num_bundles=$(docker exec appc_controller_container /opt/opendaylight/current/bin/client -u karaf bundle:list | tail -1 | cut -d\| -f1)
107 num_failed_bundles=$(docker exec appc_controller_container /opt/opendaylight/current/bin/client -u karaf bundle:list | grep Failure | wc -l)
108 failed_bundles=$(docker exec appc_controller_container /opt/opendaylight/current/bin/client -u karaf bundle:list | grep Failure)
109 echo There is/are $num_failed_bundles failed bundles out of $num_bundles installed bundles.
110 fi
111
112if [ "$num_failed_bundles" -ge 1 ]; then
113 echo "The following bundle(s) are in a failed state: "
114 echo " $failed_bundles"
115fi
116
Aaron Hay5a7cb082017-08-21 19:09:35 +0000117# Pass any variables required by Robot test suites in ROBOT_VARIABLES
Aaron Haydb1e9c52017-08-24 15:06:59 +0000118ROBOT_VARIABLES="-v SCRIPTS:${SCRIPTS}"
Aaron Hay5a7cb082017-08-21 19:09:35 +0000119
Aaron Hay0e795a72017-09-20 03:14:04 +0000120if [ "$response" == "" ] || [ "$num_bundles" == "" ]; then
121 echo "Docker container appc_controller_container is not available. Exiting."
122 exit 1
123fi
124
125