blob: 7d851738548f52e6c036084175ee11460c33e0ab [file] [log] [blame]
rajendrajaiswal47b64d72019-02-06 16:09:24 +00001#!/bin/bash
2# Place the scripts in run order:
3source ${SCRIPTS}/common_functions.sh
4
rajendrajaiswal47b64d72019-02-06 16:09:24 +00005docker login -u docker -p docker nexus3.onap.org:10001
rajendrajaiswal47b64d72019-02-06 16:09:24 +00006
AndyWalshec2894d12020-01-29 10:12:42 +00007TEST_PLANS_DIR=$WORKSPACE/plans/dcaegen2-pmmapper/pmmapper
rajendrajaiswal47b64d72019-02-06 16:09:24 +00008
AndyWalshec2894d12020-01-29 10:12:42 +00009export GATEWAY_IP=172.18.0.1
10export DR_NODE_IP=172.18.0.2
11export DR_PROV_IP=172.18.0.3
12export CONSUL_IP=172.18.0.4
13export CBS_IP=172.18.0.5
14export MARIADB_IP=172.18.0.6
15export NODE_IP=172.18.0.7
16export PMMAPPER_IP=172.18.0.8
rajendrajaiswal47b64d72019-02-06 16:09:24 +000017
dfarrelly9a4eba42020-02-28 08:47:44 +000018for asset in provserver.properties addSubscriber.txt addFeed3.txt node.properties cbs.json mrserver.js cert.jks jks.pass trust.jks trust.pass; do
AndyWalshec2894d12020-01-29 10:12:42 +000019 cp $TEST_PLANS_DIR/assets/${asset} /var/tmp/
20done
rajendrajaiswal47b64d72019-02-06 16:09:24 +000021
AndyWalshec2894d12020-01-29 10:12:42 +000022sed -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
26sed -i 's/ipaddress//g' /var/tmp/cbs.json
rajendrajaiswal47b64d72019-02-06 16:09:24 +000027
AndyWalshec2894d12020-01-29 10:12:42 +000028docker-compose -f $TEST_PLANS_DIR/docker-compose.yml up -d mariadb consul cbs node
rajendrajaiswal47b64d72019-02-06 16:09:24 +000029
AndyWalshec2894d12020-01-29 10:12:42 +000030echo "Waiting for MariaDB to come up healthy..."
31for 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
39done
40[ "$mariadb_state" != '"healthy"' ] && echo "Error: MariaDB container state not healthy" && exit 1
rajendrajaiswala1574702019-02-14 10:29:45 +000041
AndyWalshec2894d12020-01-29 10:12:42 +000042docker-compose -f $TEST_PLANS_DIR/docker-compose.yml up -d datarouter-node datarouter-prov
rajendrajaiswal47b64d72019-02-06 16:09:24 +000043
AndyWalshec2894d12020-01-29 10:12:42 +000044curl --request PUT --data @/var/tmp/cbs.json http://$CONSUL_IP:8500/v1/agent/service/register
45curl '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
rajendrajaiswal47b64d72019-02-06 16:09:24 +000050
AndyWalshec2894d12020-01-29 10:12:42 +000051docker-compose -f $TEST_PLANS_DIR/docker-compose.yml up -d pmmapper
52sleep 2
rajendrajaiswal37452e42019-04-02 08:40:58 +000053
54# Wait for initialization of Docker container for datarouter-node, datarouter-prov and mariadb, Consul, CBS
AndyWalshec2894d12020-01-29 10:12:42 +000055containers_ok=false
rajendrajaiswal37452e42019-04-02 08:40:58 +000056for 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) ] && \
AndyWalshec2894d12020-01-29 10:12:42 +000060 [ $(docker inspect --format '{{ .State.Running }}' mr-simulator) ] && \
rajendrajaiswal37452e42019-04-02 08:40:58 +000061 [ $(docker inspect --format '{{ .State.Running }}' consul) ] && \
62 [ $(docker inspect --format '{{ .State.Running }}' cbs) ] && \
AndyWalshec2894d12020-01-29 10:12:42 +000063 [ $(docker inspect --format '{{ .State.Running }}' pmmapper) ]
rajendrajaiswal140bfd22019-02-14 14:47:15 +000064 then
AndyWalshec2894d12020-01-29 10:12:42 +000065 echo "All required docker containers are up."
66 containers_ok=true
rajendrajaiswal140bfd22019-02-14 14:47:15 +000067 break
68 else
rajendrajaiswal140bfd22019-02-14 14:47:15 +000069 sleep $i
70 fi
71done
AndyWalshec2894d12020-01-29 10:12:42 +000072[ "$containers_ok" = "false" ] && echo "Error: required container not running." && exit 1
73
rajendrajaiswal37452e42019-04-02 08:40:58 +000074# Data Router Configuration.
AndyWalshec2894d12020-01-29 10:12:42 +000075docker 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"
77docker 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"
rajendrajaiswal37452e42019-04-02 08:40:58 +000079
80# Create PM Mapper feed and create PM Mapper subscriber on data router
AndyWalshec2894d12020-01-29 10:12:42 +000081curl -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
84curl -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
rajendrajaiswal37452e42019-04-02 08:40:58 +000087
AndyWalshec2894d12020-01-29 10:12:42 +000088docker cp pmmapper:/var/log/ONAP/dcaegen2/services/pm-mapper/pm-mapper_output.log /tmp/pmmapper.log
rajendrajaiswal37452e42019-04-02 08:40:58 +000089sleep 10
rajendrajaiswal855e78e2020-02-10 13:36:42 +000090docker exec -it datarouter-prov sh -c "curl http://dmaap-dr-node:8080/internal/fetchProv"
rajendrajaiswala1574702019-02-14 10:29:45 +000091curl -k https://$DR_PROV_IP:8443/internal/prov
AndyWalshec2894d12020-01-29 10:12:42 +000092
rajendrajaiswal47b64d72019-02-06 16:09:24 +000093#Pass any variables required by Robot test suites in ROBOT_VARIABLES
AndyWalshec2894d12020-01-29 10:12:42 +000094ROBOT_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}"