blob: 5d8cce623605905e587e3eac3ff61ec2144b062a [file] [log] [blame]
rajendrajaiswal47b64d72019-02-06 16:09:24 +00001#!/bin/bash
2# Place the scripts in run order:
3source ${SCRIPTS}/common_functions.sh
4
5# Clone DMaaP Message Router repo
6mkdir -p $WORKSPACE/archives/dmaapmr
7cd $WORKSPACE/archives/dmaapmr
8git clone --depth 1 http://gerrit.onap.org/r/dmaap/messagerouter/messageservice -b master
9sed -i 's/enableCadi: false/enableCadi: "false"/g' /$WORKSPACE/archives/dmaapmr/messageservice/src/main/resources/docker-compose/docker-compose.yml
10cd $WORKSPACE/archives/dmaapmr/messageservice/src/main/resources/docker-compose
11cp $WORKSPACE/archives/dmaapmr/messageservice/bundleconfig-local/etc/appprops/MsgRtrApi.properties /var/tmp/
12
13# start DMaaP MR containers with docker compose and configuration from docker-compose.yml
14docker login -u docker -p docker nexus3.onap.org:10001
15docker-compose up -d
16
17ZOOKEEPER=$(docker ps -a -q --filter="name=zookeeper_1")
18KAFKA=$(docker ps -a -q --filter="name=kafka_1")
19DMAAP=$(docker ps -a -q --filter="name=dmaap_1")
20
21# Wait for initialization of Docker contaienr for DMaaP MR, Kafka and Zookeeper
22for i in {1..10}; do
23if [ $(docker inspect --format '{{ .State.Running }}' $KAFKA) ] && \
24[ $(docker inspect --format '{{ .State.Running }}' $ZOOKEEPER) ] && \
25[ $(docker inspect --format '{{ .State.Running }}' $DMAAP) ]
26then
27 echo "DMaaP Service Running"
28 break
29else
30 echo sleep $i
31 sleep $i
32fi
33done
34
35# Get IP address of DMAAP, KAFKA, Zookeeper
36KAFKA_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $KAFKA)
37ZOOKEEPER_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $ZOOKEEPER)
38DMAAP_MR_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $DMAAP)
39
40sleep 2
41# Shutdown DMAAP Container
42docker kill $DMAAP
43
44# Initial docker-compose up and down is for populating kafka and zookeeper IPs in /var/tmp/MsgRtrApi.properites
45sed -i -e '/config.zk.servers=/ s/=.*/='$ZOOKEEPER_IP'/' /var/tmp/MsgRtrApi.properties
46sed -i -e '/kafka.metadata.broker.list=/ s/=.*/='$KAFKA_IP':9092/' /var/tmp/MsgRtrApi.properties
47
48# Start DMaaP MR containers with docker compose and configuration from docker-compose.yml
49docker login -u docker -p docker nexus3.onap.org:10001
50docker-compose up -d
51sleep 5
52
53# Clone DMaaP Data Router repo
54mkdir -p $WORKSPACE/archives/dmaapdr
55cd $WORKSPACE/archives/dmaapdr
56git clone --depth 1 https://gerrit.onap.org/r/dmaap/datarouter -b master
57cd $WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources
58mkdir docker-compose
59cd $WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources/docker-compose
60cp $WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/composefile/docker-compose-e2e.yml $WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources/docker-compose/docker-compose.yml
61
62docker login -u docker -p docker nexus3.onap.org:10001
63docker-compose up -d
64echo "Disregard the message ERROR: for datarouter-node Container 1234456 is unhealthy, this is expected behaiour at this stage"
65docker kill datarouter-prov
66docker kill datarouter-node
67docker kill cbs
68CONSUL_IP=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' consul )
69sed -i -e '/CONSUL_HOST:/ s/:.*/: '$CONSUL_IP'/' docker-compose.yml
70MARIADB=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' mariadb )
71sed -i 's/datarouter-mariadb/'$MARIADB'/g' $WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources/prov_data/provserver.properties
72docker-compose up -d
rajendrajaiswal8f0afd82019-02-11 12:30:26 +000073DR_PROV_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' datarouter-prov)
74docker kill buscontroller
75sed -i 's/dr-prov-ip/'$DR_PROV_IP'/g' docker-compose.yml
76docker-compose up -d
rajendrajaiswal47b64d72019-02-06 16:09:24 +000077
78# Wait for initialization of Docker container for datarouter-node, datarouter-prov and mariadb
79for i in {1..10}; do
80 if [ $(docker inspect --format '{{ .State.Running }}' datarouter-node) ] && \
81 [ $(docker inspect --format '{{ .State.Running }}' datarouter-prov) ] && \
82 [ $(docker inspect --format '{{ .State.Running }}' mariadb) ]
83 then
84 echo "DR Service Running"
85 break
86 else
87 echo sleep $i
88 sleep $i
89 fi
90done
91
92sleep 5
93
94# Get IP address of datarrouger-prov, datarouter-node, fileconsumer-node.
95DR_PROV_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' datarouter-prov)
96DR_NODE_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' datarouter-node)
97DR_GATEWAY_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.Gateway}}{{end}}' datarouter-prov)
98
99# Get IP address of DMAAP, KAFKA, Zookeeper, ConfigBindingService
100DMAAP_MR_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $DMAAP)
101KAFKA_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $KAFKA)
102ZOOKEEPER_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $ZOOKEEPER)
103CBS_IP=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' cbs)
104
105# Data Router Configuration:
106# Create default feed on data router
107docker 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"
108docker 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"
109docker exec datarouter-prov /bin/sh -c "echo '${DR_NODE_IP}' dmaap-dr-node >> /etc/hosts"
110docker exec datarouter-node /bin/sh -c "echo '${DR_PROV_IP}' dmaap-dr-prov >> /etc/hosts"
rajendrajaiswal8f0afd82019-02-11 12:30:26 +0000111
112# Bus Controller Configuration
113DMAAPBC_IP=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' buscontroller)
114$WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/dmaapbc.sh ${DMAAPBC_IP}
rajendrajaiswal47b64d72019-02-06 16:09:24 +0000115
116# Consul Configuration for PM Mapper
117cp $WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/assets/cbs.json /tmp/cbs.json
118sed -i 's/ipaddress/'${CBS_IP}'/g' /tmp/cbs.json
119curl --request PUT --data @/tmp/cbs.json http://$CONSUL_IP:8500/v1/agent/service/register
120curl 'http://'$CONSUL_IP':8500/v1/kv/pmmapper?dc=dc1' -X PUT -H 'Accept: application/^Con' -H 'Content-Type: application/json' -H 'X-Requested-With: XMLHttpRequest' --data @$WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/assets/config.json
121
122#Pass any variables required by Robot test suites in ROBOT_VARIABLES
rajendrajaiswal8f0afd82019-02-11 12:30:26 +0000123ROBOT_VARIABLES="-v DR_PROV_IP:${DR_PROV_IP} -v DMAAPBC_IP:${DMAAPBC_IP} -v DMAAP_MR_IP:${DMAAP_MR_IP} -v CBS_IP:${CBS_IP} -v DR_SUBSCIBER_IP:${DR_SUBSCIBER_IP}"