blob: 5f3c4a3c701fac54bf661f24c774ffc108ad663b [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
LiamBurkea4516192019-02-11 12:28:55 +00005CSIT=TRUE
6if [ ${CSIT} = "TRUE" ] ; then
7####################################################
8#Executes the below setup in an Docker Environment #
9####################################################
10
11echo "CSIT Test get executed in here"
12SFTP_PORT=22
13VESC_PORT=8080
14export VESC_PORT=${VESC_PORT}
15export CLI_EXEC_CLI_DFC="docker exec dfc /bin/sh -c \"ls /target | grep .gz\""
16
Gary Wu9abb61c2018-09-27 10:38:50 -070017# Clone DMaaP Message Router repo
18mkdir -p $WORKSPACE/archives/dmaapmr
19cd $WORKSPACE/archives/dmaapmr
20git clone --depth 1 http://gerrit.onap.org/r/dmaap/messagerouter/messageservice -b master
LiamBurkeae583be2018-10-16 10:44:12 +000021sed -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 -070022cd $WORKSPACE/archives/dmaapmr/messageservice/src/main/resources/docker-compose
23cp $WORKSPACE/archives/dmaapmr/messageservice/bundleconfig-local/etc/appprops/MsgRtrApi.properties /var/tmp/
24
25# start DMaaP MR containers with docker compose and configuration from docker-compose.yml
26docker login -u docker -p docker nexus3.onap.org:10001
27docker-compose up -d
28
29ZOOKEEPER=$(docker ps -a -q --filter="name=zookeeper_1")
30KAFKA=$(docker ps -a -q --filter="name=kafka_1")
31DMAAP=$(docker ps -a -q --filter="name=dmaap_1")
32
33# Wait for initialization of Docker contaienr for DMaaP MR, Kafka and Zookeeper
LiamBurkef708f842018-10-10 09:26:26 +000034for i in {1..10}; do
Gary Wu9abb61c2018-09-27 10:38:50 -070035if [ $(docker inspect --format '{{ .State.Running }}' $KAFKA) ] && \
36[ $(docker inspect --format '{{ .State.Running }}' $ZOOKEEPER) ] && \
37[ $(docker inspect --format '{{ .State.Running }}' $DMAAP) ]
38then
39 echo "DMaaP Service Running"
40 break
41else
42 echo sleep $i
43 sleep $i
44fi
45done
46
47# Get IP address of DMAAP, KAFKA, Zookeeper
48KAFKA_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $KAFKA)
49ZOOKEEPER_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $ZOOKEEPER)
50DMAAP_MR_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $DMAAP)
51
52sleep 2
53# Shutdown DMAAP Container
54docker kill $DMAAP
55
56# Initial docker-compose up and down is for populating kafka and zookeeper IPs in /var/tmp/MsgRtrApi.properites
57sed -i -e '/config.zk.servers=/ s/=.*/='$ZOOKEEPER_IP'/' /var/tmp/MsgRtrApi.properties
58sed -i -e '/kafka.metadata.broker.list=/ s/=.*/='$KAFKA_IP':9092/' /var/tmp/MsgRtrApi.properties
59
60# Start DMaaP MR containers with docker compose and configuration from docker-compose.yml
61docker login -u docker -p docker nexus3.onap.org:10001
62docker-compose up -d
63sleep 5
64
65# Clone DMaaP Data Router repo
66mkdir -p $WORKSPACE/archives/dmaapdr
67cd $WORKSPACE/archives/dmaapdr
68git clone --depth 1 https://gerrit.onap.org/r/dmaap/datarouter -b master
LiamBurke1344ef22018-10-19 15:22:16 +000069cd $WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources
70mkdir docker-compose
71cd $WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources/docker-compose
72cp $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
73
Gary Wu9abb61c2018-09-27 10:38:50 -070074docker login -u docker -p docker nexus3.onap.org:10001
75docker-compose up -d
LiamBurkeca7df552018-10-26 13:57:21 +000076echo "Disregard the message ERROR: for datarouter-node Container 1234456 is unhealthy, this is expected behaiour at this stage"
Gary Wu9abb61c2018-09-27 10:38:50 -070077docker kill datarouter-prov
78docker kill datarouter-node
79docker kill vescollector
80HOST_IP=$(ip route get 8.8.8.8 | awk '/8.8.8.8/ {print $NF}')
81sed -i -e '/DMAAPHOST:/ s/:.*/: '$HOST_IP'/' docker-compose.yml
82MARIADB=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' mariadb )
LiamBurke1344ef22018-10-19 15:22:16 +000083sed -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 -070084docker-compose up -d
85
86# Wait for initialization of Docker container for datarouter-node, datarouter-prov and mariadb
LiamBurkef708f842018-10-10 09:26:26 +000087for i in {1..10}; do
Gary Wu9abb61c2018-09-27 10:38:50 -070088 if [ $(docker inspect --format '{{ .State.Running }}' datarouter-node) ] && \
89 [ $(docker inspect --format '{{ .State.Running }}' datarouter-prov) ] && \
90 [ $(docker inspect --format '{{ .State.Running }}' mariadb) ]
91 then
92 echo "DR Service Running"
93 break
94 else
95 echo sleep $i
96 sleep $i
97 fi
98done
99
100sleep 5
101
102# Get IP address of datarrouger-prov, datarouter-node, fileconsumer-node.
103DR_PROV_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' datarouter-prov)
104DR_NODE_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' datarouter-node)
105DR_SUBSCIBER_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' fileconsumer-node)
106DR_GATEWAY_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.Gateway}}{{end}}' datarouter-prov)
107
108echo DR_PROV_IP=${DR_PROV_IP}
109echo DR_NODE_IP=${DR_NODE_IP}
110echo DR_GATEWAY_IP=${DR_GATEWAY_IP}
111echo DR_SUBSCIBER_IP=${DR_SUBSCIBER_IP}
112
113docker 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"
114docker 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"
115docker exec datarouter-prov /bin/sh -c "echo '${DR_NODE_IP}' dmaap-dr-node >> /etc/hosts"
116docker exec datarouter-node /bin/sh -c "echo '${DR_PROV_IP}' dmaap-dr-prov >> /etc/hosts"
117docker exec datarouter-node /bin/sh -c "echo '${DR_SUBSCIBER_IP}' dmaap-dr-subscriber >> /etc/hosts"
118
119# Get IP address of DMAAP, KAFKA, Zookeeper
120DMAAP_MR_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $DMAAP)
121KAFKA_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $KAFKA)
122ZOOKEEPER_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $ZOOKEEPER)
123VESC_IP=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' vescollector)
124SFTP_IP=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' sftp)
125
126export VESC_IP=${VESC_IP}
127export HOST_IP=${HOST_IP}
128export DMAAP_MR_IP=${DMAAP_MR_IP}
129
130#Pass any variables required by Robot test suites in ROBOT_VARIABLES
LiamBurkea4516192019-02-11 12:28:55 +0000131ROBOT_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 VESC_PORT:${VESC_PORT} -v DR_SUBSCIBER_IP:${DR_SUBSCIBER_IP}"
Gary Wu9abb61c2018-09-27 10:38:50 -0700132
133pip install jsonschema uuid
134# Wait container ready
135sleep 2
136
137# Data File Collector configuration :
LiamBurke0df2e442019-02-07 12:12:07 +0000138docker cp dfc:/config/datafile_endpoints.json /tmp/
139echo data_endpoints.json from DFC containter
140cat /tmp/datafile_endpoints.json
Gary Wu13111e92018-09-27 11:31:33 -0700141cp $WORKSPACE/plans/usecases/5G-bulkpm/assets/datafile_endpoints.json /tmp/
Gary Wu9abb61c2018-09-27 10:38:50 -0700142sed -i 's/dmaapmrhost/'${DMAAP_MR_IP}'/g' /tmp/datafile_endpoints.json
143sed -i 's/dmaapdrhost/'${DR_PROV_IP}'/g' /tmp/datafile_endpoints.json
LiamBurke0df2e442019-02-07 12:12:07 +0000144echo data_endpoints.json copied onto the DFC containter
145cat /tmp/datafile_endpoints.json
Gary Wu9abb61c2018-09-27 10:38:50 -0700146docker cp /tmp/datafile_endpoints.json dfc:/config/
LiamBurkeca7df552018-10-26 13:57:21 +0000147#Increase Logging
148docker exec dfc /bin/sh -c " sed -i 's/org.onap.dcaegen2.collectors.datafile: ERROR/org.onap.dcaegen2.collectors.datafile: TRACE/g' /config/application.yaml"
Gary Wu9abb61c2018-09-27 10:38:50 -0700149docker restart dfc
rajendrajaiswala2c1ca22018-09-30 16:42:27 +0100150docker exec dfc /bin/sh -c "echo '${DR_NODE_IP}' dmaap-dr-node >> /etc/hosts"
Gary Wu9abb61c2018-09-27 10:38:50 -0700151
152# SFTP Configuration:
153# Update the File Ready Notification with actual sftp ip address and copy pm files to sftp server.
rajendrajaiswal0d357f32018-09-28 10:18:19 +0100154cp $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 -0700155sed -i 's/sftpserver/'${SFTP_IP}'/g' $WORKSPACE/tests/usecases/5G-bulkpm/assets/json_events/FileExistNotificationUpdated.json
LiamBurkea4516192019-02-11 12:28:55 +0000156sed -i 's/sftpport/'${SFTP_PORT}'/g' $WORKSPACE/tests/usecases/5G-bulkpm/assets/json_events/FileExistNotificationUpdated.json
Gary Wu13111e92018-09-27 11:31:33 -0700157docker cp $WORKSPACE/plans/usecases/5G-bulkpm/assets/xNF.pm.xml.gz sftp:/home/admin/
Gary Wu9abb61c2018-09-27 10:38:50 -0700158
159# Data Router Configuration:
160# Create default feed and create file consumer subscriber on data router
egernug6f2874b2019-02-06 15:16:54 +0000161curl -v -X POST -H "Content-Type:application/vnd.dmaap-dr.feed" -H "X-DMAAP-DR-ON-BEHALF-OF:dradmin" --data-ascii @$WORKSPACE/plans/usecases/5G-bulkpm/assets/createFeed.json --post301 --location-trusted -k https://${DR_PROV_IP}:8443
Gary Wu13111e92018-09-27 11:31:33 -0700162cp $WORKSPACE/plans/usecases/5G-bulkpm/assets/addSubscriber.json /tmp/addSubscriber.json
Gary Wu9abb61c2018-09-27 10:38:50 -0700163sed -i 's/fileconsumer/'${DR_SUBSCIBER_IP}'/g' /tmp/addSubscriber.json
egernug6f2874b2019-02-06 15:16:54 +0000164curl -v -X POST -H "Content-Type:application/vnd.dmaap-dr.subscription" -H "X-DMAAP-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 +0100165sleep 10
LiamBurkef708f842018-10-10 09:26:26 +0000166curl -k https://$DR_PROV_IP:8443/internal/prov
LiamBurkea4516192019-02-11 12:28:55 +0000167
168else
169############################################################
170############################################################
171# Executes the below setup in an ONAP Environment #
172# Make sure the steps in the README are completed first !! #
173############################################################
174############################################################
175SFTP_PORT=2222
176
177cp $WORKSPACE/plans/usecases/5G-bulkpm/teardown.sh $WORKSPACE/plans/usecases/5G-bulkpm/teardown.sh.orig
178cp $WORKSPACE/plans/usecases/5G-bulkpm/onap.teardown.sh $WORKSPACE/plans/usecases/5G-bulkpm/teardown.sh
179
180#Get DataFileCollector POD name in this ONAP Deployment
181DFC_POD=$(kubectl -n onap get pods | grep datafile-collector | awk '{print $1}')
182export DFC_POD=${DFC_POD}
183export CLI_EXEC_CLI_DFC="kubectl exec -n onap ${DFC_POD} -it ls /target | grep .gz"
184
185# Get IP address of datarrouter-prov
186DR_PROV_IP=$(kubectl -n onap -o wide get pods | grep dmaap-dr-prov | awk '{print $6}')
187echo DR_PROV_IP=${DR_PROV_IP}
188DR_NODE_IP=$(kubectl -n onap -o=wide get pods | grep dmaap-dr-node | awk '{print $6}')
189echo DR_NODE_IP=${DR_NODE_IP}
190
191# Get IP address of exposed Ves and its port
192DMAAP_MR_IP=$(kubectl -n onap -o=wide get pods | grep dev-dmaap-message-router | grep -Ev "kafka|zookeeper" | awk '{print $6}')
193VESC_IP=$(kubectl get svc -n onap | grep vesc | awk '{print $4}')
194VESC_PORT=$(kubectl get svc -n onap | grep vesc | awk '{print $5}' | cut -d ":" -f2 | cut -d "/" -f1)
195echo VESC_IP=${VESC_IP}
196echo VESC_PORT=${VESC_PORT}
197
198export VESC_IP=${VESC_IP}
199export VESC_PORT=${VESC_PORT}
200export HOST_IP=${HOST_IP}
201export DMAAP_MR_IP=${DMAAP_MR_IP}
202
203#Get DataFileCollector POD name in this ONAP Deployment
204DFC_POD=$(kubectl -n onap get pods | grep datafile-collector | awk '{print $1}')
205export DFC_POD=${DFC_POD}
206
207pip install jsonschema uuid
208
209# Clone DMaaP Data Router repo
210mkdir -p $WORKSPACE/archives/dmaapdr
211cd $WORKSPACE/archives/dmaapdr
212git clone --depth 1 https://gerrit.onap.org/r/dmaap/datarouter -b master
213cd $WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources
214mkdir docker-compose
215cd $WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources/docker-compose
216cp $WORKSPACE/plans/usecases/5G-bulkpm/composefile/onap.docker-compose-e2e $WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources/docker-compose/docker-compose.yml
217
218#Statup the SFTP and FileConsumer containers.
219docker login -u docker -p docker nexus3.onap.org:10001
220docker-compose up -d
221
222# Wait container ready
223sleep 2
224HOST_IP=$(ip route get 8.8.8.8 | awk '/8.8.8.8/ {print $NF}')
225# SFTP Configuration:
226# Update the File Ready Notification with actual sftp ip address and copy pm files to sftp server.
227cp $WORKSPACE/tests/usecases/5G-bulkpm/assets/json_events/FileExistNotification.json $WORKSPACE/tests/usecases/5G-bulkpm/assets/json_events/FileExistNotificationUpdated.json
228sed -i 's/sftpserver/'${HOST_IP}'/g' $WORKSPACE/tests/usecases/5G-bulkpm/assets/json_events/FileExistNotificationUpdated.json
229sed -i 's/sftpport/'${SFTP_PORT}'/g' $WORKSPACE/tests/usecases/5G-bulkpm/assets/json_events/FileExistNotificationUpdated.json
230docker cp $WORKSPACE/plans/usecases/5G-bulkpm/assets/xNF.pm.xml.gz sftp:/home/admin/
231
232# Create default feed and create file consumer subscriber on data router
233curl -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
234cp $WORKSPACE/plans/usecases/5G-bulkpm/assets/addSubscriber.json /tmp/addSubscriber.json
235sed -i 's/fileconsumer/'${HOST_IP}'/g' /tmp/addSubscriber.json
236curl -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
237sleep 10
238curl -k https://$DR_PROV_IP:8443/internal/prov
239
240#Pass any variables required by Robot test suites in ROBOT_VARIABLES
241ROBOT_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 VESC_PORT:${VESC_PORT} -v DR_SUBSCIBER_IP:${DR_SUBSCIBER_IP} -v DFC_POD:${DFC_POD} -v HOST_IP:${HOST_IP} "
242
243fi;