blob: 64f1720b6b7d80f9d1463c3ad3dd44c30a158e29 [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() {
Dominic Lunanuovabfb3ea42018-08-23 21:49:47 +000034 COMPOSE_PREFIX=docker-compose
Dominic Lunanuova9dc8b5f2018-04-14 01:33:15 +000035 # 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 Lunanuova5a2d8972018-04-17 20:59:12 +000040 cd messageservice
Dominic Lunanuova9dc8b5f2018-04-14 01:33:15 +000041 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 Lunanuovabfb3ea42018-08-23 21:49:47 +000049 docker ps
Dominic Lunanuova9dc8b5f2018-04-14 01:33:15 +000050
51 # Wait for initialization of Docker contaienr for DMaaP MR, Kafka and Zookeeper
52 for i in {1..50}; do
Dominic Lunanuovabfb3ea42018-08-23 21:49:47 +000053 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 Lunanuova9dc8b5f2018-04-14 01:33:15 +000056 then
57 echo "DMaaP Service Running"
58 break
59 else
60 echo sleep $i
61 sleep $i
62 fi
63 done
64
65
Dominic Lunanuovabfb3ea42018-08-23 21:49:47 +000066 DMAAP_MR_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ${COMPOSE_PREFIX}_dmaap_1)
Dominic Lunanuova9dc8b5f2018-04-14 01:33:15 +000067 IP=${DMAAP_MR_IP}
Dominic Lunanuovabfb3ea42018-08-23 21:49:47 +000068 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 Lunanuova9dc8b5f2018-04-14 01:33:15 +000070
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 Lunanuovabfb3ea42018-08-23 21:49:47 +000089 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 Lunanuova9dc8b5f2018-04-14 01:33:15 +000092 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