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 | |
rajendrajaiswal | 855e78e | 2020-02-10 13:36:42 +0000 | [diff] [blame] | 18 | for asset in provserver.properties addSubscriber.txt addFeed3.txt node.properties cbs.json mrserver.js cert.jks.b64 jks.pass trust.jks.b64 trust.pass; do |
AndyWalshe | c2894d1 | 2020-01-29 10:12:42 +0000 | [diff] [blame] | 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 | |
| 54 | # 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] | 55 | containers_ok=false |
rajendrajaiswal | 37452e4 | 2019-04-02 08:40:58 +0000 | [diff] [blame] | 56 | for i in {1..5}; do |
| 57 | if [ $(docker inspect --format '{{ .State.Running }}' datarouter-node) ] && \ |
| 58 | [ $(docker inspect --format '{{ .State.Running }}' datarouter-prov) ] && \ |
| 59 | [ $(docker inspect --format '{{ .State.Running }}' mariadb) ] && \ |
AndyWalshe | c2894d1 | 2020-01-29 10:12:42 +0000 | [diff] [blame] | 60 | [ $(docker inspect --format '{{ .State.Running }}' mr-simulator) ] && \ |
rajendrajaiswal | 37452e4 | 2019-04-02 08:40:58 +0000 | [diff] [blame] | 61 | [ $(docker inspect --format '{{ .State.Running }}' consul) ] && \ |
| 62 | [ $(docker inspect --format '{{ .State.Running }}' cbs) ] && \ |
AndyWalshe | c2894d1 | 2020-01-29 10:12:42 +0000 | [diff] [blame] | 63 | [ $(docker inspect --format '{{ .State.Running }}' pmmapper) ] |
rajendrajaiswal | 140bfd2 | 2019-02-14 14:47:15 +0000 | [diff] [blame] | 64 | then |
AndyWalshe | c2894d1 | 2020-01-29 10:12:42 +0000 | [diff] [blame] | 65 | echo "All required docker containers are up." |
| 66 | containers_ok=true |
rajendrajaiswal | 140bfd2 | 2019-02-14 14:47:15 +0000 | [diff] [blame] | 67 | break |
| 68 | else |
rajendrajaiswal | 140bfd2 | 2019-02-14 14:47:15 +0000 | [diff] [blame] | 69 | sleep $i |
| 70 | fi |
| 71 | done |
AndyWalshe | c2894d1 | 2020-01-29 10:12:42 +0000 | [diff] [blame] | 72 | [ "$containers_ok" = "false" ] && echo "Error: required container not running." && exit 1 |
| 73 | |
rajendrajaiswal | 37452e4 | 2019-04-02 08:40:58 +0000 | [diff] [blame] | 74 | # Data Router Configuration. |
AndyWalshe | c2894d1 | 2020-01-29 10:12:42 +0000 | [diff] [blame] | 75 | docker exec -i datarouter-prov sh -c \ |
| 76 | "curl -k -X PUT https://$DR_PROV_IP:8443/internal/api/NODES?val=dmaap-dr-node\|$GATEWAY_IP" |
| 77 | docker exec -i datarouter-prov sh -c \ |
| 78 | "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] | 79 | |
| 80 | # Create PM Mapper feed and create PM Mapper subscriber on data router |
AndyWalshe | c2894d1 | 2020-01-29 10:12:42 +0000 | [diff] [blame] | 81 | curl -v -X POST -H "Content-Type:application/vnd.dmaap-dr.feed" -H "X-DMAAP-DR-ON-BEHALF-OF:pmmapper" \ |
| 82 | --data-ascii @$TEST_PLANS_DIR/assets/createFeed.json \ |
| 83 | --post301 --location-trusted -k https://${DR_PROV_IP}:8443 |
| 84 | curl -v -X POST -H "Content-Type:application/vnd.dmaap-dr.subscription" -H "X-DMAAP-DR-ON-BEHALF-OF:pmmapper" \ |
| 85 | --data-ascii @$TEST_PLANS_DIR/assets/addSubscriber.json \ |
| 86 | --post301 --location-trusted -k https://${DR_PROV_IP}:8443/subscribe/1 |
rajendrajaiswal | 37452e4 | 2019-04-02 08:40:58 +0000 | [diff] [blame] | 87 | |
AndyWalshe | c2894d1 | 2020-01-29 10:12:42 +0000 | [diff] [blame] | 88 | 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] | 89 | sleep 10 |
rajendrajaiswal | 855e78e | 2020-02-10 13:36:42 +0000 | [diff] [blame] | 90 | docker exec -it datarouter-prov sh -c "curl http://dmaap-dr-node:8080/internal/fetchProv" |
rajendrajaiswal | a157470 | 2019-02-14 10:29:45 +0000 | [diff] [blame] | 91 | curl -k https://$DR_PROV_IP:8443/internal/prov |
AndyWalshe | c2894d1 | 2020-01-29 10:12:42 +0000 | [diff] [blame] | 92 | |
rajendrajaiswal | 47b64d7 | 2019-02-06 16:09:24 +0000 | [diff] [blame] | 93 | #Pass any variables required by Robot test suites in ROBOT_VARIABLES |
AndyWalshe | c2894d1 | 2020-01-29 10:12:42 +0000 | [diff] [blame] | 94 | 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}" |