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 | |
rajendrajaiswal | 47b64d7 | 2019-02-06 16:09:24 +0000 | [diff] [blame] | 5 | docker login -u docker -p docker nexus3.onap.org:10001 |
rajendrajaiswal | 47b64d7 | 2019-02-06 16:09:24 +0000 | [diff] [blame] | 6 | |
AndyWalshe | c2894d1 | 2020-01-29 10:12:42 +0000 | [diff] [blame] | 7 | TEST_PLANS_DIR=$WORKSPACE/plans/dcaegen2-pmmapper/pmmapper |
rajendrajaiswal | 47b64d7 | 2019-02-06 16:09:24 +0000 | [diff] [blame] | 8 | |
AndyWalshe | c2894d1 | 2020-01-29 10:12:42 +0000 | [diff] [blame] | 9 | export GATEWAY_IP=172.18.0.1 |
| 10 | export DR_NODE_IP=172.18.0.2 |
| 11 | export DR_PROV_IP=172.18.0.3 |
| 12 | export CONSUL_IP=172.18.0.4 |
| 13 | export CBS_IP=172.18.0.5 |
| 14 | export MARIADB_IP=172.18.0.6 |
| 15 | export NODE_IP=172.18.0.7 |
| 16 | export PMMAPPER_IP=172.18.0.8 |
rajendrajaiswal | 47b64d7 | 2019-02-06 16:09:24 +0000 | [diff] [blame] | 17 | |
AndyWalshe | c2894d1 | 2020-01-29 10:12:42 +0000 | [diff] [blame] | 18 | for asset in provserver.properties addSubscriber.txt addFeed3.txt node.properties cbs.json mrserver.js; do |
| 19 | cp $TEST_PLANS_DIR/assets/${asset} /var/tmp/ |
| 20 | done |
rajendrajaiswal | 47b64d7 | 2019-02-06 16:09:24 +0000 | [diff] [blame] | 21 | |
AndyWalshe | c2894d1 | 2020-01-29 10:12:42 +0000 | [diff] [blame] | 22 | sed -i 's/datarouter-mariadb/'$MARIADB_IP'/g' /var/tmp/provserver.properties |
| 23 | #sed -i 's/<kafka-ip>/'$KAFKA_IP'/g' /var/tmp/addSubscriber.txt |
| 24 | #sed -i 's/<kafka-ip>/'$KAFKA_IP'/g' /var/tmp/addFeed3.txt |
| 25 | #sed -i 's/ipaddress/'$CBS_IP'/g' /var/tmp/cbs.json |
| 26 | sed -i 's/ipaddress//g' /var/tmp/cbs.json |
rajendrajaiswal | 47b64d7 | 2019-02-06 16:09:24 +0000 | [diff] [blame] | 27 | |
AndyWalshe | c2894d1 | 2020-01-29 10:12:42 +0000 | [diff] [blame] | 28 | docker-compose -f $TEST_PLANS_DIR/docker-compose.yml up -d mariadb consul cbs node |
rajendrajaiswal | 47b64d7 | 2019-02-06 16:09:24 +0000 | [diff] [blame] | 29 | |
AndyWalshe | c2894d1 | 2020-01-29 10:12:42 +0000 | [diff] [blame] | 30 | echo "Waiting for MariaDB to come up healthy..." |
| 31 | for i in {1..30}; do |
| 32 | mariadb_state=$(docker inspect --format='{{json .State.Health.Status}}' mariadb) |
| 33 | if [ $mariadb_state = '"healthy"' ] |
| 34 | then |
| 35 | break |
| 36 | else |
| 37 | sleep 2 |
| 38 | fi |
| 39 | done |
| 40 | [ "$mariadb_state" != '"healthy"' ] && echo "Error: MariaDB container state not healthy" && exit 1 |
rajendrajaiswal | a157470 | 2019-02-14 10:29:45 +0000 | [diff] [blame] | 41 | |
AndyWalshe | c2894d1 | 2020-01-29 10:12:42 +0000 | [diff] [blame] | 42 | docker-compose -f $TEST_PLANS_DIR/docker-compose.yml up -d datarouter-node datarouter-prov |
rajendrajaiswal | 47b64d7 | 2019-02-06 16:09:24 +0000 | [diff] [blame] | 43 | |
AndyWalshe | c2894d1 | 2020-01-29 10:12:42 +0000 | [diff] [blame] | 44 | curl --request PUT --data @/var/tmp/cbs.json http://$CONSUL_IP:8500/v1/agent/service/register |
| 45 | curl 'http://'$CONSUL_IP':8500/v1/kv/pmmapper?dc=dc1' -X PUT \ |
| 46 | -H 'Accept: application/json' \ |
| 47 | -H 'Content-Type: application/json' \ |
| 48 | -H 'X-Requested-With: XMLHttpRequest' \ |
| 49 | --data @$TEST_PLANS_DIR/assets/config.json |
rajendrajaiswal | 47b64d7 | 2019-02-06 16:09:24 +0000 | [diff] [blame] | 50 | |
AndyWalshe | c2894d1 | 2020-01-29 10:12:42 +0000 | [diff] [blame] | 51 | docker-compose -f $TEST_PLANS_DIR/docker-compose.yml up -d pmmapper |
| 52 | sleep 2 |
rajendrajaiswal | 37452e4 | 2019-04-02 08:40:58 +0000 | [diff] [blame] | 53 | |
rajendrajaiswal | 3b202f0 | 2019-04-09 10:37:49 +0000 | [diff] [blame] | 54 | # Setting up PM Mapper certs. |
AndyWalshe | c2894d1 | 2020-01-29 10:12:42 +0000 | [diff] [blame] | 55 | docker cp $TEST_PLANS_DIR/assets/cert.jks.b64 pmmapper:opt/app/pm-mapper/etc/ |
| 56 | docker cp $TEST_PLANS_DIR/assets/jks.pass pmmapper:opt/app/pm-mapper/etc/ |
| 57 | docker cp $TEST_PLANS_DIR/assets/trust.jks.b64 pmmapper:opt/app/pm-mapper/etc/ |
| 58 | docker cp $TEST_PLANS_DIR/assets/trust.pass pmmapper:opt/app/pm-mapper/etc/ |
| 59 | |
| 60 | docker-compose -f $TEST_PLANS_DIR/docker-compose.yml restart pmmapper |
rajendrajaiswal | 3b202f0 | 2019-04-09 10:37:49 +0000 | [diff] [blame] | 61 | |
rajendrajaiswal | 37452e4 | 2019-04-02 08:40:58 +0000 | [diff] [blame] | 62 | # Wait for initialization of Docker container for datarouter-node, datarouter-prov and mariadb, Consul, CBS |
AndyWalshe | c2894d1 | 2020-01-29 10:12:42 +0000 | [diff] [blame] | 63 | containers_ok=false |
rajendrajaiswal | 37452e4 | 2019-04-02 08:40:58 +0000 | [diff] [blame] | 64 | for i in {1..5}; do |
| 65 | if [ $(docker inspect --format '{{ .State.Running }}' datarouter-node) ] && \ |
| 66 | [ $(docker inspect --format '{{ .State.Running }}' datarouter-prov) ] && \ |
| 67 | [ $(docker inspect --format '{{ .State.Running }}' mariadb) ] && \ |
AndyWalshe | c2894d1 | 2020-01-29 10:12:42 +0000 | [diff] [blame] | 68 | [ $(docker inspect --format '{{ .State.Running }}' mr-simulator) ] && \ |
rajendrajaiswal | 37452e4 | 2019-04-02 08:40:58 +0000 | [diff] [blame] | 69 | [ $(docker inspect --format '{{ .State.Running }}' consul) ] && \ |
| 70 | [ $(docker inspect --format '{{ .State.Running }}' cbs) ] && \ |
AndyWalshe | c2894d1 | 2020-01-29 10:12:42 +0000 | [diff] [blame] | 71 | [ $(docker inspect --format '{{ .State.Running }}' pmmapper) ] |
rajendrajaiswal | 140bfd2 | 2019-02-14 14:47:15 +0000 | [diff] [blame] | 72 | then |
AndyWalshe | c2894d1 | 2020-01-29 10:12:42 +0000 | [diff] [blame] | 73 | echo "All required docker containers are up." |
| 74 | containers_ok=true |
rajendrajaiswal | 140bfd2 | 2019-02-14 14:47:15 +0000 | [diff] [blame] | 75 | break |
| 76 | else |
rajendrajaiswal | 140bfd2 | 2019-02-14 14:47:15 +0000 | [diff] [blame] | 77 | sleep $i |
| 78 | fi |
| 79 | done |
AndyWalshe | c2894d1 | 2020-01-29 10:12:42 +0000 | [diff] [blame] | 80 | [ "$containers_ok" = "false" ] && echo "Error: required container not running." && exit 1 |
| 81 | |
rajendrajaiswal | 37452e4 | 2019-04-02 08:40:58 +0000 | [diff] [blame] | 82 | # Data Router Configuration. |
AndyWalshe | c2894d1 | 2020-01-29 10:12:42 +0000 | [diff] [blame] | 83 | docker exec -i datarouter-prov sh -c \ |
| 84 | "curl -k -X PUT https://$DR_PROV_IP:8443/internal/api/NODES?val=dmaap-dr-node\|$GATEWAY_IP" |
| 85 | docker exec -i datarouter-prov sh -c \ |
| 86 | "curl -k -X PUT https://$DR_PROV_IP:8443/internal/api/PROV_AUTH_ADDRESSES?val=dmaap-dr-prov\|$GATEWAY_IP" |
rajendrajaiswal | 37452e4 | 2019-04-02 08:40:58 +0000 | [diff] [blame] | 87 | |
| 88 | # Create PM Mapper feed and create PM Mapper subscriber on data router |
AndyWalshe | c2894d1 | 2020-01-29 10:12:42 +0000 | [diff] [blame] | 89 | curl -v -X POST -H "Content-Type:application/vnd.dmaap-dr.feed" -H "X-DMAAP-DR-ON-BEHALF-OF:pmmapper" \ |
| 90 | --data-ascii @$TEST_PLANS_DIR/assets/createFeed.json \ |
| 91 | --post301 --location-trusted -k https://${DR_PROV_IP}:8443 |
| 92 | curl -v -X POST -H "Content-Type:application/vnd.dmaap-dr.subscription" -H "X-DMAAP-DR-ON-BEHALF-OF:pmmapper" \ |
| 93 | --data-ascii @$TEST_PLANS_DIR/assets/addSubscriber.json \ |
| 94 | --post301 --location-trusted -k https://${DR_PROV_IP}:8443/subscribe/1 |
rajendrajaiswal | 37452e4 | 2019-04-02 08:40:58 +0000 | [diff] [blame] | 95 | |
AndyWalshe | c2894d1 | 2020-01-29 10:12:42 +0000 | [diff] [blame] | 96 | docker cp pmmapper:/var/log/ONAP/dcaegen2/services/pm-mapper/pm-mapper_output.log /tmp/pmmapper.log |
rajendrajaiswal | 37452e4 | 2019-04-02 08:40:58 +0000 | [diff] [blame] | 97 | docker exec -it datarouter-prov sh -c "curl http://dmaap-dr-node:8080/internal/fetchProv" |
| 98 | sleep 10 |
rajendrajaiswal | a157470 | 2019-02-14 10:29:45 +0000 | [diff] [blame] | 99 | curl -k https://$DR_PROV_IP:8443/internal/prov |
AndyWalshe | c2894d1 | 2020-01-29 10:12:42 +0000 | [diff] [blame] | 100 | |
rajendrajaiswal | 47b64d7 | 2019-02-06 16:09:24 +0000 | [diff] [blame] | 101 | #Pass any variables required by Robot test suites in ROBOT_VARIABLES |
AndyWalshe | c2894d1 | 2020-01-29 10:12:42 +0000 | [diff] [blame] | 102 | 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}" |