blob: 4fef682101e4567f50818302ff3cb2188ea4a461 [file] [log] [blame]
Gary Wu9abb61c2018-09-27 10:38:50 -07001#!/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 #
35 # the default prefix for docker containers is the directory name containing the docker-compose.yml file.
36 # It can be over-written by an env variable COMPOSE_PROJECT_NAME. This env var seems to be set in the Jenkins CSIT environment
Dominic Lunanuovac078eea2018-10-01 20:21:48 +000037 COMPOSE_PREFIX=${COMPOSE_PROJECT_NAME:-dockercompose}
38 export COMPOSE_PROJECT_NAME=$COMPOSE_PREFIX
Gary Wu9abb61c2018-09-27 10:38:50 -070039 echo "COMPOSE_PROJECT_NAME=$COMPOSE_PROJECT_NAME"
40 echo "COMPOSE_PREFIX=$COMPOSE_PREFIX"
41
42 # Clone DMaaP Message Router repo
43 mkdir -p $WORKSPACE/archives/dmaapmr
44 cd $WORKSPACE/archives/dmaapmr
45 #unset http_proxy https_proxy
46 git clone --depth 1 http://gerrit.onap.org/r/dmaap/messagerouter/messageservice -b master
47 cd messageservice
48 git pull
49 cd $WORKSPACE/archives/dmaapmr/messageservice/src/main/resources/docker-compose
50 cp $WORKSPACE/archives/dmaapmr/messageservice/bundleconfig-local/etc/appprops/MsgRtrApi.properties /var/tmp/
51
52
53 # start DMaaP MR containers with docker compose and configuration from docker-compose.yml
54 docker login -u docker -p docker nexus3.onap.org:10001
55 docker-compose up -d
56 docker ps
57
58 # Wait for initialization of Docker contaienr for DMaaP MR, Kafka and Zookeeper
59 for i in {1..50}; do
60 if [ $(docker inspect --format '{{ .State.Running }}' ${COMPOSE_PREFIX}_dmaap_1) ] && \
61 [ $(docker inspect --format '{{ .State.Running }}' ${COMPOSE_PREFIX}_zookeeper_1) ] && \
62 [ $(docker inspect --format '{{ .State.Running }}' ${COMPOSE_PREFIX}_dmaap_1) ]
63 then
64 echo "DMaaP Service Running"
65 break
66 else
67 echo sleep $i
68 sleep $i
69 fi
70 done
71
72
73 DMAAP_MR_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ${COMPOSE_PREFIX}_dmaap_1)
74 IP=${DMAAP_MR_IP}
75 KAFKA_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ${COMPOSE_PREFIX}_kafka_1)
76 ZOOKEEPER_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ${COMPOSE_PREFIX}_zookeeper_1)
77
78 echo DMAAP_MR_IP=${DMAAP_MR_IP}
79 echo IP=${IP}
80 echo KAFKA_IP=${KAFKA_IP}
81 echo ZOOKEEPER_IP=${ZOOKEEPER_IP}
82
83 # Initial docker-compose up and down is for populating kafka and zookeeper IPs in /var/tmp/MsgRtrApi.properites
84 docker-compose down
85
86 # Update kafkfa and zookeeper properties in MsgRtrApi.propeties which will be copied to DMaaP Container
Dominic Lunanuova32c0ee82018-10-03 01:28:25 +000087 sed -i -e 's/<zookeeper_host>/zookeeper/' /var/tmp/MsgRtrApi.properties
88 sed -i -e 's/<kafka_host>:<kafka_port>/kafka:9092/' /var/tmp/MsgRtrApi.properties
Gary Wu9abb61c2018-09-27 10:38:50 -070089
90 docker-compose build
91 docker login -u docker -p docker nexus3.onap.org:10001
92 docker-compose up -d
Dominic Lunanuova32c0ee82018-10-03 01:28:25 +000093 docker ps
Gary Wu9abb61c2018-09-27 10:38:50 -070094
95 # Wait for initialization of Docker containers
96 for i in {1..50}; do
97 if [ $(docker inspect --format '{{ .State.Running }}' ${COMPOSE_PREFIX}_dmaap_1) ] && \
98 [ $(docker inspect --format '{{ .State.Running }}' ${COMPOSE_PREFIX}_zookeeper_1) ] && \
99 [ $(docker inspect --format '{{ .State.Running }}' ${COMPOSE_PREFIX}_dmaap_1) ]
100 then
101 echo "DMaaP Service Running"
102 break
103 else
104 echo sleep $i
105 sleep $i
106 fi
107 done
Dominic Lunanuova32c0ee82018-10-03 01:28:25 +0000108 DMAAP_MR_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ${COMPOSE_PREFIX}_dmaap_1)
109 IP=${DMAAP_MR_IP}
110 KAFKA_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ${COMPOSE_PREFIX}_kafka_1)
111 ZOOKEEPER_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ${COMPOSE_PREFIX}_zookeeper_1)
112
113 echo "After restart of ZK and Kafka..."
114 echo DMAAP_MR_IP=${DMAAP_MR_IP}
115 echo IP=${IP}
116 echo KAFKA_IP=${KAFKA_IP}
117 echo ZOOKEEPER_IP=${ZOOKEEPER_IP}
Gary Wu9abb61c2018-09-27 10:38:50 -0700118
pkaras4cb0ffb2019-04-02 08:45:29 +0200119 source ${SCRIPTS}/common_functions.sh
120 bypass_ip_adress ${DMAAP_MR_IP}
121 bypass_ip_adress ${KAFKA_IP}
122 bypass_ip_adress ${ZOOKEEPER_IP}
123
Gary Wu9abb61c2018-09-27 10:38:50 -0700124 # Wait for initialization of docker services
125 for i in {1..50}; do
126 curl -sS -m 1 ${DMAAP_MR_IP}:3904/events/TestTopic && break
127 echo sleep $i
128 sleep $i
129 done
130}
131