8798e561ae1b1dcea7bc7c7b9bc953753c5095ff
[integration.git] / test / csit / plans / appc / healthcheck / setup.sh
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/appc/script1.sh
22
23 export NEXUS_USERNAME=docker
24 export NEXUS_PASSWD=docker
25 export NEXUS_DOCKER_REPO=nexus3.onap.org:10001
26 export DMAAP_TOPIC=AUTO
27 export APPC_DOCKER_IMAGE_VERSION=1.1-STAGING-latest
28 export CCSDK_DOCKER_IMAGE_VERSION=0.1-STAGING-latest
29
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 APPC repo to get docker-compose for APPC
38 mkdir -p $WORKSPACE/archives/appc
39 cd $WORKSPACE/archives
40 git clone -b master --single-branch http://gerrit.onap.org/r/appc/deployment.git appc
41 cd $WORKSPACE/archives/appc
42 git pull
43 cd $WORKSPACE/archives/appc/docker-compose
44 sed -i "s/DMAAP_TOPIC_ENV=.*/DMAAP_TOPIC_ENV="$DMAAP_TOPIC"/g" docker-compose.yml
45 docker login -u $NEXUS_USERNAME -p $NEXUS_PASSWD $NEXUS_DOCKER_REPO
46 docker pull $NEXUS_DOCKER_REPO/openecomp/appc-image:$APPC_DOCKER_IMAGE_VERSION
47 docker tag $NEXUS_DOCKER_REPO/openecomp/appc-image:$APPC_DOCKER_IMAGE_VERSION openecomp/appc-image:latest
48 docker pull $NEXUS_DOCKER_REPO/onap/ccsdk-dgbuilder-image:$CCSDK_DOCKER_IMAGE_VERSION
49 docker tag $NEXUS_DOCKER_REPO/onap/ccsdk-dgbuilder-image:$CCSDK_DOCKER_IMAGE_VERSION onap/ccsdk-dgbuilder-image:latest
50 # start APPC containers with docker compose and configuration from docker-compose.yml
51 docker-compose up -d
52 # WAIT 5 minutes maximum and test every 5 seconds if APPC is up using HealthCheck API
53 TIME_OUT=2000
54 INTERVAL=30
55 TIME=0
56 while [ "$TIME" -lt "$TIME_OUT" ]; do
57
58 startODL_status=$(docker exec appc_controller_container ps -e | grep startODL | wc -l)
59 waiting_bundles=$(docker exec appc_controller_container /opt/opendaylight/current/bin/client -u karaf bundle:list | grep Waiting | wc -l)
60 run_level=$(docker exec appc_controller_container /opt/opendaylight/current/bin/client -u karaf system:start-level)
61
62   if [ "$run_level" == "Level 100" ] && [ "$startODL_status" -lt "1" ] && [ "$waiting_bundles" -lt "1" ] ; then
63     echo APPC started in $TIME seconds
64     break;
65   fi
66
67   echo Sleep: $INTERVAL seconds before testing if APPC is up. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds
68   sleep $INTERVAL
69   TIME=$(($TIME+$INTERVAL))
70 done
71
72 if [ "$TIME" -ge "$TIME_OUT" ]; then
73   echo TIME OUT: Docker containers not started in $TIME_OUT seconds... Could cause problems for testing activities...
74 fi
75
76 sleep 300
77
78 # Pass any variables required by Robot test suites in ROBOT_VARIABLES
79 ROBOT_VARIABLES="-v SCRIPTS:${SCRIPTS}"