Dominic Lunanuova | 9dc8b5f | 2018-04-14 01:33:15 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # ============LICENSE_START======================================================= |
| 4 | # ONAP DMAAP MR |
| 5 | # ================================================================================ |
| 6 | # Copyright (C) 2018 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 | # This script is a copy of plans/dmaap/mrpubsub/setup.sh, placed in the scripts |
| 25 | # dir, and edited to be a callable function from other plans. e.g. dmaap-buscontroller needs it. |
| 26 | # |
| 27 | source ${SCRIPTS}/common_functions.sh |
| 28 | |
| 29 | # function to launch DMaaP MR docker containers. |
| 30 | # sets global var IP with assigned IP address of MR container. |
| 31 | # (kafka and zk containers are not called externally) |
| 32 | |
| 33 | function dmaap_mr_launch() { |
Dominic Lunanuova | bfb3ea4 | 2018-08-23 21:49:47 +0000 | [diff] [blame] | 34 | COMPOSE_PREFIX=docker-compose |
Dominic Lunanuova | 9dc8b5f | 2018-04-14 01:33:15 +0000 | [diff] [blame] | 35 | # Clone DMaaP Message Router repo |
| 36 | mkdir -p $WORKSPACE/archives/dmaapmr |
| 37 | cd $WORKSPACE/archives/dmaapmr |
| 38 | #unset http_proxy https_proxy |
| 39 | git clone --depth 1 http://gerrit.onap.org/r/dmaap/messagerouter/messageservice -b master |
Dominic Lunanuova | 5a2d897 | 2018-04-17 20:59:12 +0000 | [diff] [blame] | 40 | cd messageservice |
Dominic Lunanuova | 9dc8b5f | 2018-04-14 01:33:15 +0000 | [diff] [blame] | 41 | git pull |
| 42 | cd $WORKSPACE/archives/dmaapmr/messageservice/src/main/resources/docker-compose |
| 43 | cp $WORKSPACE/archives/dmaapmr/messageservice/bundleconfig-local/etc/appprops/MsgRtrApi.properties /var/tmp/ |
| 44 | |
| 45 | |
| 46 | # start DMaaP MR containers with docker compose and configuration from docker-compose.yml |
| 47 | docker login -u docker -p docker nexus3.onap.org:10001 |
| 48 | docker-compose up -d |
Dominic Lunanuova | bfb3ea4 | 2018-08-23 21:49:47 +0000 | [diff] [blame] | 49 | docker ps |
Dominic Lunanuova | 9dc8b5f | 2018-04-14 01:33:15 +0000 | [diff] [blame] | 50 | |
| 51 | # Wait for initialization of Docker contaienr for DMaaP MR, Kafka and Zookeeper |
| 52 | for i in {1..50}; do |
Dominic Lunanuova | bfb3ea4 | 2018-08-23 21:49:47 +0000 | [diff] [blame] | 53 | if [ $(docker inspect --format '{{ .State.Running }}' ${COMPOSE_PREFIX}_dmaap_1) ] && \ |
| 54 | [ $(docker inspect --format '{{ .State.Running }}' ${COMPOSE_PREFIX}_zookeeper_1) ] && \ |
| 55 | [ $(docker inspect --format '{{ .State.Running }}' ${COMPOSE_PREFIX}_dmaap_1) ] |
Dominic Lunanuova | 9dc8b5f | 2018-04-14 01:33:15 +0000 | [diff] [blame] | 56 | then |
| 57 | echo "DMaaP Service Running" |
| 58 | break |
| 59 | else |
| 60 | echo sleep $i |
| 61 | sleep $i |
| 62 | fi |
| 63 | done |
| 64 | |
| 65 | |
Dominic Lunanuova | bfb3ea4 | 2018-08-23 21:49:47 +0000 | [diff] [blame] | 66 | DMAAP_MR_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ${COMPOSE_PREFIX}_dmaap_1) |
Dominic Lunanuova | 9dc8b5f | 2018-04-14 01:33:15 +0000 | [diff] [blame] | 67 | IP=${DMAAP_MR_IP} |
Dominic Lunanuova | bfb3ea4 | 2018-08-23 21:49:47 +0000 | [diff] [blame] | 68 | KAFKA_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ${COMPOSE_PREFIX}_kafka_1) |
| 69 | ZOOKEEPER_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ${COMPOSE_PREFIX}_zookeeper_1) |
Dominic Lunanuova | 9dc8b5f | 2018-04-14 01:33:15 +0000 | [diff] [blame] | 70 | |
| 71 | echo DMAAP_MR_IP=${DMAAP_MR_IP} |
| 72 | echo IP=${IP} |
| 73 | echo KAFKA_IP=${KAFKA_IP} |
| 74 | echo ZOOKEEPER_IP=${ZOOKEEPER_IP} |
| 75 | |
| 76 | # Initial docker-compose up and down is for populating kafka and zookeeper IPs in /var/tmp/MsgRtrApi.properites |
| 77 | docker-compose down |
| 78 | |
| 79 | # Update kafkfa and zookeeper properties in MsgRtrApi.propeties which will be copied to DMaaP Container |
| 80 | sed -i -e 's/<zookeeper_host>/'$ZOOKEEPER_IP'/' /var/tmp/MsgRtrApi.properties |
| 81 | sed -i -e 's/<kafka_host>:<kafka_port>/'$KAFKA_IP':9092/' /var/tmp/MsgRtrApi.properties |
| 82 | |
| 83 | docker-compose build |
| 84 | docker login -u docker -p docker nexus3.onap.org:10001 |
| 85 | docker-compose up -d |
| 86 | |
| 87 | # Wait for initialization of Docker containers |
| 88 | for i in {1..50}; do |
Dominic Lunanuova | bfb3ea4 | 2018-08-23 21:49:47 +0000 | [diff] [blame] | 89 | if [ $(docker inspect --format '{{ .State.Running }}' ${COMPOSE_PREFIX}_dmaap_1) ] && \ |
| 90 | [ $(docker inspect --format '{{ .State.Running }}' ${COMPOSE_PREFIX}_zookeeper_1) ] && \ |
| 91 | [ $(docker inspect --format '{{ .State.Running }}' ${COMPOSE_PREFIX}_dmaap_1) ] |
Dominic Lunanuova | 9dc8b5f | 2018-04-14 01:33:15 +0000 | [diff] [blame] | 92 | then |
| 93 | echo "DMaaP Service Running" |
| 94 | break |
| 95 | else |
| 96 | echo sleep $i |
| 97 | sleep $i |
| 98 | fi |
| 99 | done |
| 100 | |
| 101 | # Wait for initialization of docker services |
| 102 | for i in {1..50}; do |
| 103 | curl -sS -m 1 ${DMAAP_MR_IP}:3904/events/TestTopic && break |
| 104 | echo sleep $i |
| 105 | sleep $i |
| 106 | done |
| 107 | } |
| 108 | |