blob: 9fbd2ef9910b8f5afa3284c5988c17bdb2d2572d [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/usecases/5G-bulkpm/assets/application.yaml dfc:/opt/app/datafile/config/
LiamBurkef8d0c2e2019-03-13 12:47:16 +0000146#Increase Logging
yanhuanwangb7d9f292019-09-10 13:38:46 +0200147#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 +0000148docker restart dfc
149sleep 2
150
LiamBurke248195d2019-04-03 10:21:12 +0100151# Wait for initialization of Docker container for datarouter-node, datarouter-prov and mariadb, Consul, CBS
LiamBurke3608af72019-03-12 22:50:33 +0000152for i in {1..10}; do
153 if [ $(docker inspect --format '{{ .State.Running }}' consul) ] && \
rajendrajaiswal44762cc2019-07-31 15:45:04 +0000154 [ $(docker inspect --format '{{ .State.Running }}' cbs) ]
LiamBurke3608af72019-03-12 22:50:33 +0000155 then
LiamBurke248195d2019-04-03 10:21:12 +0100156 echo "Data Router, Consul, Config Binding Service Services Running"
LiamBurke3608af72019-03-12 22:50:33 +0000157 break
158 else
159 echo sleep $i
160 sleep $i
161 fi
162done
163sleep 10
164
LiamBurkecf7c8ca2019-03-15 15:25:23 +0000165pip install jsonschema uuid simplejson
Gary Wu9abb61c2018-09-27 10:38:50 -0700166# Wait container ready
167sleep 2
168
Gary Wu9abb61c2018-09-27 10:38:50 -0700169# Update the File Ready Notification with actual sftp ip address and copy pm files to sftp server.
rajendrajaiswal0d357f32018-09-28 10:18:19 +0100170cp $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 -0700171sed -i 's/sftpserver/'${SFTP_IP}'/g' $WORKSPACE/tests/usecases/5G-bulkpm/assets/json_events/FileExistNotificationUpdated.json
LiamBurkea4516192019-02-11 12:28:55 +0000172sed -i 's/sftpport/'${SFTP_PORT}'/g' $WORKSPACE/tests/usecases/5G-bulkpm/assets/json_events/FileExistNotificationUpdated.json
Gary Wu13111e92018-09-27 11:31:33 -0700173docker cp $WORKSPACE/plans/usecases/5G-bulkpm/assets/xNF.pm.xml.gz sftp:/home/admin/
LiamBurkeab2e0982019-04-11 11:43:42 +0100174docker 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 -0700175
176# Data Router Configuration:
177# Create default feed and create file consumer subscriber on data router
egernug6f2874b2019-02-06 15:16:54 +0000178curl -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 -0700179cp $WORKSPACE/plans/usecases/5G-bulkpm/assets/addSubscriber.json /tmp/addSubscriber.json
Gary Wu9abb61c2018-09-27 10:38:50 -0700180sed -i 's/fileconsumer/'${DR_SUBSCIBER_IP}'/g' /tmp/addSubscriber.json
egernug6f2874b2019-02-06 15:16:54 +0000181curl -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 +0100182sleep 10
LiamBurkef708f842018-10-10 09:26:26 +0000183curl -k https://$DR_PROV_IP:8443/internal/prov
LiamBurkea4516192019-02-11 12:28:55 +0000184
LiamBurkef9d624a2019-04-10 10:41:26 +0100185# Consul Configuration for PM Mapper
186cp $WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/assets/cbs.json /tmp/cbs.json
187sed -i 's/ipaddress/'${CBS_IP}'/g' /tmp/cbs.json
188curl --request PUT --data @/tmp/cbs.json http://$CONSUL_IP:8500/v1/agent/service/register
rajendrajaiswalc117c752020-02-26 14:57:17 +0000189curl '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 +0100190
191# PM Mapper startup and configuration
192mkdir /tmp/docker-compose
193cd /tmp/docker-compose
tragaitcd8b66c2020-02-05 17:02:20 +0000194cp $WORKSPACE/plans/usecases/5G-bulkpm/composefile/docker-compose-pmmapper.yml /tmp/docker-compose/docker-compose.yml
LiamBurkef9d624a2019-04-10 10:41:26 +0100195CBS_IP=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' cbs)
196sed -i 's/CBSIP/'$CBS_IP'/g' docker-compose.yml
197sed -i 's/1.1.1.1/'$DR_NODE_IP'/g' docker-compose.yml
rajendrajaiswal44762cc2019-07-31 15:45:04 +0000198sed -i 's/4.4.4.4/'$MARIADB'/g' docker-compose.yml
LiamBurkef9d624a2019-04-10 10:41:26 +0100199docker-compose up -d
200
LiamBurkeab2e0982019-04-11 11:43:42 +0100201cd $WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources/docker-compose
202PMMAPPER_IP=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' pmmapper)
203docker kill datarouter-node
204docker kill datarouter-prov
205sed -i 's/1.1.1.1/'$DR_NODE_IP'/g' docker-compose.yml
206sed -i 's/2.2.2.2/'$DR_PROV_IP'/g' docker-compose.yml
207sed -i 's/3.3.3.3/'$PMMAPPER_IP'/g' docker-compose.yml
208docker-compose up -d
209
LiamBurkef9d624a2019-04-10 10:41:26 +0100210# Setting up PM Mapper certs.
rajendrajaiswal744ed222020-03-02 14:53:27 +0000211docker cp $WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/assets/cert.jks pmmapper:opt/app/pm-mapper/etc/
LiamBurkef9d624a2019-04-10 10:41:26 +0100212docker cp $WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/assets/jks.pass pmmapper:opt/app/pm-mapper/etc/
rajendrajaiswal744ed222020-03-02 14:53:27 +0000213docker cp $WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/assets/trust.jks pmmapper:opt/app/pm-mapper/etc/
LiamBurkef9d624a2019-04-10 10:41:26 +0100214docker cp $WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/assets/trust.pass pmmapper:opt/app/pm-mapper/etc/
215docker restart pmmapper
LiamBurkeab2e0982019-04-11 11:43:42 +0100216sleep 5
LiamBurkef9d624a2019-04-10 10:41:26 +0100217
rajendrajaiswal44762cc2019-07-31 15:45:04 +0000218# Simulation setup for Message Router
219docker cp $WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/assets/mrserver.js mariadb:/
220docker exec mariadb /bin/bash -c "apt update"
221sleep 2
222docker exec mariadb /bin/bash -c "apt install nodejs -y"
223sleep 10
224docker exec mariadb /bin/bash -c "nodejs mrserver.js &" &
225
LiamBurkef9d624a2019-04-10 10:41:26 +0100226# Create PM Mapper feed and create PM Mapper subscriber on data router
LiamBurkeab2e0982019-04-11 11:43:42 +0100227#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 +0100228curl -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
229
230# Create PM Mapper tocic in Message Router
LiamBurkef9d624a2019-04-10 10:41:26 +0100231PMMAPPER_IP=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' pmmapper)
232docker exec pmmapper /bin/sh -c "cat /var/log/ONAP/dcaegen2/services/pm-mapper/pm-mapper_output.log" > /tmp/pmmapper.log
233cat /tmp/pmmapper.log
234docker exec -it datarouter-prov sh -c "curl http://dmaap-dr-node:8080/internal/fetchProv"
235sleep 10
236curl -k https://$DR_PROV_IP:8443/internal/prov
LiamBurkef9d624a2019-04-10 10:41:26 +0100237
238#Pass any variables required by Robot test suites in ROBOT_VARIABLES
rajendrajaiswalc117c752020-02-26 14:57:17 +0000239ROBOT_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}"