tragait | 42a41b3 | 2019-07-10 12:51:38 +0000 | [diff] [blame] | 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.5.2 |
| 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.5.2 |
| 28 | export CCSDK_DOCKER_IMAGE_VERSION=0.4-STAGING-latest |
| 29 | export CCSDK_DOCKER_BP_IMAGE_VERSION=0.4.5 |
| 30 | REQUEST_DATA_PATH=$WORKSPACE/tests/usecases/5G-config-over-netconf/data |
| 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 master --single-branch --depth=1 http://gerrit.onap.org/r/integration.git integration |
| 42 | cd $WORKSPACE/archives/integration |
| 43 | git 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 |
| 46 | HOST_IP_ADDR=localhost |
| 47 | # Clone SDNC repo to get docker-compose for SDNC |
| 48 | mkdir -p $WORKSPACE/archives/sdnc |
| 49 | cd $WORKSPACE/archives |
| 50 | git clone -b master --single-branch --depth=1 http://gerrit.onap.org/r/sdnc/oam.git sdnc |
| 51 | cd $WORKSPACE/archives/sdnc |
| 52 | git pull |
| 53 | unset http_proxy https_proxy |
| 54 | |
| 55 | sed -i "s/DMAAP_TOPIC_ENV=.*/DMAAP_TOPIC_ENV="AUTO"/g" docker-compose.yml |
| 56 | docker login -u $NEXUS_USERNAME -p $NEXUS_PASSWD $NEXUS_DOCKER_REPO |
| 57 | |
| 58 | docker pull $NEXUS_DOCKER_REPO/onap/sdnc-image:$DOCKER_SDNC_TAG |
| 59 | docker tag $NEXUS_DOCKER_REPO/onap/sdnc-image:$DOCKER_SDNC_TAG onap/sdnc-image:latest |
| 60 | |
| 61 | docker pull $NEXUS_DOCKER_REPO/onap/sdnc-ansible-server-image:$DOCKER_IMAGE_VERSION |
| 62 | docker tag $NEXUS_DOCKER_REPO/onap/sdnc-ansible-server-image:$DOCKER_IMAGE_VERSION onap/sdnc-ansible-server-image:latest |
| 63 | |
| 64 | docker pull $NEXUS_DOCKER_REPO/onap/ccsdk-dgbuilder-image:$CCSDK_DOCKER_IMAGE_VERSION |
| 65 | docker tag $NEXUS_DOCKER_REPO/onap/ccsdk-dgbuilder-image:$CCSDK_DOCKER_IMAGE_VERSION onap/ccsdk-dgbuilder-image:latest |
| 66 | |
| 67 | docker pull $NEXUS_DOCKER_REPO/onap/admportal-sdnc-image:$DOCKER_IMAGE_VERSION |
| 68 | docker tag $NEXUS_DOCKER_REPO/onap/admportal-sdnc-image:$DOCKER_IMAGE_VERSION onap/admportal-sdnc-image:latest |
| 69 | |
| 70 | docker pull $NEXUS_DOCKER_REPO/onap/sdnc-ueb-listener-image:$DOCKER_IMAGE_VERSION |
| 71 | docker tag $NEXUS_DOCKER_REPO/onap/sdnc-ueb-listener-image:$DOCKER_IMAGE_VERSION onap/sdnc-ueb-listener-image:latest |
| 72 | |
| 73 | docker pull $NEXUS_DOCKER_REPO/onap/sdnc-dmaap-listener-image:$DOCKER_IMAGE_VERSION |
| 74 | docker tag $NEXUS_DOCKER_REPO/onap/sdnc-dmaap-listener-image:$DOCKER_IMAGE_VERSION onap/sdnc-dmaap-listener-image:latest |
| 75 | |
| 76 | docker pull $NEXUS_DOCKER_REPO/onap/ccsdk-blueprintsprocessor:$CCSDK_DOCKER_BP_IMAGE_VERSION |
| 77 | docker tag $NEXUS_DOCKER_REPO/onap/ccsdk-blueprintsprocessor:$CCSDK_DOCKER_BP_IMAGE_VERSION onap/ccsdk-blueprintsprocessor:latest |
| 78 | |
| 79 | |
| 80 | CERT_SUBPATH=plans/sdnc/sdnc_netconf_tls_post_deploy/certs |
| 81 | export SDNC_CERT_PATH=${WORKSPACE}/${CERT_SUBPATH} |
| 82 | |
| 83 | cd $WORKSPACE/archives/sdnc/installation/src/main/yaml |
| 84 | sed -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 |
| 86 | docker-compose up -d |
| 87 | |
| 88 | cd $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 |
| 92 | TIME_OUT=1000 |
| 93 | INTERVAL=30 |
| 94 | TIME=0 |
| 95 | while [ "$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)) |
| 106 | done |
| 107 | |
| 108 | export LOCAL_IP=$(ip -4 addr show docker0 | grep -Po 'inet \K[\d.]+') |
| 109 | sed -i "s/pnfaddr/$LOCAL_IP/g" $REQUEST_DATA_PATH/mount.xml |
| 110 | |
| 111 | if [ "$TIME" -ge "$TIME_OUT" ]; then |
| 112 | echo TIME OUT: Docker containers not started in $TIME_OUT seconds... Could cause problems for testing activities... |
| 113 | fi |
| 114 | |
| 115 | #sleep 800 |
| 116 | |
| 117 | TIME_OUT=1500 |
| 118 | INTERVAL=60 |
| 119 | TIME=0 |
| 120 | while [ "$TIME" -lt "$TIME_OUT" ]; do |
| 121 | docker exec sdnc_controller_container rm -f /opt/opendaylight/current/etc/host.key |
| 122 | response=$(docker exec sdnc_controller_container /opt/opendaylight/current/bin/client system:start-level) |
| 123 | docker 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)) |
| 133 | done |
| 134 | |
| 135 | if [ "$TIME" -ge "$TIME_OUT" ]; then |
| 136 | echo TIME OUT: karaf session not started in $TIME_OUT seconds... Could cause problems for testing activities... |
| 137 | fi |
| 138 | |
| 139 | response=$(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 | |
| 147 | if [ "$num_failed_bundles" -ge 1 ]; then |
| 148 | echo "The following bundle(s) are in a failed state: " |
| 149 | echo " $failed_bundles" |
| 150 | fi |
| 151 | |
| 152 | ########################################## blueprintsprocessor setup ########################################################## |
| 153 | |
| 154 | mkdir -p $WORKSPACE/archives/cds |
| 155 | cd $WORKSPACE/archives |
| 156 | |
| 157 | git clone -b master --single-branch --depth=1 http://gerrit.onap.org/r/ccsdk/cds.git cds |
| 158 | cd $WORKSPACE/archives/cds |
| 159 | git pull |
| 160 | unset http_proxy https_proxy |
| 161 | cd $WORKSPACE/archives/cds/ms/blueprintsprocessor/distribution/src/main/dc/ |
| 162 | |
| 163 | ############# update ip of sdnc in docker-compose########### |
| 164 | SDNC_CONTAINER=$(docker ps -a -q --filter="name=sdnc_controller_container") |
| 165 | SDNC_CONTAINER_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $SDNC_CONTAINER) |
| 166 | echo " " >> docker-compose.yaml |
| 167 | echo " extra_hosts:" >> docker-compose.yaml |
| 168 | echo " - 'sdnc:$LOCAL_IP'" >> docker-compose.yaml |
| 169 | ############################################################# |
| 170 | |
| 171 | docker-compose up & |
| 172 | sleep 10 |
| 173 | ################# Check state of BP #################### |
| 174 | BP_CONTAINER=$(docker ps -a -q --filter="name=bp-rest") |
| 175 | CCSDK_MARIADB=$(docker ps -a -q --filter="name=ccsdk-mariadb") |
| 176 | for i in {1..10}; do |
| 177 | if [ $(docker inspect --format '{{ .State.Running }}' $BP_CONTAINER) ] && \ |
| 178 | [ $(docker inspect --format '{{ .State.Running }}' $CCSDK_MARIADB) ] |
| 179 | then |
| 180 | echo "Blueprint proc Service Running" |
| 181 | break |
| 182 | else |
| 183 | echo sleep $i |
| 184 | sleep $i |
| 185 | fi |
| 186 | done |
| 187 | |
| 188 | ########## update pnf simulator ip in config deploy request ######## |
| 189 | |
| 190 | NETOPEER_CONTAINER=$(docker ps -a -q --filter="name=netopeer") |
| 191 | NETOPEER_CONTAINER_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $SDNC_CONTAINER) |
| 192 | RES_KEY=$(uuidgen -r) |
| 193 | sed -i "s/pnfaddr/$LOCAL_IP/g" $REQUEST_DATA_PATH/config-deploy.json |
| 194 | sed -i "s/pnfaddr/$LOCAL_IP/g" $REQUEST_DATA_PATH/config-assign.json |
| 195 | |
| 196 | sed -i "s/reskey/$RES_KEY/g" $REQUEST_DATA_PATH/config-deploy.json |
| 197 | sed -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 |
| 201 | sleep 150 |
| 202 | |
| 203 | |
| 204 | # Pass any variables required by Robot test suites in ROBOT_VARIABLES |
| 205 | ROBOT_VARIABLES="-v SCRIPTS:${SCRIPTS}" |