Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [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 )" |
Gary Wu | 13111e9 | 2018-09-27 11:31:33 -0700 | [diff] [blame] | 21 | source ${WORKSPACE}/scripts/appc/script1.sh |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 22 | |
Taka Cho | fee760e | 2020-04-09 17:59:43 -0400 | [diff] [blame] | 23 | export APPC_DOCKER_IMAGE_VERSION=1.7.2-SNAPSHOT-latest |
umry8364 | 81be59d | 2019-10-01 11:10:09 +0200 | [diff] [blame] | 24 | export DGBUILDER_DOCKER_IMAGE_VERSION=0.6.0 |
Taka Cho | fee760e | 2020-04-09 17:59:43 -0400 | [diff] [blame] | 25 | export ANSIBLE_DOCKER_IMAGE_VERSION=0.4.4 |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 26 | export BRANCH=master |
| 27 | export SOLUTION_NAME=onap |
| 28 | |
| 29 | export NEXUS_USERNAME=docker |
| 30 | export NEXUS_PASSWD=docker |
| 31 | export NEXUS_DOCKER_REPO=nexus3.onap.org:10001 |
| 32 | export DMAAP_TOPIC=AUTO |
| 33 | |
| 34 | export MTU=$(/sbin/ifconfig | grep MTU | sed 's/.*MTU://' | sed 's/ .*//' | sort -n | head -1) |
| 35 | |
| 36 | if [ "$MTU" == "" ]; then |
| 37 | export MTU="1450" |
| 38 | fi |
| 39 | |
| 40 | |
| 41 | # Clone APPC repo to get docker-compose for APPC |
| 42 | mkdir -p $WORKSPACE/archives/appc |
| 43 | cd $WORKSPACE/archives |
| 44 | git clone -b $BRANCH --single-branch http://gerrit.onap.org/r/appc/deployment.git appc |
| 45 | cd $WORKSPACE/archives/appc |
| 46 | git pull |
| 47 | cd $WORKSPACE/archives/appc/docker-compose |
| 48 | sed -i "s/DMAAP_TOPIC_ENV=.*/DMAAP_TOPIC_ENV="$DMAAP_TOPIC"/g" docker-compose.yml |
| 49 | docker login -u $NEXUS_USERNAME -p $NEXUS_PASSWD $NEXUS_DOCKER_REPO |
Aaron Hay | 73792ad | 2018-10-05 20:25:34 +0000 | [diff] [blame] | 50 | |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 51 | docker pull $NEXUS_DOCKER_REPO/${SOLUTION_NAME}/appc-image:$APPC_DOCKER_IMAGE_VERSION |
| 52 | docker tag $NEXUS_DOCKER_REPO/${SOLUTION_NAME}/appc-image:$APPC_DOCKER_IMAGE_VERSION ${SOLUTION_NAME}/appc-image:latest |
Aaron Hay | 73792ad | 2018-10-05 20:25:34 +0000 | [diff] [blame] | 53 | |
| 54 | docker pull $NEXUS_DOCKER_REPO/${SOLUTION_NAME}/ccsdk-dgbuilder-image:$DGBUILDER_DOCKER_IMAGE_VERSION |
| 55 | docker tag $NEXUS_DOCKER_REPO/${SOLUTION_NAME}/ccsdk-dgbuilder-image:$DGBUILDER_DOCKER_IMAGE_VERSION ${SOLUTION_NAME}/ccsdk-dgbuilder-image:latest |
| 56 | |
| 57 | docker pull $NEXUS_DOCKER_REPO/${SOLUTION_NAME}/ccsdk-ansible-server-image:$ANSIBLE_DOCKER_IMAGE_VERSION |
| 58 | docker tag $NEXUS_DOCKER_REPO/${SOLUTION_NAME}/ccsdk-ansible-server-image:$ANSIBLE_DOCKER_IMAGE_VERSION ${SOLUTION_NAME}/ccsdk-ansible-server-image:latest |
| 59 | |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 60 | docker pull $NEXUS_DOCKER_REPO/${SOLUTION_NAME}/appc-cdt-image:$APPC_DOCKER_IMAGE_VERSION |
| 61 | docker tag $NEXUS_DOCKER_REPO/${SOLUTION_NAME}/appc-cdt-image:$APPC_DOCKER_IMAGE_VERSION ${SOLUTION_NAME}/appc-cdt-image:latest |
| 62 | |
| 63 | # start APPC containers with docker compose and configuration from docker-compose.yml |
| 64 | docker-compose up -d |
| 65 | # WAIT 5 minutes maximum and test every 5 seconds if APPC is up using HealthCheck API |
Taka Cho | fee760e | 2020-04-09 17:59:43 -0400 | [diff] [blame] | 66 | TIME_OUT=1000 |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 67 | INTERVAL=30 |
| 68 | TIME=0 |
| 69 | while [ "$TIME" -lt "$TIME_OUT" ]; do |
Taka Cho | fee760e | 2020-04-09 17:59:43 -0400 | [diff] [blame] | 70 | response=$(curl --write-out '%{http_code}' --silent --output /dev/null -H "Authorization: Basic YWRtaW46S3A4Yko0U1hzek0wV1hsaGFrM2VIbGNzZTJnQXc4NHZhb0dHbUp2VXkyVQ==" -X POST -H "X-FromAppId: csit-appc" -H "X-TransactionId: csit-appc" -H "Accept: application/json" -H "Content-Type: application/json" http://localhost:8282/restconf/operations/SLI-API:healthcheck ); echo $response |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 71 | |
Taka Cho | fee760e | 2020-04-09 17:59:43 -0400 | [diff] [blame] | 72 | if [ "$response" == "200" ]; then |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 73 | echo APPC started in $TIME seconds |
| 74 | break; |
| 75 | fi |
| 76 | |
| 77 | echo Sleep: $INTERVAL seconds before testing if APPC is up. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds |
| 78 | sleep $INTERVAL |
| 79 | TIME=$(($TIME+$INTERVAL)) |
| 80 | done |
| 81 | |
| 82 | if [ "$TIME" -ge "$TIME_OUT" ]; then |
Taka Cho | fee760e | 2020-04-09 17:59:43 -0400 | [diff] [blame] | 83 | echo TIME OUT: APPC Docker containers not started in $TIME_OUT seconds... Could cause problems for testing activities... |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 84 | fi |
| 85 | |
Taka Cho | fee760e | 2020-04-09 17:59:43 -0400 | [diff] [blame] | 86 | TIME_OUT=1000 |
| 87 | INTERVAL=60 |
| 88 | TIME=0 |
| 89 | while [ "$TIME" -lt "$TIME_OUT" ]; do |
| 90 | response=$(docker exec --tty appc_controller_container /opt/opendaylight/current/bin/client system:start-level) |
| 91 | |
| 92 | if grep -q 'Level 100' <<< ${response}; then |
| 93 | echo APPC karaf started in $TIME seconds |
| 94 | break; |
| 95 | fi |
| 96 | |
| 97 | echo Sleep: $INTERVAL seconds before testing if APPC is up. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds |
| 98 | sleep $INTERVAL |
| 99 | TIME=$(($TIME+$INTERVAL)) |
| 100 | done |
| 101 | |
| 102 | if [ "$TIME" -ge "$TIME_OUT" ]; then |
| 103 | echo TIME OUT: karaf session not started in $TIME_OUT seconds... Could cause problems for testing activities... |
| 104 | fi |
| 105 | |
| 106 | |
| 107 | TIME_OUT=1000 |
| 108 | INTERVAL=60 |
| 109 | TIME=0 |
| 110 | while [ "$TIME" -lt "$TIME_OUT" ]; do |
| 111 | response=$(docker exec --tty appc_controller_container /opt/opendaylight/current/bin/client bundle:list | grep appc-design-services-provider) |
| 112 | |
| 113 | if grep -q 'appc-design-services-provider' <<< ${response}; then |
| 114 | echo APPC features started in $TIME seconds |
| 115 | break; |
| 116 | fi |
| 117 | |
| 118 | echo Sleep: $INTERVAL seconds before testing if APPC is up. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds |
| 119 | sleep $INTERVAL |
| 120 | TIME=$(($TIME+$INTERVAL)) |
| 121 | done |
| 122 | |
| 123 | if [ "$TIME" -ge "$TIME_OUT" ]; then |
| 124 | echo TIME OUT: karaf session not started in $TIME_OUT seconds... Could cause problems for testing activities... |
| 125 | fi |
| 126 | |
| 127 | |
| 128 | # Sleep additional 5 minutes (300 secs) to give application time to finish |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 129 | sleep 300 |
| 130 | |
| 131 | # Pass any variables required by Robot test suites in ROBOT_VARIABLES |
| 132 | ROBOT_VARIABLES="-v SCRIPTS:${SCRIPTS}" |