blob: cc638be41855e89892cad438e04bed614f2e3849 [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
LiamBurkea4516192019-02-11 12:28:55 +00004SFTP_PORT=22
5VESC_PORT=8080
6export VESC_PORT=${VESC_PORT}
7export CLI_EXEC_CLI_DFC="docker exec dfc /bin/sh -c \"ls /target | grep .gz\""
8
Gary Wu9abb61c2018-09-27 10:38:50 -07009# Clone DMaaP Message Router repo
10mkdir -p $WORKSPACE/archives/dmaapmr
11cd $WORKSPACE/archives/dmaapmr
12git clone --depth 1 http://gerrit.onap.org/r/dmaap/messagerouter/messageservice -b master
LiamBurkeae583be2018-10-16 10:44:12 +000013sed -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 -070014cd $WORKSPACE/archives/dmaapmr/messageservice/src/main/resources/docker-compose
15cp $WORKSPACE/archives/dmaapmr/messageservice/bundleconfig-local/etc/appprops/MsgRtrApi.properties /var/tmp/
16
17# start DMaaP MR containers with docker compose and configuration from docker-compose.yml
18docker login -u docker -p docker nexus3.onap.org:10001
19docker-compose up -d
20
21ZOOKEEPER=$(docker ps -a -q --filter="name=zookeeper_1")
22KAFKA=$(docker ps -a -q --filter="name=kafka_1")
23DMAAP=$(docker ps -a -q --filter="name=dmaap_1")
24
25# Wait for initialization of Docker contaienr for DMaaP MR, Kafka and Zookeeper
LiamBurkef708f842018-10-10 09:26:26 +000026for i in {1..10}; do
Gary Wu9abb61c2018-09-27 10:38:50 -070027if [ $(docker inspect --format '{{ .State.Running }}' $KAFKA) ] && \
28[ $(docker inspect --format '{{ .State.Running }}' $ZOOKEEPER) ] && \
29[ $(docker inspect --format '{{ .State.Running }}' $DMAAP) ]
30then
31 echo "DMaaP Service Running"
32 break
33else
34 echo sleep $i
35 sleep $i
36fi
37done
38
39# Get IP address of DMAAP, KAFKA, Zookeeper
40KAFKA_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $KAFKA)
41ZOOKEEPER_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $ZOOKEEPER)
42DMAAP_MR_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $DMAAP)
43
44sleep 2
45# Shutdown DMAAP Container
46docker kill $DMAAP
47
48# Initial docker-compose up and down is for populating kafka and zookeeper IPs in /var/tmp/MsgRtrApi.properites
49sed -i -e '/config.zk.servers=/ s/=.*/='$ZOOKEEPER_IP'/' /var/tmp/MsgRtrApi.properties
50sed -i -e '/kafka.metadata.broker.list=/ s/=.*/='$KAFKA_IP':9092/' /var/tmp/MsgRtrApi.properties
51
52# Start DMaaP MR containers with docker compose and configuration from docker-compose.yml
53docker login -u docker -p docker nexus3.onap.org:10001
54docker-compose up -d
55sleep 5
56
57# Clone DMaaP Data Router repo
58mkdir -p $WORKSPACE/archives/dmaapdr
59cd $WORKSPACE/archives/dmaapdr
60git clone --depth 1 https://gerrit.onap.org/r/dmaap/datarouter -b master
LiamBurke1344ef22018-10-19 15:22:16 +000061cd $WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources
62mkdir docker-compose
63cd $WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources/docker-compose
64cp $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
65
Gary Wu9abb61c2018-09-27 10:38:50 -070066docker login -u docker -p docker nexus3.onap.org:10001
67docker-compose up -d
LiamBurkeca7df552018-10-26 13:57:21 +000068echo "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 -070069docker kill vescollector
LiamBurke3608af72019-03-12 22:50:33 +000070docker kill cbs
LiamBurke248195d2019-04-03 10:21:12 +010071sleep 10
LiamBurke3608af72019-03-12 22:50:33 +000072CONSUL_IP=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' consul )
73sed -i -e '/CONSUL_HOST:/ s/:.*/: '$CONSUL_IP'/' docker-compose.yml
Gary Wu9abb61c2018-09-27 10:38:50 -070074HOST_IP=$(ip route get 8.8.8.8 | awk '/8.8.8.8/ {print $NF}')
rajendrajaiswalc117c752020-02-26 14:57:17 +000075DMAAP_MR_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $DMAAP)
76sed -i -e '/DMAAPHOST:/ s/:.*/: '$DMAAP_MR_IP'/' docker-compose.yml
Gary Wu9abb61c2018-09-27 10:38:50 -070077MARIADB=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' mariadb )
LiamBurke1344ef22018-10-19 15:22:16 +000078sed -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 -070079docker-compose up -d
LiamBurke248195d2019-04-03 10:21:12 +010080sleep 5
81# Get IP address of datarrouger-prov, datarouter-node, fileconsumer-node.
82DR_PROV_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' datarouter-prov)
83DR_NODE_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' datarouter-node)
84DR_SUBSCIBER_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' fileconsumer-node)
85DR_GATEWAY_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.Gateway}}{{end}}' datarouter-prov)
86
87echo DR_PROV_IP=${DR_PROV_IP}
88echo DR_NODE_IP=${DR_NODE_IP}
89echo DR_GATEWAY_IP=${DR_GATEWAY_IP}
90echo DR_SUBSCIBER_IP=${DR_SUBSCIBER_IP}
91
92docker kill datarouter-node
93docker kill datarouter-prov
94sed -i 's/1.1.1.1/'$DR_NODE_IP'/g' docker-compose.yml
95sed -i 's/2.2.2.2/'$DR_PROV_IP'/g' docker-compose.yml
96docker-compose up -d
Gary Wu9abb61c2018-09-27 10:38:50 -070097
98# Wait for initialization of Docker container for datarouter-node, datarouter-prov and mariadb
LiamBurkef708f842018-10-10 09:26:26 +000099for i in {1..10}; do
Gary Wu9abb61c2018-09-27 10:38:50 -0700100 if [ $(docker inspect --format '{{ .State.Running }}' datarouter-node) ] && \
101 [ $(docker inspect --format '{{ .State.Running }}' datarouter-prov) ] && \
102 [ $(docker inspect --format '{{ .State.Running }}' mariadb) ]
103 then
104 echo "DR Service Running"
105 break
106 else
107 echo sleep $i
108 sleep $i
109 fi
110done
111
112sleep 5
Gary Wu9abb61c2018-09-27 10:38:50 -0700113
114docker 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"
115docker 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 -0700116docker exec datarouter-node /bin/sh -c "echo '${DR_SUBSCIBER_IP}' dmaap-dr-subscriber >> /etc/hosts"
117
LiamBurke248195d2019-04-03 10:21:12 +0100118
Gary Wu9abb61c2018-09-27 10:38:50 -0700119# 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
LiamBurke3608af72019-03-12 22:50:33 +0000130
LiamBurkef8d0c2e2019-03-13 12:47:16 +0000131# Data File Collector configuration :
rajendrajaiswal44762cc2019-07-31 15:45:04 +0000132sed -i 's/5.5.5.5/'$DR_NODE_IP'/g' docker-compose.yml
LiamBurkef8d0c2e2019-03-13 12:47:16 +0000133cp $WORKSPACE/plans/usecases/5G-bulkpm/assets/datafile_endpoints.json /tmp/
134sed -i 's/dmaapmrhost/'${DMAAP_MR_IP}'/g' /tmp/datafile_endpoints.json
135sed -i 's/dmaapdrhost/'${DR_PROV_IP}'/g' /tmp/datafile_endpoints.json
136echo data_endpoints.json to be copied onto the DFC containter
137cat /tmp/datafile_endpoints.json
138docker-compose up -d
139sleep 2
140# DFC is now online
141docker cp dfc:/opt/app/datafile/config/datafile_endpoints.json /tmp/datafile_endpoints.json.fromcontainer
142echo data_endpoints.json from DFC containter
143cat /tmp/datafile_endpoints.json.fromcontainer
144docker cp /tmp/datafile_endpoints.json dfc:/opt/app/datafile/config/
yanhuanwangb7d9f292019-09-10 13:38:46 +0200145docker cp $WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/assets/cert.jks.b64 dfc:/opt/app/datafile/etc/cert/
146docker cp $WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/assets/jks.pass dfc:/opt/app/datafile/etc/cert/
147docker cp $WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/assets/trust.jks.b64 dfc:/opt/app/datafile/etc/cert/
148docker cp $WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/assets/trust.pass dfc:/opt/app/datafile/etc/cert/
149docker cp $WORKSPACE/plans/usecases/5G-bulkpm/assets/application.yaml dfc:/opt/app/datafile/config/
LiamBurkef8d0c2e2019-03-13 12:47:16 +0000150#Increase Logging
yanhuanwangb7d9f292019-09-10 13:38:46 +0200151#docker 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 +0000152docker restart dfc
153sleep 2
154
LiamBurke248195d2019-04-03 10:21:12 +0100155# Wait for initialization of Docker container for datarouter-node, datarouter-prov and mariadb, Consul, CBS
LiamBurke3608af72019-03-12 22:50:33 +0000156for i in {1..10}; do
157 if [ $(docker inspect --format '{{ .State.Running }}' consul) ] && \
rajendrajaiswal44762cc2019-07-31 15:45:04 +0000158 [ $(docker inspect --format '{{ .State.Running }}' cbs) ]
LiamBurke3608af72019-03-12 22:50:33 +0000159 then
LiamBurke248195d2019-04-03 10:21:12 +0100160 echo "Data Router, Consul, Config Binding Service Services Running"
LiamBurke3608af72019-03-12 22:50:33 +0000161 break
162 else
163 echo sleep $i
164 sleep $i
165 fi
166done
167sleep 10
168
LiamBurkecf7c8ca2019-03-15 15:25:23 +0000169pip install jsonschema uuid simplejson
Gary Wu9abb61c2018-09-27 10:38:50 -0700170# Wait container ready
171sleep 2
172
Gary Wu9abb61c2018-09-27 10:38:50 -0700173# Update the File Ready Notification with actual sftp ip address and copy pm files to sftp server.
rajendrajaiswal0d357f32018-09-28 10:18:19 +0100174cp $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 -0700175sed -i 's/sftpserver/'${SFTP_IP}'/g' $WORKSPACE/tests/usecases/5G-bulkpm/assets/json_events/FileExistNotificationUpdated.json
LiamBurkea4516192019-02-11 12:28:55 +0000176sed -i 's/sftpport/'${SFTP_PORT}'/g' $WORKSPACE/tests/usecases/5G-bulkpm/assets/json_events/FileExistNotificationUpdated.json
Gary Wu13111e92018-09-27 11:31:33 -0700177docker cp $WORKSPACE/plans/usecases/5G-bulkpm/assets/xNF.pm.xml.gz sftp:/home/admin/
LiamBurkeab2e0982019-04-11 11:43:42 +0100178docker cp $WORKSPACE/tests/dcaegen2-pmmapper/pmmapper/assets/A20181002.0000-1000-0015-1000_5G.xml.gz sftp:/home/admin/
Gary Wu9abb61c2018-09-27 10:38:50 -0700179
180# Data Router Configuration:
181# Create default feed and create file consumer subscriber on data router
egernug6f2874b2019-02-06 15:16:54 +0000182curl -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 -0700183cp $WORKSPACE/plans/usecases/5G-bulkpm/assets/addSubscriber.json /tmp/addSubscriber.json
Gary Wu9abb61c2018-09-27 10:38:50 -0700184sed -i 's/fileconsumer/'${DR_SUBSCIBER_IP}'/g' /tmp/addSubscriber.json
egernug6f2874b2019-02-06 15:16:54 +0000185curl -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 +0100186sleep 10
LiamBurkef708f842018-10-10 09:26:26 +0000187curl -k https://$DR_PROV_IP:8443/internal/prov
LiamBurkea4516192019-02-11 12:28:55 +0000188
LiamBurkef9d624a2019-04-10 10:41:26 +0100189# Consul Configuration for PM Mapper
190cp $WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/assets/cbs.json /tmp/cbs.json
191sed -i 's/ipaddress/'${CBS_IP}'/g' /tmp/cbs.json
192curl --request PUT --data @/tmp/cbs.json http://$CONSUL_IP:8500/v1/agent/service/register
rajendrajaiswalc117c752020-02-26 14:57:17 +0000193curl 'http://'$CONSUL_IP':8500/v1/kv/pmmapper?dc=dc1' -X PUT -H 'Accept: application/json' -H 'Content-Type: application/json' -H 'X-Requested-With: XMLHttpRequest' --data @$WORKSPACE/plans/usecases/5G-bulkpm/assets/config.json
LiamBurkef9d624a2019-04-10 10:41:26 +0100194
195# PM Mapper startup and configuration
196mkdir /tmp/docker-compose
197cd /tmp/docker-compose
tragaitcd8b66c2020-02-05 17:02:20 +0000198cp $WORKSPACE/plans/usecases/5G-bulkpm/composefile/docker-compose-pmmapper.yml /tmp/docker-compose/docker-compose.yml
LiamBurkef9d624a2019-04-10 10:41:26 +0100199CBS_IP=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' cbs)
200sed -i 's/CBSIP/'$CBS_IP'/g' docker-compose.yml
201sed -i 's/1.1.1.1/'$DR_NODE_IP'/g' docker-compose.yml
rajendrajaiswal44762cc2019-07-31 15:45:04 +0000202sed -i 's/4.4.4.4/'$MARIADB'/g' docker-compose.yml
LiamBurkef9d624a2019-04-10 10:41:26 +0100203docker-compose up -d
204
LiamBurkeab2e0982019-04-11 11:43:42 +0100205cd $WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources/docker-compose
206PMMAPPER_IP=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' pmmapper)
207docker kill datarouter-node
208docker kill datarouter-prov
209sed -i 's/1.1.1.1/'$DR_NODE_IP'/g' docker-compose.yml
210sed -i 's/2.2.2.2/'$DR_PROV_IP'/g' docker-compose.yml
211sed -i 's/3.3.3.3/'$PMMAPPER_IP'/g' docker-compose.yml
212docker-compose up -d
213
LiamBurkef9d624a2019-04-10 10:41:26 +0100214# Setting up PM Mapper certs.
215docker cp $WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/assets/cert.jks.b64 pmmapper:opt/app/pm-mapper/etc/
216docker cp $WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/assets/jks.pass pmmapper:opt/app/pm-mapper/etc/
217docker cp $WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/assets/trust.jks.b64 pmmapper:opt/app/pm-mapper/etc/
218docker cp $WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/assets/trust.pass pmmapper:opt/app/pm-mapper/etc/
219docker restart pmmapper
LiamBurkeab2e0982019-04-11 11:43:42 +0100220sleep 5
LiamBurkef9d624a2019-04-10 10:41:26 +0100221
rajendrajaiswal44762cc2019-07-31 15:45:04 +0000222# Simulation setup for Message Router
223docker cp $WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/assets/mrserver.js mariadb:/
224docker exec mariadb /bin/bash -c "apt update"
225sleep 2
226docker exec mariadb /bin/bash -c "apt install nodejs -y"
227sleep 10
228docker exec mariadb /bin/bash -c "nodejs mrserver.js &" &
229
LiamBurkef9d624a2019-04-10 10:41:26 +0100230# Create PM Mapper feed and create PM Mapper subscriber on data router
LiamBurkeab2e0982019-04-11 11:43:42 +0100231#curl -v -X POST -H "Content-Type:application/vnd.dmaap-dr.feed" -H "X-DMAAP-DR-ON-BEHALF-OF:pmmapper" --data-ascii @$WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/assets/createFeed.json --post301 --location-trusted -k https://${DR_PROV_IP}:8443
LiamBurkef9d624a2019-04-10 10:41:26 +0100232curl -v -X POST -H "Content-Type:application/vnd.dmaap-dr.subscription" -H "X-DMAAP-DR-ON-BEHALF-OF:pmmapper" --data-ascii @$WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/assets/addSubscriber.json --post301 --location-trusted -k https://${DR_PROV_IP}:8443/subscribe/1
233
234# Create PM Mapper tocic in Message Router
LiamBurkef9d624a2019-04-10 10:41:26 +0100235PMMAPPER_IP=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' pmmapper)
236docker exec pmmapper /bin/sh -c "cat /var/log/ONAP/dcaegen2/services/pm-mapper/pm-mapper_output.log" > /tmp/pmmapper.log
237cat /tmp/pmmapper.log
238docker exec -it datarouter-prov sh -c "curl http://dmaap-dr-node:8080/internal/fetchProv"
239sleep 10
240curl -k https://$DR_PROV_IP:8443/internal/prov
LiamBurkef9d624a2019-04-10 10:41:26 +0100241
242#Pass any variables required by Robot test suites in ROBOT_VARIABLES
rajendrajaiswalc117c752020-02-26 14:57:17 +0000243ROBOT_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}"