Merge "Drools-apps CSIT randomly fails deploying policies"
[integration/csit.git] / plans / usecases-config-over-netconf / config-over-netconf / setup.sh
1 #!/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
24 SCRIPTS="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
25 export PARENT=usecases-config-over-netconf
26 export SUB_PARENT=config-over-netconf
27 source ${WORKSPACE}/plans/$PARENT/$SUB_PARENT/test.properties
28
29 export MTU=$(/sbin/ifconfig | grep MTU | sed 's/.*MTU://' | sed 's/ .*//' | sort -n | head -1)
30
31 if [ "$MTU" == "" ]; then
32           export MTU="1450"
33 fi
34
35 # clone integration branch for pnf-simulator
36 mkdir -m 755 -p $WORKSPACE/temp/integration
37 cd $WORKSPACE/temp
38 git clone -b dublin --single-branch --depth=1 http://gerrit.onap.org/r/integration.git integration
39
40 HOST_IP_ADDR=localhost
41
42 # setup sdnc
43
44 cd $SDNC_DOCKER_PATH
45 unset http_proxy https_proxy
46
47 docker pull $NETOPEER_DOCKER_REPO:$NETOPEER_IMAGE_TAG
48 docker tag  $NETOPEER_DOCKER_REPO:$NETOPEER_IMAGE_TAG $NETOPEER_DOCKER_REPO:latest
49 #sed -i "s/DMAAP_TOPIC_ENV=.*/DMAAP_TOPIC_ENV="AUTO"/g" diocker-compose.yml
50 docker login -u $NEXUS_USERNAME -p $NEXUS_PASSWD $NEXUS_DOCKER_REPO
51
52 docker pull $NEXUS_DOCKER_REPO/onap/sdnc-image:$SDNC_IMAGE_TAG
53 docker tag $NEXUS_DOCKER_REPO/onap/sdnc-image:$SDNC_IMAGE_TAG onap/sdnc-image:latest
54
55 docker pull $NEXUS_DOCKER_REPO/onap/sdnc-ansible-server-image:$ANSIBLE_IMAGE_TAG
56 docker tag $NEXUS_DOCKER_REPO/onap/sdnc-ansible-server-image:$ANSIBLE_IMAGE_TAG onap/sdnc-ansible-server-image:latest
57
58 docker pull $NEXUS_DOCKER_REPO/onap/ccsdk-blueprintsprocessor:$BP_IMAGE_TAG
59 docker tag $NEXUS_DOCKER_REPO/onap/ccsdk-blueprintsprocessor:$BP_IMAGE_TAG onap/ccsdk-blueprintsprocessor:latest
60
61 export SDNC_CERT_PATH=${CERT_SUBPATH}
62 #sed -i 's/sdnc_controller_container/sdnc_controller_container\n    volumes: \n      - $SDNC_CERT_PATH:\/opt\/opendaylight\/current\/certs/' docker-compose.yaml
63 # start SDNC containers with docker compose and configuration from docker-compose.yml
64 docker-compose up -d
65
66 # start pnf simulator
67
68 cd $INT_DOCKER_PATH
69
70 ./simulator.sh start&
71
72 # WAIT 10 minutes maximum and test every 5 seconds if SDNC is up using HealthCheck API
73 TIME_OUT=1000
74 INTERVAL=30
75 TIME=0
76 while [ "$TIME" -lt "$TIME_OUT" ]; do
77   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 );
78   echo $response
79
80   if [ "$response" == "200" ]; then
81     echo SDNC started in $TIME seconds
82     break;
83   fi
84
85   echo Sleep: $INTERVAL seconds before testing if SDNC is up. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds
86   sleep $INTERVAL
87   TIME=$(($TIME+$INTERVAL))
88 done
89
90 export LOCAL_IP=$(ip -4 addr show docker0 | grep -Po 'inet \K[\d.]+')
91 sed -i "s/pnfaddr/$LOCAL_IP/g" $REQUEST_DATA_PATH/mount.xml
92
93
94 if [ "$TIME" -ge "$TIME_OUT" ]; then
95    echo TIME OUT: karaf session not started in $TIME_OUT seconds... Could cause problems for testing activities...
96 fi
97
98 ########################################## blueprintsprocessor setup ##########################################################
99 source $CDS_DOCKER_PATH/cds_setup.sh
100
101 ########## update pnf simulator ip in config deploy request ########
102
103 NETOPEER_CONTAINER=$(docker ps -a -q --filter="name=netopeer")
104 NETOPEER_CONTAINER_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $SDNC_CONTAINER)
105 RES_KEY=$(uuidgen -r)
106 sed -i "s/pnfaddr/$LOCAL_IP/g" $REQUEST_DATA_PATH/config-deploy.json
107 sed -i "s/pnfaddr/$LOCAL_IP/g" $REQUEST_DATA_PATH/config-assign.json
108
109 sed -i "s/reskey/$RES_KEY/g" $REQUEST_DATA_PATH/config-deploy.json
110 sed -i "s/reskey/$RES_KEY/g" $REQUEST_DATA_PATH/config-assign.json
111
112 #########################check if server is up gracefully ######################################
113
114 # Sleep additional 3 minutes (180 secs) to give application time to finish
115
116 sleep 150
117
118 # Pass any variables required by Robot test suites in ROBOT_VARIABLES
119
120 ROBOT_VARIABLES="-v SCRIPTS:${SCRIPTS}"