Update CSIT to use Frankfurt images
[integration/csit.git] / plans / sdnc / sdnc_netconf_tls_post_deploy / setup.sh
1 #!/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:
20 SCRIPTS="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
21 source ${WORKSPACE}/scripts/sdnc/script1.sh
22 export DOCKER_SDNC_TAG=1.8-STAGING-latest
23 export NEXUS_USERNAME=docker
24 export NEXUS_PASSWD=docker
25 export NEXUS_DOCKER_REPO=nexus3.onap.org:10001
26 export DMAAP_TOPIC=AUTO
27 export DOCKER_IMAGE_VERSION=1.8-STAGING-latest
28 export CCSDK_DOCKER_IMAGE_VERSION=0.7-STAGING-latest
29 export SDNC_GERRIT_BRANCH=frankfurt
30 export INTEGRATION_GERRIT_BRANCH=master
31
32 export MTU=$(/sbin/ifconfig | grep MTU | sed 's/.*MTU://' | sed 's/ .*//' | sort -n | head -1)
33
34 if [ "$MTU" == "" ]; then
35           export MTU="1450"
36 fi
37
38 # Clone SDNC repo to get docker-compose for SDNC
39 mkdir -p $WORKSPACE/archives/integration
40 cd $WORKSPACE/archives
41 git clone -b ${INTEGRATION_GERRIT_BRANCH} --single-branch --depth=1 http://gerrit.onap.org/r/integration.git integration
42 cd $WORKSPACE/archives/integration
43 git pull
44 HOST_IP_ADDR=localhost
45 # Clone SDNC repo to get docker-compose for SDNC
46 mkdir -p $WORKSPACE/archives/sdnc
47 cd $WORKSPACE/archives
48 git clone -b ${SDNC_GERRIT_BRANCH} --single-branch --depth=1 http://gerrit.onap.org/r/sdnc/oam.git sdnc
49 cd $WORKSPACE/archives/sdnc
50 git pull
51 unset http_proxy https_proxy
52 cd $WORKSPACE/archives/sdnc/installation/src/main/yaml
53
54 sed -i "s/DMAAP_TOPIC_ENV=.*/DMAAP_TOPIC_ENV=\"AUTO\"/g" docker-compose.yml
55 docker login -u $NEXUS_USERNAME -p $NEXUS_PASSWD $NEXUS_DOCKER_REPO
56
57 docker pull $NEXUS_DOCKER_REPO/onap/sdnc-image:$DOCKER_SDNC_TAG
58 docker tag $NEXUS_DOCKER_REPO/onap/sdnc-image:$DOCKER_SDNC_TAG onap/sdnc-image:latest
59
60 docker pull $NEXUS_DOCKER_REPO/onap/sdnc-ansible-server-image:$DOCKER_IMAGE_VERSION
61 docker tag $NEXUS_DOCKER_REPO/onap/sdnc-ansible-server-image:$DOCKER_IMAGE_VERSION onap/sdnc-ansible-server-image:latest
62
63 docker pull $NEXUS_DOCKER_REPO/onap/ccsdk-dgbuilder-image:$CCSDK_DOCKER_IMAGE_VERSION
64 docker tag $NEXUS_DOCKER_REPO/onap/ccsdk-dgbuilder-image:$CCSDK_DOCKER_IMAGE_VERSION onap/ccsdk-dgbuilder-image:latest
65
66 docker pull $NEXUS_DOCKER_REPO/onap/admportal-sdnc-image:$DOCKER_IMAGE_VERSION
67 docker tag $NEXUS_DOCKER_REPO/onap/admportal-sdnc-image:$DOCKER_IMAGE_VERSION onap/admportal-sdnc-image:latest
68
69 docker pull $NEXUS_DOCKER_REPO/onap/sdnc-ueb-listener-image:$DOCKER_IMAGE_VERSION
70 docker tag $NEXUS_DOCKER_REPO/onap/sdnc-ueb-listener-image:$DOCKER_IMAGE_VERSION onap/sdnc-ueb-listener-image:latest
71
72 docker pull $NEXUS_DOCKER_REPO/onap/sdnc-dmaap-listener-image:$DOCKER_IMAGE_VERSION
73
74 docker tag $NEXUS_DOCKER_REPO/onap/sdnc-dmaap-listener-image:$DOCKER_IMAGE_VERSION onap/sdnc-dmaap-listener-image:latest
75
76 CERT_SUBPATH=plans/sdnc/sdnc_netconf_tls_post_deploy/certs
77
78 export SDNC_CERT_PATH=${WORKSPACE}/${CERT_SUBPATH}
79 sed -i 's/sdnc_controller_container/sdnc_controller_container\n    volumes: \n      - $SDNC_CERT_PATH:\/opt\/opendaylight\/current\/certs/' docker-compose.yml
80 # start SDNC containers with docker compose and configuration from docker-compose.yml
81 docker-compose up -d
82
83 # PNF simulator has permission problems - creates files as root, which causes build to be unstable
84 # Commenting it out for now, since netconf mount is not working anyway.
85 # cd $WORKSPACE/archives/integration/test/mocks/pnfsimulator/pnfsimulator
86 # docker-compose up -d
87
88 # WAIT 10 minutes maximum and test every 5 seconds if SDNC is up using HealthCheck API
89 TIME_OUT=1000
90 INTERVAL=30
91 TIME=0
92 while [ "$TIME" -lt "$TIME_OUT" ]; do
93   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
94
95   if [ "$response" == "200" ]; then
96     echo SDNC started in $TIME seconds
97     break;
98   fi
99
100   echo Sleep: $INTERVAL seconds before testing if SDNC is up. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds
101   sleep $INTERVAL
102   TIME=$(($TIME+$INTERVAL))
103 done
104
105 export PNF_IP=$(ip -4 addr show docker0 | grep -Po 'inet \K[\d.]+')
106 sed -i "s/pnfaddr/$PNF_IP/g" $WORKSPACE/tests/sdnc/sdnc_netconf_tls_post_deploy/data/mount.xml
107
108 if [ "$TIME" -ge "$TIME_OUT" ]; then
109    echo TIME OUT: Docker containers not started in $TIME_OUT seconds... Could cause problems for testing activities...
110 fi
111
112 #sleep 800
113
114 TIME_OUT=1500
115 INTERVAL=60
116 TIME=0
117 while [ "$TIME" -lt "$TIME_OUT" ]; do
118   response=$(docker exec -ti sdnc_controller_container /opt/opendaylight/current/bin/client system:start-level)
119
120   if grep -q 'Level 100' <<< ${response}; then
121     echo SDNC karaf started in $TIME seconds
122     break;
123   fi
124
125   echo Sleep: $INTERVAL seconds before testing if SDNC is up. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds
126   sleep $INTERVAL
127   TIME=$(($TIME+$INTERVAL))
128 done
129
130 if [ "$TIME" -ge "$TIME_OUT" ]; then
131    echo TIME OUT: karaf session not started in $TIME_OUT seconds... Could cause problems for testing activities...
132 fi
133
134 response=$(docker exec -ti sdnc_controller_container /opt/opendaylight/current/bin/client system:start-level)
135
136   if grep -q 'Level 100' <<< ${response}; then
137     num_failed_bundles=$(docker exec -ti sdnc_controller_container /opt/opendaylight/current/bin/client bundle:list | grep Failure | wc -l)
138     failed_bundles=$(docker exec -ti sdnc_controller_container /opt/opendaylight/current/bin/client bundle:list | grep Failure)
139     echo There is/are $num_failed_bundles failed bundles out of $num_bundles installed bundles.
140   fi
141
142 if [ "$num_failed_bundles" -ge 1 ]; then
143   echo "The following bundle(s) are in a failed state: "
144   echo "  $failed_bundles"
145 fi
146
147 # Sleep additional 5 minutes (300 secs) to give application time to finish
148 sleep 200
149
150 # Pass any variables required by Robot test suites in ROBOT_VARIABLES
151 ROBOT_VARIABLES="-v SCRIPTS:${SCRIPTS}"