Varun Gudisena | 18e5406 | 2017-09-21 20:25:18 +0000 | [diff] [blame^] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # ============LICENSE_START======================================================= |
| 4 | # ONAP DMAAP MR |
| 5 | # ================================================================================ |
| 6 | # Copyright (C) 2017 AT&T Intellectual Property. All rights |
| 7 | # reserved. |
| 8 | # ================================================================================ |
| 9 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 10 | # you may not use this file except in compliance with the License. |
| 11 | # You may obtain a copy of the License at |
| 12 | # |
| 13 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 14 | # |
| 15 | # Unless required by applicable law or agreed to in writing, software |
| 16 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 18 | # See the License for the specific language governing permissions and |
| 19 | # limitations under the License. |
| 20 | # ============LICENSE_END============================================ |
| 21 | # =================================================================== |
| 22 | # ECOMP is a trademark and service mark of AT&T Intellectual Property. |
| 23 | # |
| 24 | # Place the scripts in run order: |
| 25 | source ${SCRIPTS}/common_functions.sh |
| 26 | |
| 27 | # Clone DMaaP Message Router repo |
| 28 | mkdir -p $WORKSPACE/archives/dmaapmr |
| 29 | cd $WORKSPACE/archives/dmaapmr |
| 30 | #unset http_proxy https_proxy |
| 31 | git clone --depth 1 http://gerrit.onap.org/r/dmaap/messagerouter/messageservice -b master |
| 32 | git pull |
| 33 | cd $WORKSPACE/archives/dmaapmr/messageservice/src/main/resources/docker-compose |
| 34 | cp $WORKSPACE/archives/dmaapmr/messageservice/bundleconfig-local/etc/appprops/MsgRtrApi.properties /var/tmp/ |
| 35 | |
| 36 | |
| 37 | # start DMaaP MR containers with docker compose and configuration from docker-compose.yml |
| 38 | docker-compose up -d |
| 39 | |
| 40 | # Wait for initialization of Docker contaienr for DMaaP MR, Kafka and Zookeeper |
| 41 | for i in {1..50}; do |
| 42 | if [ $(docker inspect --format '{{ .State.Running }}' dockercompose_dmaap_1) ] && \ |
| 43 | [ $(docker inspect --format '{{ .State.Running }}' dockercompose_zookeeper_1) ] && \ |
| 44 | [ $(docker inspect --format '{{ .State.Running }}' dockercompose_dmaap_1) ] |
| 45 | then |
| 46 | echo "DMaaP Service Running" |
| 47 | break |
| 48 | else |
| 49 | echo sleep $i |
| 50 | sleep $i |
| 51 | fi |
| 52 | done |
| 53 | |
| 54 | |
| 55 | DMAAP_MR_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' dockercompose_dmaap_1) |
| 56 | KAFKA_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' dockercompose_kafka_1) |
| 57 | ZOOKEEPER_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' dockercompose_zookeeper_1) |
| 58 | |
| 59 | echo DMAAP_MR_IP=${DMAAP_MR_IP} |
| 60 | echo KAFKA_IP=${KAFKA_IP} |
| 61 | echo ZOOKEEPER_IP=${ZOOKEEPER_IP} |
| 62 | |
| 63 | # Initial docker-compose up and down is for populating kafka and zookeeper IPs in /var/tmp/MsgRtrApi.properites |
| 64 | docker-compose down |
| 65 | |
| 66 | # Update kafkfa and zookeeper properties in MsgRtrApi.propeties which will be copied to DMaaP Container |
| 67 | sed -i -e 's/<zookeeper_host>/'$ZOOKEEPER_IP'/' /var/tmp/MsgRtrApi.properties |
| 68 | sed -i -e 's/<kafka_host>:<kafka_port>/'$KAFKA_IP':9092/' /var/tmp/MsgRtrApi.properties |
| 69 | |
| 70 | docker-compose build |
| 71 | docker-compose up -d |
| 72 | |
| 73 | # Wait for initialization of Docker containers |
| 74 | for i in {1..50}; do |
| 75 | if [ $(docker inspect --format '{{ .State.Running }}' dockercompose_dmaap_1) ] && \ |
| 76 | [ $(docker inspect --format '{{ .State.Running }}' dockercompose_zookeeper_1) ] && \ |
| 77 | [ $(docker inspect --format '{{ .State.Running }}' dockercompose_dmaap_1) ] |
| 78 | then |
| 79 | echo "DMaaP Service Running" |
| 80 | break |
| 81 | else |
| 82 | echo sleep $i |
| 83 | sleep $i |
| 84 | fi |
| 85 | done |
| 86 | |
| 87 | # Wait for initialization of docker services |
| 88 | for i in {1..50}; do |
| 89 | curl -sS -m 1 ${DMAAP_MR_IP}:3904/events/TestTopic && break |
| 90 | echo sleep $i |
| 91 | sleep $i |
| 92 | done |
| 93 | |
| 94 | #Pass any variables required by Robot test suites in ROBOT_VARIABLES |
| 95 | ROBOT_VARIABLES="-v DMAAP_MR_IP:${DMAAP_MR_IP}" |