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 . |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 14 | |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 15 | # start DMaaP DR containers with docker compose and configuration from docker-compose.yml |
| 16 | docker login -u docker -p docker nexus3.onap.org:10001 |
| 17 | docker-compose up -d |
| 18 | |
| 19 | # 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] | 20 | for i in {1..10}; do |
econwar | 624a9bd | 2019-02-08 16:02:29 +0000 | [diff] [blame] | 21 | if [ $(docker inspect --format '{{ .State.Running }}' subscriber-node2) ] && \ |
| 22 | [ $(docker inspect --format '{{ .State.Running }}' subscriber-node) ] && \ |
| 23 | [ $(docker inspect --format '{{ .State.Running }}' datarouter-node) ] && \ |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 24 | [ $(docker inspect --format '{{ .State.Running }}' datarouter-prov) ] && \ |
| 25 | [ $(docker inspect --format '{{ .State.Running }}' mariadb) ] |
| 26 | then |
| 27 | echo "DR Service Running" |
| 28 | break |
| 29 | else |
| 30 | echo sleep $i |
| 31 | sleep $i |
| 32 | fi |
| 33 | done |
| 34 | |
Stanislav Chlebec | d3c71b1 | 2018-12-03 18:06:21 +0100 | [diff] [blame] | 35 | # Wait for healthy container datarouter-prov |
| 36 | for i in {1..10}; do |
| 37 | if [ "$(docker inspect --format '{{ .State.Health.Status }}' datarouter-prov)" = 'healthy' ] |
| 38 | then |
| 39 | echo datarouter-prov.State.Health.Status is $(docker inspect --format '{{ .State.Health.Status }}' datarouter-prov) |
| 40 | echo "DR Service Running, datarouter-prov container is healthy" |
| 41 | break |
| 42 | else |
| 43 | echo datarouter-prov.State.Health.Status is $(docker inspect --format '{{ .State.Health.Status }}' datarouter-prov) |
| 44 | echo sleep $i |
| 45 | sleep $i |
| 46 | if [ $i = 10 ] |
| 47 | then |
| 48 | echo datarouter-prov container is not in healthy state - the test is not made, teardown... |
| 49 | cd $WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources |
| 50 | docker-compose down -v |
| 51 | exit 1 |
| 52 | fi |
| 53 | fi |
| 54 | done |
| 55 | |
econwar | 624a9bd | 2019-02-08 16:02:29 +0000 | [diff] [blame] | 56 | DR_PROV_IP=`get-instance-ip.sh datarouter-prov` |
| 57 | DR_NODE_IP=`get-instance-ip.sh datarouter-node` |
| 58 | DR_SUB_IP=`get-instance-ip.sh subscriber-node` |
| 59 | DR_SUB2_IP=`get-instance-ip.sh subscriber-node2` |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 60 | DR_GATEWAY_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.Gateway}}{{end}}' datarouter-prov) |
| 61 | |
| 62 | echo DR_PROV_IP=${DR_PROV_IP} |
| 63 | echo DR_NODE_IP=${DR_NODE_IP} |
econwar | 624a9bd | 2019-02-08 16:02:29 +0000 | [diff] [blame] | 64 | echo DR_SUB_IP=${DR_SUB_IP} |
| 65 | echo DR_SUB2_IP=${DR_SUB2_IP} |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 66 | echo DR_GATEWAY_IP=${DR_GATEWAY_IP} |
| 67 | |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 68 | 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" |
| 69 | |
| 70 | #Pass any variables required by Robot test suites in ROBOT_VARIABLES |
econwar | 624a9bd | 2019-02-08 16:02:29 +0000 | [diff] [blame] | 71 | 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}" |