blob: 2924bd21f2eda9e607afa2cab7a47ab74a559aae [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
rajendrajaiswala1574702019-02-14 10:29:45 +000035# Get IP address of KAFKA, Zookeeper
rajendrajaiswal47b64d72019-02-06 16:09:24 +000036KAFKA_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $KAFKA)
37ZOOKEEPER_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $ZOOKEEPER)
rajendrajaiswal47b64d72019-02-06 16:09:24 +000038
rajendrajaiswal47b64d72019-02-06 16:09:24 +000039# Shutdown DMAAP Container
40docker kill $DMAAP
41
42# Initial docker-compose up and down is for populating kafka and zookeeper IPs in /var/tmp/MsgRtrApi.properites
43sed -i -e '/config.zk.servers=/ s/=.*/='$ZOOKEEPER_IP'/' /var/tmp/MsgRtrApi.properties
44sed -i -e '/kafka.metadata.broker.list=/ s/=.*/='$KAFKA_IP':9092/' /var/tmp/MsgRtrApi.properties
45
46# Start DMaaP MR containers with docker compose and configuration from docker-compose.yml
47docker login -u docker -p docker nexus3.onap.org:10001
48docker-compose up -d
49sleep 5
50
rajendrajaiswala1574702019-02-14 10:29:45 +000051# Get IP address of DMAAP Message Router.
52DMAAP_MR_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $DMAAP)
53
54# Clone DMaaP Data Router repo and Initialization of Data Router, Consul, Config Binding Service and Buscontroller
rajendrajaiswal47b64d72019-02-06 16:09:24 +000055mkdir -p $WORKSPACE/archives/dmaapdr
56cd $WORKSPACE/archives/dmaapdr
57git clone --depth 1 https://gerrit.onap.org/r/dmaap/datarouter -b master
58cd $WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources
59mkdir docker-compose
60cd $WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources/docker-compose
61cp $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
rajendrajaiswala1574702019-02-14 10:29:45 +000062cp $WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/assets/docker-databus-controller.conf /tmp/
63sed -i 's/DMAAPMR/'$DMAAP_MR_IP'/g' /tmp/docker-databus-controller.conf
rajendrajaiswal47b64d72019-02-06 16:09:24 +000064docker login -u docker -p docker nexus3.onap.org:10001
65docker-compose up -d
66echo "Disregard the message ERROR: for datarouter-node Container 1234456 is unhealthy, this is expected behaiour at this stage"
67docker kill datarouter-prov
68docker kill datarouter-node
69docker kill cbs
70CONSUL_IP=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' consul )
71sed -i -e '/CONSUL_HOST:/ s/:.*/: '$CONSUL_IP'/' docker-compose.yml
72MARIADB=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' mariadb )
73sed -i 's/datarouter-mariadb/'$MARIADB'/g' $WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources/prov_data/provserver.properties
74docker-compose up -d
rajendrajaiswal8f0afd82019-02-11 12:30:26 +000075DR_PROV_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' datarouter-prov)
76docker kill buscontroller
rajendrajaiswala1574702019-02-14 10:29:45 +000077sed -i 's/DMAAPDR/'$DR_PROV_IP'/g' docker-compose.yml
78sed -i 's/DMAAPMR/'$DMAAP_MR_IP'/g' docker-compose.yml
rajendrajaiswal8f0afd82019-02-11 12:30:26 +000079docker-compose up -d
rajendrajaiswala1574702019-02-14 10:29:45 +000080sed -i 's/DMAAPDR/'$DR_PROV_IP'/g' /tmp/docker-databus-controller.conf
rajendrajaiswal47b64d72019-02-06 16:09:24 +000081
rajendrajaiswala1574702019-02-14 10:29:45 +000082# Wait for initialization of Docker container for datarouter-node, datarouter-prov and mariadb, Consul, CBS, Buscontroller
rajendrajaiswal47b64d72019-02-06 16:09:24 +000083for i in {1..10}; do
84 if [ $(docker inspect --format '{{ .State.Running }}' datarouter-node) ] && \
85 [ $(docker inspect --format '{{ .State.Running }}' datarouter-prov) ] && \
rajendrajaiswala1574702019-02-14 10:29:45 +000086 [ $(docker inspect --format '{{ .State.Running }}' mariadb) ] && \
87 [ $(docker inspect --format '{{ .State.Running }}' consul) ] && \
88 [ $(docker inspect --format '{{ .State.Running }}' cbs) ] && \
89 [ $(docker inspect --format '{{ .State.Running }}' buscontroller) ]
rajendrajaiswal47b64d72019-02-06 16:09:24 +000090 then
rajendrajaiswal140bfd22019-02-14 14:47:15 +000091 echo "Data Router, Consul, Config Binding Service, Buscontroller Services Running"
rajendrajaiswal47b64d72019-02-06 16:09:24 +000092 break
93 else
94 echo sleep $i
95 sleep $i
96 fi
97done
rajendrajaiswal5f3f5712019-02-27 11:35:09 +000098sleep 15
rajendrajaiswala1574702019-02-14 10:29:45 +000099# Data Router Configuration.
rajendrajaiswal47b64d72019-02-06 16:09:24 +0000100DR_NODE_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' datarouter-node)
101DR_GATEWAY_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.Gateway}}{{end}}' datarouter-prov)
rajendrajaiswal47b64d72019-02-06 16:09:24 +0000102docker 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"
103docker 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"
104docker exec datarouter-prov /bin/sh -c "echo '${DR_NODE_IP}' dmaap-dr-node >> /etc/hosts"
105docker exec datarouter-node /bin/sh -c "echo '${DR_PROV_IP}' dmaap-dr-prov >> /etc/hosts"
rajendrajaiswal8f0afd82019-02-11 12:30:26 +0000106
107# Bus Controller Configuration
108DMAAPBC_IP=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' buscontroller)
109$WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/dmaapbc.sh ${DMAAPBC_IP}
rajendrajaiswal47b64d72019-02-06 16:09:24 +0000110
111# Consul Configuration for PM Mapper
112cp $WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/assets/cbs.json /tmp/cbs.json
113sed -i 's/ipaddress/'${CBS_IP}'/g' /tmp/cbs.json
114curl --request PUT --data @/tmp/cbs.json http://$CONSUL_IP:8500/v1/agent/service/register
115curl '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
116
rajendrajaiswala1574702019-02-14 10:29:45 +0000117# PM Mapper startup and configuration
118mkdir /tmp/docker-compose
119cd /tmp/docker-compose
120cp $WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/composefile/docker-compose-pmmapper.yml /tmp/docker-compose/docker-compose.yml
121CBS_IP=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' cbs)
122sed -i 's/CBSIP/'$CBS_IP'/g' docker-compose.yml
123sed -i 's/BUSIP/'$DMAAPBC_IP'/g' docker-compose.yml
JoeOLeary667bd592019-03-05 09:21:26 +0000124sed -i 's/DRNODEIP/'$DR_NODE_IP'/g' docker-compose.yml
rajendrajaiswala1574702019-02-14 10:29:45 +0000125docker-compose up -d
rajendrajaiswal140bfd22019-02-14 14:47:15 +0000126
127# Wait for initialization of Docker container for 3GPP PM Mapper
128for i in {1..10}; do
129 if [ $(docker inspect --format '{{ .State.Running }}' pmmapper) ]
130 then
131 echo "PM Mapper Service Running"
132 break
133 else
134 echo sleep $i
135 sleep $i
136 fi
137done
rajendrajaiswala1574702019-02-14 10:29:45 +0000138PMMAPPER_IP=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' pmmapper)
rajendrajaiswal140bfd22019-02-14 14:47:15 +0000139docker exec datarouter-prov /bin/sh -c "echo '${PMMAPPER_IP}' 3gpppmmapper >> /etc/hosts"
JoeOLeary667bd592019-03-05 09:21:26 +0000140docker exec datarouter-node /bin/sh -c "echo '${PMMAPPER_IP}' 3gpppmmapper >> /etc/hosts"
rajendrajaiswala1574702019-02-14 10:29:45 +0000141sleep 10
rajendrajaiswal7f7dab02019-02-15 10:23:53 +0000142docker exec pmmapper /bin/sh -c "cat /var/log/ONAP/dcaegen2/services/pm-mapper/pm-mapper_output.log" > /tmp/pmmapper.log
143cat /tmp/pmmapper.log
rajendrajaiswal95e6fa72019-02-27 13:43:30 +0000144docker exec buscontroller /bin/sh -c "cat /opt/app/dmaapbc/logs/ONAP/application.log"
rajendrajaiswala1574702019-02-14 10:29:45 +0000145curl -k https://$DR_PROV_IP:8443/internal/prov
146
rajendrajaiswal47b64d72019-02-06 16:09:24 +0000147#Pass any variables required by Robot test suites in ROBOT_VARIABLES
rajendrajaiswalb60c9ee2019-03-15 12:31:17 +0000148ROBOT_VARIABLES="-v CONSUL_IP:${CONSUL_IP} -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 PMMAPPER_IP:${PMMAPPER_IP} -v DR_NODE_IP:${DR_NODE_IP}"