[DMAAP-MR] Migrate csit suite to the repo
[dmaap/messagerouter/messageservice.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 # Modification 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 # function to launch DMaaP MR docker containers.
25 # sets global var DMAAP_MR_IP with assigned IP address of MR container.
26 # (kafka and zk containers are not called externally)
27
28 function dmaap_mr_launch() {
29     mkdir -p $WORKSPACE/archives/dmaap/mr/last_run_logs
30
31     # start DMaaP MR containers with docker compose and configuration from docker-compose.yml
32     docker login -u docker -p docker nexus3.onap.org:10001
33     docker-compose -f ${WORKSPACE}/scripts/dmaap-message-router/docker-compose/docker-compose.yml up -d
34     docker ps
35
36     # Wait for initialization of Docker containers for DMaaP MR, Kafka and Zookeeper
37     for i in {1..50}; do
38         if [[ $(docker inspect --format '{{ .State.Running }}' dmaap-mr) ]] && \
39             [[ $(docker inspect --format '{{ .State.Running }}' dmaap-kafka) ]] && \
40             [[ $(docker inspect --format '{{ .State.Running }}' dmaap-zookeeper) ]]
41         then
42             echo "DMaaP Service Running"
43             break
44         else
45             echo sleep $i
46             sleep $i
47         fi
48     done
49
50 DMAAP_MR_IP=`get-instance-ip.sh dmaap-mr`
51 echo MR_IP=${DMAAP_MR_IP}
52 export DMAAP_MR_IP
53
54 echo "Waiting for dmaap-message-router to come up ..."
55 for i in {1..20}; do
56     dmaap_state=$(curl --write-out '%{http_code}' --silent --output /dev/null $DMAAP_MR_IP:3904/topics)
57     if [ ${dmaap_state} == "200" ]
58     then
59       break
60     else
61       sleep 5
62     fi
63 done
64
65 }
66