blob: 8cb3d9f8865ec753601f42ae6e74ac5169e58bc0 [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
Remigiusz Janeczek92dff7d2020-07-15 15:22:57 +020081#Add SFTP server pubilc key to known hosts of datafile collector
82HOST_NAMES=$(docker inspect -f '{{ range .NetworkSettings.Networks}}{{join .Aliases ","}}{{end}}' sftp)
83KEY_ENTRY=$(echo $HOST_NAMES "$(docker exec sftp cat /etc/ssh/ssh_host_rsa_key.pub)" | sed -e 's/\w*@\w*$//')
84docker exec -i -u root dcaegen2-datafile-collector sh -c "echo $KEY_ENTRY >> /home/datafile/.ssh/known_hosts"
85
efiacor125390b2020-05-06 01:14:00 +010086# Add gateway IP to DR Prov
87docker 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"
88docker 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"
89
90#Increase DFC Logging
91#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"
92
93# Copy sample PM file to sftp server
94docker cp $WORKSPACE/plans/usecases-5G-bulkpm/5G-bulkpm/assets/A20181002.0000-1000-0015-1000_5G.xml.gz sftp:/home/admin/
95
96# Data Router Configuration:
97# Create default feed on DMaaP data router
98curl -v -X POST -H "Content-Type:application/vnd.dmaap-dr.feed" -H "X-DMAAP-DR-ON-BEHALF-OF:dradmin" \
99--data-ascii @$WORKSPACE/plans/usecases-5G-bulkpm/5G-bulkpm/assets/dmaap_dr/createFeed.json --post301 \
100--location-trusted -k https://${DR_PROV_IP}:8443
101sleep 2
102# Create file consumer subscriber on DMaaP data router
103curl -X POST -H "Content-Type:application/vnd.dmaap-dr.subscription" -H "X-DMAAP-DR-ON-BEHALF-OF:dradmin" \
104--data-ascii @$WORKSPACE/plans/usecases-5G-bulkpm/5G-bulkpm/assets/dmaap_dr/addDefaultSubscriber.json --post301 \
105--location-trusted -k https://${DR_PROV_IP}:8443/subscribe/1
106sleep 2
107# Add PM Mapper subscriber on data router feed
108curl -v -X POST -H "Content-Type:application/vnd.dmaap-dr.subscription" -H "X-DMAAP-DR-ON-BEHALF-OF:pmmapper" \
109--data-ascii @$WORKSPACE/plans/usecases-5G-bulkpm/5G-bulkpm/assets/dmaap_dr/addPmMapperSubscriber.json \
110--post301 --location-trusted -k https://${DR_PROV_IP}:8443/subscribe/1
111
112# Check DMaaP DR provisioning
113curl -k https://${DR_PROV_IP}:8443/internal/prov
114
115# Add necessary python libs
116pip install jsonschema uuid simplejson
117
118# Export necessary vars
119export VESC_IP=${VESC_IP}
120export VESC_PORT=8080
121export DMAAP_MR_IP=${DMAAP_MR_IP}
122
123#Pass any variables required by Robot test suites in ROBOT_VARIABLES
Remigiusz Janeczek92dff7d2020-07-15 15:22:57 +0200124ROBOT_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}"