blob: a30a7b454327afa8f56bedd73f81a212d5b37185 [file] [log] [blame]
tragait42a41b32019-07-10 12:51:38 +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:
20SCRIPTS="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
21source ${WORKSPACE}/scripts/sdnc/script1.sh
22export DOCKER_SDNC_TAG=1.5.2
23export NEXUS_USERNAME=docker
24export NEXUS_PASSWD=docker
25export NEXUS_DOCKER_REPO=nexus3.onap.org:10001
26export DMAAP_TOPIC=AUTO
27export DOCKER_IMAGE_VERSION=1.5.2
28export CCSDK_DOCKER_IMAGE_VERSION=0.4-STAGING-latest
29export CCSDK_DOCKER_BP_IMAGE_VERSION=0.4.5
30REQUEST_DATA_PATH=$WORKSPACE/tests/usecases/5G-config-over-netconf/data
31
32export MTU=$(/sbin/ifconfig | grep MTU | sed 's/.*MTU://' | sed 's/ .*//' | sort -n | head -1)
33
34if [ "$MTU" == "" ]; then
35 export MTU="1450"
36fi
37
38# Clone SDNC repo to get docker-compose for SDNC
39mkdir -p $WORKSPACE/archives/integration
40cd $WORKSPACE/archives
41git clone -b master --single-branch --depth=1 http://gerrit.onap.org/r/integration.git integration
42cd $WORKSPACE/archives/integration
43git pull
44#cd $WORKSPACE/archives/integration/test/mocks/pnfsimulator
45#sed -i 's/nexus3.onap.org:10003\/onap\/pnf-simulator:4.0.0-SNAPSHOT/nexus3.onap.org:10001\/onap\/pnf-simulator:latest/' docker-compose.yml
46HOST_IP_ADDR=localhost
47# Clone SDNC repo to get docker-compose for SDNC
48mkdir -p $WORKSPACE/archives/sdnc
49cd $WORKSPACE/archives
50git clone -b master --single-branch --depth=1 http://gerrit.onap.org/r/sdnc/oam.git sdnc
51cd $WORKSPACE/archives/sdnc
52git pull
53unset http_proxy https_proxy
54
55sed -i "s/DMAAP_TOPIC_ENV=.*/DMAAP_TOPIC_ENV="AUTO"/g" docker-compose.yml
56docker login -u $NEXUS_USERNAME -p $NEXUS_PASSWD $NEXUS_DOCKER_REPO
57
58docker pull $NEXUS_DOCKER_REPO/onap/sdnc-image:$DOCKER_SDNC_TAG
59docker tag $NEXUS_DOCKER_REPO/onap/sdnc-image:$DOCKER_SDNC_TAG onap/sdnc-image:latest
60
61docker pull $NEXUS_DOCKER_REPO/onap/sdnc-ansible-server-image:$DOCKER_IMAGE_VERSION
62docker tag $NEXUS_DOCKER_REPO/onap/sdnc-ansible-server-image:$DOCKER_IMAGE_VERSION onap/sdnc-ansible-server-image:latest
63
64docker pull $NEXUS_DOCKER_REPO/onap/ccsdk-dgbuilder-image:$CCSDK_DOCKER_IMAGE_VERSION
65docker tag $NEXUS_DOCKER_REPO/onap/ccsdk-dgbuilder-image:$CCSDK_DOCKER_IMAGE_VERSION onap/ccsdk-dgbuilder-image:latest
66
67docker pull $NEXUS_DOCKER_REPO/onap/admportal-sdnc-image:$DOCKER_IMAGE_VERSION
68docker tag $NEXUS_DOCKER_REPO/onap/admportal-sdnc-image:$DOCKER_IMAGE_VERSION onap/admportal-sdnc-image:latest
69
70docker pull $NEXUS_DOCKER_REPO/onap/sdnc-ueb-listener-image:$DOCKER_IMAGE_VERSION
71docker tag $NEXUS_DOCKER_REPO/onap/sdnc-ueb-listener-image:$DOCKER_IMAGE_VERSION onap/sdnc-ueb-listener-image:latest
72
73docker pull $NEXUS_DOCKER_REPO/onap/sdnc-dmaap-listener-image:$DOCKER_IMAGE_VERSION
74docker tag $NEXUS_DOCKER_REPO/onap/sdnc-dmaap-listener-image:$DOCKER_IMAGE_VERSION onap/sdnc-dmaap-listener-image:latest
75
76docker pull $NEXUS_DOCKER_REPO/onap/ccsdk-blueprintsprocessor:$CCSDK_DOCKER_BP_IMAGE_VERSION
77docker tag $NEXUS_DOCKER_REPO/onap/ccsdk-blueprintsprocessor:$CCSDK_DOCKER_BP_IMAGE_VERSION onap/ccsdk-blueprintsprocessor:latest
78
79
80CERT_SUBPATH=plans/sdnc/sdnc_netconf_tls_post_deploy/certs
81export SDNC_CERT_PATH=${WORKSPACE}/${CERT_SUBPATH}
82
83cd $WORKSPACE/archives/sdnc/installation/src/main/yaml
84sed -i 's/sdnc_controller_container/sdnc_controller_container\n volumes: \n - $SDNC_CERT_PATH:\/opt\/opendaylight\/current\/certs/' docker-compose.yml
85# start SDNC containers with docker compose and configuration from docker-compose.yml
86docker-compose up -d
87
88cd $WORKSPACE/archives/integration/test/mocks/pnfsimulator
89./simulator.sh start&
90
91# WAIT 10 minutes maximum and test every 5 seconds if SDNC is up using HealthCheck API
92TIME_OUT=1000
93INTERVAL=30
94TIME=0
95while [ "$TIME" -lt "$TIME_OUT" ]; do
96 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
97
98 if [ "$response" == "200" ]; then
99 echo SDNC started in $TIME seconds
100 break;
101 fi
102
103 echo Sleep: $INTERVAL seconds before testing if SDNC is up. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds
104 sleep $INTERVAL
105 TIME=$(($TIME+$INTERVAL))
106done
107
108export LOCAL_IP=$(ip -4 addr show docker0 | grep -Po 'inet \K[\d.]+')
109sed -i "s/pnfaddr/$LOCAL_IP/g" $REQUEST_DATA_PATH/mount.xml
110
111if [ "$TIME" -ge "$TIME_OUT" ]; then
112 echo TIME OUT: Docker containers not started in $TIME_OUT seconds... Could cause problems for testing activities...
113fi
114
115#sleep 800
116
117TIME_OUT=1500
118INTERVAL=60
119TIME=0
120while [ "$TIME" -lt "$TIME_OUT" ]; do
121docker exec sdnc_controller_container rm -f /opt/opendaylight/current/etc/host.key
122response=$(docker exec sdnc_controller_container /opt/opendaylight/current/bin/client system:start-level)
123docker exec sdnc_controller_container rm -f /opt/opendaylight/current/etc/host.key
124
125 if [ "$response" == "Level 100" ] ; then
126 echo SDNC karaf started in $TIME seconds
127 break;
128 fi
129
130 echo Sleep: $INTERVAL seconds before testing if SDNC is up. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds
131 sleep $INTERVAL
132 TIME=$(($TIME+$INTERVAL))
133done
134
135if [ "$TIME" -ge "$TIME_OUT" ]; then
136 echo TIME OUT: karaf session not started in $TIME_OUT seconds... Could cause problems for testing activities...
137fi
138
139response=$(docker exec sdnc_controller_container /opt/opendaylight/current/bin/client system:start-level)
140
141 if [ "$response" == "Level 100" ] ; then
142 num_failed_bundles=$(docker exec sdnc_controller_container /opt/opendaylight/current/bin/client bundle:list | grep Failure | wc -l)
143 failed_bundles=$(docker exec sdnc_controller_container /opt/opendaylight/current/bin/client bundle:list | grep Failure)
144 echo There is/are $num_failed_bundles failed bundles out of $num_bundles installed bundles.
145 fi
146
147if [ "$num_failed_bundles" -ge 1 ]; then
148 echo "The following bundle(s) are in a failed state: "
149 echo " $failed_bundles"
150fi
151
152########################################## blueprintsprocessor setup ##########################################################
153
154mkdir -p $WORKSPACE/archives/cds
155cd $WORKSPACE/archives
156
157git clone -b master --single-branch --depth=1 http://gerrit.onap.org/r/ccsdk/cds.git cds
158cd $WORKSPACE/archives/cds
159git pull
160unset http_proxy https_proxy
161cd $WORKSPACE/archives/cds/ms/blueprintsprocessor/distribution/src/main/dc/
162
163############# update ip of sdnc in docker-compose###########
164SDNC_CONTAINER=$(docker ps -a -q --filter="name=sdnc_controller_container")
165SDNC_CONTAINER_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $SDNC_CONTAINER)
166echo " " >> docker-compose.yaml
167echo " extra_hosts:" >> docker-compose.yaml
168echo " - 'sdnc:$LOCAL_IP'" >> docker-compose.yaml
169#############################################################
170
171docker-compose up &
172sleep 10
173################# Check state of BP ####################
174BP_CONTAINER=$(docker ps -a -q --filter="name=bp-rest")
175CCSDK_MARIADB=$(docker ps -a -q --filter="name=ccsdk-mariadb")
176for i in {1..10}; do
177if [ $(docker inspect --format '{{ .State.Running }}' $BP_CONTAINER) ] && \
178[ $(docker inspect --format '{{ .State.Running }}' $CCSDK_MARIADB) ]
179then
180 echo "Blueprint proc Service Running"
181 break
182else
183 echo sleep $i
184 sleep $i
185fi
186done
187
188########## update pnf simulator ip in config deploy request ########
189
190NETOPEER_CONTAINER=$(docker ps -a -q --filter="name=netopeer")
191NETOPEER_CONTAINER_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $SDNC_CONTAINER)
192RES_KEY=$(uuidgen -r)
193sed -i "s/pnfaddr/$LOCAL_IP/g" $REQUEST_DATA_PATH/config-deploy.json
194sed -i "s/pnfaddr/$LOCAL_IP/g" $REQUEST_DATA_PATH/config-assign.json
195
196sed -i "s/reskey/$RES_KEY/g" $REQUEST_DATA_PATH/config-deploy.json
197sed -i "s/reskey/$RES_KEY/g" $REQUEST_DATA_PATH/config-assign.json
198
199####################################################################
200# Sleep additional 3 minutes (180 secs) to give application time to finish
201sleep 150
202
203
204# Pass any variables required by Robot test suites in ROBOT_VARIABLES
205ROBOT_VARIABLES="-v SCRIPTS:${SCRIPTS}"