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