blob: 5d99b1c1f84601cdc4ce611be903d9e9642a54a6 [file] [log] [blame]
Gary Wu9abb61c2018-09-27 10:38:50 -07001#!/bin/bash
LiamBurkecf7c8ca2019-03-15 15:25:23 +00002# Place the scripts in run order:
Gary Wu9abb61c2018-09-27 10:38:50 -07003source ${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
LiamBurke3608af72019-03-12 22:50:33 +000073cp $WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/assets/docker-databus-controller.conf /tmp/
74sed -i 's/DMAAPMR/'$DMAAP_MR_IP'/g' /tmp/docker-databus-controller.conf
LiamBurke1344ef22018-10-19 15:22:16 +000075
Gary Wu9abb61c2018-09-27 10:38:50 -070076docker login -u docker -p docker nexus3.onap.org:10001
77docker-compose up -d
LiamBurkeca7df552018-10-26 13:57:21 +000078echo "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 -070079docker kill vescollector
LiamBurke3608af72019-03-12 22:50:33 +000080docker kill cbs
LiamBurke248195d2019-04-03 10:21:12 +010081sleep 10
LiamBurke3608af72019-03-12 22:50:33 +000082CONSUL_IP=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' consul )
83sed -i -e '/CONSUL_HOST:/ s/:.*/: '$CONSUL_IP'/' docker-compose.yml
Gary Wu9abb61c2018-09-27 10:38:50 -070084HOST_IP=$(ip route get 8.8.8.8 | awk '/8.8.8.8/ {print $NF}')
85sed -i -e '/DMAAPHOST:/ s/:.*/: '$HOST_IP'/' docker-compose.yml
86MARIADB=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' mariadb )
LiamBurke1344ef22018-10-19 15:22:16 +000087sed -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 -070088docker-compose up -d
LiamBurke248195d2019-04-03 10:21:12 +010089sleep 5
90# Get IP address of datarrouger-prov, datarouter-node, fileconsumer-node.
91DR_PROV_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' datarouter-prov)
92DR_NODE_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' datarouter-node)
93DR_SUBSCIBER_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' fileconsumer-node)
94DR_GATEWAY_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.Gateway}}{{end}}' datarouter-prov)
95
96echo DR_PROV_IP=${DR_PROV_IP}
97echo DR_NODE_IP=${DR_NODE_IP}
98echo DR_GATEWAY_IP=${DR_GATEWAY_IP}
99echo DR_SUBSCIBER_IP=${DR_SUBSCIBER_IP}
100
101docker kill datarouter-node
102docker kill datarouter-prov
103sed -i 's/1.1.1.1/'$DR_NODE_IP'/g' docker-compose.yml
104sed -i 's/2.2.2.2/'$DR_PROV_IP'/g' docker-compose.yml
105docker-compose up -d
Gary Wu9abb61c2018-09-27 10:38:50 -0700106
107# Wait for initialization of Docker container for datarouter-node, datarouter-prov and mariadb
LiamBurkef708f842018-10-10 09:26:26 +0000108for i in {1..10}; do
Gary Wu9abb61c2018-09-27 10:38:50 -0700109 if [ $(docker inspect --format '{{ .State.Running }}' datarouter-node) ] && \
110 [ $(docker inspect --format '{{ .State.Running }}' datarouter-prov) ] && \
111 [ $(docker inspect --format '{{ .State.Running }}' mariadb) ]
112 then
113 echo "DR Service Running"
114 break
115 else
116 echo sleep $i
117 sleep $i
118 fi
119done
120
121sleep 5
Gary Wu9abb61c2018-09-27 10:38:50 -0700122
123docker 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"
124docker 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"
Gary Wu9abb61c2018-09-27 10:38:50 -0700125docker exec datarouter-node /bin/sh -c "echo '${DR_SUBSCIBER_IP}' dmaap-dr-subscriber >> /etc/hosts"
126
LiamBurke248195d2019-04-03 10:21:12 +0100127
Gary Wu9abb61c2018-09-27 10:38:50 -0700128# Get IP address of DMAAP, KAFKA, Zookeeper
129DMAAP_MR_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $DMAAP)
130KAFKA_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $KAFKA)
131ZOOKEEPER_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $ZOOKEEPER)
132VESC_IP=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' vescollector)
133SFTP_IP=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' sftp)
134
135export VESC_IP=${VESC_IP}
136export HOST_IP=${HOST_IP}
137export DMAAP_MR_IP=${DMAAP_MR_IP}
138
LiamBurke3608af72019-03-12 22:50:33 +0000139
LiamBurkef8d0c2e2019-03-13 12:47:16 +0000140# Data File Collector configuration :
141sed -i 's/DR_NODE_IP/'$DR_NODE_IP'/g' docker-compose.yml
142cp $WORKSPACE/plans/usecases/5G-bulkpm/assets/datafile_endpoints.json /tmp/
143sed -i 's/dmaapmrhost/'${DMAAP_MR_IP}'/g' /tmp/datafile_endpoints.json
144sed -i 's/dmaapdrhost/'${DR_PROV_IP}'/g' /tmp/datafile_endpoints.json
145echo data_endpoints.json to be copied onto the DFC containter
146cat /tmp/datafile_endpoints.json
147docker-compose up -d
148sleep 2
149# DFC is now online
150docker cp dfc:/opt/app/datafile/config/datafile_endpoints.json /tmp/datafile_endpoints.json.fromcontainer
151echo data_endpoints.json from DFC containter
152cat /tmp/datafile_endpoints.json.fromcontainer
153docker cp /tmp/datafile_endpoints.json dfc:/opt/app/datafile/config/
154#Increase Logging
LiamBurkeb86a8bc2019-03-26 22:25:10 +0000155docker exec dfc /bin/sh -c " sed -i 's/org.onap.dcaegen2.collectors.datafile: WARN/org.onap.dcaegen2.collectors.datafile: TRACE/g' /opt/app/datafile/config/application.yaml"
LiamBurkef8d0c2e2019-03-13 12:47:16 +0000156docker restart dfc
157sleep 2
158
LiamBurke248195d2019-04-03 10:21:12 +0100159# Wait for initialization of Docker container for datarouter-node, datarouter-prov and mariadb, Consul, CBS
LiamBurke3608af72019-03-12 22:50:33 +0000160for i in {1..10}; do
161 if [ $(docker inspect --format '{{ .State.Running }}' consul) ] && \
LiamBurke248195d2019-04-03 10:21:12 +0100162 [ $(docker inspect --format '{{ .State.Running }}' cbs) ]
LiamBurke3608af72019-03-12 22:50:33 +0000163 then
LiamBurke248195d2019-04-03 10:21:12 +0100164 echo "Data Router, Consul, Config Binding Service Services Running"
LiamBurke3608af72019-03-12 22:50:33 +0000165 break
166 else
167 echo sleep $i
168 sleep $i
169 fi
170done
171sleep 10
172
Gary Wu9abb61c2018-09-27 10:38:50 -0700173#Pass any variables required by Robot test suites in ROBOT_VARIABLES
LiamBurke236c10d2019-03-25 13:22:47 +0000174ROBOT_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 SFTP_IP:${SFTP_IP}"
Gary Wu9abb61c2018-09-27 10:38:50 -0700175
LiamBurkecf7c8ca2019-03-15 15:25:23 +0000176pip install jsonschema uuid simplejson
Gary Wu9abb61c2018-09-27 10:38:50 -0700177# Wait container ready
178sleep 2
179
Gary Wu9abb61c2018-09-27 10:38:50 -0700180# Update the File Ready Notification with actual sftp ip address and copy pm files to sftp server.
rajendrajaiswal0d357f32018-09-28 10:18:19 +0100181cp $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 -0700182sed -i 's/sftpserver/'${SFTP_IP}'/g' $WORKSPACE/tests/usecases/5G-bulkpm/assets/json_events/FileExistNotificationUpdated.json
LiamBurkea4516192019-02-11 12:28:55 +0000183sed -i 's/sftpport/'${SFTP_PORT}'/g' $WORKSPACE/tests/usecases/5G-bulkpm/assets/json_events/FileExistNotificationUpdated.json
Gary Wu13111e92018-09-27 11:31:33 -0700184docker cp $WORKSPACE/plans/usecases/5G-bulkpm/assets/xNF.pm.xml.gz sftp:/home/admin/
Gary Wu9abb61c2018-09-27 10:38:50 -0700185
186# Data Router Configuration:
187# Create default feed and create file consumer subscriber on data router
egernug6f2874b2019-02-06 15:16:54 +0000188curl -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 -0700189cp $WORKSPACE/plans/usecases/5G-bulkpm/assets/addSubscriber.json /tmp/addSubscriber.json
Gary Wu9abb61c2018-09-27 10:38:50 -0700190sed -i 's/fileconsumer/'${DR_SUBSCIBER_IP}'/g' /tmp/addSubscriber.json
egernug6f2874b2019-02-06 15:16:54 +0000191curl -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 +0100192sleep 10
LiamBurkef708f842018-10-10 09:26:26 +0000193curl -k https://$DR_PROV_IP:8443/internal/prov
LiamBurkea4516192019-02-11 12:28:55 +0000194
195else
196############################################################
197############################################################
198# Executes the below setup in an ONAP Environment #
199# Make sure the steps in the README are completed first !! #
200############################################################
201############################################################
202SFTP_PORT=2222
203
204cp $WORKSPACE/plans/usecases/5G-bulkpm/teardown.sh $WORKSPACE/plans/usecases/5G-bulkpm/teardown.sh.orig
205cp $WORKSPACE/plans/usecases/5G-bulkpm/onap.teardown.sh $WORKSPACE/plans/usecases/5G-bulkpm/teardown.sh
206
207#Get DataFileCollector POD name in this ONAP Deployment
208DFC_POD=$(kubectl -n onap get pods | grep datafile-collector | awk '{print $1}')
209export DFC_POD=${DFC_POD}
210export CLI_EXEC_CLI_DFC="kubectl exec -n onap ${DFC_POD} -it ls /target | grep .gz"
211
212# Get IP address of datarrouter-prov
213DR_PROV_IP=$(kubectl -n onap -o wide get pods | grep dmaap-dr-prov | awk '{print $6}')
214echo DR_PROV_IP=${DR_PROV_IP}
215DR_NODE_IP=$(kubectl -n onap -o=wide get pods | grep dmaap-dr-node | awk '{print $6}')
216echo DR_NODE_IP=${DR_NODE_IP}
217
218# Get IP address of exposed Ves and its port
219DMAAP_MR_IP=$(kubectl -n onap -o=wide get pods | grep dev-dmaap-message-router | grep -Ev "kafka|zookeeper" | awk '{print $6}')
220VESC_IP=$(kubectl get svc -n onap | grep vesc | awk '{print $4}')
221VESC_PORT=$(kubectl get svc -n onap | grep vesc | awk '{print $5}' | cut -d ":" -f2 | cut -d "/" -f1)
222echo VESC_IP=${VESC_IP}
223echo VESC_PORT=${VESC_PORT}
224
225export VESC_IP=${VESC_IP}
226export VESC_PORT=${VESC_PORT}
227export HOST_IP=${HOST_IP}
228export DMAAP_MR_IP=${DMAAP_MR_IP}
229
230#Get DataFileCollector POD name in this ONAP Deployment
231DFC_POD=$(kubectl -n onap get pods | grep datafile-collector | awk '{print $1}')
232export DFC_POD=${DFC_POD}
233
LiamBurkecf7c8ca2019-03-15 15:25:23 +0000234pip install jsonschema uuid simplejson
LiamBurkea4516192019-02-11 12:28:55 +0000235
236# Clone DMaaP Data Router repo
237mkdir -p $WORKSPACE/archives/dmaapdr
238cd $WORKSPACE/archives/dmaapdr
239git clone --depth 1 https://gerrit.onap.org/r/dmaap/datarouter -b master
240cd $WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources
241mkdir docker-compose
242cd $WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources/docker-compose
243cp $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
244
245#Statup the SFTP and FileConsumer containers.
246docker login -u docker -p docker nexus3.onap.org:10001
247docker-compose up -d
248
249# Wait container ready
250sleep 2
251HOST_IP=$(ip route get 8.8.8.8 | awk '/8.8.8.8/ {print $NF}')
252# SFTP Configuration:
253# Update the File Ready Notification with actual sftp ip address and copy pm files to sftp server.
254cp $WORKSPACE/tests/usecases/5G-bulkpm/assets/json_events/FileExistNotification.json $WORKSPACE/tests/usecases/5G-bulkpm/assets/json_events/FileExistNotificationUpdated.json
255sed -i 's/sftpserver/'${HOST_IP}'/g' $WORKSPACE/tests/usecases/5G-bulkpm/assets/json_events/FileExistNotificationUpdated.json
256sed -i 's/sftpport/'${SFTP_PORT}'/g' $WORKSPACE/tests/usecases/5G-bulkpm/assets/json_events/FileExistNotificationUpdated.json
257docker cp $WORKSPACE/plans/usecases/5G-bulkpm/assets/xNF.pm.xml.gz sftp:/home/admin/
258
259# Create default feed and create file consumer subscriber on data router
LiamBurkeb86a8bc2019-03-26 22:25:10 +0000260curl -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
LiamBurkea4516192019-02-11 12:28:55 +0000261cp $WORKSPACE/plans/usecases/5G-bulkpm/assets/addSubscriber.json /tmp/addSubscriber.json
262sed -i 's/fileconsumer/'${HOST_IP}'/g' /tmp/addSubscriber.json
LiamBurkeb86a8bc2019-03-26 22:25:10 +0000263curl -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
LiamBurkea4516192019-02-11 12:28:55 +0000264sleep 10
265curl -k https://$DR_PROV_IP:8443/internal/prov
266
267#Pass any variables required by Robot test suites in ROBOT_VARIABLES
268ROBOT_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} "
269
LiamBurkecf7c8ca2019-03-15 15:25:23 +0000270fi;