blob: 6df4b2f6172c062a643a9a32bc3703bc8b89cbe2 [file] [log] [blame]
rajendrajaiswal6823ae72018-09-07 15:23:18 +01001#!/bin/bash
2# Place the scripts in run order:
3#Make sure python-uuid is installed
4
5# Place the scripts in run order:
6source ${SCRIPTS}/dcae-bulkpm/xNFSimulator.sh
7
8# Place the scripts in run order:
9source ${SCRIPTS}/common_functions.sh
10
LiamBurkec5fa5952018-09-17 14:34:05 +010011# Clone DMaaP Data Router repo
12mkdir -p $WORKSPACE/archives/dmaapdr
13cd $WORKSPACE/archives/dmaapdr
rajendrajaiswal6823ae72018-09-07 15:23:18 +010014
LiamBurkec5fa5952018-09-17 14:34:05 +010015git clone --depth 1 https://gerrit.onap.org/r/dmaap/datarouter -b master
16cd datarouter
17git pull
18cd $WORKSPACE/archives/dmaapdr/datarouter/docker-compose/
19
20# start DMaaP DR containers with docker compose and configuration from docker-compose.yml
21docker login -u docker -p docker nexus3.onap.org:10001
22docker-compose up -d
23
24# Wait for initialization of Docker container for datarouter-node, datarouter-prov and mariadb
25for i in {1..50}; do
26 if [ $(docker inspect --format '{{ .State.Running }}' datarouter-node) ] && \
27 [ $(docker inspect --format '{{ .State.Running }}' datarouter-prov) ] && \
28 [ $(docker inspect --format '{{ .State.Running }}' mariadb) ]
29 then
30 echo "DR Service Running"
31 break
32 else
33 echo sleep $i
34 sleep $i
35 fi
36done
37
38DR_PROV_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' datarouter-prov)
39DR_NODE_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' datarouter-node)
40DR_GATEWAY_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.Gateway}}{{end}}' datarouter-prov)
41
42#Add the DR_NODE_IP to /etc/hosts
43sudo echo "${DR_NODE_IP} dmaap-dr-node" >> /etc/hosts
44sudo echo "${DR_PROV_IP} dmaap-dr-prov" >> /etc/hosts
45
46echo DR_PROV_IP=${DR_PROV_IP}
47echo DR_NODE_IP=${DR_NODE_IP}
48echo DR_GATEWAY_IP=${DR_GATEWAY_IP}
49
50docker exec -i datarouter-prov sh -c "curl -k -X PUT https://$DR_PROV_IP:8443/internal/api/NODES?val=dmaap-dr-node\|$DR_GATEWAY_IP"
51docker exec -i datarouter-prov sh -c "curl -k -X PUT https://$DR_PROV_IP:8443/internal/api/PROV_AUTH_ADDRESSES?val=dmaap-dr-prov\|$DR_GATEWAY_IP"
52
53# Start DCAE VES Collector
54cd $WORKSPACE/
55HOST_IP=$(ip route get 8.8.8.8 | awk '/8.8.8.8/ {print $NF}')
rajendrajaiswal6823ae72018-09-07 15:23:18 +010056VESC_IMAGE=nexus3.onap.org:10001/onap/org.onap.dcaegen2.collectors.ves.vescollector:1.3.1
57echo VESC_IMAGE=${VESC_IMAGE}
58
LiamBurkec5fa5952018-09-17 14:34:05 +010059docker run -d --name vesc -e DMAAPHOST=${HOST_IP} ${VESC_IMAGE}
60VESC_IP=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' vesc)
rajendrajaiswal6823ae72018-09-07 15:23:18 +010061
62# Clone DMaaP Message Router repo
63mkdir -p $WORKSPACE/archives/dmaapmr
64cd $WORKSPACE/archives/dmaapmr
rajendrajaiswal6823ae72018-09-07 15:23:18 +010065git clone --depth 1 http://gerrit.onap.org/r/dmaap/messagerouter/messageservice -b master
66git pull
67cd $WORKSPACE/archives/dmaapmr/messageservice/src/main/resources/docker-compose
68cp $WORKSPACE/archives/dmaapmr/messageservice/bundleconfig-local/etc/appprops/MsgRtrApi.properties /var/tmp/
69
rajendrajaiswal6823ae72018-09-07 15:23:18 +010070# start DMaaP MR containers with docker compose and configuration from docker-compose.yml
71docker login -u docker -p docker nexus3.onap.org:10001
72docker-compose up -d
73
LiamBurkec5fa5952018-09-17 14:34:05 +010074ZOOKEEPER=$(docker ps -a -q --filter="name=zookeeper_1")
75KAFKA=$(docker ps -a -q --filter="name=kafka_1")
76DMAAP=$(docker ps -a -q --filter="name=dmaap_1")
77
rajendrajaiswal6823ae72018-09-07 15:23:18 +010078# Wait for initialization of Docker contaienr for DMaaP MR, Kafka and Zookeeper
79for i in {1..50}; do
LiamBurkec5fa5952018-09-17 14:34:05 +010080if [ $(docker inspect --format '{{ .State.Running }}' $KAFKA) ] && \
81[ $(docker inspect --format '{{ .State.Running }}' $ZOOKEEPER) ] && \
82[ $(docker inspect --format '{{ .State.Running }}' $DMAAP) ]
rajendrajaiswal6823ae72018-09-07 15:23:18 +010083then
84 echo "DMaaP Service Running"
85 break
86else
87 echo sleep $i
88 sleep $i
89fi
90done
91
92# Get IP address of DMAAP, KAFKA, Zookeeper
LiamBurkec5fa5952018-09-17 14:34:05 +010093DMAAP_MR_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $DMAAP)
94KAFKA_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $KAFKA)
95ZOOKEEPER_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $ZOOKEEPER)
rajendrajaiswal6823ae72018-09-07 15:23:18 +010096
97echo DMAAP_MR_IP=${DMAAP_MR_IP}
98echo KAFKA_IP=${KAFKA_IP}
99echo ZOOKEEPER_IP=${ZOOKEEPER_IP}
100
101# Shutdown DMAAP Container
LiamBurkec5fa5952018-09-17 14:34:05 +0100102docker kill $DMAAP
rajendrajaiswal6823ae72018-09-07 15:23:18 +0100103
104# Initial docker-compose up and down is for populating kafka and zookeeper IPs in /var/tmp/MsgRtrApi.properites
105sed -i -e '/config.zk.servers=/ s/=.*/='$ZOOKEEPER_IP'/' /var/tmp/MsgRtrApi.properties
106sed -i -e '/kafka.metadata.broker.list=/ s/=.*/='$KAFKA_IP':9092/' /var/tmp/MsgRtrApi.properties
107
108# Start DMaaP MR containers with docker compose and configuration from docker-compose.yml
109docker-compose build
110docker login -u docker -p docker nexus3.onap.org:10001
111docker-compose up -d
112sleep 5
113
rajendrajaiswal6823ae72018-09-07 15:23:18 +0100114export VESC_IP=${VESC_IP}
115export HOST_IP=${HOST_IP}
116export DMAAP_MR_IP=${DMAAP_MR_IP}
LiamBurkec5fa5952018-09-17 14:34:05 +0100117#Pass any variables required by Robot test suites in ROBOT_VARIABLES
118ROBOT_VARIABLES="-v DR_PROV_IP:${DR_PROV_IP} -v DR_NODE_IP:${DR_NODE_IP} -v DMAAP_MR_IP:${DMAAP_MR_IP} -v VESC_IP:${VESC_IP}"
rajendrajaiswal6823ae72018-09-07 15:23:18 +0100119
120pip install jsonschema uuid
121# Wait container ready
LiamBurkec5fa5952018-09-17 14:34:05 +0100122sleep 2