blob: e52195f50e3e0413b89fe08c22931941730ef853 [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
rajendrajaiswal3b202f02019-04-09 10:37:49 +000086# Setting up PM Mapper certs.
87docker cp $WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/assets/cert.jks.b64 pmmapper:opt/app/pm-mapper/etc/
88docker cp $WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/assets/jks.pass pmmapper:opt/app/pm-mapper/etc/
89docker cp $WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/assets/trust.jks.b64 pmmapper:opt/app/pm-mapper/etc/
90docker cp $WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/assets/trust.pass pmmapper:opt/app/pm-mapper/etc/
91docker restart pmmapper
92
rajendrajaiswal37452e42019-04-02 08:40:58 +000093# Wait for initialization of Docker container for datarouter-node, datarouter-prov and mariadb, Consul, CBS
94for i in {1..5}; do
95 if [ $(docker inspect --format '{{ .State.Running }}' datarouter-node) ] && \
96 [ $(docker inspect --format '{{ .State.Running }}' datarouter-prov) ] && \
97 [ $(docker inspect --format '{{ .State.Running }}' mariadb) ] && \
98 [ $(docker inspect --format '{{ .State.Running }}' consul) ] && \
99 [ $(docker inspect --format '{{ .State.Running }}' cbs) ] && \
100 [ $(docker inspect --format '{{ .State.Running }}' pmmapper) ] && \
101 [ $(docker inspect --format '{{ .State.Running }}' $KAFKA) ] && \
102 [ $(docker inspect --format '{{ .State.Running }}' $ZOOKEEPER) ] && \
103 [ $(docker inspect --format '{{ .State.Running }}' $DMAAP) ]
rajendrajaiswal140bfd22019-02-14 14:47:15 +0000104 then
rajendrajaiswal37452e42019-04-02 08:40:58 +0000105 echo "Message Router, Data Router, Consul, Config Binding Service Running and PM Mapper services are running healthy"
rajendrajaiswal140bfd22019-02-14 14:47:15 +0000106 break
107 else
108 echo sleep $i
109 sleep $i
110 fi
111done
rajendrajaiswal37452e42019-04-02 08:40:58 +0000112# Data Router Configuration.
113DR_NODE_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' datarouter-node)
114DR_GATEWAY_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.Gateway}}{{end}}' datarouter-prov)
115docker 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"
116docker 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"
117
118# Create PM Mapper feed and create PM Mapper subscriber on data router
119curl -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
120curl -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
121
122# Create PM Mapper tocic in Message Router
123curl -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 +0000124PMMAPPER_IP=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' pmmapper)
rajendrajaiswal7f7dab02019-02-15 10:23:53 +0000125docker exec pmmapper /bin/sh -c "cat /var/log/ONAP/dcaegen2/services/pm-mapper/pm-mapper_output.log" > /tmp/pmmapper.log
126cat /tmp/pmmapper.log
rajendrajaiswal37452e42019-04-02 08:40:58 +0000127docker exec -it datarouter-prov sh -c "curl http://dmaap-dr-node:8080/internal/fetchProv"
128sleep 10
rajendrajaiswala1574702019-02-14 10:29:45 +0000129curl -k https://$DR_PROV_IP:8443/internal/prov
rajendrajaiswal37452e42019-04-02 08:40:58 +0000130curl http://${DMAAP_MR_IP}:3904/events/PM_MAPPER/CG1/C1?timeout=1000
rajendrajaiswala1574702019-02-14 10:29:45 +0000131
rajendrajaiswal47b64d72019-02-06 16:09:24 +0000132#Pass any variables required by Robot test suites in ROBOT_VARIABLES
rajendrajaiswal3b202f02019-04-09 10:37:49 +0000133ROBOT_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}"