blob: b91baa3a9160c360082051c823faf8d69b90db85 [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 Hay5a7cb082017-08-21 19:09:35 +000023export MTU=$(/sbin/ifconfig | grep MTU | sed 's/.*MTU://' | sed 's/ .*//' | sort -n | head -1)
24
25
26# Clone APPC repo to get docker-compose for APPC
27mkdir -p $WORKSPACE/archives/appc
28cd $WORKSPACE/archives
29git clone -b master --single-branch http://gerrit.onap.org/r/appc/deployment.git appc
30cd $WORKSPACE/archives/appc
31git pull
Aaron Haydb1e9c52017-08-24 15:06:59 +000032unset http_proxy https_proxy
Aaron Hay5a7cb082017-08-21 19:09:35 +000033cd $WORKSPACE/archives/appc/docker-compose
34
35sed -i "s/DMAAP_TOPIC_ENV=.*/DMAAP_TOPIC_ENV="AUTO"/g" docker-compose.yml
36docker login -u docker -p docker nexus3.onap.org:10001
37
38docker pull nexus3.onap.org:10001/openecomp/appc-image:1.1-STAGING-latest
39docker tag nexus3.onap.org:10001/openecomp/appc-image:1.1-STAGING-latest openecomp/appc-image:latest
40
41docker pull nexus3.onap.org:10001/openecomp/dgbuilder-sdnc-image:1.1-STAGING-latest
42docker tag nexus3.onap.org:10001/openecomp/dgbuilder-sdnc-image:1.1-STAGING-latest openecomp/dgbuilder-sdnc-image:latest
43
44# start APPC containers with docker compose and configuration from docker-compose.yml
45/opt/docker/docker-compose up -d
46
47# WAIT 5 minutes maximum and test every 5 seconds if APPC is up using HealthCheck API
Aaron Haydb1e9c52017-08-24 15:06:59 +000048TIME_OUT=500
49INTERVAL=30
Aaron Hay5a7cb082017-08-21 19:09:35 +000050TIME=0
51while [ "$TIME" -lt "$TIME_OUT" ]; do
52 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
53
54 if [ "$response" == "200" ]; then
55 echo APPC started in $TIME seconds
56 break;
57 fi
58
59 echo Sleep: $INTERVAL seconds before testing if APPC is up. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds
60 sleep $INTERVAL
61 TIME=$(($TIME+$INTERVAL))
62done
63
64if [ "$TIME" -ge "$TIME_OUT" ]; then
65 echo TIME OUT: Docker containers not started in $TIME_OUT seconds... Could cause problems for testing activities...
66fi
67
Aaron Haydb1e9c52017-08-24 15:06:59 +000068#sleep 800
69
70TIME_OUT=1500
71INTERVAL=60
72TIME=0
73while [ "$TIME" -lt "$TIME_OUT" ]; do
74
75response=$(docker exec appc_controller_container /opt/opendaylight/current/bin/client -u karaf system:start-level)
76num_bundles=$(docker exec appc_controller_container /opt/opendaylight/current/bin/client -u karaf bundle:list | tail -1 | cut -d\| -f1)
77
78 if [ "$response" == "Level 100" ] && [ "$num_bundles" -ge 394 ]; then
79 echo APPC karaf started in $TIME seconds
80 break;
81 fi
82
83 echo Sleep: $INTERVAL seconds before testing if APPC is up. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds
84 sleep $INTERVAL
85 TIME=$(($TIME+$INTERVAL))
86done
87
88if [ "$TIME" -ge "$TIME_OUT" ]; then
89 echo TIME OUT: karaf session not started in $TIME_OUT seconds... Could cause problems for testing activities...
90fi
91
92response=$(docker exec appc_controller_container /opt/opendaylight/current/bin/client -u karaf system:start-level)
93num_bundles=$(docker exec appc_controller_container /opt/opendaylight/current/bin/client -u karaf bundle:list | tail -1 | cut -d\| -f1)
94
95 if [ "$response" == "Level 100" ] && [ "$num_bundles" -ge 394 ]; then
96 num_bundles=$(docker exec appc_controller_container /opt/opendaylight/current/bin/client -u karaf bundle:list | tail -1 | cut -d\| -f1)
97 num_failed_bundles=$(docker exec appc_controller_container /opt/opendaylight/current/bin/client -u karaf bundle:list | grep Failure | wc -l)
98 failed_bundles=$(docker exec appc_controller_container /opt/opendaylight/current/bin/client -u karaf bundle:list | grep Failure)
99 echo There is/are $num_failed_bundles failed bundles out of $num_bundles installed bundles.
100 fi
101
102if [ "$num_failed_bundles" -ge 1 ]; then
103 echo "The following bundle(s) are in a failed state: "
104 echo " $failed_bundles"
105fi
106
Aaron Hay5a7cb082017-08-21 19:09:35 +0000107# Pass any variables required by Robot test suites in ROBOT_VARIABLES
Aaron Haydb1e9c52017-08-24 15:06:59 +0000108ROBOT_VARIABLES="-v SCRIPTS:${SCRIPTS}"
Aaron Hay5a7cb082017-08-21 19:09:35 +0000109