rajendrajaiswal | 47b64d7 | 2019-02-06 16:09:24 +0000 | [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 |
| 9 | sed -i 's/enableCadi: false/enableCadi: "false"/g' /$WORKSPACE/archives/dmaapmr/messageservice/src/main/resources/docker-compose/docker-compose.yml |
| 10 | cd $WORKSPACE/archives/dmaapmr/messageservice/src/main/resources/docker-compose |
| 11 | cp $WORKSPACE/archives/dmaapmr/messageservice/bundleconfig-local/etc/appprops/MsgRtrApi.properties /var/tmp/ |
| 12 | |
| 13 | # start DMaaP MR containers with docker compose and configuration from docker-compose.yml |
| 14 | docker login -u docker -p docker nexus3.onap.org:10001 |
| 15 | docker-compose up -d |
| 16 | |
| 17 | ZOOKEEPER=$(docker ps -a -q --filter="name=zookeeper_1") |
| 18 | KAFKA=$(docker ps -a -q --filter="name=kafka_1") |
| 19 | DMAAP=$(docker ps -a -q --filter="name=dmaap_1") |
| 20 | |
rajendrajaiswal | a157470 | 2019-02-14 10:29:45 +0000 | [diff] [blame] | 21 | # Get IP address of KAFKA, Zookeeper |
rajendrajaiswal | 47b64d7 | 2019-02-06 16:09:24 +0000 | [diff] [blame] | 22 | KAFKA_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $KAFKA) |
| 23 | ZOOKEEPER_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $ZOOKEEPER) |
rajendrajaiswal | 47b64d7 | 2019-02-06 16:09:24 +0000 | [diff] [blame] | 24 | |
rajendrajaiswal | 47b64d7 | 2019-02-06 16:09:24 +0000 | [diff] [blame] | 25 | # Shutdown DMAAP Container |
| 26 | docker kill $DMAAP |
| 27 | |
| 28 | # Initial docker-compose up and down is for populating kafka and zookeeper IPs in /var/tmp/MsgRtrApi.properites |
| 29 | sed -i -e '/config.zk.servers=/ s/=.*/='$ZOOKEEPER_IP'/' /var/tmp/MsgRtrApi.properties |
| 30 | sed -i -e '/kafka.metadata.broker.list=/ s/=.*/='$KAFKA_IP':9092/' /var/tmp/MsgRtrApi.properties |
| 31 | |
| 32 | # Start DMaaP MR containers with docker compose and configuration from docker-compose.yml |
| 33 | docker login -u docker -p docker nexus3.onap.org:10001 |
| 34 | docker-compose up -d |
| 35 | sleep 5 |
| 36 | |
rajendrajaiswal | a157470 | 2019-02-14 10:29:45 +0000 | [diff] [blame] | 37 | # Get IP address of DMAAP Message Router. |
| 38 | DMAAP_MR_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $DMAAP) |
| 39 | |
rajendrajaiswal | 37452e4 | 2019-04-02 08:40:58 +0000 | [diff] [blame] | 40 | # Clone DMaaP Data Router repo and Initialization of Data Router, Consul, Config Binding Service |
rajendrajaiswal | 47b64d7 | 2019-02-06 16:09:24 +0000 | [diff] [blame] | 41 | mkdir -p $WORKSPACE/archives/dmaapdr |
| 42 | cd $WORKSPACE/archives/dmaapdr |
| 43 | git clone --depth 1 https://gerrit.onap.org/r/dmaap/datarouter -b master |
| 44 | cd $WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources |
| 45 | mkdir docker-compose |
| 46 | cd $WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources/docker-compose |
| 47 | cp $WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/composefile/docker-compose-e2e.yml $WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources/docker-compose/docker-compose.yml |
rajendrajaiswal | 47b64d7 | 2019-02-06 16:09:24 +0000 | [diff] [blame] | 48 | docker login -u docker -p docker nexus3.onap.org:10001 |
| 49 | docker-compose up -d |
| 50 | echo "Disregard the message ERROR: for datarouter-node Container 1234456 is unhealthy, this is expected behaiour at this stage" |
rajendrajaiswal | 37452e4 | 2019-04-02 08:40:58 +0000 | [diff] [blame] | 51 | sleep 10 |
rajendrajaiswal | 47b64d7 | 2019-02-06 16:09:24 +0000 | [diff] [blame] | 52 | docker kill cbs |
| 53 | CONSUL_IP=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' consul ) |
| 54 | sed -i -e '/CONSUL_HOST:/ s/:.*/: '$CONSUL_IP'/' docker-compose.yml |
| 55 | MARIADB=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' mariadb ) |
| 56 | sed -i 's/datarouter-mariadb/'$MARIADB'/g' $WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources/prov_data/provserver.properties |
| 57 | docker-compose up -d |
rajendrajaiswal | 8f0afd8 | 2019-02-11 12:30:26 +0000 | [diff] [blame] | 58 | DR_PROV_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' datarouter-prov) |
rajendrajaiswal | 47b64d7 | 2019-02-06 16:09:24 +0000 | [diff] [blame] | 59 | DR_NODE_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' datarouter-node) |
rajendrajaiswal | 47b64d7 | 2019-02-06 16:09:24 +0000 | [diff] [blame] | 60 | |
| 61 | # Consul Configuration for PM Mapper |
| 62 | cp $WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/assets/cbs.json /tmp/cbs.json |
| 63 | sed -i 's/ipaddress/'${CBS_IP}'/g' /tmp/cbs.json |
| 64 | curl --request PUT --data @/tmp/cbs.json http://$CONSUL_IP:8500/v1/agent/service/register |
rajendrajaiswal | 37452e4 | 2019-04-02 08:40:58 +0000 | [diff] [blame] | 65 | curl '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/dcaegen2-pmmapper/pmmapper/assets/config.json |
rajendrajaiswal | 47b64d7 | 2019-02-06 16:09:24 +0000 | [diff] [blame] | 66 | |
rajendrajaiswal | a157470 | 2019-02-14 10:29:45 +0000 | [diff] [blame] | 67 | # PM Mapper startup and configuration |
| 68 | mkdir /tmp/docker-compose |
| 69 | cd /tmp/docker-compose |
| 70 | cp $WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/composefile/docker-compose-pmmapper.yml /tmp/docker-compose/docker-compose.yml |
| 71 | CBS_IP=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' cbs) |
| 72 | sed -i 's/CBSIP/'$CBS_IP'/g' docker-compose.yml |
rajendrajaiswal | 37452e4 | 2019-04-02 08:40:58 +0000 | [diff] [blame] | 73 | sed -i 's/1.1.1.1/'$DR_NODE_IP'/g' docker-compose.yml |
| 74 | sed -i 's/4.4.4.4/'$DMAAP_MR_IP'/g' docker-compose.yml |
rajendrajaiswal | a157470 | 2019-02-14 10:29:45 +0000 | [diff] [blame] | 75 | docker-compose up -d |
rajendrajaiswal | 140bfd2 | 2019-02-14 14:47:15 +0000 | [diff] [blame] | 76 | |
rajendrajaiswal | 37452e4 | 2019-04-02 08:40:58 +0000 | [diff] [blame] | 77 | cd $WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources/docker-compose |
| 78 | PMMAPPER_IP=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' pmmapper) |
| 79 | docker kill datarouter-node |
| 80 | docker kill datarouter-prov |
| 81 | sed -i 's/1.1.1.1/'$DR_NODE_IP'/g' docker-compose.yml |
| 82 | sed -i 's/2.2.2.2/'$DR_PROV_IP'/g' docker-compose.yml |
| 83 | sed -i 's/3.3.3.3/'$PMMAPPER_IP'/g' docker-compose.yml |
| 84 | docker-compose up -d |
| 85 | |
rajendrajaiswal | 3b202f0 | 2019-04-09 10:37:49 +0000 | [diff] [blame] | 86 | # Setting up PM Mapper certs. |
| 87 | docker cp $WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/assets/cert.jks.b64 pmmapper:opt/app/pm-mapper/etc/ |
| 88 | docker cp $WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/assets/jks.pass pmmapper:opt/app/pm-mapper/etc/ |
| 89 | docker cp $WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/assets/trust.jks.b64 pmmapper:opt/app/pm-mapper/etc/ |
| 90 | docker cp $WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/assets/trust.pass pmmapper:opt/app/pm-mapper/etc/ |
| 91 | docker restart pmmapper |
| 92 | |
rajendrajaiswal | 37452e4 | 2019-04-02 08:40:58 +0000 | [diff] [blame] | 93 | # Wait for initialization of Docker container for datarouter-node, datarouter-prov and mariadb, Consul, CBS |
| 94 | for i in {1..5}; do |
| 95 | if [ $(docker inspect --format '{{ .State.Running }}' datarouter-node) ] && \ |
| 96 | [ $(docker inspect --format '{{ .State.Running }}' datarouter-prov) ] && \ |
| 97 | [ $(docker inspect --format '{{ .State.Running }}' mariadb) ] && \ |
| 98 | [ $(docker inspect --format '{{ .State.Running }}' consul) ] && \ |
| 99 | [ $(docker inspect --format '{{ .State.Running }}' cbs) ] && \ |
| 100 | [ $(docker inspect --format '{{ .State.Running }}' pmmapper) ] && \ |
| 101 | [ $(docker inspect --format '{{ .State.Running }}' $KAFKA) ] && \ |
| 102 | [ $(docker inspect --format '{{ .State.Running }}' $ZOOKEEPER) ] && \ |
| 103 | [ $(docker inspect --format '{{ .State.Running }}' $DMAAP) ] |
rajendrajaiswal | 140bfd2 | 2019-02-14 14:47:15 +0000 | [diff] [blame] | 104 | then |
rajendrajaiswal | 37452e4 | 2019-04-02 08:40:58 +0000 | [diff] [blame] | 105 | echo "Message Router, Data Router, Consul, Config Binding Service Running and PM Mapper services are running healthy" |
rajendrajaiswal | 140bfd2 | 2019-02-14 14:47:15 +0000 | [diff] [blame] | 106 | break |
| 107 | else |
| 108 | echo sleep $i |
| 109 | sleep $i |
| 110 | fi |
| 111 | done |
rajendrajaiswal | 37452e4 | 2019-04-02 08:40:58 +0000 | [diff] [blame] | 112 | # Data Router Configuration. |
| 113 | DR_NODE_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' datarouter-node) |
| 114 | DR_GATEWAY_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.Gateway}}{{end}}' datarouter-prov) |
| 115 | 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" |
| 116 | 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" |
| 117 | |
| 118 | # Create PM Mapper feed and create PM Mapper subscriber on data router |
| 119 | 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 |
| 120 | curl -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 |
| 121 | |
| 122 | # Create PM Mapper tocic in Message Router |
| 123 | curl -v -X POST http://${DMAAP_MR_IP}:3904/topics/create -d @$WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/assets/createTopic.json -H "Content-Type: application/json" |
rajendrajaiswal | a157470 | 2019-02-14 10:29:45 +0000 | [diff] [blame] | 124 | PMMAPPER_IP=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' pmmapper) |
rajendrajaiswal | 7f7dab0 | 2019-02-15 10:23:53 +0000 | [diff] [blame] | 125 | docker exec pmmapper /bin/sh -c "cat /var/log/ONAP/dcaegen2/services/pm-mapper/pm-mapper_output.log" > /tmp/pmmapper.log |
| 126 | cat /tmp/pmmapper.log |
rajendrajaiswal | 37452e4 | 2019-04-02 08:40:58 +0000 | [diff] [blame] | 127 | docker exec -it datarouter-prov sh -c "curl http://dmaap-dr-node:8080/internal/fetchProv" |
| 128 | sleep 10 |
rajendrajaiswal | a157470 | 2019-02-14 10:29:45 +0000 | [diff] [blame] | 129 | curl -k https://$DR_PROV_IP:8443/internal/prov |
rajendrajaiswal | 37452e4 | 2019-04-02 08:40:58 +0000 | [diff] [blame] | 130 | curl http://${DMAAP_MR_IP}:3904/events/PM_MAPPER/CG1/C1?timeout=1000 |
rajendrajaiswal | a157470 | 2019-02-14 10:29:45 +0000 | [diff] [blame] | 131 | |
rajendrajaiswal | 47b64d7 | 2019-02-06 16:09:24 +0000 | [diff] [blame] | 132 | #Pass any variables required by Robot test suites in ROBOT_VARIABLES |
rajendrajaiswal | 3b202f0 | 2019-04-09 10:37:49 +0000 | [diff] [blame] | 133 | ROBOT_VARIABLES="-v CONSUL_IP:${CONSUL_IP} -v DR_PROV_IP:${DR_PROV_IP} -v DMAAP_MR_IP:${DMAAP_MR_IP} -v CBS_IP:${CBS_IP} -v PMMAPPER_IP:${PMMAPPER_IP} -v DR_NODE_IP:${DR_NODE_IP}" |