blob: c9f5318ddd6123190741ef04f504f02384f2d862 [file] [log] [blame]
rajendrajaiswal6823ae72018-09-07 15:23:18 +01001#!/bin/bash
2# Place the scripts in run order:
rajendrajaiswal6823ae72018-09-07 15:23:18 +01003source ${SCRIPTS}/common_functions.sh
4
rajendrajaiswal6823ae72018-09-07 15:23:18 +01005# Clone DMaaP Message Router repo
6mkdir -p $WORKSPACE/archives/dmaapmr
7cd $WORKSPACE/archives/dmaapmr
rajendrajaiswal6823ae72018-09-07 15:23:18 +01008git clone --depth 1 http://gerrit.onap.org/r/dmaap/messagerouter/messageservice -b master
9git pull
10cd $WORKSPACE/archives/dmaapmr/messageservice/src/main/resources/docker-compose
11cp $WORKSPACE/archives/dmaapmr/messageservice/bundleconfig-local/etc/appprops/MsgRtrApi.properties /var/tmp/
12
rajendrajaiswal6823ae72018-09-07 15:23:18 +010013# 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
LiamBurkec5fa5952018-09-17 14:34:05 +010017ZOOKEEPER=$(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
rajendrajaiswal6823ae72018-09-07 15:23:18 +010021# Wait for initialization of Docker contaienr for DMaaP MR, Kafka and Zookeeper
22for i in {1..50}; do
LiamBurkec5fa5952018-09-17 14:34:05 +010023if [ $(docker inspect --format '{{ .State.Running }}' $KAFKA) ] && \
24[ $(docker inspect --format '{{ .State.Running }}' $ZOOKEEPER) ] && \
25[ $(docker inspect --format '{{ .State.Running }}' $DMAAP) ]
rajendrajaiswal6823ae72018-09-07 15:23:18 +010026then
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
LiamBurkec5fa5952018-09-17 14:34:05 +010036KAFKA_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $KAFKA)
37ZOOKEEPER_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $ZOOKEEPER)
rajendrajaiswal4a93e492018-09-24 12:37:13 +010038DMAAP_MR_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $DMAAP)
rajendrajaiswal6823ae72018-09-07 15:23:18 +010039
rajendrajaiswal4a93e492018-09-24 12:37:13 +010040sleep 2
rajendrajaiswal6823ae72018-09-07 15:23:18 +010041# Shutdown DMAAP Container
LiamBurkec5fa5952018-09-17 14:34:05 +010042docker kill $DMAAP
rajendrajaiswal6823ae72018-09-07 15:23:18 +010043
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
rajendrajaiswal6823ae72018-09-07 15:23:18 +010049docker login -u docker -p docker nexus3.onap.org:10001
50docker-compose up -d
51sleep 5
52
rajendrajaiswal4a93e492018-09-24 12:37:13 +010053# 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 datarouter
58cd $WORKSPACE/archives/dmaapdr/datarouter/docker-compose/
59rm -rf docker-compose.yml
60cp $WORKSPACE/test/csit/plans/dcae-bulkpm/bulkpm-suite/composefile/docker-compose-e2e.yml $WORKSPACE/archives/dmaapdr/datarouter/docker-compose/docker-compose.yml
61docker login -u docker -p docker nexus3.onap.org:10001
62docker-compose up -d
63docker kill datarouter-prov
64docker kill datarouter-node
65docker kill vescollector
66sed -i -e '/DMAAPHOST:/ s/:.*/: '$DMAAP_MR_IP'/' docker-compose.yml
67MARIADB=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' mariadb )
68sed -i 's/172.100.0.2/'$MARIADB'/g' $WORKSPACE/archives/dmaapdr/datarouter/docker-compose/prov_data/provserver.properties
69docker-compose up -d
70
71# Wait for initialization of Docker container for datarouter-node, datarouter-prov and mariadb
72for i in {1..50}; do
73 if [ $(docker inspect --format '{{ .State.Running }}' datarouter-node) ] && \
74 [ $(docker inspect --format '{{ .State.Running }}' datarouter-prov) ] && \
75 [ $(docker inspect --format '{{ .State.Running }}' mariadb) ]
76 then
77 echo "DR Service Running"
78 break
79 else
80 echo sleep $i
81 sleep $i
82 fi
83done
84
85sleep 5
86
87# Get IP address of datarrouger-prov, datarouter-node, subscriber-node, subscriber-node.
88DR_PROV_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' datarouter-prov)
89DR_NODE_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' datarouter-node)
90DR_SUBSCIBER_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' subscriber-node)
91DR_GATEWAY_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.Gateway}}{{end}}' datarouter-prov)
92
93#Add the DR_NODE_IP to /etc/hosts
94echo "${DR_NODE_IP} dmaap-dr-node" >> /etc/hosts
95echo "${DR_PROV_IP} dmaap-dr-prov" >> /etc/hosts
96
97echo DR_PROV_IP=${DR_PROV_IP}
98echo DR_NODE_IP=${DR_NODE_IP}
99echo DR_GATEWAY_IP=${DR_GATEWAY_IP}
100echo DR_SUBSCIBER_IP=${DR_SUBSCIBER_IP}
101
102docker 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"
106docker exec datarouter-node /bin/sh -c "echo '${DR_SUBSCIBER_IP}' dmaap-dr-subscriber >> /etc/hosts"
107
108# Get IP address of DMAAP, KAFKA, Zookeeper
109DMAAP_MR_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $DMAAP)
110KAFKA_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $KAFKA)
111ZOOKEEPER_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $ZOOKEEPER)
112VESC_IP=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' vescollector)
113
rajendrajaiswal6823ae72018-09-07 15:23:18 +0100114export VESC_IP=${VESC_IP}
115export HOST_IP=${HOST_IP}
116export DMAAP_MR_IP=${DMAAP_MR_IP}
rajendrajaiswal4a93e492018-09-24 12:37:13 +0100117
118echo "${DMAAP_MR_IP} dmaap-mr" >> /etc/hosts
119
LiamBurkec5fa5952018-09-17 14:34:05 +0100120#Pass any variables required by Robot test suites in ROBOT_VARIABLES
121ROBOT_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 +0100122
123pip install jsonschema uuid
124# Wait container ready
LiamBurkec5fa5952018-09-17 14:34:05 +0100125sleep 2