blob: 4645223a229bab7ed91b43edb833fa3afdf6db74 [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
AndyWalshec2894d12020-01-29 10:12:42 +000018for asset in provserver.properties addSubscriber.txt addFeed3.txt node.properties cbs.json mrserver.js; do
19 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
rajendrajaiswal3b202f02019-04-09 10:37:49 +000054# Setting up PM Mapper certs.
AndyWalshec2894d12020-01-29 10:12:42 +000055docker cp $TEST_PLANS_DIR/assets/cert.jks.b64 pmmapper:opt/app/pm-mapper/etc/
56docker cp $TEST_PLANS_DIR/assets/jks.pass pmmapper:opt/app/pm-mapper/etc/
57docker cp $TEST_PLANS_DIR/assets/trust.jks.b64 pmmapper:opt/app/pm-mapper/etc/
58docker cp $TEST_PLANS_DIR/assets/trust.pass pmmapper:opt/app/pm-mapper/etc/
59
60docker-compose -f $TEST_PLANS_DIR/docker-compose.yml restart pmmapper
rajendrajaiswal3b202f02019-04-09 10:37:49 +000061
rajendrajaiswal37452e42019-04-02 08:40:58 +000062# Wait for initialization of Docker container for datarouter-node, datarouter-prov and mariadb, Consul, CBS
AndyWalshec2894d12020-01-29 10:12:42 +000063containers_ok=false
rajendrajaiswal37452e42019-04-02 08:40:58 +000064for i in {1..5}; do
65 if [ $(docker inspect --format '{{ .State.Running }}' datarouter-node) ] && \
66 [ $(docker inspect --format '{{ .State.Running }}' datarouter-prov) ] && \
67 [ $(docker inspect --format '{{ .State.Running }}' mariadb) ] && \
AndyWalshec2894d12020-01-29 10:12:42 +000068 [ $(docker inspect --format '{{ .State.Running }}' mr-simulator) ] && \
rajendrajaiswal37452e42019-04-02 08:40:58 +000069 [ $(docker inspect --format '{{ .State.Running }}' consul) ] && \
70 [ $(docker inspect --format '{{ .State.Running }}' cbs) ] && \
AndyWalshec2894d12020-01-29 10:12:42 +000071 [ $(docker inspect --format '{{ .State.Running }}' pmmapper) ]
rajendrajaiswal140bfd22019-02-14 14:47:15 +000072 then
AndyWalshec2894d12020-01-29 10:12:42 +000073 echo "All required docker containers are up."
74 containers_ok=true
rajendrajaiswal140bfd22019-02-14 14:47:15 +000075 break
76 else
rajendrajaiswal140bfd22019-02-14 14:47:15 +000077 sleep $i
78 fi
79done
AndyWalshec2894d12020-01-29 10:12:42 +000080[ "$containers_ok" = "false" ] && echo "Error: required container not running." && exit 1
81
rajendrajaiswal37452e42019-04-02 08:40:58 +000082# Data Router Configuration.
AndyWalshec2894d12020-01-29 10:12:42 +000083docker exec -i datarouter-prov sh -c \
84 "curl -k -X PUT https://$DR_PROV_IP:8443/internal/api/NODES?val=dmaap-dr-node\|$GATEWAY_IP"
85docker exec -i datarouter-prov sh -c \
86 "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 +000087
88# Create PM Mapper feed and create PM Mapper subscriber on data router
AndyWalshec2894d12020-01-29 10:12:42 +000089curl -v -X POST -H "Content-Type:application/vnd.dmaap-dr.feed" -H "X-DMAAP-DR-ON-BEHALF-OF:pmmapper" \
90 --data-ascii @$TEST_PLANS_DIR/assets/createFeed.json \
91 --post301 --location-trusted -k https://${DR_PROV_IP}:8443
92curl -v -X POST -H "Content-Type:application/vnd.dmaap-dr.subscription" -H "X-DMAAP-DR-ON-BEHALF-OF:pmmapper" \
93 --data-ascii @$TEST_PLANS_DIR/assets/addSubscriber.json \
94 --post301 --location-trusted -k https://${DR_PROV_IP}:8443/subscribe/1
rajendrajaiswal37452e42019-04-02 08:40:58 +000095
AndyWalshec2894d12020-01-29 10:12:42 +000096docker cp pmmapper:/var/log/ONAP/dcaegen2/services/pm-mapper/pm-mapper_output.log /tmp/pmmapper.log
rajendrajaiswal37452e42019-04-02 08:40:58 +000097docker exec -it datarouter-prov sh -c "curl http://dmaap-dr-node:8080/internal/fetchProv"
98sleep 10
rajendrajaiswala1574702019-02-14 10:29:45 +000099curl -k https://$DR_PROV_IP:8443/internal/prov
AndyWalshec2894d12020-01-29 10:12:42 +0000100
rajendrajaiswal47b64d72019-02-06 16:09:24 +0000101#Pass any variables required by Robot test suites in ROBOT_VARIABLES
AndyWalshec2894d12020-01-29 10:12:42 +0000102ROBOT_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}"