blob: 5139cbabe54fc14aea34820da3730e396ff9eebe [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
LiamBurkeae583be2018-10-16 10:44:12 +00009sed -i 's/enableCadi: false/enableCadi: "false"/g' /$WORKSPACE/archives/dmaapmr/messageservice/src/main/resources/docker-compose/docker-compose.yml
Gary Wu9abb61c2018-09-27 10:38:50 -070010cd $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
LiamBurkef708f842018-10-10 09:26:26 +000022for i in {1..10}; do
Gary Wu9abb61c2018-09-27 10:38:50 -070023if [ $(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
35# Get IP address of DMAAP, KAFKA, Zookeeper
36KAFKA_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $KAFKA)
37ZOOKEEPER_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $ZOOKEEPER)
38DMAAP_MR_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $DMAAP)
39
40sleep 2
41# Shutdown DMAAP Container
42docker kill $DMAAP
43
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
49docker login -u docker -p docker nexus3.onap.org:10001
50docker-compose up -d
51sleep 5
52
53# 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
LiamBurke1344ef22018-10-19 15:22:16 +000057cd $WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources
58mkdir docker-compose
59cd $WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources/docker-compose
60cp $WORKSPACE/plans/usecases/5G-bulkpm/composefile/docker-compose-e2e.yml $WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources/docker-compose/docker-compose.yml
61
Gary Wu9abb61c2018-09-27 10:38:50 -070062docker login -u docker -p docker nexus3.onap.org:10001
63docker-compose up -d
64docker kill datarouter-prov
65docker kill datarouter-node
66docker kill vescollector
67HOST_IP=$(ip route get 8.8.8.8 | awk '/8.8.8.8/ {print $NF}')
68sed -i -e '/DMAAPHOST:/ s/:.*/: '$HOST_IP'/' docker-compose.yml
69MARIADB=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' mariadb )
LiamBurke1344ef22018-10-19 15:22:16 +000070sed -i 's/datarouter-mariadb/'$MARIADB'/g' $WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources/prov_data/provserver.properties
Gary Wu9abb61c2018-09-27 10:38:50 -070071docker-compose up -d
72
73# Wait for initialization of Docker container for datarouter-node, datarouter-prov and mariadb
LiamBurkef708f842018-10-10 09:26:26 +000074for i in {1..10}; do
Gary Wu9abb61c2018-09-27 10:38:50 -070075 if [ $(docker inspect --format '{{ .State.Running }}' datarouter-node) ] && \
76 [ $(docker inspect --format '{{ .State.Running }}' datarouter-prov) ] && \
77 [ $(docker inspect --format '{{ .State.Running }}' mariadb) ]
78 then
79 echo "DR Service Running"
80 break
81 else
82 echo sleep $i
83 sleep $i
84 fi
85done
86
87sleep 5
88
89# Get IP address of datarrouger-prov, datarouter-node, fileconsumer-node.
90DR_PROV_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' datarouter-prov)
91DR_NODE_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' datarouter-node)
92DR_SUBSCIBER_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' fileconsumer-node)
93DR_GATEWAY_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.Gateway}}{{end}}' datarouter-prov)
94
95echo DR_PROV_IP=${DR_PROV_IP}
96echo DR_NODE_IP=${DR_NODE_IP}
97echo DR_GATEWAY_IP=${DR_GATEWAY_IP}
98echo DR_SUBSCIBER_IP=${DR_SUBSCIBER_IP}
99
100docker 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"
101docker 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"
102docker exec datarouter-prov /bin/sh -c "echo '${DR_NODE_IP}' dmaap-dr-node >> /etc/hosts"
103docker exec datarouter-node /bin/sh -c "echo '${DR_PROV_IP}' dmaap-dr-prov >> /etc/hosts"
104docker exec datarouter-node /bin/sh -c "echo '${DR_SUBSCIBER_IP}' dmaap-dr-subscriber >> /etc/hosts"
105
106# Get IP address of DMAAP, KAFKA, Zookeeper
107DMAAP_MR_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $DMAAP)
108KAFKA_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $KAFKA)
109ZOOKEEPER_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $ZOOKEEPER)
110VESC_IP=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' vescollector)
111SFTP_IP=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' sftp)
112
113export VESC_IP=${VESC_IP}
114export HOST_IP=${HOST_IP}
115export DMAAP_MR_IP=${DMAAP_MR_IP}
116
117#Pass any variables required by Robot test suites in ROBOT_VARIABLES
118ROBOT_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}"
119
120pip install jsonschema uuid
121# Wait container ready
122sleep 2
123
124# Data File Collector configuration :
Gary Wu13111e92018-09-27 11:31:33 -0700125cp $WORKSPACE/plans/usecases/5G-bulkpm/assets/datafile_endpoints.json /tmp/
Gary Wu9abb61c2018-09-27 10:38:50 -0700126sed -i 's/dmaapmrhost/'${DMAAP_MR_IP}'/g' /tmp/datafile_endpoints.json
127sed -i 's/dmaapdrhost/'${DR_PROV_IP}'/g' /tmp/datafile_endpoints.json
128docker cp /tmp/datafile_endpoints.json dfc:/config/
129docker restart dfc
rajendrajaiswala2c1ca22018-09-30 16:42:27 +0100130docker exec dfc /bin/sh -c "echo '${DR_NODE_IP}' dmaap-dr-node >> /etc/hosts"
Gary Wu9abb61c2018-09-27 10:38:50 -0700131
132# SFTP Configuration:
133# Update the File Ready Notification with actual sftp ip address and copy pm files to sftp server.
rajendrajaiswal0d357f32018-09-28 10:18:19 +0100134cp $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 -0700135sed -i 's/sftpserver/'${SFTP_IP}'/g' $WORKSPACE/tests/usecases/5G-bulkpm/assets/json_events/FileExistNotificationUpdated.json
136docker cp $WORKSPACE/plans/usecases/5G-bulkpm/assets/xNF.pm.xml.gz sftp:/home/admin/
Gary Wu9abb61c2018-09-27 10:38:50 -0700137
138# Data Router Configuration:
139# Create default feed and create file consumer subscriber on data router
Gary Wu13111e92018-09-27 11:31:33 -0700140curl -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
141cp $WORKSPACE/plans/usecases/5G-bulkpm/assets/addSubscriber.json /tmp/addSubscriber.json
Gary Wu9abb61c2018-09-27 10:38:50 -0700142sed -i 's/fileconsumer/'${DR_SUBSCIBER_IP}'/g' /tmp/addSubscriber.json
rajendrajaiswala2c1ca22018-09-30 16:42:27 +0100143curl -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
rajendrajaiswalb99eedc2018-10-02 09:42:23 +0100144sleep 10
LiamBurkef708f842018-10-10 09:26:26 +0000145curl -k https://$DR_PROV_IP:8443/internal/prov