Fixed Config-Over-Netconf CSIT
[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 SCRIPTS="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
24 source "${WORKSPACE}"/plans/usecases-config-over-netconf/config-over-netconf/test.properties
25
26 export MTU=$(/sbin/ifconfig | grep MTU | sed 's/.*MTU://' | sed 's/ .*//' | sort -n | head -1)
27
28 if [ "$MTU" == "" ]; then
29   export MTU="1450"
30 fi
31
32 export CONFIG_OVER_NETCONF=${CONFIG_OVER_NETCONF}
33
34 # Prepare enviroment
35 echo "Uninstall docker-py and reinstall docker."
36 pip uninstall -y docker-py
37 pip uninstall -y docker
38 pip install -U docker==2.7.0
39
40 # Disable Proxy - for local run
41 unset http_proxy https_proxy
42
43 # Export default Networking bridge created on the host machine
44 export LOCAL_IP=$(ip -4 addr show docker0 | grep -Po 'inet \K[\d.]+')
45
46 ###################### Netconf-PNP-Simulator Setup ######################
47
48 # Export Netconf-Pnp Simulator conf path
49 export NETCONF_CONFIG_PATH
50
51 # Start N etconf-Pnp-Simulator Container with docker-compose and configuration from docker-compose.yml
52 docker-compose -f "${CONFIG_OVER_NETCONF}"/netconf-pnp-simulator/docker-compose.yml up -d
53
54 # Update default Networking bridge IP in mount.json file
55 sed -i "s/pnfaddr/${LOCAL_IP}/g" "${REQUEST_DATA_PATH}"/mount.xml
56
57 ############################## SDNC Setup ##############################
58
59 export SDNC_CERT_PATH="${CERT_SUBPATH}"
60
61 docker pull "${NEXUS_DOCKER_REPO}"/onap/sdnc-image:"${SDNC_IMAGE_TAG}"
62 docker tag "${NEXUS_DOCKER_REPO}"/onap/sdnc-image:"${SDNC_IMAGE_TAG}" onap/sdnc-image:latest
63
64 docker pull "${NEXUS_DOCKER_REPO}"/onap/sdnc-ansible-server-image:"${ANSIBLE_IMAGE_TAG}"
65 docker tag "${NEXUS_DOCKER_REPO}"/onap/sdnc-ansible-server-image:"${ANSIBLE_IMAGE_TAG}" onap/sdnc-ansible-server-image:latest
66
67 docker-compose -f "${CONFIG_OVER_NETCONF}"/sdn/docker-compose.yaml up -d
68
69 # Check if SDNC Service is healthy and ready
70 for i in {1..10}; do
71   SDNC_IP=$(get-instance-ip.sh sdnc_controller_container)
72   RESP_CODE=$(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)
73   if [[ "${RESP_CODE}" == '200' ]]; then
74     echo "SDNC Service is Ready."
75     break
76   fi
77   echo "Waiting for SDNC Service to Start Up..."
78   sleep 2m
79 done
80
81 if [[ "${SDNC_IP}" == 'none' || "${SDNC_IP}" == '' || "${RESP_CODE}" != '200' ]]; then
82   echo "SDNC Service not started Could cause problems for testing activities...!"
83 fi
84
85 ############################## CDS Setup ##############################
86
87 docker pull "${NEXUS_DOCKER_REPO}"/onap/ccsdk-blueprintsprocessor:"${BP_IMAGE_TAG}"
88 docker tag "${NEXUS_DOCKER_REPO}"/onap/ccsdk-blueprintsprocessor:"${BP_IMAGE_TAG}" onap/ccsdk-blueprintsprocessor:latest
89
90 docker-compose -f "${CONFIG_OVER_NETCONF}"/cds/docker-compose.yaml up -d
91
92 echo "Sleeping 1 minute"
93 sleep 1m
94
95 BP_CONTAINER=$(docker ps -a -q --filter="name=bp-rest")
96 CCSDK_MARIADB=$(docker ps -a -q --filter="name=ccsdk-mariadb")
97
98 for i in {1..10}; do
99   if [ $(docker inspect --format='{{ .State.Running }}' "${BP_CONTAINER}") ] &&
100     [ $(docker inspect --format='{{ .State.Running }}' "${CCSDK_MARIADB}") ]; then
101     echo "Blueprint Proc Service Running"
102     break
103   else
104     echo sleep "${i}"
105     sleep "${i}"
106   fi
107 done
108
109 ############################ Update Setup ############################
110
111 RES_KEY=$(uuidgen -r)
112 sed -i "s/pnfaddr/$LOCAL_IP/g" "${REQUEST_DATA_PATH}"/config-deploy.json
113 sed -i "s/pnfaddr/$LOCAL_IP/g" "${REQUEST_DATA_PATH}"/config-assign.json
114
115 sed -i "s/reskey/$RES_KEY/g" "${REQUEST_DATA_PATH}"/config-deploy.json
116 sed -i "s/reskey/$RES_KEY/g" "${REQUEST_DATA_PATH}"/config-assign.json
117
118 # Pass any variables required by Robot test suites in ROBOT_VARIABLES
119 REPO_IP='127.0.0.1'
120 ROBOT_VARIABLES+=" -v REPO_IP:${REPO_IP} "
121 ROBOT_VARIABLES+=" -v SCRIPTS:${SCRIPTS} "