Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # Place the scripts in run order: |
| 3 | source ${SCRIPTS}/common_functions.sh |
| 4 | |
LiamBurke | a451619 | 2019-02-11 12:28:55 +0000 | [diff] [blame] | 5 | CSIT=TRUE |
| 6 | if [ ${CSIT} = "TRUE" ] ; then |
| 7 | #################################################### |
| 8 | #Executes the below setup in an Docker Environment # |
| 9 | #################################################### |
| 10 | |
| 11 | echo "CSIT Test get executed in here" |
| 12 | SFTP_PORT=22 |
| 13 | VESC_PORT=8080 |
| 14 | export VESC_PORT=${VESC_PORT} |
| 15 | export CLI_EXEC_CLI_DFC="docker exec dfc /bin/sh -c \"ls /target | grep .gz\"" |
| 16 | |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 17 | # Clone DMaaP Message Router repo |
| 18 | mkdir -p $WORKSPACE/archives/dmaapmr |
| 19 | cd $WORKSPACE/archives/dmaapmr |
| 20 | git clone --depth 1 http://gerrit.onap.org/r/dmaap/messagerouter/messageservice -b master |
LiamBurke | ae583be | 2018-10-16 10:44:12 +0000 | [diff] [blame] | 21 | sed -i 's/enableCadi: false/enableCadi: "false"/g' /$WORKSPACE/archives/dmaapmr/messageservice/src/main/resources/docker-compose/docker-compose.yml |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 22 | cd $WORKSPACE/archives/dmaapmr/messageservice/src/main/resources/docker-compose |
| 23 | cp $WORKSPACE/archives/dmaapmr/messageservice/bundleconfig-local/etc/appprops/MsgRtrApi.properties /var/tmp/ |
| 24 | |
| 25 | # start DMaaP MR containers with docker compose and configuration from docker-compose.yml |
| 26 | docker login -u docker -p docker nexus3.onap.org:10001 |
| 27 | docker-compose up -d |
| 28 | |
| 29 | ZOOKEEPER=$(docker ps -a -q --filter="name=zookeeper_1") |
| 30 | KAFKA=$(docker ps -a -q --filter="name=kafka_1") |
| 31 | DMAAP=$(docker ps -a -q --filter="name=dmaap_1") |
| 32 | |
| 33 | # Wait for initialization of Docker contaienr for DMaaP MR, Kafka and Zookeeper |
LiamBurke | f708f84 | 2018-10-10 09:26:26 +0000 | [diff] [blame] | 34 | for i in {1..10}; do |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 35 | if [ $(docker inspect --format '{{ .State.Running }}' $KAFKA) ] && \ |
| 36 | [ $(docker inspect --format '{{ .State.Running }}' $ZOOKEEPER) ] && \ |
| 37 | [ $(docker inspect --format '{{ .State.Running }}' $DMAAP) ] |
| 38 | then |
| 39 | echo "DMaaP Service Running" |
| 40 | break |
| 41 | else |
| 42 | echo sleep $i |
| 43 | sleep $i |
| 44 | fi |
| 45 | done |
| 46 | |
| 47 | # Get IP address of DMAAP, KAFKA, Zookeeper |
| 48 | KAFKA_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $KAFKA) |
| 49 | ZOOKEEPER_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $ZOOKEEPER) |
| 50 | DMAAP_MR_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $DMAAP) |
| 51 | |
| 52 | sleep 2 |
| 53 | # Shutdown DMAAP Container |
| 54 | docker kill $DMAAP |
| 55 | |
| 56 | # Initial docker-compose up and down is for populating kafka and zookeeper IPs in /var/tmp/MsgRtrApi.properites |
| 57 | sed -i -e '/config.zk.servers=/ s/=.*/='$ZOOKEEPER_IP'/' /var/tmp/MsgRtrApi.properties |
| 58 | sed -i -e '/kafka.metadata.broker.list=/ s/=.*/='$KAFKA_IP':9092/' /var/tmp/MsgRtrApi.properties |
| 59 | |
| 60 | # Start DMaaP MR containers with docker compose and configuration from docker-compose.yml |
| 61 | docker login -u docker -p docker nexus3.onap.org:10001 |
| 62 | docker-compose up -d |
| 63 | sleep 5 |
| 64 | |
| 65 | # Clone DMaaP Data Router repo |
| 66 | mkdir -p $WORKSPACE/archives/dmaapdr |
| 67 | cd $WORKSPACE/archives/dmaapdr |
| 68 | git clone --depth 1 https://gerrit.onap.org/r/dmaap/datarouter -b master |
LiamBurke | 1344ef2 | 2018-10-19 15:22:16 +0000 | [diff] [blame] | 69 | cd $WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources |
| 70 | mkdir docker-compose |
| 71 | cd $WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources/docker-compose |
| 72 | cp $WORKSPACE/plans/usecases/5G-bulkpm/composefile/docker-compose-e2e.yml $WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources/docker-compose/docker-compose.yml |
| 73 | |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 74 | docker login -u docker -p docker nexus3.onap.org:10001 |
| 75 | docker-compose up -d |
LiamBurke | ca7df55 | 2018-10-26 13:57:21 +0000 | [diff] [blame] | 76 | echo "Disregard the message ERROR: for datarouter-node Container 1234456 is unhealthy, this is expected behaiour at this stage" |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 77 | docker kill datarouter-prov |
| 78 | docker kill datarouter-node |
| 79 | docker kill vescollector |
| 80 | HOST_IP=$(ip route get 8.8.8.8 | awk '/8.8.8.8/ {print $NF}') |
| 81 | sed -i -e '/DMAAPHOST:/ s/:.*/: '$HOST_IP'/' docker-compose.yml |
| 82 | MARIADB=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' mariadb ) |
LiamBurke | 1344ef2 | 2018-10-19 15:22:16 +0000 | [diff] [blame] | 83 | sed -i 's/datarouter-mariadb/'$MARIADB'/g' $WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources/prov_data/provserver.properties |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 84 | docker-compose up -d |
| 85 | |
| 86 | # Wait for initialization of Docker container for datarouter-node, datarouter-prov and mariadb |
LiamBurke | f708f84 | 2018-10-10 09:26:26 +0000 | [diff] [blame] | 87 | for i in {1..10}; do |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 88 | if [ $(docker inspect --format '{{ .State.Running }}' datarouter-node) ] && \ |
| 89 | [ $(docker inspect --format '{{ .State.Running }}' datarouter-prov) ] && \ |
| 90 | [ $(docker inspect --format '{{ .State.Running }}' mariadb) ] |
| 91 | then |
| 92 | echo "DR Service Running" |
| 93 | break |
| 94 | else |
| 95 | echo sleep $i |
| 96 | sleep $i |
| 97 | fi |
| 98 | done |
| 99 | |
| 100 | sleep 5 |
| 101 | |
| 102 | # Get IP address of datarrouger-prov, datarouter-node, fileconsumer-node. |
| 103 | DR_PROV_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' datarouter-prov) |
| 104 | DR_NODE_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' datarouter-node) |
| 105 | DR_SUBSCIBER_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' fileconsumer-node) |
| 106 | DR_GATEWAY_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.Gateway}}{{end}}' datarouter-prov) |
| 107 | |
| 108 | echo DR_PROV_IP=${DR_PROV_IP} |
| 109 | echo DR_NODE_IP=${DR_NODE_IP} |
| 110 | echo DR_GATEWAY_IP=${DR_GATEWAY_IP} |
| 111 | echo DR_SUBSCIBER_IP=${DR_SUBSCIBER_IP} |
| 112 | |
| 113 | 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" |
| 114 | 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" |
| 115 | docker exec datarouter-prov /bin/sh -c "echo '${DR_NODE_IP}' dmaap-dr-node >> /etc/hosts" |
| 116 | docker exec datarouter-node /bin/sh -c "echo '${DR_PROV_IP}' dmaap-dr-prov >> /etc/hosts" |
| 117 | docker exec datarouter-node /bin/sh -c "echo '${DR_SUBSCIBER_IP}' dmaap-dr-subscriber >> /etc/hosts" |
| 118 | |
| 119 | # Get IP address of DMAAP, KAFKA, Zookeeper |
| 120 | DMAAP_MR_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $DMAAP) |
| 121 | KAFKA_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $KAFKA) |
| 122 | ZOOKEEPER_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $ZOOKEEPER) |
| 123 | VESC_IP=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' vescollector) |
| 124 | SFTP_IP=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' sftp) |
| 125 | |
| 126 | export VESC_IP=${VESC_IP} |
| 127 | export HOST_IP=${HOST_IP} |
| 128 | export DMAAP_MR_IP=${DMAAP_MR_IP} |
| 129 | |
| 130 | #Pass any variables required by Robot test suites in ROBOT_VARIABLES |
LiamBurke | a451619 | 2019-02-11 12:28:55 +0000 | [diff] [blame] | 131 | ROBOT_VARIABLES="-v DR_PROV_IP:${DR_PROV_IP} -v DR_NODE_IP:${DR_NODE_IP} -v DMAAP_MR_IP:${DMAAP_MR_IP} -v VESC_IP:${VESC_IP} -v VESC_PORT:${VESC_PORT} -v DR_SUBSCIBER_IP:${DR_SUBSCIBER_IP}" |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 132 | |
| 133 | pip install jsonschema uuid |
| 134 | # Wait container ready |
| 135 | sleep 2 |
| 136 | |
| 137 | # Data File Collector configuration : |
LiamBurke | 0df2e44 | 2019-02-07 12:12:07 +0000 | [diff] [blame] | 138 | docker cp dfc:/config/datafile_endpoints.json /tmp/ |
| 139 | echo data_endpoints.json from DFC containter |
| 140 | cat /tmp/datafile_endpoints.json |
Gary Wu | 13111e9 | 2018-09-27 11:31:33 -0700 | [diff] [blame] | 141 | cp $WORKSPACE/plans/usecases/5G-bulkpm/assets/datafile_endpoints.json /tmp/ |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 142 | sed -i 's/dmaapmrhost/'${DMAAP_MR_IP}'/g' /tmp/datafile_endpoints.json |
| 143 | sed -i 's/dmaapdrhost/'${DR_PROV_IP}'/g' /tmp/datafile_endpoints.json |
LiamBurke | 0df2e44 | 2019-02-07 12:12:07 +0000 | [diff] [blame] | 144 | echo data_endpoints.json copied onto the DFC containter |
| 145 | cat /tmp/datafile_endpoints.json |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 146 | docker cp /tmp/datafile_endpoints.json dfc:/config/ |
LiamBurke | ca7df55 | 2018-10-26 13:57:21 +0000 | [diff] [blame] | 147 | #Increase Logging |
| 148 | docker exec dfc /bin/sh -c " sed -i 's/org.onap.dcaegen2.collectors.datafile: ERROR/org.onap.dcaegen2.collectors.datafile: TRACE/g' /config/application.yaml" |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 149 | docker restart dfc |
rajendrajaiswal | a2c1ca2 | 2018-09-30 16:42:27 +0100 | [diff] [blame] | 150 | docker exec dfc /bin/sh -c "echo '${DR_NODE_IP}' dmaap-dr-node >> /etc/hosts" |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 151 | |
| 152 | # SFTP Configuration: |
| 153 | # Update the File Ready Notification with actual sftp ip address and copy pm files to sftp server. |
rajendrajaiswal | 0d357f3 | 2018-09-28 10:18:19 +0100 | [diff] [blame] | 154 | cp $WORKSPACE/tests/usecases/5G-bulkpm/assets/json_events/FileExistNotification.json $WORKSPACE/tests/usecases/5G-bulkpm/assets/json_events/FileExistNotificationUpdated.json |
Gary Wu | 13111e9 | 2018-09-27 11:31:33 -0700 | [diff] [blame] | 155 | sed -i 's/sftpserver/'${SFTP_IP}'/g' $WORKSPACE/tests/usecases/5G-bulkpm/assets/json_events/FileExistNotificationUpdated.json |
LiamBurke | a451619 | 2019-02-11 12:28:55 +0000 | [diff] [blame] | 156 | sed -i 's/sftpport/'${SFTP_PORT}'/g' $WORKSPACE/tests/usecases/5G-bulkpm/assets/json_events/FileExistNotificationUpdated.json |
Gary Wu | 13111e9 | 2018-09-27 11:31:33 -0700 | [diff] [blame] | 157 | docker cp $WORKSPACE/plans/usecases/5G-bulkpm/assets/xNF.pm.xml.gz sftp:/home/admin/ |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 158 | |
| 159 | # Data Router Configuration: |
| 160 | # Create default feed and create file consumer subscriber on data router |
egernug | 6f2874b | 2019-02-06 15:16:54 +0000 | [diff] [blame] | 161 | curl -v -X POST -H "Content-Type:application/vnd.dmaap-dr.feed" -H "X-DMAAP-DR-ON-BEHALF-OF:dradmin" --data-ascii @$WORKSPACE/plans/usecases/5G-bulkpm/assets/createFeed.json --post301 --location-trusted -k https://${DR_PROV_IP}:8443 |
Gary Wu | 13111e9 | 2018-09-27 11:31:33 -0700 | [diff] [blame] | 162 | cp $WORKSPACE/plans/usecases/5G-bulkpm/assets/addSubscriber.json /tmp/addSubscriber.json |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 163 | sed -i 's/fileconsumer/'${DR_SUBSCIBER_IP}'/g' /tmp/addSubscriber.json |
egernug | 6f2874b | 2019-02-06 15:16:54 +0000 | [diff] [blame] | 164 | curl -v -X POST -H "Content-Type:application/vnd.dmaap-dr.subscription" -H "X-DMAAP-DR-ON-BEHALF-OF:dradmin" --data-ascii @/tmp/addSubscriber.json --post301 --location-trusted -k https://${DR_PROV_IP}:8443/subscribe/1 |
rajendrajaiswal | b99eedc | 2018-10-02 09:42:23 +0100 | [diff] [blame] | 165 | sleep 10 |
LiamBurke | f708f84 | 2018-10-10 09:26:26 +0000 | [diff] [blame] | 166 | curl -k https://$DR_PROV_IP:8443/internal/prov |
LiamBurke | a451619 | 2019-02-11 12:28:55 +0000 | [diff] [blame] | 167 | |
| 168 | else |
| 169 | ############################################################ |
| 170 | ############################################################ |
| 171 | # Executes the below setup in an ONAP Environment # |
| 172 | # Make sure the steps in the README are completed first !! # |
| 173 | ############################################################ |
| 174 | ############################################################ |
| 175 | SFTP_PORT=2222 |
| 176 | |
| 177 | cp $WORKSPACE/plans/usecases/5G-bulkpm/teardown.sh $WORKSPACE/plans/usecases/5G-bulkpm/teardown.sh.orig |
| 178 | cp $WORKSPACE/plans/usecases/5G-bulkpm/onap.teardown.sh $WORKSPACE/plans/usecases/5G-bulkpm/teardown.sh |
| 179 | |
| 180 | #Get DataFileCollector POD name in this ONAP Deployment |
| 181 | DFC_POD=$(kubectl -n onap get pods | grep datafile-collector | awk '{print $1}') |
| 182 | export DFC_POD=${DFC_POD} |
| 183 | export CLI_EXEC_CLI_DFC="kubectl exec -n onap ${DFC_POD} -it ls /target | grep .gz" |
| 184 | |
| 185 | # Get IP address of datarrouter-prov |
| 186 | DR_PROV_IP=$(kubectl -n onap -o wide get pods | grep dmaap-dr-prov | awk '{print $6}') |
| 187 | echo DR_PROV_IP=${DR_PROV_IP} |
| 188 | DR_NODE_IP=$(kubectl -n onap -o=wide get pods | grep dmaap-dr-node | awk '{print $6}') |
| 189 | echo DR_NODE_IP=${DR_NODE_IP} |
| 190 | |
| 191 | # Get IP address of exposed Ves and its port |
| 192 | DMAAP_MR_IP=$(kubectl -n onap -o=wide get pods | grep dev-dmaap-message-router | grep -Ev "kafka|zookeeper" | awk '{print $6}') |
| 193 | VESC_IP=$(kubectl get svc -n onap | grep vesc | awk '{print $4}') |
| 194 | VESC_PORT=$(kubectl get svc -n onap | grep vesc | awk '{print $5}' | cut -d ":" -f2 | cut -d "/" -f1) |
| 195 | echo VESC_IP=${VESC_IP} |
| 196 | echo VESC_PORT=${VESC_PORT} |
| 197 | |
| 198 | export VESC_IP=${VESC_IP} |
| 199 | export VESC_PORT=${VESC_PORT} |
| 200 | export HOST_IP=${HOST_IP} |
| 201 | export DMAAP_MR_IP=${DMAAP_MR_IP} |
| 202 | |
| 203 | #Get DataFileCollector POD name in this ONAP Deployment |
| 204 | DFC_POD=$(kubectl -n onap get pods | grep datafile-collector | awk '{print $1}') |
| 205 | export DFC_POD=${DFC_POD} |
| 206 | |
| 207 | pip install jsonschema uuid |
| 208 | |
| 209 | # Clone DMaaP Data Router repo |
| 210 | mkdir -p $WORKSPACE/archives/dmaapdr |
| 211 | cd $WORKSPACE/archives/dmaapdr |
| 212 | git clone --depth 1 https://gerrit.onap.org/r/dmaap/datarouter -b master |
| 213 | cd $WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources |
| 214 | mkdir docker-compose |
| 215 | cd $WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources/docker-compose |
| 216 | cp $WORKSPACE/plans/usecases/5G-bulkpm/composefile/onap.docker-compose-e2e $WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources/docker-compose/docker-compose.yml |
| 217 | |
| 218 | #Statup the SFTP and FileConsumer containers. |
| 219 | docker login -u docker -p docker nexus3.onap.org:10001 |
| 220 | docker-compose up -d |
| 221 | |
| 222 | # Wait container ready |
| 223 | sleep 2 |
| 224 | HOST_IP=$(ip route get 8.8.8.8 | awk '/8.8.8.8/ {print $NF}') |
| 225 | # SFTP Configuration: |
| 226 | # Update the File Ready Notification with actual sftp ip address and copy pm files to sftp server. |
| 227 | cp $WORKSPACE/tests/usecases/5G-bulkpm/assets/json_events/FileExistNotification.json $WORKSPACE/tests/usecases/5G-bulkpm/assets/json_events/FileExistNotificationUpdated.json |
| 228 | sed -i 's/sftpserver/'${HOST_IP}'/g' $WORKSPACE/tests/usecases/5G-bulkpm/assets/json_events/FileExistNotificationUpdated.json |
| 229 | sed -i 's/sftpport/'${SFTP_PORT}'/g' $WORKSPACE/tests/usecases/5G-bulkpm/assets/json_events/FileExistNotificationUpdated.json |
| 230 | docker cp $WORKSPACE/plans/usecases/5G-bulkpm/assets/xNF.pm.xml.gz sftp:/home/admin/ |
| 231 | |
| 232 | # Create default feed and create file consumer subscriber on data router |
| 233 | curl -v -X POST -H "Content-Type:application/vnd.att-dr.feed" -H "X-ATT-DR-ON-BEHALF-OF:dradmin" --data-ascii @$WORKSPACE/plans/usecases/5G-bulkpm/assets/createFeed.json --post301 --location-trusted -k https://${DR_PROV_IP}:8443 |
| 234 | cp $WORKSPACE/plans/usecases/5G-bulkpm/assets/addSubscriber.json /tmp/addSubscriber.json |
| 235 | sed -i 's/fileconsumer/'${HOST_IP}'/g' /tmp/addSubscriber.json |
| 236 | curl -v -X POST -H "Content-Type:application/vnd.att-dr.subscription" -H "X-ATT-DR-ON-BEHALF-OF:dradmin" --data-ascii @/tmp/addSubscriber.json --post301 --location-trusted -k https://${DR_PROV_IP}:8443/subscribe/1 |
| 237 | sleep 10 |
| 238 | curl -k https://$DR_PROV_IP:8443/internal/prov |
| 239 | |
| 240 | #Pass any variables required by Robot test suites in ROBOT_VARIABLES |
| 241 | ROBOT_VARIABLES="-v DR_PROV_IP:${DR_PROV_IP} -v DR_NODE_IP:${DR_NODE_IP} -v DMAAP_MR_IP:${DMAAP_MR_IP} -v VESC_IP:${VESC_IP} -v VESC_PORT:${VESC_PORT} -v DR_SUBSCIBER_IP:${DR_SUBSCIBER_IP} -v DFC_POD:${DFC_POD} -v HOST_IP:${HOST_IP} " |
| 242 | |
| 243 | fi; |