Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | source ${SCRIPTS}/common_functions.sh |
| 4 | |
| 5 | # Clone DMaaP Data Router repo |
| 6 | mkdir -p $WORKSPACE/archives/dmaapdr |
| 7 | cd $WORKSPACE/archives/dmaapdr |
| 8 | |
| 9 | git clone --depth 1 https://gerrit.onap.org/r/dmaap/datarouter -b master |
| 10 | cd datarouter |
| 11 | git pull |
Conor Ward | 18eb8c4 | 2018-10-19 14:21:17 +0100 | [diff] [blame] | 12 | cd $WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources |
econwar | 624a9bd | 2019-02-08 16:02:29 +0000 | [diff] [blame] | 13 | cp $WORKSPACE/plans/dmaap-datarouter/dr-suite/docker-compose/docker-compose.yml . |
efiacor | 87e2e55 | 2019-03-25 11:40:55 +0000 | [diff] [blame] | 14 | cp $WORKSPACE/plans/dmaap-datarouter/dr-suite/docker-compose/provserver.properties ./prov_data/provserver.properties |
| 15 | cp $WORKSPACE/plans/dmaap-datarouter/dr-suite/docker-compose/node.properties ./node_data/node.properties |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 16 | |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 17 | # start DMaaP DR containers with docker compose and configuration from docker-compose.yml |
| 18 | docker login -u docker -p docker nexus3.onap.org:10001 |
| 19 | docker-compose up -d |
| 20 | |
| 21 | # Wait for initialization of Docker container for datarouter-node, datarouter-prov and mariadb |
Conor Ward | 18eb8c4 | 2018-10-19 14:21:17 +0100 | [diff] [blame] | 22 | for i in {1..10}; do |
econwar | 624a9bd | 2019-02-08 16:02:29 +0000 | [diff] [blame] | 23 | if [ $(docker inspect --format '{{ .State.Running }}' subscriber-node2) ] && \ |
| 24 | [ $(docker inspect --format '{{ .State.Running }}' subscriber-node) ] && \ |
| 25 | [ $(docker inspect --format '{{ .State.Running }}' datarouter-node) ] && \ |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 26 | [ $(docker inspect --format '{{ .State.Running }}' datarouter-prov) ] && \ |
| 27 | [ $(docker inspect --format '{{ .State.Running }}' mariadb) ] |
| 28 | then |
| 29 | echo "DR Service Running" |
| 30 | break |
| 31 | else |
| 32 | echo sleep $i |
| 33 | sleep $i |
| 34 | fi |
| 35 | done |
| 36 | |
Stanislav Chlebec | d3c71b1 | 2018-12-03 18:06:21 +0100 | [diff] [blame] | 37 | # Wait for healthy container datarouter-prov |
| 38 | for i in {1..10}; do |
| 39 | if [ "$(docker inspect --format '{{ .State.Health.Status }}' datarouter-prov)" = 'healthy' ] |
| 40 | then |
| 41 | echo datarouter-prov.State.Health.Status is $(docker inspect --format '{{ .State.Health.Status }}' datarouter-prov) |
| 42 | echo "DR Service Running, datarouter-prov container is healthy" |
| 43 | break |
| 44 | else |
| 45 | echo datarouter-prov.State.Health.Status is $(docker inspect --format '{{ .State.Health.Status }}' datarouter-prov) |
| 46 | echo sleep $i |
| 47 | sleep $i |
| 48 | if [ $i = 10 ] |
| 49 | then |
| 50 | echo datarouter-prov container is not in healthy state - the test is not made, teardown... |
| 51 | cd $WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources |
efiacor | 87e2e55 | 2019-03-25 11:40:55 +0000 | [diff] [blame] | 52 | docker-compose rm -sf |
Stanislav Chlebec | d3c71b1 | 2018-12-03 18:06:21 +0100 | [diff] [blame] | 53 | exit 1 |
| 54 | fi |
| 55 | fi |
| 56 | done |
| 57 | |
econwar | 624a9bd | 2019-02-08 16:02:29 +0000 | [diff] [blame] | 58 | DR_PROV_IP=`get-instance-ip.sh datarouter-prov` |
| 59 | DR_NODE_IP=`get-instance-ip.sh datarouter-node` |
| 60 | DR_SUB_IP=`get-instance-ip.sh subscriber-node` |
| 61 | DR_SUB2_IP=`get-instance-ip.sh subscriber-node2` |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 62 | DR_GATEWAY_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.Gateway}}{{end}}' datarouter-prov) |
| 63 | |
| 64 | echo DR_PROV_IP=${DR_PROV_IP} |
| 65 | echo DR_NODE_IP=${DR_NODE_IP} |
econwar | 624a9bd | 2019-02-08 16:02:29 +0000 | [diff] [blame] | 66 | echo DR_SUB_IP=${DR_SUB_IP} |
| 67 | echo DR_SUB2_IP=${DR_SUB2_IP} |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 68 | echo DR_GATEWAY_IP=${DR_GATEWAY_IP} |
| 69 | |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 70 | 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" |
| 71 | |
| 72 | #Pass any variables required by Robot test suites in ROBOT_VARIABLES |
econwar | 624a9bd | 2019-02-08 16:02:29 +0000 | [diff] [blame] | 73 | ROBOT_VARIABLES="-v DR_PROV_IP:${DR_PROV_IP} -v DR_NODE_IP:${DR_NODE_IP} -v DR_SUB_IP:${DR_SUB_IP} -v DR_SUB2_IP:${DR_SUB2_IP}" |