blob: 1f5f26df2cfbdd5c1b0595c3c4c23843e454da2d [file] [log] [blame]
efiacor125390b2020-05-06 01:14:00 +01001#!/bin/bash
2# Place the scripts in run order:
3source ${SCRIPTS}/common_functions.sh
4
5# Clone DMaaP Message Router repo
6mkdir -p $WORKSPACE/archives/dmaapmr
7cd $WORKSPACE/archives/dmaapmr
8git clone --depth 1 http://gerrit.onap.org/r/dmaap/messagerouter/messageservice -b master
9mkdir $WORKSPACE/archives/dmaapmr/messageservice/src/main/resources/docker-compose/tmp/
10# Copy custom docker-compose file
11cp $WORKSPACE/plans/usecases-5G-bulkpm/5G-bulkpm/composefile/docker-compose-mr.yml \
12$WORKSPACE/archives/dmaapmr/messageservice/src/main/resources/docker-compose/tmp/docker-compose-mr.yml
13
14# Login to onap docker
15docker login -u docker -p docker nexus3.onap.org:10001
16# Start DMaaP MR containers with docker compose and configuration from docker-compose-mr.yml
17docker-compose -f $WORKSPACE/archives/dmaapmr/messageservice/src/main/resources/docker-compose/tmp/docker-compose-mr.yml up -d
18sleep 5
19
20# Wait for initialization of Docker contaienr for DMaaP MR, Kafka and Zookeeper
21for i in 1 2 3 4 5 6 7 8 9 10; do
22 if [[ $(docker inspect --format '{{ .State.Running }}' dmaap-message-router-kafka) ]] && \
23 [[ $(docker inspect --format '{{ .State.Running }}' dmaap-message-router-zookeeper) ]] && \
24 [[ $(docker inspect --format '{{ .State.Running }}' dmaap-message-router-server) ]]
25 then
26 echo "Message Router service running"
27 break
28 else
29 echo sleep ${i}
30 sleep ${i}
31 fi
32done
33
34# Clone DMaaP Data Router repo
35mkdir -p $WORKSPACE/archives/dmaapdr
36cd $WORKSPACE/archives/dmaapdr
37git clone --depth 1 https://gerrit.onap.org/r/dmaap/datarouter -b master
38mkdir $WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources/docker-compose
39
40# Copy e2e docker compose assets to tmp dir
41cp $WORKSPACE/plans/usecases-5G-bulkpm/5G-bulkpm/composefile/docker-compose-e2e.yml \
42$WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources/docker-compose/docker-compose-e2e.yml
43cp -rf $WORKSPACE/plans/usecases-5G-bulkpm/5G-bulkpm/assets/cbs_sim/ \
44$WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources/docker-compose/
45cp -rf $WORKSPACE/plans/usecases-5G-bulkpm/5G-bulkpm/assets/dfc/ \
46$WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources/docker-compose/
47cp -rf $WORKSPACE/plans/usecases-5G-bulkpm/5G-bulkpm/assets/pm_mapper_certs/ \
48$WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources/docker-compose/
49
50# Start cbs-sim for pmmapper stability
51docker-compose -f $WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources/docker-compose/docker-compose-e2e.yml up -d cbs-sim
52echo "Starting cbs-sim"
53sleep 10
54
55# Start the rest of the e2e containers
56docker-compose -f $WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources/docker-compose/docker-compose-e2e.yml up -d
57
58# Wait for initialization of the following containers
59for i in 1 2 3 4 5 6 7 8 9 10; do
60 if [[ $(docker inspect --format '{{ .State.Running }}' dmaap-datarouter-node) ]] && \
61 [[ $(docker inspect --format '{{ .State.Running }}' dmaap-datarouter-prov) ]] && \
62 [[ $(docker inspect --format '{{ .State.Running }}' dmaap-dr-prov-mariadb) ]] && \
63 [[ $(docker inspect --format '{{ .State.Running }}' dcaegen2-pm-mapper) ]] && \
64 [[ $(docker inspect --format '{{ .State.Running }}' dcaegen2-datafile-collector) ]]
65 then
66 echo "Data Router service running"
67 break
68 else
69 echo sleep ${i}
70 sleep ${i}
71 fi
72done
73
74# Get IP address of docker-host, dmaap-dr-prov, dmaap-dr-gateway, dmaap-mr and ves collector.
75#HOST_IP=$(ip route get 8.8.8.8 | awk '/8.8.8.8/ {print $7}')
76DR_PROV_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' dmaap-datarouter-prov)
77DR_GATEWAY_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.Gateway}}{{end}}' dmaap-datarouter-prov)
78DMAAP_MR_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' dmaap-message-router-server)
79VESC_IP=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' dcaegen2-vescollector)
80
81# Add gateway IP to DR Prov
82docker 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"
83docker 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"
84
85#Increase DFC Logging
86#docker exec dfc /bin/sh -c " sed -i 's/org.onap.dcaegen2.collectors.datafile: WARN/org.onap.dcaegen2.collectors.datafile: TRACE/g' /opt/app/datafile/config/application.yaml"
87
88# Copy sample PM file to sftp server
89docker cp $WORKSPACE/plans/usecases-5G-bulkpm/5G-bulkpm/assets/A20181002.0000-1000-0015-1000_5G.xml.gz sftp:/home/admin/
90
91# Data Router Configuration:
92# Create default feed on DMaaP data router
93curl -v -X POST -H "Content-Type:application/vnd.dmaap-dr.feed" -H "X-DMAAP-DR-ON-BEHALF-OF:dradmin" \
94--data-ascii @$WORKSPACE/plans/usecases-5G-bulkpm/5G-bulkpm/assets/dmaap_dr/createFeed.json --post301 \
95--location-trusted -k https://${DR_PROV_IP}:8443
96sleep 2
97# Create file consumer subscriber on DMaaP data router
98curl -X POST -H "Content-Type:application/vnd.dmaap-dr.subscription" -H "X-DMAAP-DR-ON-BEHALF-OF:dradmin" \
99--data-ascii @$WORKSPACE/plans/usecases-5G-bulkpm/5G-bulkpm/assets/dmaap_dr/addDefaultSubscriber.json --post301 \
100--location-trusted -k https://${DR_PROV_IP}:8443/subscribe/1
101sleep 2
102# Add PM Mapper subscriber on data router feed
103curl -v -X POST -H "Content-Type:application/vnd.dmaap-dr.subscription" -H "X-DMAAP-DR-ON-BEHALF-OF:pmmapper" \
104--data-ascii @$WORKSPACE/plans/usecases-5G-bulkpm/5G-bulkpm/assets/dmaap_dr/addPmMapperSubscriber.json \
105--post301 --location-trusted -k https://${DR_PROV_IP}:8443/subscribe/1
106
107# Check DMaaP DR provisioning
108curl -k https://${DR_PROV_IP}:8443/internal/prov
109
110# Add necessary python libs
111pip install jsonschema uuid simplejson
112
113# Export necessary vars
114export VESC_IP=${VESC_IP}
115export VESC_PORT=8080
116export DMAAP_MR_IP=${DMAAP_MR_IP}
117
118#Pass any variables required by Robot test suites in ROBOT_VARIABLES
119ROBOT_VARIABLES="-v DR_PROV_IP:${DR_PROV_IP} -v DMAAP_MR_IP:${DMAAP_MR_IP} -v VESC_IP:${VESC_IP} -v VESC_PORT:${VESC_PORT}"