From 9abb61ca2cea1907cab2cec312d6dca6e53a93cd Mon Sep 17 00:00:00 2001 From: Gary Wu Date: Thu, 27 Sep 2018 10:38:50 -0700 Subject: Move CSIT to integration/csit repo To facilite branching of CSIT tests, all CSIT test code and scripts are relocated to the integration/csit repo. Change-Id: I1e4c0eff44691f73f8098b3c52764107f6b8b8df Issue-ID: INT-671 Signed-off-by: Gary Wu --- scripts/dmaap-buscontroller/.mock-aaf.sh.swp | Bin 0 -> 12288 bytes scripts/dmaap-buscontroller/dmaapbc-init.sh | 76 ++++++++++++++++++++++++++ scripts/dmaap-buscontroller/dmaapbc-launch.sh | 34 ++++++++++++ scripts/dmaap-buscontroller/dr-launch.sh | 59 ++++++++++++++++++++ scripts/dmaap-buscontroller/init-mock-aaf.sh | 53 ++++++++++++++++++ scripts/dmaap-buscontroller/init-mock-drps.sh | 17 ++++++ scripts/dmaap-buscontroller/init-mock-mrc.sh | 17 ++++++ scripts/dmaap-buscontroller/onapCSIT.env | 18 ++++++ scripts/dmaap-buscontroller/start-mock.sh | 48 ++++++++++++++++ 9 files changed, 322 insertions(+) create mode 100644 scripts/dmaap-buscontroller/.mock-aaf.sh.swp create mode 100755 scripts/dmaap-buscontroller/dmaapbc-init.sh create mode 100755 scripts/dmaap-buscontroller/dmaapbc-launch.sh create mode 100644 scripts/dmaap-buscontroller/dr-launch.sh create mode 100755 scripts/dmaap-buscontroller/init-mock-aaf.sh create mode 100755 scripts/dmaap-buscontroller/init-mock-drps.sh create mode 100755 scripts/dmaap-buscontroller/init-mock-mrc.sh create mode 100644 scripts/dmaap-buscontroller/onapCSIT.env create mode 100755 scripts/dmaap-buscontroller/start-mock.sh (limited to 'scripts/dmaap-buscontroller') diff --git a/scripts/dmaap-buscontroller/.mock-aaf.sh.swp b/scripts/dmaap-buscontroller/.mock-aaf.sh.swp new file mode 100644 index 00000000..edadfe90 Binary files /dev/null and b/scripts/dmaap-buscontroller/.mock-aaf.sh.swp differ diff --git a/scripts/dmaap-buscontroller/dmaapbc-init.sh b/scripts/dmaap-buscontroller/dmaapbc-init.sh new file mode 100755 index 00000000..804603f2 --- /dev/null +++ b/scripts/dmaap-buscontroller/dmaapbc-init.sh @@ -0,0 +1,76 @@ +#!/bin/bash + +# $1 is the IP address of the buscontroller +# $2 is the IP address of the DRPS +# $3 is the IP address of the MRC +# $4 is the protocol (defaults to http) + +PROTO=${4:-http} +if [ "$PROTO" = "http" ] +then + PORT=8080 + CURLOPT="-v" + MRPORT=3904 + DRPORT=8080 +else + PORT=8443 + CURLOPT="-v -k" + MRPORT=3905 + DRPORT=8443 +fi + +# INITIALIZE: dmaap object +JSON=/tmp/$$.dmaap +cat << EOF > $JSON +{ + "version": "1", + "topicNsRoot": "org.onap.dmaap", + "drProvUrl": "${PROTO}://dmaap-dr-prov:${DRPORT}", + "dmaapName": "onapCSIT", + "bridgeAdminTopic": "MM_AGENT_PROV" + +} +EOF + +echo "Initializing /dmaap endpoint" +curl ${CURLOPT} -X POST -d @${JSON} -H "Content-Type: application/json" ${PROTO}://$1:${PORT}/webapi/dmaap + + + +# INITIALIZE: dcaeLocation object +JSON=/tmp/$$.loc +cat << EOF > $JSON +{ + "dcaeLocationName": "csit-sanfrancisco", + "dcaeLayer": "central-cloud", + "clli": "CSIT12345", + "zone": "zoneA" + +} +EOF + +echo "Initializing /dcaeLocations endpoint" +curl ${CURLOPT} -X POST -d @${JSON} -H "Content-Type: application/json" ${PROTO}://$1:${PORT}/webapi/dcaeLocations + + +# INITIALIZE: MR object in 1 site +# since MR is currently deployed via docker-compose, its IP doesn't seem +# to be routable from DBCL. Fortunately, the MR port is mapped from the docker bridge IP address. +# Found this article for how to deterine the docker bridge IP so using it as a workaround. +# https://stackoverflow.com/questions/22944631/how-to-get-the-ip-address-of-the-docker-host-from-inside-a-docker-container +# Used the following snippet found buried in a comment to an answer and then modified for only 1 value. +DOCKER_HOST=$(ip -4 addr show docker0 | grep -Po 'inet \K[\d.]+' | head -1 ) +# Perhaps there is a better way... +JSON=/tmp/$$.mrc +cat << EOF > $JSON +{ + "dcaeLocationName": "csit-sanfrancisco", + "fqdn": "$DOCKER_HOST", + "topicProtocol" : "http", + "topicPort": "${MRPORT}" + +} +EOF + +echo "Initializing /mr_clusters endpoint" +curl ${CURLOPT} -X POST -d @${JSON} -H "Content-Type: application/json" ${PROTO}://$1:${PORT}/webapi/mr_clusters diff --git a/scripts/dmaap-buscontroller/dmaapbc-launch.sh b/scripts/dmaap-buscontroller/dmaapbc-launch.sh new file mode 100755 index 00000000..317c17f1 --- /dev/null +++ b/scripts/dmaap-buscontroller/dmaapbc-launch.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +# script to launch DMaaP buscontroller docker container +# sets global var IP with assigned IP address + +function dmaapbc_launch() { + TAG="nexus3.onap.org:10001/onap/dmaap/buscontroller" + CONTAINER_NAME=dmaapbc + IP="" + + cd ${WORKSPACE}/test/csit/scripts/dmaap-buscontroller + + TMP_CFG=/tmp/docker-databus-controller.conf + . ./onapCSIT.env > $TMP_CFG + ADDHOSTS="" + if [ ! -z "$2" ] + then + ADDHOSTS="$ADDHOSTS --add-host=message-router:$2" + fi + if [ ! -z "$3" ] + then + ADDHOSTS="$ADDHOSTS --add-host=dmaap-dr-prov:$3" + fi + docker run -d $ADDHOSTS --name $CONTAINER_NAME -v $TMP_CFG:/opt/app/config/conf $TAG + IP=`get-instance-ip.sh ${CONTAINER_NAME}` + + # Wait for initialization + for i in {1..10}; do + curl -sS ${IP}:8080 && break + echo sleep $i + sleep $i + done + +} diff --git a/scripts/dmaap-buscontroller/dr-launch.sh b/scripts/dmaap-buscontroller/dr-launch.sh new file mode 100644 index 00000000..abc0aae8 --- /dev/null +++ b/scripts/dmaap-buscontroller/dr-launch.sh @@ -0,0 +1,59 @@ + +#!/bin/bash + +#!/bin/bash + +# script to launch DMaaP DR docker containers +# sets global var IP with assigned IP address of DR Prov + +function dmaap_dr_launch() { + IP="" + + + # This next section was copied from scripts/dmaap-datarouter/dr-suite/setup.sh + # and slightly modified... + + # Clone DMaaP Data Router repo + mkdir -p $WORKSPACE/archives/dmaapdr + cd $WORKSPACE/archives/dmaapdr + + git clone --depth 1 https://gerrit.onap.org/r/dmaap/datarouter -b master + cd datarouter + git pull + cd $WORKSPACE/archives/dmaapdr/datarouter/docker-compose/ + + sed -i 's/10003/10001/g' docker-compose.yml + # start DMaaP DR containers with docker compose and configuration from docker-compose.yml + docker login -u docker -p docker nexus3.onap.org:10001 + docker-compose up -d + + # Wait for initialization of Docker container for datarouter-node, datarouter-prov and mariadb + for i in {1..50}; do + if [ $(docker inspect --format '{{ .State.Running }}' datarouter-node) ] && \ + [ $(docker inspect --format '{{ .State.Running }}' datarouter-prov) ] && \ + [ $(docker inspect --format '{{ .State.Running }}' mariadb) ] + then + echo "DR Service Running" + break + else + echo sleep $i + sleep $i + fi + done + + DR_PROV_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' datarouter-prov) + DR_NODE_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' datarouter-node) + DR_GATEWAY_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.Gateway}}{{end}}' datarouter-prov) + + echo DR_PROV_IP=${DR_PROV_IP} + echo DR_NODE_IP=${DR_NODE_IP} + echo DR_GATEWAY_IP=${DR_GATEWAY_IP} + + 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" + 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" + + #Pass any variables required by Robot test suites in ROBOT_VARIABLES + ROBOT_VARIABLES="-v DR_PROV_IP:${DR_PROV_IP} -v DR_NODE_IP:${DR_NODE_IP}" + + IP=${DR_GATEWAY_IP} +} diff --git a/scripts/dmaap-buscontroller/init-mock-aaf.sh b/scripts/dmaap-buscontroller/init-mock-aaf.sh new file mode 100755 index 00000000..f25404ce --- /dev/null +++ b/scripts/dmaap-buscontroller/init-mock-aaf.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +# $1 is the IP address of the AAF mock server + +#curl -v -X PUT -d @- http://$1:1080/expectation << EOF +#{ +# "httpRequest": { +# "method": "GET", +# "path": "/hello" +# }, +# "httpResponse": { +# "body": "Hello world!", +# "statusCode": 200 +# }, +# "times" : { +# "unlimited" : true +# } +#} +#EOF +# "httpRequest": { +# "method": "POST", +# "path": "/proxy/authz/.*" +# }, + +curl -v -X PUT -d @- http://$1:1080/expectation << EOF +{ + "httpRequest": { + "method": ".*", + "path": "/.*" + }, + "httpResponse": { + "body": "Hello world!", + "statusCode": 200 + }, + "times" : { + "unlimited" : true + } +} +EOF + +#curl -v -X PUT -d @- http://$1:1080/expectation << EOF +#{ +# "httpRequest": { +# "method": "POST", +# "path": "/proxy/authz/role/perm" +# }, +# "httpResponse": { +# "body": "Hello world!", +# "statusCode": 200 +# } +#} +#EOF + diff --git a/scripts/dmaap-buscontroller/init-mock-drps.sh b/scripts/dmaap-buscontroller/init-mock-drps.sh new file mode 100755 index 00000000..e0f1d0f1 --- /dev/null +++ b/scripts/dmaap-buscontroller/init-mock-drps.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +# $1 is the IP address of the DRPS (Data Router Provisioning Server) mock server + +curl -v -X PUT -d @- http://$1:1080/expectation << EOF +{ + "httpRequest": { + "method": "GET", + "path": "/hello" + }, + "httpResponse": { + "body": "Hello world!", + "statusCode": 200 + } +} +EOF + diff --git a/scripts/dmaap-buscontroller/init-mock-mrc.sh b/scripts/dmaap-buscontroller/init-mock-mrc.sh new file mode 100755 index 00000000..75c1a419 --- /dev/null +++ b/scripts/dmaap-buscontroller/init-mock-mrc.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +# $1 is the IP address of the MRC (MR Central) mock server + +curl -v -X PUT -d @- http://$1:1080/expectation << EOF +{ + "httpRequest": { + "method": "GET", + "path": "/hello" + }, + "httpResponse": { + "body": "Hello world!", + "statusCode": 200 + } +} +EOF + diff --git a/scripts/dmaap-buscontroller/onapCSIT.env b/scripts/dmaap-buscontroller/onapCSIT.env new file mode 100644 index 00000000..db865818 --- /dev/null +++ b/scripts/dmaap-buscontroller/onapCSIT.env @@ -0,0 +1,18 @@ +#!/bin/bash +# +# environment settings for Dmaap Bus Controller Integration Test. +# assumes args are: +# $1 - FQDN of AAF server +# $2 - FQDN of MR server +# $3 - FQDN of DRPS Server +# Only need to set values where defaults aren't appropriate +# +cat <