blob: 3d3a9ef599bdf77c8ed753999a04f7c264c80251 [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 datarouter-prov
80docker kill datarouter-node
81docker kill vescollector
LiamBurke3608af72019-03-12 22:50:33 +000082docker kill cbs
83CONSUL_IP=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' consul )
84sed -i -e '/CONSUL_HOST:/ s/:.*/: '$CONSUL_IP'/' docker-compose.yml
Gary Wu9abb61c2018-09-27 10:38:50 -070085HOST_IP=$(ip route get 8.8.8.8 | awk '/8.8.8.8/ {print $NF}')
86sed -i -e '/DMAAPHOST:/ s/:.*/: '$HOST_IP'/' docker-compose.yml
87MARIADB=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' mariadb )
LiamBurke1344ef22018-10-19 15:22:16 +000088sed -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 -070089docker-compose up -d
90
91# Wait for initialization of Docker container for datarouter-node, datarouter-prov and mariadb
LiamBurkef708f842018-10-10 09:26:26 +000092for i in {1..10}; do
Gary Wu9abb61c2018-09-27 10:38:50 -070093 if [ $(docker inspect --format '{{ .State.Running }}' datarouter-node) ] && \
94 [ $(docker inspect --format '{{ .State.Running }}' datarouter-prov) ] && \
95 [ $(docker inspect --format '{{ .State.Running }}' mariadb) ]
96 then
97 echo "DR Service Running"
98 break
99 else
100 echo sleep $i
101 sleep $i
102 fi
103done
104
105sleep 5
Gary Wu9abb61c2018-09-27 10:38:50 -0700106# Get IP address of datarrouger-prov, datarouter-node, fileconsumer-node.
107DR_PROV_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' datarouter-prov)
108DR_NODE_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' datarouter-node)
109DR_SUBSCIBER_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' fileconsumer-node)
110DR_GATEWAY_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.Gateway}}{{end}}' datarouter-prov)
111
112echo DR_PROV_IP=${DR_PROV_IP}
113echo DR_NODE_IP=${DR_NODE_IP}
114echo DR_GATEWAY_IP=${DR_GATEWAY_IP}
115echo DR_SUBSCIBER_IP=${DR_SUBSCIBER_IP}
116
117docker 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"
118docker 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"
119docker exec datarouter-prov /bin/sh -c "echo '${DR_NODE_IP}' dmaap-dr-node >> /etc/hosts"
120docker exec datarouter-node /bin/sh -c "echo '${DR_PROV_IP}' dmaap-dr-prov >> /etc/hosts"
121docker exec datarouter-node /bin/sh -c "echo '${DR_SUBSCIBER_IP}' dmaap-dr-subscriber >> /etc/hosts"
122
123# Get IP address of DMAAP, KAFKA, Zookeeper
124DMAAP_MR_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $DMAAP)
125KAFKA_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $KAFKA)
126ZOOKEEPER_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $ZOOKEEPER)
127VESC_IP=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' vescollector)
128SFTP_IP=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' sftp)
129
130export VESC_IP=${VESC_IP}
131export HOST_IP=${HOST_IP}
132export DMAAP_MR_IP=${DMAAP_MR_IP}
133
LiamBurke3608af72019-03-12 22:50:33 +0000134docker kill buscontroller
135sed -i 's/DMAAPDR/'$DR_PROV_IP'/g' docker-compose.yml
136sed -i 's/DMAAPMR/'$DMAAP_MR_IP'/g' docker-compose.yml
137docker-compose up -d
138sed -i 's/DMAAPDR/'$DR_PROV_IP'/g' /tmp/docker-databus-controller.conf
139
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
LiamBurke3608af72019-03-12 22:50:33 +0000159# Wait for initialization of Docker container for datarouter-node, datarouter-prov and mariadb, Consul, CBS, Buscontroller
160for i in {1..10}; do
161 if [ $(docker inspect --format '{{ .State.Running }}' consul) ] && \
162 [ $(docker inspect --format '{{ .State.Running }}' cbs) ] && \
163 [ $(docker inspect --format '{{ .State.Running }}' buscontroller) ]
164 then
165 echo "Data Router, Consul, Config Binding Service, Buscontroller Services Running"
166 break
167 else
168 echo sleep $i
169 sleep $i
170 fi
171done
172sleep 10
173
Gary Wu9abb61c2018-09-27 10:38:50 -0700174#Pass any variables required by Robot test suites in ROBOT_VARIABLES
LiamBurke236c10d2019-03-25 13:22:47 +0000175ROBOT_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 -0700176
LiamBurkecf7c8ca2019-03-15 15:25:23 +0000177pip install jsonschema uuid simplejson
Gary Wu9abb61c2018-09-27 10:38:50 -0700178# Wait container ready
179sleep 2
180
Gary Wu9abb61c2018-09-27 10:38:50 -0700181# Update the File Ready Notification with actual sftp ip address and copy pm files to sftp server.
rajendrajaiswal0d357f32018-09-28 10:18:19 +0100182cp $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 -0700183sed -i 's/sftpserver/'${SFTP_IP}'/g' $WORKSPACE/tests/usecases/5G-bulkpm/assets/json_events/FileExistNotificationUpdated.json
LiamBurkea4516192019-02-11 12:28:55 +0000184sed -i 's/sftpport/'${SFTP_PORT}'/g' $WORKSPACE/tests/usecases/5G-bulkpm/assets/json_events/FileExistNotificationUpdated.json
Gary Wu13111e92018-09-27 11:31:33 -0700185docker cp $WORKSPACE/plans/usecases/5G-bulkpm/assets/xNF.pm.xml.gz sftp:/home/admin/
Gary Wu9abb61c2018-09-27 10:38:50 -0700186
187# Data Router Configuration:
188# Create default feed and create file consumer subscriber on data router
egernug6f2874b2019-02-06 15:16:54 +0000189curl -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 -0700190cp $WORKSPACE/plans/usecases/5G-bulkpm/assets/addSubscriber.json /tmp/addSubscriber.json
Gary Wu9abb61c2018-09-27 10:38:50 -0700191sed -i 's/fileconsumer/'${DR_SUBSCIBER_IP}'/g' /tmp/addSubscriber.json
egernug6f2874b2019-02-06 15:16:54 +0000192curl -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 +0100193sleep 10
LiamBurkef708f842018-10-10 09:26:26 +0000194curl -k https://$DR_PROV_IP:8443/internal/prov
LiamBurkea4516192019-02-11 12:28:55 +0000195
196else
197############################################################
198############################################################
199# Executes the below setup in an ONAP Environment #
200# Make sure the steps in the README are completed first !! #
201############################################################
202############################################################
203SFTP_PORT=2222
204
205cp $WORKSPACE/plans/usecases/5G-bulkpm/teardown.sh $WORKSPACE/plans/usecases/5G-bulkpm/teardown.sh.orig
206cp $WORKSPACE/plans/usecases/5G-bulkpm/onap.teardown.sh $WORKSPACE/plans/usecases/5G-bulkpm/teardown.sh
207
208#Get DataFileCollector POD name in this ONAP Deployment
209DFC_POD=$(kubectl -n onap get pods | grep datafile-collector | awk '{print $1}')
210export DFC_POD=${DFC_POD}
211export CLI_EXEC_CLI_DFC="kubectl exec -n onap ${DFC_POD} -it ls /target | grep .gz"
212
213# Get IP address of datarrouter-prov
214DR_PROV_IP=$(kubectl -n onap -o wide get pods | grep dmaap-dr-prov | awk '{print $6}')
215echo DR_PROV_IP=${DR_PROV_IP}
216DR_NODE_IP=$(kubectl -n onap -o=wide get pods | grep dmaap-dr-node | awk '{print $6}')
217echo DR_NODE_IP=${DR_NODE_IP}
218
219# Get IP address of exposed Ves and its port
220DMAAP_MR_IP=$(kubectl -n onap -o=wide get pods | grep dev-dmaap-message-router | grep -Ev "kafka|zookeeper" | awk '{print $6}')
221VESC_IP=$(kubectl get svc -n onap | grep vesc | awk '{print $4}')
222VESC_PORT=$(kubectl get svc -n onap | grep vesc | awk '{print $5}' | cut -d ":" -f2 | cut -d "/" -f1)
223echo VESC_IP=${VESC_IP}
224echo VESC_PORT=${VESC_PORT}
225
226export VESC_IP=${VESC_IP}
227export VESC_PORT=${VESC_PORT}
228export HOST_IP=${HOST_IP}
229export DMAAP_MR_IP=${DMAAP_MR_IP}
230
231#Get DataFileCollector POD name in this ONAP Deployment
232DFC_POD=$(kubectl -n onap get pods | grep datafile-collector | awk '{print $1}')
233export DFC_POD=${DFC_POD}
234
LiamBurkecf7c8ca2019-03-15 15:25:23 +0000235pip install jsonschema uuid simplejson
LiamBurkea4516192019-02-11 12:28:55 +0000236
237# Clone DMaaP Data Router repo
238mkdir -p $WORKSPACE/archives/dmaapdr
239cd $WORKSPACE/archives/dmaapdr
240git clone --depth 1 https://gerrit.onap.org/r/dmaap/datarouter -b master
241cd $WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources
242mkdir docker-compose
243cd $WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources/docker-compose
244cp $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
245
246#Statup the SFTP and FileConsumer containers.
247docker login -u docker -p docker nexus3.onap.org:10001
248docker-compose up -d
249
250# Wait container ready
251sleep 2
252HOST_IP=$(ip route get 8.8.8.8 | awk '/8.8.8.8/ {print $NF}')
253# SFTP Configuration:
254# Update the File Ready Notification with actual sftp ip address and copy pm files to sftp server.
255cp $WORKSPACE/tests/usecases/5G-bulkpm/assets/json_events/FileExistNotification.json $WORKSPACE/tests/usecases/5G-bulkpm/assets/json_events/FileExistNotificationUpdated.json
256sed -i 's/sftpserver/'${HOST_IP}'/g' $WORKSPACE/tests/usecases/5G-bulkpm/assets/json_events/FileExistNotificationUpdated.json
257sed -i 's/sftpport/'${SFTP_PORT}'/g' $WORKSPACE/tests/usecases/5G-bulkpm/assets/json_events/FileExistNotificationUpdated.json
258docker cp $WORKSPACE/plans/usecases/5G-bulkpm/assets/xNF.pm.xml.gz sftp:/home/admin/
259
260# Create default feed and create file consumer subscriber on data router
LiamBurkeb86a8bc2019-03-26 22:25:10 +0000261curl -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 +0000262cp $WORKSPACE/plans/usecases/5G-bulkpm/assets/addSubscriber.json /tmp/addSubscriber.json
263sed -i 's/fileconsumer/'${HOST_IP}'/g' /tmp/addSubscriber.json
LiamBurkeb86a8bc2019-03-26 22:25:10 +0000264curl -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 +0000265sleep 10
266curl -k https://$DR_PROV_IP:8443/internal/prov
267
268#Pass any variables required by Robot test suites in ROBOT_VARIABLES
269ROBOT_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} "
270
LiamBurkecf7c8ca2019-03-15 15:25:23 +0000271fi;