blob: 95fecff39f6597ff452ba19da92bd70c2a01f1e2 [file] [log] [blame]
Dominic Lunanuova9dc8b5f2018-04-14 01:33:15 +00001#!/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#
27source ${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
33function dmaap_mr_launch() {
34 # Clone DMaaP Message Router repo
35 mkdir -p $WORKSPACE/archives/dmaapmr
36 cd $WORKSPACE/archives/dmaapmr
37 #unset http_proxy https_proxy
38 git clone --depth 1 http://gerrit.onap.org/r/dmaap/messagerouter/messageservice -b master
39 git pull
40 cd $WORKSPACE/archives/dmaapmr/messageservice/src/main/resources/docker-compose
41 cp $WORKSPACE/archives/dmaapmr/messageservice/bundleconfig-local/etc/appprops/MsgRtrApi.properties /var/tmp/
42
43
44 # start DMaaP MR containers with docker compose and configuration from docker-compose.yml
45 docker login -u docker -p docker nexus3.onap.org:10001
46 docker-compose up -d
47
48 # Wait for initialization of Docker contaienr for DMaaP MR, Kafka and Zookeeper
49 for i in {1..50}; do
50 if [ $(docker inspect --format '{{ .State.Running }}' dockercompose_dmaap_1) ] && \
51 [ $(docker inspect --format '{{ .State.Running }}' dockercompose_zookeeper_1) ] && \
52 [ $(docker inspect --format '{{ .State.Running }}' dockercompose_dmaap_1) ]
53 then
54 echo "DMaaP Service Running"
55 break
56 else
57 echo sleep $i
58 sleep $i
59 fi
60 done
61
62
63 DMAAP_MR_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' dockercompose_dmaap_1)
64 IP=${DMAAP_MR_IP}
65 KAFKA_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' dockercompose_kafka_1)
66 ZOOKEEPER_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' dockercompose_zookeeper_1)
67
68 echo DMAAP_MR_IP=${DMAAP_MR_IP}
69 echo IP=${IP}
70 echo KAFKA_IP=${KAFKA_IP}
71 echo ZOOKEEPER_IP=${ZOOKEEPER_IP}
72
73 # Initial docker-compose up and down is for populating kafka and zookeeper IPs in /var/tmp/MsgRtrApi.properites
74 docker-compose down
75
76 # Update kafkfa and zookeeper properties in MsgRtrApi.propeties which will be copied to DMaaP Container
77 sed -i -e 's/<zookeeper_host>/'$ZOOKEEPER_IP'/' /var/tmp/MsgRtrApi.properties
78 sed -i -e 's/<kafka_host>:<kafka_port>/'$KAFKA_IP':9092/' /var/tmp/MsgRtrApi.properties
79
80 docker-compose build
81 docker login -u docker -p docker nexus3.onap.org:10001
82 docker-compose up -d
83
84 # Wait for initialization of Docker containers
85 for i in {1..50}; do
86 if [ $(docker inspect --format '{{ .State.Running }}' dockercompose_dmaap_1) ] && \
87 [ $(docker inspect --format '{{ .State.Running }}' dockercompose_zookeeper_1) ] && \
88 [ $(docker inspect --format '{{ .State.Running }}' dockercompose_dmaap_1) ]
89 then
90 echo "DMaaP Service Running"
91 break
92 else
93 echo sleep $i
94 sleep $i
95 fi
96 done
97
98 # Wait for initialization of docker services
99 for i in {1..50}; do
100 curl -sS -m 1 ${DMAAP_MR_IP}:3904/events/TestTopic && break
101 echo sleep $i
102 sleep $i
103 done
104}
105