blob: 9e87b041652b38fb2fcad93b60a8583d9c369133 [file] [log] [blame]
tragait3ae5ef42019-09-06 11:31:59 +01001#!/bin/bash
2#
3# ============LICENSE_START=======================================================
4# Copyright (C) 2019 Nordix Foundation.
5# ================================================================================
6# Licensed under the Apache License, Version 2.0 (the "License");
7# you may not use this file except in compliance with the License.
8# You may obtain a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS,
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17#
18# SPDX-License-Identifier: Apache-2.0
19# ============LICENSE_END=========================================================
20
21# @author Rahul Tyagi (rahul.tyagi@est.tech)
22
23
24SCRIPTS="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
25export PARENT=usecases
26export SUB_PARENT=config-over-netconf
27source ${WORKSPACE}/plans/$PARENT/$SUB_PARENT/test.properties
28
29export MTU=$(/sbin/ifconfig | grep MTU | sed 's/.*MTU://' | sed 's/ .*//' | sort -n | head -1)
30
31if [ "$MTU" == "" ]; then
32 export MTU="1450"
33fi
34
35# clone integration branch for pnf-simulator
36mkdir -m 755 -p $WORKSPACE/temp/integration
37cd $WORKSPACE/temp
38git clone -b dublin --single-branch --depth=1 http://gerrit.onap.org/r/integration.git integration
39
40HOST_IP_ADDR=localhost
41
42# setup sdnc
43
44cd $SDNC_DOCKER_PATH
45unset http_proxy https_proxy
46
47#sed -i "s/DMAAP_TOPIC_ENV=.*/DMAAP_TOPIC_ENV="AUTO"/g" diocker-compose.yml
48docker login -u $NEXUS_USERNAME -p $NEXUS_PASSWD $NEXUS_DOCKER_REPO
49
50docker pull $NEXUS_DOCKER_REPO/onap/sdnc-image:$SDNC_IMAGE_TAG
51docker tag $NEXUS_DOCKER_REPO/onap/sdnc-image:$SDNC_IMAGE_TAG onap/sdnc-image:latest
52
53docker pull $NEXUS_DOCKER_REPO/onap/sdnc-ansible-server-image:$ANSIBLE_IMAGE_TAG
54docker tag $NEXUS_DOCKER_REPO/onap/sdnc-ansible-server-image:$ANSIBLE_IMAGE_TAG onap/sdnc-ansible-server-image:latest
55
56docker pull $NEXUS_DOCKER_REPO/onap/ccsdk-blueprintsprocessor:$BP_IMAGE_TAG
57docker tag $NEXUS_DOCKER_REPO/onap/ccsdk-blueprintsprocessor:$BP_IMAGE_TAG onap/ccsdk-blueprintsprocessor:latest
58
59export SDNC_CERT_PATH=${CERT_SUBPATH}
60#sed -i 's/sdnc_controller_container/sdnc_controller_container\n volumes: \n - $SDNC_CERT_PATH:\/opt\/opendaylight\/current\/certs/' docker-compose.yaml
61# start SDNC containers with docker compose and configuration from docker-compose.yml
62docker-compose up -d
63
64# start pnf simulator
65
66cd $INT_DOCKER_PATH
67
68./simulator.sh start&
69
70# WAIT 10 minutes maximum and test every 5 seconds if SDNC is up using HealthCheck API
71TIME_OUT=1000
72INTERVAL=30
73TIME=0
74while [ "$TIME" -lt "$TIME_OUT" ]; do
75 response=$(curl --write-out '%{http_code}' --silent --output /dev/null -H "Authorization: Basic YWRtaW46S3A4Yko0U1hzek0wV1hsaGFrM2VIbGNzZTJnQXc4NHZhb0dHbUp2VXkyVQ==" -X POST -H "X-FromAppId: csit-sdnc" -H "X-TransactionId: csit-sdnc" -H "Accept: application/json" -H "Content-Type: application/json" http://localhost:8282/restconf/operations/SLI-API:healthcheck ); echo $response
76
77 if [ "$response" == "200" ]; then
78 echo SDNC started in $TIME seconds
79 break;
80 fi
81
82 echo Sleep: $INTERVAL seconds before testing if SDNC is up. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds
83 sleep $INTERVAL
84 TIME=$(($TIME+$INTERVAL))
85done
86
87export LOCAL_IP=$(ip -4 addr show docker0 | grep -Po 'inet \K[\d.]+')
88sed -i "s/pnfaddr/$LOCAL_IP/g" $REQUEST_DATA_PATH/mount.xml
89
90
91if [ "$TIME" -ge "$TIME_OUT" ]; then
92 echo TIME OUT: karaf session not started in $TIME_OUT seconds... Could cause problems for testing activities...
93fi
94
95########################################## blueprintsprocessor setup ##########################################################
96source $CDS_DOCKER_PATH/cds_setup.sh
97
98########## update pnf simulator ip in config deploy request ########
99
100NETOPEER_CONTAINER=$(docker ps -a -q --filter="name=netopeer")
101NETOPEER_CONTAINER_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $SDNC_CONTAINER)
102RES_KEY=$(uuidgen -r)
103sed -i "s/pnfaddr/$LOCAL_IP/g" $REQUEST_DATA_PATH/config-deploy.json
104sed -i "s/pnfaddr/$LOCAL_IP/g" $REQUEST_DATA_PATH/config-assign.json
105
106sed -i "s/reskey/$RES_KEY/g" $REQUEST_DATA_PATH/config-deploy.json
107sed -i "s/reskey/$RES_KEY/g" $REQUEST_DATA_PATH/config-assign.json
108
109#########################check if server is up gracefully ######################################
110
111TIME_OUT=1500
112INTERVAL=60
113TIME=0
114while [ "$TIME" -lt "$TIME_OUT" ]; do
115docker exec sdnc_controller_container rm -f /opt/opendaylight/current/etc/host.key
116response=$(docker exec sdnc_controller_container /opt/opendaylight/current/bin/client system:start-level)
117docker exec sdnc_controller_container rm -f /opt/opendaylight/current/etc/host.key
118
119 if [ "$response" == "Level 100" ] ; then
120 echo SDNC karaf started in $TIME seconds
121 break;
122 fi
123
124 echo Sleep: $INTERVAL seconds before testing if SDNC is up. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds
125 sleep $INTERVAL
126 TIME=$(($TIME+$INTERVAL))
127done
128
129if [ "$TIME" -ge "$TIME_OUT" ]; then
130 echo TIME OUT: karaf session not started in $TIME_OUT seconds... Could cause problems for testing activities...
131fi
132
133response=$(docker exec sdnc_controller_container /opt/opendaylight/current/bin/client system:start-level)
134
135 if [ "$response" == "Level 100" ] ; then
136 num_failed_bundles=$(docker exec sdnc_controller_container /opt/opendaylight/current/bin/client bundle:list | grep Failure | wc -l)
137 failed_bundles=$(docker exec sdnc_controller_container /opt/opendaylight/current/bin/client bundle:list | grep Failure)
138 echo There is/are $num_failed_bundles failed bundles out of $num_bundles installed bundles.
139 fi
140
141if [ "$num_failed_bundles" -ge 1 ]; then
142 echo "The following bundle(s) are in a failed state: "
143 echo " $failed_bundles"
144fi
145
146
147# Sleep additional 3 minutes (180 secs) to give application time to finish
148
149sleep 150
150
151# Pass any variables required by Robot test suites in ROBOT_VARIABLES
152
153ROBOT_VARIABLES="-v SCRIPTS:${SCRIPTS}"