blob: 5a0339eab16f930cdddae42ea225295989d0e92d [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
rajendrajaiswala1574702019-02-14 10:29:45 +000021# Get IP address of KAFKA, Zookeeper
rajendrajaiswal47b64d72019-02-06 16:09:24 +000022KAFKA_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $KAFKA)
23ZOOKEEPER_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $ZOOKEEPER)
rajendrajaiswal47b64d72019-02-06 16:09:24 +000024
rajendrajaiswal47b64d72019-02-06 16:09:24 +000025# Shutdown DMAAP Container
26docker kill $DMAAP
27
28# Initial docker-compose up and down is for populating kafka and zookeeper IPs in /var/tmp/MsgRtrApi.properites
29sed -i -e '/config.zk.servers=/ s/=.*/='$ZOOKEEPER_IP'/' /var/tmp/MsgRtrApi.properties
30sed -i -e '/kafka.metadata.broker.list=/ s/=.*/='$KAFKA_IP':9092/' /var/tmp/MsgRtrApi.properties
31
32# Start DMaaP MR containers with docker compose and configuration from docker-compose.yml
33docker login -u docker -p docker nexus3.onap.org:10001
34docker-compose up -d
35sleep 5
36
rajendrajaiswala1574702019-02-14 10:29:45 +000037# Get IP address of DMAAP Message Router.
38DMAAP_MR_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $DMAAP)
39
rajendrajaiswal37452e42019-04-02 08:40:58 +000040# Clone DMaaP Data Router repo and Initialization of Data Router, Consul, Config Binding Service
rajendrajaiswal47b64d72019-02-06 16:09:24 +000041mkdir -p $WORKSPACE/archives/dmaapdr
42cd $WORKSPACE/archives/dmaapdr
43git clone --depth 1 https://gerrit.onap.org/r/dmaap/datarouter -b master
44cd $WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources
45mkdir docker-compose
46cd $WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources/docker-compose
47cp $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
rajendrajaiswal47b64d72019-02-06 16:09:24 +000048docker login -u docker -p docker nexus3.onap.org:10001
49docker-compose up -d
50echo "Disregard the message ERROR: for datarouter-node Container 1234456 is unhealthy, this is expected behaiour at this stage"
rajendrajaiswal37452e42019-04-02 08:40:58 +000051sleep 10
rajendrajaiswal47b64d72019-02-06 16:09:24 +000052docker kill cbs
53CONSUL_IP=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' consul )
54sed -i -e '/CONSUL_HOST:/ s/:.*/: '$CONSUL_IP'/' docker-compose.yml
55MARIADB=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' mariadb )
56sed -i 's/datarouter-mariadb/'$MARIADB'/g' $WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources/prov_data/provserver.properties
57docker-compose up -d
rajendrajaiswal8f0afd82019-02-11 12:30:26 +000058DR_PROV_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' datarouter-prov)
rajendrajaiswal47b64d72019-02-06 16:09:24 +000059DR_NODE_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' datarouter-node)
rajendrajaiswal47b64d72019-02-06 16:09:24 +000060
61# Consul Configuration for PM Mapper
62cp $WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/assets/cbs.json /tmp/cbs.json
63sed -i 's/ipaddress/'${CBS_IP}'/g' /tmp/cbs.json
64curl --request PUT --data @/tmp/cbs.json http://$CONSUL_IP:8500/v1/agent/service/register
rajendrajaiswal37452e42019-04-02 08:40:58 +000065curl 'http://'$CONSUL_IP':8500/v1/kv/pmmapper?dc=dc1' -X PUT -H 'Accept: application/json' -H 'Content-Type: application/json' -H 'X-Requested-With: XMLHttpRequest' --data @$WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/assets/config.json
rajendrajaiswal47b64d72019-02-06 16:09:24 +000066
rajendrajaiswala1574702019-02-14 10:29:45 +000067# PM Mapper startup and configuration
68mkdir /tmp/docker-compose
69cd /tmp/docker-compose
70cp $WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/composefile/docker-compose-pmmapper.yml /tmp/docker-compose/docker-compose.yml
71CBS_IP=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' cbs)
72sed -i 's/CBSIP/'$CBS_IP'/g' docker-compose.yml
rajendrajaiswal37452e42019-04-02 08:40:58 +000073sed -i 's/1.1.1.1/'$DR_NODE_IP'/g' docker-compose.yml
74sed -i 's/4.4.4.4/'$DMAAP_MR_IP'/g' docker-compose.yml
rajendrajaiswala1574702019-02-14 10:29:45 +000075docker-compose up -d
rajendrajaiswal140bfd22019-02-14 14:47:15 +000076
rajendrajaiswal37452e42019-04-02 08:40:58 +000077cd $WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources/docker-compose
78PMMAPPER_IP=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' pmmapper)
79docker kill datarouter-node
80docker kill datarouter-prov
81sed -i 's/1.1.1.1/'$DR_NODE_IP'/g' docker-compose.yml
82sed -i 's/2.2.2.2/'$DR_PROV_IP'/g' docker-compose.yml
83sed -i 's/3.3.3.3/'$PMMAPPER_IP'/g' docker-compose.yml
84docker-compose up -d
85
86# Wait for initialization of Docker container for datarouter-node, datarouter-prov and mariadb, Consul, CBS
87for i in {1..5}; do
88 if [ $(docker inspect --format '{{ .State.Running }}' datarouter-node) ] && \
89 [ $(docker inspect --format '{{ .State.Running }}' datarouter-prov) ] && \
90 [ $(docker inspect --format '{{ .State.Running }}' mariadb) ] && \
91 [ $(docker inspect --format '{{ .State.Running }}' consul) ] && \
92 [ $(docker inspect --format '{{ .State.Running }}' cbs) ] && \
93 [ $(docker inspect --format '{{ .State.Running }}' pmmapper) ] && \
94 [ $(docker inspect --format '{{ .State.Running }}' $KAFKA) ] && \
95 [ $(docker inspect --format '{{ .State.Running }}' $ZOOKEEPER) ] && \
96 [ $(docker inspect --format '{{ .State.Running }}' $DMAAP) ]
rajendrajaiswal140bfd22019-02-14 14:47:15 +000097 then
rajendrajaiswal37452e42019-04-02 08:40:58 +000098 echo "Message Router, Data Router, Consul, Config Binding Service Running and PM Mapper services are running healthy"
rajendrajaiswal140bfd22019-02-14 14:47:15 +000099 break
100 else
101 echo sleep $i
102 sleep $i
103 fi
104done
rajendrajaiswal37452e42019-04-02 08:40:58 +0000105# Data Router Configuration.
106DR_NODE_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' datarouter-node)
107DR_GATEWAY_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.Gateway}}{{end}}' datarouter-prov)
108docker 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"
109docker 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"
110
111# Create PM Mapper feed and create PM Mapper subscriber on data router
112curl -v -X POST -H "Content-Type:application/vnd.dmaap-dr.feed" -H "X-DMAAP-DR-ON-BEHALF-OF:pmmapper" --data-ascii @$WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/assets/createFeed.json --post301 --location-trusted -k https://${DR_PROV_IP}:8443
113curl -v -X POST -H "Content-Type:application/vnd.dmaap-dr.subscription" -H "X-DMAAP-DR-ON-BEHALF-OF:pmmapper" --data-ascii @$WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/assets/addSubscriber.json --post301 --location-trusted -k https://${DR_PROV_IP}:8443/subscribe/1
114
115# Create PM Mapper tocic in Message Router
116curl -v -X POST http://${DMAAP_MR_IP}:3904/topics/create -d @$WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/assets/createTopic.json -H "Content-Type: application/json"
rajendrajaiswala1574702019-02-14 10:29:45 +0000117PMMAPPER_IP=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' pmmapper)
rajendrajaiswal7f7dab02019-02-15 10:23:53 +0000118docker exec pmmapper /bin/sh -c "cat /var/log/ONAP/dcaegen2/services/pm-mapper/pm-mapper_output.log" > /tmp/pmmapper.log
119cat /tmp/pmmapper.log
rajendrajaiswal37452e42019-04-02 08:40:58 +0000120docker exec -it datarouter-prov sh -c "curl http://dmaap-dr-node:8080/internal/fetchProv"
121sleep 10
rajendrajaiswala1574702019-02-14 10:29:45 +0000122curl -k https://$DR_PROV_IP:8443/internal/prov
rajendrajaiswal37452e42019-04-02 08:40:58 +0000123curl http://${DMAAP_MR_IP}:3904/events/PM_MAPPER/CG1/C1?timeout=1000
rajendrajaiswala1574702019-02-14 10:29:45 +0000124
rajendrajaiswal47b64d72019-02-06 16:09:24 +0000125#Pass any variables required by Robot test suites in ROBOT_VARIABLES
rajendrajaiswal37452e42019-04-02 08:40:58 +0000126ROBOT_VARIABLES="-v CONSUL_IP:${CONSUL_IP} -v DR_PROV_IP:${DR_PROV_IP} -v DMAAP_MR_IP:${DMAAP_MR_IP} -v CBS_IP:${CBS_IP} -v PMMAPPER_IP:${PMMAPPER_IP} -v DR_NODE_IP:${DR_NODE_IP}"
127export ROBOT_VARIABLES