efiacor | 125390b | 2020-05-06 01:14:00 +0100 | [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 | mkdir $WORKSPACE/archives/dmaapmr/messageservice/src/main/resources/docker-compose/tmp/ |
| 10 | # Copy custom docker-compose file |
| 11 | cp $WORKSPACE/plans/usecases-5G-bulkpm/5G-bulkpm/composefile/docker-compose-mr.yml \ |
| 12 | $WORKSPACE/archives/dmaapmr/messageservice/src/main/resources/docker-compose/tmp/docker-compose-mr.yml |
| 13 | |
| 14 | # Login to onap docker |
| 15 | docker login -u docker -p docker nexus3.onap.org:10001 |
| 16 | # Start DMaaP MR containers with docker compose and configuration from docker-compose-mr.yml |
| 17 | docker-compose -f $WORKSPACE/archives/dmaapmr/messageservice/src/main/resources/docker-compose/tmp/docker-compose-mr.yml up -d |
| 18 | sleep 5 |
| 19 | |
| 20 | # Wait for initialization of Docker contaienr for DMaaP MR, Kafka and Zookeeper |
| 21 | for i in 1 2 3 4 5 6 7 8 9 10; do |
| 22 | if [[ $(docker inspect --format '{{ .State.Running }}' dmaap-message-router-kafka) ]] && \ |
| 23 | [[ $(docker inspect --format '{{ .State.Running }}' dmaap-message-router-zookeeper) ]] && \ |
| 24 | [[ $(docker inspect --format '{{ .State.Running }}' dmaap-message-router-server) ]] |
| 25 | then |
| 26 | echo "Message Router service running" |
| 27 | break |
| 28 | else |
| 29 | echo sleep ${i} |
| 30 | sleep ${i} |
| 31 | fi |
| 32 | done |
| 33 | |
| 34 | # Clone DMaaP Data Router repo |
| 35 | mkdir -p $WORKSPACE/archives/dmaapdr |
| 36 | cd $WORKSPACE/archives/dmaapdr |
| 37 | git clone --depth 1 https://gerrit.onap.org/r/dmaap/datarouter -b master |
| 38 | mkdir $WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources/docker-compose |
| 39 | |
| 40 | # Copy e2e docker compose assets to tmp dir |
| 41 | cp $WORKSPACE/plans/usecases-5G-bulkpm/5G-bulkpm/composefile/docker-compose-e2e.yml \ |
| 42 | $WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources/docker-compose/docker-compose-e2e.yml |
| 43 | cp -rf $WORKSPACE/plans/usecases-5G-bulkpm/5G-bulkpm/assets/cbs_sim/ \ |
| 44 | $WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources/docker-compose/ |
| 45 | cp -rf $WORKSPACE/plans/usecases-5G-bulkpm/5G-bulkpm/assets/dfc/ \ |
| 46 | $WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources/docker-compose/ |
| 47 | cp -rf $WORKSPACE/plans/usecases-5G-bulkpm/5G-bulkpm/assets/pm_mapper_certs/ \ |
| 48 | $WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources/docker-compose/ |
| 49 | |
| 50 | # Start cbs-sim for pmmapper stability |
| 51 | docker-compose -f $WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources/docker-compose/docker-compose-e2e.yml up -d cbs-sim |
| 52 | echo "Starting cbs-sim" |
| 53 | sleep 10 |
| 54 | |
| 55 | # Start the rest of the e2e containers |
| 56 | docker-compose -f $WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources/docker-compose/docker-compose-e2e.yml up -d |
| 57 | |
| 58 | # Wait for initialization of the following containers |
| 59 | for i in 1 2 3 4 5 6 7 8 9 10; do |
| 60 | if [[ $(docker inspect --format '{{ .State.Running }}' dmaap-datarouter-node) ]] && \ |
| 61 | [[ $(docker inspect --format '{{ .State.Running }}' dmaap-datarouter-prov) ]] && \ |
| 62 | [[ $(docker inspect --format '{{ .State.Running }}' dmaap-dr-prov-mariadb) ]] && \ |
| 63 | [[ $(docker inspect --format '{{ .State.Running }}' dcaegen2-pm-mapper) ]] && \ |
| 64 | [[ $(docker inspect --format '{{ .State.Running }}' dcaegen2-datafile-collector) ]] |
| 65 | then |
| 66 | echo "Data Router service running" |
| 67 | break |
| 68 | else |
| 69 | echo sleep ${i} |
| 70 | sleep ${i} |
| 71 | fi |
| 72 | done |
| 73 | |
| 74 | # Get IP address of docker-host, dmaap-dr-prov, dmaap-dr-gateway, dmaap-mr and ves collector. |
| 75 | #HOST_IP=$(ip route get 8.8.8.8 | awk '/8.8.8.8/ {print $7}') |
| 76 | DR_PROV_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' dmaap-datarouter-prov) |
| 77 | DR_GATEWAY_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.Gateway}}{{end}}' dmaap-datarouter-prov) |
| 78 | DMAAP_MR_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' dmaap-message-router-server) |
| 79 | VESC_IP=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' dcaegen2-vescollector) |
| 80 | |
| 81 | # Add gateway IP to DR Prov |
| 82 | 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" |
| 83 | 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" |
| 84 | |
| 85 | #Increase DFC Logging |
| 86 | #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" |
| 87 | |
| 88 | # Copy sample PM file to sftp server |
| 89 | docker cp $WORKSPACE/plans/usecases-5G-bulkpm/5G-bulkpm/assets/A20181002.0000-1000-0015-1000_5G.xml.gz sftp:/home/admin/ |
| 90 | |
| 91 | # Data Router Configuration: |
| 92 | # Create default feed on DMaaP data router |
| 93 | curl -v -X POST -H "Content-Type:application/vnd.dmaap-dr.feed" -H "X-DMAAP-DR-ON-BEHALF-OF:dradmin" \ |
| 94 | --data-ascii @$WORKSPACE/plans/usecases-5G-bulkpm/5G-bulkpm/assets/dmaap_dr/createFeed.json --post301 \ |
| 95 | --location-trusted -k https://${DR_PROV_IP}:8443 |
| 96 | sleep 2 |
| 97 | # Create file consumer subscriber on DMaaP data router |
| 98 | curl -X POST -H "Content-Type:application/vnd.dmaap-dr.subscription" -H "X-DMAAP-DR-ON-BEHALF-OF:dradmin" \ |
| 99 | --data-ascii @$WORKSPACE/plans/usecases-5G-bulkpm/5G-bulkpm/assets/dmaap_dr/addDefaultSubscriber.json --post301 \ |
| 100 | --location-trusted -k https://${DR_PROV_IP}:8443/subscribe/1 |
| 101 | sleep 2 |
| 102 | # Add PM Mapper subscriber on data router feed |
| 103 | curl -v -X POST -H "Content-Type:application/vnd.dmaap-dr.subscription" -H "X-DMAAP-DR-ON-BEHALF-OF:pmmapper" \ |
| 104 | --data-ascii @$WORKSPACE/plans/usecases-5G-bulkpm/5G-bulkpm/assets/dmaap_dr/addPmMapperSubscriber.json \ |
| 105 | --post301 --location-trusted -k https://${DR_PROV_IP}:8443/subscribe/1 |
| 106 | |
| 107 | # Check DMaaP DR provisioning |
| 108 | curl -k https://${DR_PROV_IP}:8443/internal/prov |
| 109 | |
| 110 | # Add necessary python libs |
| 111 | pip install jsonschema uuid simplejson |
| 112 | |
| 113 | # Export necessary vars |
| 114 | export VESC_IP=${VESC_IP} |
| 115 | export VESC_PORT=8080 |
| 116 | export DMAAP_MR_IP=${DMAAP_MR_IP} |
| 117 | |
| 118 | #Pass any variables required by Robot test suites in ROBOT_VARIABLES |
| 119 | ROBOT_VARIABLES="-v DR_PROV_IP:${DR_PROV_IP} -v DMAAP_MR_IP:${DMAAP_MR_IP} -v VESC_IP:${VESC_IP} -v VESC_PORT:${VESC_PORT}" |