blob: 03943451961919dc50c0dbdfae238e246421d888 [file] [log] [blame]
Gary Wu9abb61c2018-09-27 10:38:50 -07001#!/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
Gary Wu9abb61c2018-09-27 10:38:50 -07009cd $WORKSPACE/archives/dmaapmr/messageservice/src/main/resources/docker-compose
10cp $WORKSPACE/archives/dmaapmr/messageservice/bundleconfig-local/etc/appprops/MsgRtrApi.properties /var/tmp/
11
12# start DMaaP MR containers with docker compose and configuration from docker-compose.yml
13docker login -u docker -p docker nexus3.onap.org:10001
14docker-compose up -d
15
16ZOOKEEPER=$(docker ps -a -q --filter="name=zookeeper_1")
17KAFKA=$(docker ps -a -q --filter="name=kafka_1")
18DMAAP=$(docker ps -a -q --filter="name=dmaap_1")
19
20# Wait for initialization of Docker contaienr for DMaaP MR, Kafka and Zookeeper
21for i in {1..50}; do
22if [ $(docker inspect --format '{{ .State.Running }}' $KAFKA) ] && \
23[ $(docker inspect --format '{{ .State.Running }}' $ZOOKEEPER) ] && \
24[ $(docker inspect --format '{{ .State.Running }}' $DMAAP) ]
25then
26 echo "DMaaP Service Running"
27 break
28else
29 echo sleep $i
30 sleep $i
31fi
32done
33
34# Get IP address of DMAAP, KAFKA, Zookeeper
35KAFKA_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $KAFKA)
36ZOOKEEPER_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $ZOOKEEPER)
37DMAAP_MR_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $DMAAP)
38
39sleep 2
40# Shutdown DMAAP Container
41docker kill $DMAAP
42
43# Initial docker-compose up and down is for populating kafka and zookeeper IPs in /var/tmp/MsgRtrApi.properites
44sed -i -e '/config.zk.servers=/ s/=.*/='$ZOOKEEPER_IP'/' /var/tmp/MsgRtrApi.properties
45sed -i -e '/kafka.metadata.broker.list=/ s/=.*/='$KAFKA_IP':9092/' /var/tmp/MsgRtrApi.properties
46
47# Start DMaaP MR containers with docker compose and configuration from docker-compose.yml
48docker login -u docker -p docker nexus3.onap.org:10001
49docker-compose up -d
50sleep 5
51
52# Clone DMaaP Data Router repo
53mkdir -p $WORKSPACE/archives/dmaapdr
54cd $WORKSPACE/archives/dmaapdr
55git clone --depth 1 https://gerrit.onap.org/r/dmaap/datarouter -b master
56cd datarouter
57cd $WORKSPACE/archives/dmaapdr/datarouter/docker-compose/
58rm -rf docker-compose.yml
Gary Wu13111e92018-09-27 11:31:33 -070059cp $WORKSPACE/plans/usecases/5G-bulkpm/composefile/docker-compose-e2e.yml $WORKSPACE/archives/dmaapdr/datarouter/docker-compose/docker-compose.yml
Gary Wu9abb61c2018-09-27 10:38:50 -070060docker login -u docker -p docker nexus3.onap.org:10001
61docker-compose up -d
62docker kill datarouter-prov
63docker kill datarouter-node
64docker kill vescollector
65HOST_IP=$(ip route get 8.8.8.8 | awk '/8.8.8.8/ {print $NF}')
66sed -i -e '/DMAAPHOST:/ s/:.*/: '$HOST_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, fileconsumer-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}}' fileconsumer-node)
91DR_GATEWAY_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.Gateway}}{{end}}' datarouter-prov)
92
93echo DR_PROV_IP=${DR_PROV_IP}
94echo DR_NODE_IP=${DR_NODE_IP}
95echo DR_GATEWAY_IP=${DR_GATEWAY_IP}
96echo DR_SUBSCIBER_IP=${DR_SUBSCIBER_IP}
97
98docker 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"
99docker 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"
100docker exec datarouter-prov /bin/sh -c "echo '${DR_NODE_IP}' dmaap-dr-node >> /etc/hosts"
101docker exec datarouter-node /bin/sh -c "echo '${DR_PROV_IP}' dmaap-dr-prov >> /etc/hosts"
102docker exec datarouter-node /bin/sh -c "echo '${DR_SUBSCIBER_IP}' dmaap-dr-subscriber >> /etc/hosts"
103
104# Get IP address of DMAAP, KAFKA, Zookeeper
105DMAAP_MR_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $DMAAP)
106KAFKA_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $KAFKA)
107ZOOKEEPER_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $ZOOKEEPER)
108VESC_IP=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' vescollector)
109SFTP_IP=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' sftp)
110
111export VESC_IP=${VESC_IP}
112export HOST_IP=${HOST_IP}
113export DMAAP_MR_IP=${DMAAP_MR_IP}
114
115#Pass any variables required by Robot test suites in ROBOT_VARIABLES
116ROBOT_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} -v DR_SUBSCIBER_IP:${DR_SUBSCIBER_IP}"
117
118pip install jsonschema uuid
119# Wait container ready
120sleep 2
121
122# Data File Collector configuration :
Gary Wu13111e92018-09-27 11:31:33 -0700123cp $WORKSPACE/plans/usecases/5G-bulkpm/assets/datafile_endpoints.json /tmp/
Gary Wu9abb61c2018-09-27 10:38:50 -0700124sed -i 's/dmaapmrhost/'${DMAAP_MR_IP}'/g' /tmp/datafile_endpoints.json
125sed -i 's/dmaapdrhost/'${DR_PROV_IP}'/g' /tmp/datafile_endpoints.json
126docker cp /tmp/datafile_endpoints.json dfc:/config/
127docker restart dfc
rajendrajaiswala2c1ca22018-09-30 16:42:27 +0100128docker exec dfc /bin/sh -c "echo '${DR_NODE_IP}' dmaap-dr-node >> /etc/hosts"
Gary Wu9abb61c2018-09-27 10:38:50 -0700129
130# SFTP Configuration:
131# Update the File Ready Notification with actual sftp ip address and copy pm files to sftp server.
rajendrajaiswal0d357f32018-09-28 10:18:19 +0100132cp $WORKSPACE/tests/usecases/5G-bulkpm/assets/json_events/FileExistNotification.json $WORKSPACE/tests/usecases/5G-bulkpm/assets/json_events/FileExistNotificationUpdated.json
Gary Wu13111e92018-09-27 11:31:33 -0700133sed -i 's/sftpserver/'${SFTP_IP}'/g' $WORKSPACE/tests/usecases/5G-bulkpm/assets/json_events/FileExistNotificationUpdated.json
134docker cp $WORKSPACE/plans/usecases/5G-bulkpm/assets/xNF.pm.xml.gz sftp:/home/admin/
Gary Wu9abb61c2018-09-27 10:38:50 -0700135
136# Data Router Configuration:
137# Create default feed and create file consumer subscriber on data router
Gary Wu13111e92018-09-27 11:31:33 -0700138curl -v -X POST -H "Content-Type:application/vnd.att-dr.feed" -H "X-ATT-DR-ON-BEHALF-OF:dradmin" --data-ascii @$WORKSPACE/plans/usecases/5G-bulkpm/assets/createFeed.json --post301 --location-trusted -k https://${DR_PROV_IP}:8443
139cp $WORKSPACE/plans/usecases/5G-bulkpm/assets/addSubscriber.json /tmp/addSubscriber.json
Gary Wu9abb61c2018-09-27 10:38:50 -0700140sed -i 's/fileconsumer/'${DR_SUBSCIBER_IP}'/g' /tmp/addSubscriber.json
rajendrajaiswala2c1ca22018-09-30 16:42:27 +0100141curl -v -X POST -H "Content-Type:application/vnd.att-dr.subscription" -H "X-ATT-DR-ON-BEHALF-OF:dradmin" --data-ascii @/tmp/addSubscriber.json --post301 --location-trusted -k https://${DR_PROV_IP}:8443/subscribe/1
142sleep 60
143curl -k https://$DR_PROV_IP:8443/internal/prov