Move CSIT to integration/csit repo
[integration/csit.git] / scripts / dmaap-buscontroller / dr-launch.sh
1
2 #!/bin/bash
3
4 #!/bin/bash
5
6 # script to launch DMaaP DR  docker containers
7 # sets global var IP with assigned IP address of DR Prov
8
9 function dmaap_dr_launch() {
10         IP=""
11
12
13         # This next section was copied from scripts/dmaap-datarouter/dr-suite/setup.sh
14         # and slightly modified...
15
16         # Clone DMaaP Data Router repo
17         mkdir -p $WORKSPACE/archives/dmaapdr
18         cd $WORKSPACE/archives/dmaapdr
19
20         git clone --depth 1 https://gerrit.onap.org/r/dmaap/datarouter -b master
21         cd datarouter
22         git pull
23         cd $WORKSPACE/archives/dmaapdr/datarouter/docker-compose/
24
25         sed -i 's/10003/10001/g' docker-compose.yml
26         # start DMaaP DR containers with docker compose and configuration from docker-compose.yml
27         docker login -u docker -p docker nexus3.onap.org:10001
28         docker-compose up -d
29
30         # Wait for initialization of Docker container for datarouter-node, datarouter-prov and mariadb
31         for i in {1..50}; do
32             if [ $(docker inspect --format '{{ .State.Running }}' datarouter-node) ] && \
33                 [ $(docker inspect --format '{{ .State.Running }}' datarouter-prov) ] && \
34                 [ $(docker inspect --format '{{ .State.Running }}' mariadb) ]
35             then
36                 echo "DR Service Running"
37                 break
38             else
39                 echo sleep $i
40                 sleep $i
41             fi
42         done
43
44         DR_PROV_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' datarouter-prov)
45         DR_NODE_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' datarouter-node)
46         DR_GATEWAY_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.Gateway}}{{end}}' datarouter-prov)
47
48         echo DR_PROV_IP=${DR_PROV_IP}
49         echo DR_NODE_IP=${DR_NODE_IP}
50         echo DR_GATEWAY_IP=${DR_GATEWAY_IP}
51
52         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"
53         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"
54
55         #Pass any variables required by Robot test suites in ROBOT_VARIABLES
56         ROBOT_VARIABLES="-v DR_PROV_IP:${DR_PROV_IP} -v DR_NODE_IP:${DR_NODE_IP}"
57
58         IP=${DR_GATEWAY_IP}
59 }