[DMAAP-BC] Consolidate bus controller repos
[dmaap/buscontroller.git] / csit / scripts / dmaap-message-router / dmaap-mr-launch.sh
1 #!/bin/bash
2 #
3 # ============LICENSE_START=======================================================
4 # ONAP DMAAP MR 
5 # ================================================================================
6 # Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
7 # Modifications copyright (C) 2021 Nordix Foundation..
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
28 # function to launch DMaaP MR docker containers.
29 # sets global var IP with assigned IP address of MR container.
30 # (kafka and zk containers are not called externally)
31
32 function dmaap_mr_launch() {
33
34   mkdir -p ${WORKSPACE}/archives/dmaap/last_run_logs
35
36   # start DMaaP MR containers with docker compose and configuration from docker-compose.yml
37   docker login -u docker -p docker nexus3.onap.org:10001
38   docker-compose -f "${WORKSPACE}"/scripts/dmaap-message-router/docker-compose/docker-compose.yml up -d
39   docker ps
40
41   # Wait for initialization of Docker containers for DMaaP MR, Kafka and Zookeeper
42   for i in {1..50}; do
43       if [ $(docker inspect --format '{{ .State.Running }}' dmaap-mr) ] && \
44         [ $(docker inspect --format '{{ .State.Running }}' zookeeper) ] && \
45         [ $(docker inspect --format '{{ .State.Running }}' kafka) ]
46       then
47           echo "DMaaP Service Running"
48           break
49       else
50           echo sleep $i
51           sleep $i
52       fi
53   done
54
55   DMAAP_MR_IP=$(get-instance-ip.sh dmaap-mr)
56   IP=${DMAAP_MR_IP}
57   KAFKA_IP=$(get-instance-ip.sh kafka)
58   ZOOKEEPER_IP=$(get-instance-ip.sh zookeeper)
59
60   echo DMAAP_MR_IP="${DMAAP_MR_IP}"
61   echo IP="${IP}"
62   echo KAFKA_IP="${KAFKA_IP}"
63   echo ZOOKEEPER_IP="${ZOOKEEPER_IP}"
64
65   # Wait for initialization of docker services
66   for i in {1..50}; do
67       curl -sS -m 1 "${DMAAP_MR_IP}":3904/events/TestTopic && break
68       echo sleep $i
69       sleep $i
70   done
71 }
72