Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # Place the scripts in run order: |
| 3 | source ${SCRIPTS}/common_functions.sh |
| 4 | |
| 5 | # Clone DMaaP Message Router repo |
| 6 | mkdir -p $WORKSPACE/archives/dmaapmr |
| 7 | cd $WORKSPACE/archives/dmaapmr |
| 8 | git clone --depth 1 http://gerrit.onap.org/r/dmaap/messagerouter/messageservice -b master |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 9 | cd $WORKSPACE/archives/dmaapmr/messageservice/src/main/resources/docker-compose |
| 10 | cp $WORKSPACE/archives/dmaapmr/messageservice/bundleconfig-local/etc/appprops/MsgRtrApi.properties /var/tmp/ |
| 11 | |
| 12 | # start DMaaP MR containers with docker compose and configuration from docker-compose.yml |
| 13 | docker login -u docker -p docker nexus3.onap.org:10001 |
| 14 | docker-compose up -d |
| 15 | |
| 16 | ZOOKEEPER=$(docker ps -a -q --filter="name=zookeeper_1") |
| 17 | KAFKA=$(docker ps -a -q --filter="name=kafka_1") |
| 18 | DMAAP=$(docker ps -a -q --filter="name=dmaap_1") |
| 19 | |
| 20 | # Wait for initialization of Docker contaienr for DMaaP MR, Kafka and Zookeeper |
| 21 | for i in {1..50}; do |
| 22 | if [ $(docker inspect --format '{{ .State.Running }}' $KAFKA) ] && \ |
| 23 | [ $(docker inspect --format '{{ .State.Running }}' $ZOOKEEPER) ] && \ |
| 24 | [ $(docker inspect --format '{{ .State.Running }}' $DMAAP) ] |
| 25 | then |
| 26 | echo "DMaaP Service Running" |
| 27 | break |
| 28 | else |
| 29 | echo sleep $i |
| 30 | sleep $i |
| 31 | fi |
| 32 | done |
| 33 | |
| 34 | # Get IP address of DMAAP, KAFKA, Zookeeper |
| 35 | KAFKA_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $KAFKA) |
| 36 | ZOOKEEPER_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $ZOOKEEPER) |
| 37 | DMAAP_MR_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $DMAAP) |
| 38 | |
| 39 | sleep 2 |
| 40 | # Shutdown DMAAP Container |
| 41 | docker kill $DMAAP |
| 42 | |
| 43 | # Initial docker-compose up and down is for populating kafka and zookeeper IPs in /var/tmp/MsgRtrApi.properites |
| 44 | sed -i -e '/config.zk.servers=/ s/=.*/='$ZOOKEEPER_IP'/' /var/tmp/MsgRtrApi.properties |
| 45 | sed -i -e '/kafka.metadata.broker.list=/ s/=.*/='$KAFKA_IP':9092/' /var/tmp/MsgRtrApi.properties |
| 46 | |
| 47 | # Start DMaaP MR containers with docker compose and configuration from docker-compose.yml |
| 48 | docker login -u docker -p docker nexus3.onap.org:10001 |
| 49 | docker-compose up -d |
| 50 | sleep 5 |
| 51 | |
| 52 | # Clone DMaaP Data Router repo |
| 53 | mkdir -p $WORKSPACE/archives/dmaapdr |
| 54 | cd $WORKSPACE/archives/dmaapdr |
| 55 | git clone --depth 1 https://gerrit.onap.org/r/dmaap/datarouter -b master |
| 56 | cd datarouter |
| 57 | cd $WORKSPACE/archives/dmaapdr/datarouter/docker-compose/ |
| 58 | rm -rf docker-compose.yml |
Gary Wu | 13111e9 | 2018-09-27 11:31:33 -0700 | [diff] [blame] | 59 | cp $WORKSPACE/plans/usecases/5G-bulkpm/composefile/docker-compose-e2e.yml $WORKSPACE/archives/dmaapdr/datarouter/docker-compose/docker-compose.yml |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 60 | docker login -u docker -p docker nexus3.onap.org:10001 |
| 61 | docker-compose up -d |
| 62 | docker kill datarouter-prov |
| 63 | docker kill datarouter-node |
| 64 | docker kill vescollector |
| 65 | HOST_IP=$(ip route get 8.8.8.8 | awk '/8.8.8.8/ {print $NF}') |
| 66 | sed -i -e '/DMAAPHOST:/ s/:.*/: '$HOST_IP'/' docker-compose.yml |
| 67 | MARIADB=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' mariadb ) |
| 68 | sed -i 's/172.100.0.2/'$MARIADB'/g' $WORKSPACE/archives/dmaapdr/datarouter/docker-compose/prov_data/provserver.properties |
| 69 | docker-compose up -d |
| 70 | |
| 71 | # Wait for initialization of Docker container for datarouter-node, datarouter-prov and mariadb |
| 72 | for i in {1..50}; do |
| 73 | if [ $(docker inspect --format '{{ .State.Running }}' datarouter-node) ] && \ |
| 74 | [ $(docker inspect --format '{{ .State.Running }}' datarouter-prov) ] && \ |
| 75 | [ $(docker inspect --format '{{ .State.Running }}' mariadb) ] |
| 76 | then |
| 77 | echo "DR Service Running" |
| 78 | break |
| 79 | else |
| 80 | echo sleep $i |
| 81 | sleep $i |
| 82 | fi |
| 83 | done |
| 84 | |
| 85 | sleep 5 |
| 86 | |
| 87 | # Get IP address of datarrouger-prov, datarouter-node, fileconsumer-node. |
| 88 | DR_PROV_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' datarouter-prov) |
| 89 | DR_NODE_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' datarouter-node) |
| 90 | DR_SUBSCIBER_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' fileconsumer-node) |
| 91 | DR_GATEWAY_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.Gateway}}{{end}}' datarouter-prov) |
| 92 | |
| 93 | echo DR_PROV_IP=${DR_PROV_IP} |
| 94 | echo DR_NODE_IP=${DR_NODE_IP} |
| 95 | echo DR_GATEWAY_IP=${DR_GATEWAY_IP} |
| 96 | echo DR_SUBSCIBER_IP=${DR_SUBSCIBER_IP} |
| 97 | |
| 98 | docker 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" |
| 99 | docker 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" |
| 100 | docker exec datarouter-prov /bin/sh -c "echo '${DR_NODE_IP}' dmaap-dr-node >> /etc/hosts" |
| 101 | docker exec datarouter-node /bin/sh -c "echo '${DR_PROV_IP}' dmaap-dr-prov >> /etc/hosts" |
| 102 | docker exec datarouter-node /bin/sh -c "echo '${DR_SUBSCIBER_IP}' dmaap-dr-subscriber >> /etc/hosts" |
| 103 | |
| 104 | # Get IP address of DMAAP, KAFKA, Zookeeper |
| 105 | DMAAP_MR_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $DMAAP) |
| 106 | KAFKA_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $KAFKA) |
| 107 | ZOOKEEPER_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $ZOOKEEPER) |
| 108 | VESC_IP=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' vescollector) |
| 109 | SFTP_IP=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' sftp) |
| 110 | |
| 111 | export VESC_IP=${VESC_IP} |
| 112 | export HOST_IP=${HOST_IP} |
| 113 | export DMAAP_MR_IP=${DMAAP_MR_IP} |
| 114 | |
| 115 | #Pass any variables required by Robot test suites in ROBOT_VARIABLES |
| 116 | ROBOT_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 DR_SUBSCIBER_IP:${DR_SUBSCIBER_IP}" |
| 117 | |
| 118 | pip install jsonschema uuid |
| 119 | # Wait container ready |
| 120 | sleep 2 |
| 121 | |
| 122 | # Data File Collector configuration : |
Gary Wu | 13111e9 | 2018-09-27 11:31:33 -0700 | [diff] [blame] | 123 | cp $WORKSPACE/plans/usecases/5G-bulkpm/assets/datafile_endpoints.json /tmp/ |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 124 | sed -i 's/dmaapmrhost/'${DMAAP_MR_IP}'/g' /tmp/datafile_endpoints.json |
| 125 | sed -i 's/dmaapdrhost/'${DR_PROV_IP}'/g' /tmp/datafile_endpoints.json |
| 126 | docker cp /tmp/datafile_endpoints.json dfc:/config/ |
| 127 | docker restart dfc |
rajendrajaiswal | a2c1ca2 | 2018-09-30 16:42:27 +0100 | [diff] [blame] | 128 | docker exec dfc /bin/sh -c "echo '${DR_NODE_IP}' dmaap-dr-node >> /etc/hosts" |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 129 | |
| 130 | # SFTP Configuration: |
| 131 | # Update the File Ready Notification with actual sftp ip address and copy pm files to sftp server. |
rajendrajaiswal | 0d357f3 | 2018-09-28 10:18:19 +0100 | [diff] [blame] | 132 | cp $WORKSPACE/tests/usecases/5G-bulkpm/assets/json_events/FileExistNotification.json $WORKSPACE/tests/usecases/5G-bulkpm/assets/json_events/FileExistNotificationUpdated.json |
Gary Wu | 13111e9 | 2018-09-27 11:31:33 -0700 | [diff] [blame] | 133 | sed -i 's/sftpserver/'${SFTP_IP}'/g' $WORKSPACE/tests/usecases/5G-bulkpm/assets/json_events/FileExistNotificationUpdated.json |
| 134 | docker cp $WORKSPACE/plans/usecases/5G-bulkpm/assets/xNF.pm.xml.gz sftp:/home/admin/ |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 135 | |
| 136 | # Data Router Configuration: |
| 137 | # Create default feed and create file consumer subscriber on data router |
Gary Wu | 13111e9 | 2018-09-27 11:31:33 -0700 | [diff] [blame] | 138 | curl -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 |
| 139 | cp $WORKSPACE/plans/usecases/5G-bulkpm/assets/addSubscriber.json /tmp/addSubscriber.json |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 140 | sed -i 's/fileconsumer/'${DR_SUBSCIBER_IP}'/g' /tmp/addSubscriber.json |
rajendrajaiswal | a2c1ca2 | 2018-09-30 16:42:27 +0100 | [diff] [blame] | 141 | curl -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 |
| 142 | sleep 60 |
| 143 | curl -k https://$DR_PROV_IP:8443/internal/prov |