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 | |
Remigiusz Janeczek | 92dff7d | 2020-07-15 15:22:57 +0200 | [diff] [blame] | 81 | #Add SFTP server pubilc key to known hosts of datafile collector |
| 82 | HOST_NAMES=$(docker inspect -f '{{ range .NetworkSettings.Networks}}{{join .Aliases ","}}{{end}}' sftp) |
| 83 | KEY_ENTRY=$(echo $HOST_NAMES "$(docker exec sftp cat /etc/ssh/ssh_host_rsa_key.pub)" | sed -e 's/\w*@\w*$//') |
| 84 | docker exec -i -u root dcaegen2-datafile-collector sh -c "echo $KEY_ENTRY >> /home/datafile/.ssh/known_hosts" |
| 85 | |
efiacor | 125390b | 2020-05-06 01:14:00 +0100 | [diff] [blame] | 86 | # Add gateway IP to DR Prov |
| 87 | 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" |
| 88 | 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" |
| 89 | |
| 90 | #Increase DFC Logging |
| 91 | #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" |
| 92 | |
| 93 | # Copy sample PM file to sftp server |
| 94 | docker cp $WORKSPACE/plans/usecases-5G-bulkpm/5G-bulkpm/assets/A20181002.0000-1000-0015-1000_5G.xml.gz sftp:/home/admin/ |
| 95 | |
| 96 | # Data Router Configuration: |
| 97 | # Create default feed on DMaaP data router |
| 98 | curl -v -X POST -H "Content-Type:application/vnd.dmaap-dr.feed" -H "X-DMAAP-DR-ON-BEHALF-OF:dradmin" \ |
| 99 | --data-ascii @$WORKSPACE/plans/usecases-5G-bulkpm/5G-bulkpm/assets/dmaap_dr/createFeed.json --post301 \ |
| 100 | --location-trusted -k https://${DR_PROV_IP}:8443 |
| 101 | sleep 2 |
| 102 | # Create file consumer subscriber on DMaaP data router |
| 103 | curl -X POST -H "Content-Type:application/vnd.dmaap-dr.subscription" -H "X-DMAAP-DR-ON-BEHALF-OF:dradmin" \ |
| 104 | --data-ascii @$WORKSPACE/plans/usecases-5G-bulkpm/5G-bulkpm/assets/dmaap_dr/addDefaultSubscriber.json --post301 \ |
| 105 | --location-trusted -k https://${DR_PROV_IP}:8443/subscribe/1 |
| 106 | sleep 2 |
| 107 | # Add PM Mapper subscriber on data router feed |
| 108 | curl -v -X POST -H "Content-Type:application/vnd.dmaap-dr.subscription" -H "X-DMAAP-DR-ON-BEHALF-OF:pmmapper" \ |
| 109 | --data-ascii @$WORKSPACE/plans/usecases-5G-bulkpm/5G-bulkpm/assets/dmaap_dr/addPmMapperSubscriber.json \ |
| 110 | --post301 --location-trusted -k https://${DR_PROV_IP}:8443/subscribe/1 |
| 111 | |
| 112 | # Check DMaaP DR provisioning |
| 113 | curl -k https://${DR_PROV_IP}:8443/internal/prov |
| 114 | |
| 115 | # Add necessary python libs |
| 116 | pip install jsonschema uuid simplejson |
| 117 | |
| 118 | # Export necessary vars |
| 119 | export VESC_IP=${VESC_IP} |
| 120 | export VESC_PORT=8080 |
| 121 | export DMAAP_MR_IP=${DMAAP_MR_IP} |
| 122 | |
| 123 | #Pass any variables required by Robot test suites in ROBOT_VARIABLES |
Remigiusz Janeczek | 92dff7d | 2020-07-15 15:22:57 +0200 | [diff] [blame] | 124 | 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}" |