diff options
Diffstat (limited to 'test')
80 files changed, 2328 insertions, 111 deletions
diff --git a/test/csit/plans/aai/resources/testplan.txt b/test/csit/plans/aai/resources/testplan.txt index 444104f94..79fc6d3d3 100644 --- a/test/csit/plans/aai/resources/testplan.txt +++ b/test/csit/plans/aai/resources/testplan.txt @@ -1,3 +1,5 @@ # Test suites are relative paths under [integration.git]/test/csit/tests/. # Place the suites in run order. -aai/resources/suite1 +aai/resources/api_suite +aai/resources/relationship_suite +aai/resources/error_handling_suite diff --git a/test/csit/plans/holmes-rule-management/sanity-check/setup.sh b/test/csit/plans/holmes-rule-management/sanity-check/setup.sh index cbe107c16..681a9e789 100644 --- a/test/csit/plans/holmes-rule-management/sanity-check/setup.sh +++ b/test/csit/plans/holmes-rule-management/sanity-check/setup.sh @@ -17,7 +17,7 @@ # Place the scripts in run order: # Download and start MySQL -docker pull postgresql:9.5 +docker pull postgres:9.5 docker run --name postgres-holmes -p 5432:5432 -e POSTGRES_USER=holmes -e POSTGRES_PASSWORD=holmespwd -d postgres:9.5 DB_IP=`get-instance-ip.sh postgres-holmes` echo DB_IP=${DB_IP} @@ -26,7 +26,7 @@ echo DB_IP=${DB_IP} docker login -u docker -p docker nexus3.onap.org:10001 # Start MSB -docker run -d -p 8500:8500 --name msb_consul nexus3.onap.org:10001/onap/msb/msb_base +docker run -d -p 8500:8500 --name msb_consul consul CONSUL_IP=`get-instance-ip.sh msb_consul` echo CONSUL_IP=${CONSUL_IP} docker run -d -p 10081:10081 -e CONSUL_IP=$CONSUL_IP --name msb_discovery nexus3.onap.org:10001/onap/msb/msb_discovery @@ -37,7 +37,7 @@ MSB_IP=`get-instance-ip.sh msb_internal_apigateway` echo MSB_IP=${MSB_IP} # Start rulemgt -source ${SCRIPTS}/holmes/rule-management/startup.sh i-rulemgt ${DB_IP} ${MSB_IP} 80 +source ${SCRIPTS}/holmes/rule-management/startup.sh i-rulemgt ${DB_IP} ${MSB_IP} 1 RULEMGT_IP=`get-instance-ip.sh i-rulemgt` echo RULEMGT_IP=${RULEMGT_IP} @@ -49,7 +49,7 @@ for i in {1..20}; do done # Start engine-d -source ${SCRIPTS}/holmes/engine-management/startup.sh i-engine-d ${DB_IP} ${MSB_IP} 80 +source ${SCRIPTS}/holmes/engine-management/startup.sh i-engine-d ${DB_IP} ${MSB_IP} 1 ENGINE_D_IP=`get-instance-ip.sh i-engine-d` echo ENGINE_D_IP=${ENGINE_D_IP} diff --git a/test/csit/plans/integration/vCPE/setup.sh b/test/csit/plans/integration/vCPE/setup.sh new file mode 100755 index 000000000..1b9cc343d --- /dev/null +++ b/test/csit/plans/integration/vCPE/setup.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# +# Copyright 2016-2017 Huawei Technologies Co., Ltd. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Place the scripts in run order: + +# Pass any variables required by Robot test suites in ROBOT_VARIABLES +ROBOT_VARIABLES="" + diff --git a/test/csit/plans/integration/vCPE/teardown.sh b/test/csit/plans/integration/vCPE/teardown.sh new file mode 100755 index 000000000..8beb6e1f9 --- /dev/null +++ b/test/csit/plans/integration/vCPE/teardown.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# +# Copyright 2016-2017 Huawei Technologies Co., Ltd. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + + diff --git a/test/csit/plans/integration/vCPE/testplan.txt b/test/csit/plans/integration/vCPE/testplan.txt new file mode 100644 index 000000000..2b3d4ad5d --- /dev/null +++ b/test/csit/plans/integration/vCPE/testplan.txt @@ -0,0 +1,3 @@ +# Test suites are relative paths under [integration.git]/test/csit/tests/. +# Place the suites in run order. +integration/vCPE diff --git a/test/csit/plans/msb/iag-redirect-discovery/setup.sh b/test/csit/plans/msb/iag-redirect-discovery/setup.sh new file mode 100644 index 000000000..e14c28fe6 --- /dev/null +++ b/test/csit/plans/msb/iag-redirect-discovery/setup.sh @@ -0,0 +1,55 @@ +#!/bin/bash +# +# Copyright 2017 ZTE, Inc. and others. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +source ${SCRIPTS}/common_functions.sh + +#start msb +docker run -d -p 8500:8500 --name msb_consul consul +MSB_CONSUL_IP=`get-instance-ip.sh msb_consul` +echo MSB_CONSUL_IP=${MSB_CONSUL_IP} + +docker run -d -p 10081:10081 -e CONSUL_IP=$MSB_CONSUL_IP --name msb_discovery nexus3.onap.org:10001/onap/msb/msb_discovery +MSB_DISCOVERY_IP=`get-instance-ip.sh msb_discovery` +echo DISCOVERY_IP=${MSB_DISCOVERY_IP} + +docker run -d -p 80:80 -e CONSUL_IP=$MSB_CONSUL_IP -e SDCLIENT_IP=$MSB_DISCOVERY_IP -e "ROUTE_LABELS=visualRange:1" --name msb_internal_apigateway nexus3.onap.org:10001/onap/msb/msb_apigateway +MSB_IAG_IP=`get-instance-ip.sh msb_internal_apigateway` +echo MSB_IAG_IP=${MSB_IAG_IP} + +# Start rest example service +docker run -d -p 9090:9090 --name i-rest-example zhaohuabing/rest-example +REST_EXAMPLE_IP=`get-instance-ip.sh i-rest-example` +echo REST_EXAMPLE_IP=${REST_EXAMPLE_IP} + + +# Wait for initialization(8500 Consul, 10081 Service Registration & Discovery, 80 api gateway) +for i in {1..10}; do + curl -sS -m 1 ${MSB_CONSUL_IP}:8500 && curl -sS -m 1 ${MSB_DISCOVERY_IP}:10081 && curl -sS -m 1 ${MSB_IAG_IP}:80 && break + echo sleep $i + sleep $i +done + +#Need some time for the initialization of MSB services +sleep 60 + +curl -X POST \ + -H "Content-Type: application/json" \ + -d '{"serviceName": "test", "version": "v1", "url": "/","protocol": "REST", "lb_policy":"round-robin","nodes": [ {"ip": "'${REST_EXAMPLE_IP}'","port": "9090"}]}' \ + "http://${MSB_IAG_IP}:80/api/microservices/v1/services" + +# Pass any variables required by Robot suites in ROBOT_VARIABLES +ROBOT_VARIABLES="-v MSB_IAG_IP:${MSB_IAG_IP} -v MSB_DISCOVERY_IP:${MSB_DISCOVERY_IP} -v REST_EXAMPLE_IP:${REST_EXAMPLE_IP}"
\ No newline at end of file diff --git a/test/csit/plans/msb/iag-redirect-discovery/teardown.sh b/test/csit/plans/msb/iag-redirect-discovery/teardown.sh new file mode 100644 index 000000000..b79456731 --- /dev/null +++ b/test/csit/plans/msb/iag-redirect-discovery/teardown.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# +# Copyright 2017 ZTE, Inc. and others. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +kill-instance.sh msb_consul +kill-instance.sh msb_discovery +kill-instance.sh msb_internal_apigateway +kill-instance.sh i-rest-example diff --git a/test/csit/plans/msb/iag-redirect-discovery/testplan.txt b/test/csit/plans/msb/iag-redirect-discovery/testplan.txt new file mode 100644 index 000000000..54bb307bf --- /dev/null +++ b/test/csit/plans/msb/iag-redirect-discovery/testplan.txt @@ -0,0 +1,4 @@ +# Test suites are relative paths under [integration.git]/test/csit/tests/. +# Place the suites in run order. +msb/rest-service-discovery +msb/rest-service-api-gateway
\ No newline at end of file diff --git a/test/csit/plans/msb/rest-service/setup.sh b/test/csit/plans/msb/rest-service/setup.sh index 18b17ff8f..9682cde74 100644 --- a/test/csit/plans/msb/rest-service/setup.sh +++ b/test/csit/plans/msb/rest-service/setup.sh @@ -18,20 +18,20 @@ source ${SCRIPTS}/common_functions.sh #start msb -sudo docker run -d -p 8500:8500 --name msb_consul consul +docker run -d -p 8500:8500 --name msb_consul consul MSB_CONSUL_IP=`get-instance-ip.sh msb_consul` echo MSB_CONSUL_IP=${MSB_CONSUL_IP} -sudo docker run -d -p 10081:10081 -e CONSUL_IP=$MSB_CONSUL_IP --name msb_discovery nexus3.onap.org:10001/onap/msb/msb_discovery +docker run -d -p 10081:10081 -e CONSUL_IP=$MSB_CONSUL_IP --name msb_discovery nexus3.onap.org:10001/onap/msb/msb_discovery MSB_DISCOVERY_IP=`get-instance-ip.sh msb_discovery` echo DISCOVERY_IP=${MSB_DISCOVERY_IP} -sudo docker run -d -p 80:80 -e CONSUL_IP=$MSB_CONSUL_IP -e SDCLIENT_IP=$MSB_DISCOVERY_IP -e "ROUTE_LABELS=visualRange:1" --name msb_internal_apigateway nexus3.onap.org:10001/onap/msb/msb_apigateway +docker run -d -p 80:80 -e CONSUL_IP=$MSB_CONSUL_IP -e SDCLIENT_IP=$MSB_DISCOVERY_IP -e "ROUTE_LABELS=visualRange:1" --name msb_internal_apigateway nexus3.onap.org:10001/onap/msb/msb_apigateway MSB_IAG_IP=`get-instance-ip.sh msb_internal_apigateway` echo MSB_IAG_IP=${MSB_IAG_IP} # Start rest example service -sudo docker run -d -p 9090:9090 --name i-rest-example zhaohuabing/rest-example +docker run -d -p 9090:9090 --name i-rest-example zhaohuabing/rest-example REST_EXAMPLE_IP=`get-instance-ip.sh i-rest-example` echo REST_EXAMPLE_IP=${REST_EXAMPLE_IP} @@ -43,7 +43,7 @@ for i in {1..10}; do sleep $i done -#Need some time so service info can be synced from discovery to api gateway +#Need some time for the initialization of MSB services sleep 60 curl -X POST \ diff --git a/test/csit/plans/multicloud-ocata/functionality1/setup.sh b/test/csit/plans/multicloud-ocata/functionality1/setup.sh new file mode 100644 index 000000000..5630849cf --- /dev/null +++ b/test/csit/plans/multicloud-ocata/functionality1/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# +# Copyright (c) 2017 Wind River Systems, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + +# +# Place the scripts in run order: +# Start all process required for executing test case + +source ${SCRIPTS}/common_functions.sh + +# start multicloud-ocata +docker run -d --name multicloud-ocata nexus3.onap.org:10001/onap/multicloud/openstack-ocata +SERVICE_IP=`get-instance-ip.sh multicloud-ocata` +SERVICE_PORT=9004 + +for i in {1..50}; do + curl -sS ${SERVICE_IP}:${SERVICE_PORT} && break + echo sleep $i + sleep $i +done + +echo SCRIPTS +# Pass any variables required by Robot test suites in ROBOT_VARIABLES +ROBOT_VARIABLES+="-v SERVICE_IP:${SERVICE_IP} " +ROBOT_VARIABLES+="-v SERVICE_PORT:${SERVICE_PORT} " diff --git a/test/csit/plans/multicloud-ocata/functionality1/teardown.sh b/test/csit/plans/multicloud-ocata/functionality1/teardown.sh new file mode 100644 index 000000000..6ecb74ebd --- /dev/null +++ b/test/csit/plans/multicloud-ocata/functionality1/teardown.sh @@ -0,0 +1,15 @@ +#!/bin/bash +# +# Copyright (c) 2017 Wind River Systems, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + +# This script is sourced by run-csit.sh after Robot test completion. +kill-instance.sh multicloud-ocata diff --git a/test/csit/plans/multicloud-ocata/functionality1/testplan.txt b/test/csit/plans/multicloud-ocata/functionality1/testplan.txt new file mode 100644 index 000000000..fcd795da3 --- /dev/null +++ b/test/csit/plans/multicloud-ocata/functionality1/testplan.txt @@ -0,0 +1,3 @@ +# Test suites are relative paths under [integration.git]/test/csit/tests/. +# Place the suites in run order. +multicloud-ocata/provision/sanity_test_multicloud.robot diff --git a/test/csit/plans/multicloud/functionality1/setup.sh b/test/csit/plans/multicloud/functionality1/setup.sh index b43f4b856..993a39f68 100755 --- a/test/csit/plans/multicloud/functionality1/setup.sh +++ b/test/csit/plans/multicloud/functionality1/setup.sh @@ -17,17 +17,10 @@ # Place the scripts in run order: # Start all process required for executing test case -# start msb -# Replace this when msb is ready for onap -docker run -d --name i-msb -p 80:80 openoint/common-services-msb -MSB_IP=`get-instance-ip.sh i-msb` - -# start esr -# docker run -d --name i-esr -e MSB_ADDR=${MSB_IP}:80 openoint/common-services-extsys +source ${SCRIPTS}/common_functions.sh # start multivim-broker -# Replace this when multivim-broker container is ready -docker run -d --name multivim-broker -e MSB_ADDR=${MSB_IP}:80 openoint/multivim-broker +docker run -d --name multivim-broker nexus3.onap.org:10001/onap/multicloud/framework BROKER_IP=`get-instance-ip.sh multivim-broker` for i in {1..50}; do curl -sS ${BROKER_IP}:9001 && break @@ -37,4 +30,4 @@ done echo SCRIPTS # Pass any variables required by Robot test suites in ROBOT_VARIABLES -ROBOT_VARIABLES="-v MSB_IP:${MSB_IP}" +ROBOT_VARIABLES="-v BROKER_IP:${BROKER_IP}" diff --git a/test/csit/plans/multicloud/functionality1/teardown.sh b/test/csit/plans/multicloud/functionality1/teardown.sh index 4ca6dbc99..1732649af 100755 --- a/test/csit/plans/multicloud/functionality1/teardown.sh +++ b/test/csit/plans/multicloud/functionality1/teardown.sh @@ -16,5 +16,4 @@ # # This script is sourced by run-csit.sh after Robot test completion. -kill-instance.sh i-msb kill-instance.sh multivim-broker diff --git a/test/csit/plans/sdnc/healthcheck/health_check.sh b/test/csit/plans/sdnc/healthcheck/health_check.sh new file mode 100644 index 000000000..96c99848a --- /dev/null +++ b/test/csit/plans/sdnc/healthcheck/health_check.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +############################################################################### +# Copyright 2017 Huawei Technologies Co., Ltd. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +############################################################################### +SCRIPTS="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +echo $SCRIPTS + +response=$(curl --write-out '%{http_code}' --silent --output /dev/null -H "Authorization: Basic YWRtaW46S3A4Yko0U1hzek0wV1hsaGFrM2VIbGNzZTJnQXc4NHZhb0dHbUp2VXkyVQ==" -X POST -H "X-FromAppId: csit-sdnc" -H "X-TransactionId: csit-sdnc" -H "Accept: application/json" -H "Content-Type: application/json" http://localhost:8282/restconf/operations/SLI-API:healthcheck ) + +if [ "$response" == "200" ]; then + echo "SDNC health check passed." + exit 0; +fi + +echo "SDNC health check failed with response code ${response}." +exit 1 diff --git a/test/csit/plans/sdnc/healthcheck/setup.sh b/test/csit/plans/sdnc/healthcheck/setup.sh new file mode 100644 index 000000000..643d54fe9 --- /dev/null +++ b/test/csit/plans/sdnc/healthcheck/setup.sh @@ -0,0 +1,118 @@ +#!/bin/bash +# +# Copyright 2016-2017 Huawei Technologies Co., Ltd. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Modifications copyright (c) 2017 AT&T Intellectual Property +# +# Place the scripts in run order: +SCRIPTS="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +source ${WORKSPACE}/test/csit/scripts/sdnc/script1.sh + +export MTU=$(/sbin/ifconfig | grep MTU | sed 's/.*MTU://' | sed 's/ .*//' | sort -n | head -1) + +if [ "$MTU" == "" ]; then + export MTU="1450" +fi + + +# Clone SDNC repo to get docker-compose for SDNC +mkdir -p $WORKSPACE/archives/sdnc +cd $WORKSPACE/archives +git clone -b master --single-branch http://gerrit.onap.org/r/sdnc/oam.git sdnc +cd $WORKSPACE/archives/sdnc +git pull +unset http_proxy https_proxy +cd $WORKSPACE/archives/sdnc/installation/src/main/yaml + +sed -i "s/DMAAP_TOPIC_ENV=.*/DMAAP_TOPIC_ENV="AUTO"/g" docker-compose.yml +docker login -u docker -p docker nexus3.onap.org:10001 + +docker pull nexus3.onap.org:10001/onap/sdnc-image:latest +docker tag nexus3.onap.org:10001/onap/sdnc-image:latest onap/sdnc-image:latest + +docker pull nexus3.onap.org:10001/onap/ccsdk-dgbuilder-image:latest +docker tag nexus3.onap.org:10001/onap/ccsdk-dgbuilder-image:latest onap/ccsdk-dgbuilder-image:latest + +docker pull nexus3.onap.org:10001/onap/admportal-sdnc-image:latest +docker tag nexus3.onap.org:10001/onap/admportal-sdnc-image:latest onap/admportal-sdnc-image:latest + +# start SDNC containers with docker compose and configuration from docker-compose.yml +curl -L https://github.com/docker/compose/releases/download/1.9.0/docker-compose-`uname -s`-`uname -m` > docker-compose +chmod +x docker-compose +./docker-compose up -d + +# WAIT 5 minutes maximum and test every 5 seconds if SDNC is up using HealthCheck API +TIME_OUT=500 +INTERVAL=30 +TIME=0 +while [ "$TIME" -lt "$TIME_OUT" ]; do + response=$(curl --write-out '%{http_code}' --silent --output /dev/null -H "Authorization: Basic YWRtaW46S3A4Yko0U1hzek0wV1hsaGFrM2VIbGNzZTJnQXc4NHZhb0dHbUp2VXkyVQ==" -X POST -H "X-FromAppId: csit-sdnc" -H "X-TransactionId: csit-sdnc" -H "Accept: application/json" -H "Content-Type: application/json" http://localhost:8282/restconf/operations/SLI-API:healthcheck ); echo $response + + if [ "$response" == "200" ]; then + echo SDNC started in $TIME seconds + break; + fi + + echo Sleep: $INTERVAL seconds before testing if SDNC is up. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds + sleep $INTERVAL + TIME=$(($TIME+$INTERVAL)) +done + +if [ "$TIME" -ge "$TIME_OUT" ]; then + echo TIME OUT: Docker containers not started in $TIME_OUT seconds... Could cause problems for testing activities... +fi + +#sleep 800 + +TIME_OUT=1500 +INTERVAL=60 +TIME=0 +while [ "$TIME" -lt "$TIME_OUT" ]; do + +response=$(docker exec sdnc_controller_container /opt/opendaylight/current/bin/client -u karaf system:start-level) +num_bundles=$(docker exec sdnc_controller_container /opt/opendaylight/current/bin/client -u karaf bundle:list | tail -1 | cut -d\| -f1) + + if [ "$response" == "Level 100" ] && [ "$num_bundles" -ge 333 ]; then + echo SDNC karaf started in $TIME seconds + break; + fi + + echo Sleep: $INTERVAL seconds before testing if SDNC is up. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds + sleep $INTERVAL + TIME=$(($TIME+$INTERVAL)) +done + +if [ "$TIME" -ge "$TIME_OUT" ]; then + echo TIME OUT: karaf session not started in $TIME_OUT seconds... Could cause problems for testing activities... +fi + +response=$(docker exec sdnc_controller_container /opt/opendaylight/current/bin/client -u karaf system:start-level) +num_bundles=$(docker exec sdnc_controller_container /opt/opendaylight/current/bin/client -u karaf bundle:list | tail -1 | cut -d\| -f1) + + if [ "$response" == "Level 100" ] && [ "$num_bundles" -ge 333 ]; then + num_bundles=$(docker exec sdnc_controller_container /opt/opendaylight/current/bin/client -u karaf bundle:list | tail -1 | cut -d\| -f1) + num_failed_bundles=$(docker exec sdnc_controller_container /opt/opendaylight/current/bin/client -u karaf bundle:list | grep Failure | wc -l) + failed_bundles=$(docker exec sdnc_controller_container /opt/opendaylight/current/bin/client -u karaf bundle:list | grep Failure) + echo There is/are $num_failed_bundles failed bundles out of $num_bundles installed bundles. + fi + +if [ "$num_failed_bundles" -ge 1 ]; then + echo "The following bundle(s) are in a failed state: " + echo " $failed_bundles" +fi + +# Pass any variables required by Robot test suites in ROBOT_VARIABLES +ROBOT_VARIABLES="-v SCRIPTS:${SCRIPTS}" + diff --git a/test/csit/plans/sdnc/healthcheck/teardown.sh b/test/csit/plans/sdnc/healthcheck/teardown.sh new file mode 100644 index 000000000..4d99b9f31 --- /dev/null +++ b/test/csit/plans/sdnc/healthcheck/teardown.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# +# Copyright 2016-2017 Huawei Technologies Co., Ltd. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Modifications copyright (c) 2017 AT&T Intellectual Property +# + +kill-instance.sh sdnc_controller_container +kill-instance.sh sdnc_dgbuilder_container +kill-instance.sh sdnc_portal_container +kill-instance.sh sdnc_db_container + +# $WORKSPACE/archives/appc deleted with archives folder when tests starts so we keep it at the end for debugging diff --git a/test/csit/plans/sdnc/healthcheck/testplan.txt b/test/csit/plans/sdnc/healthcheck/testplan.txt new file mode 100644 index 000000000..3fa8dde53 --- /dev/null +++ b/test/csit/plans/sdnc/healthcheck/testplan.txt @@ -0,0 +1,4 @@ +# Test suites are relative paths under [integration.git]/test/csit/tests/. +# Place the suites in run order. +sdnc/healthcheck + diff --git a/test/csit/plans/vfc-gvnfm-vnflcm/sanity-check/setup.sh b/test/csit/plans/vfc-gvnfm-vnflcm/sanity-check/setup.sh index deb491642..634c32722 100755 --- a/test/csit/plans/vfc-gvnfm-vnflcm/sanity-check/setup.sh +++ b/test/csit/plans/vfc-gvnfm-vnflcm/sanity-check/setup.sh @@ -44,7 +44,7 @@ echo sleep 30 sleep 30 # start vfc-vnflcm -docker run -d --name vfc-vnflcm -v /var/lib/mysql -e MSB_ADDR=${MSB_DISCOVERY_IP}:10081 nexus3.onap.org:10001/onap/vfc/vnflcm +docker run -d --name vfc-vnflcm -v /var/lib/mysql -e MSB_ADDR=${MSB_IAG_IP}:80 nexus3.onap.org:10001/onap/vfc/vnflcm VNFLCM_IP=`get-instance-ip.sh vfc-vnflcm` # Wait for initialization @@ -58,4 +58,4 @@ docker cp vfc-vnflcm:/service/vfc/gvnfm/vnflcm/lcm/logs/runtime_lcm.log ./ cat runtime_lcm.log # Pass any variables required by Robot test suites in ROBOT_VARIABLES -ROBOT_VARIABLES="-v MSB_IAG_IP:${MSB_IAG_IP} -v MSB_DISCOVERY_IP:${MSB_DISCOVERY_IP} -v VNFLCM_IP:${VNFLCM_IP}" +ROBOT_VARIABLES="-v MSB_IAG_IP:${MSB_IAG_IP} -v VNFLCM_IP:${VNFLCM_IP}" diff --git a/test/csit/plans/vfc-gvnfm-vnfres/sanity-check/setup.sh b/test/csit/plans/vfc-gvnfm-vnfres/sanity-check/setup.sh index 78cc5e0cb..0139bcdcc 100755 --- a/test/csit/plans/vfc-gvnfm-vnfres/sanity-check/setup.sh +++ b/test/csit/plans/vfc-gvnfm-vnfres/sanity-check/setup.sh @@ -42,37 +42,15 @@ done echo sleep 60 sleep 60 # start vfc-vnfres -docker run -d --name vfc-vnfres -v /var/lib/mysql -e MSB_ADDR=${MSB_DISCOVERY_IP}:10081 nexus3.onap.org:10001/onap/vfc/vnfres +docker run -d --name vfc-vnfres -v /var/lib/mysql -e MSB_ADDR=${MSB_IAG_IP}:80 nexus3.onap.org:10001/onap/vfc/vnfres VNFRES_IP=`get-instance-ip.sh vfc-vnfres` -docker logs -f vfc-vnfres > vfc-vnfres.log & # Wait for initialization for i in {1..10}; do curl -sS ${VNFRES_IP}:8802 && break echo sleep $i sleep $i done -cat vfc-vnfres.log - -echo "================================================" -docker cp vfc-vnfres:/service/vfc/gvnfm/vnfres/res/docker/docker-entrypoint.sh ./ -cat docker-entrypoint.sh - -echo "================================================" -docker cp vfc-vnfres:/service/vfc/gvnfm/vnfres/res/docker/instance_config.sh ./ -cat instance_config.sh - -echo "================================================" -docker cp vfc-vnfres:/service/vfc/gvnfm/vnfres/res/docker/instance_init.sh ./ -cat instance_init.sh - -echo "================================================" -docker cp vfc-vnfres:/service/vfc/gvnfm/vnfres/res/docker/instance_run.sh ./ -cat instance_run.sh - -#echo "================================================" -#docker cp vfc-vnfres:/service/vfc/gvnfm/vnfres/res/logs/runtime_res.log ./ -#cat instance_init.sh # Pass any variables required by Robot test suites in ROBOT_VARIABLES -ROBOT_VARIABLES="-v MSB_IAG_IP:${MSB_IAG_IP} -v MSB_DISCOVERY_IP:${MSB_DISCOVERY_IP} -v VNFRES_IP:${VNFRES_IP}" +ROBOT_VARIABLES="-v MSB_IAG_IP:${MSB_IAG_IP} -v VNFRES_IP:${VNFRES_IP}" diff --git a/test/csit/plans/vfc-nfvo-driver-ems/sanity-check/setup.sh b/test/csit/plans/vfc-nfvo-driver-ems/sanity-check/setup.sh new file mode 100755 index 000000000..09978ca6d --- /dev/null +++ b/test/csit/plans/vfc-nfvo-driver-ems/sanity-check/setup.sh @@ -0,0 +1,62 @@ +#!/bin/bash +# +# Copyright 2017 ZTE Corporation. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Place the scripts in run order: +# Start all process required for executing test case + +source ${SCRIPTS}/common_functions.sh + +#start msb +docker run -d -p 8500:8500 --name msb_consul consul +MSB_CONSUL_IP=`get-instance-ip.sh msb_consul` +echo MSB_CONSUL_IP=${MSB_CONSUL_IP} + +docker run -d -p 10081:10081 -e CONSUL_IP=$MSB_CONSUL_IP --name msb_discovery nexus3.onap.org:10001/onap/msb/msb_discovery +MSB_DISCOVERY_IP=`get-instance-ip.sh msb_discovery` +echo DISCOVERY_IP=${MSB_DISCOVERY_IP} + +docker run -d -p 80:80 -e CONSUL_IP=$MSB_CONSUL_IP -e SDCLIENT_IP=$MSB_DISCOVERY_IP -e "ROUTE_LABELS=visualRange:1" --name msb_internal_apigateway nexus3.onap.org:10001/onap/msb/msb_apigateway +MSB_IAG_IP=`get-instance-ip.sh msb_internal_apigateway` +echo MSB_IAG_IP=${MSB_IAG_IP} + +# Wait for initialization(8500 Consul, 10081 Service Registration & Discovery, 80 api gateway) +for i in {1..10}; do + curl -sS -m 1 ${MSB_CONSUL_IP}:8500 && curl -sS -m 1 ${MSB_DISCOVERY_IP}:10081 && curl -sS -m 1 ${MSB_IAG_IP}:80 && break + echo sleep $i + sleep $i +done + +# Need some time so service info can be synced from discovery to api gateway +echo sleep 60 +sleep 60 + +# start vfc-emsdriver +docker run -d --name vfc-emsdriver -e MSB_ADDR=${MSB_IAG_IP}:80 nexus3.onap.org:10001/onap/vfc/emsdriver +EMS_DRV_IP=`get-instance-ip.sh vfc-emsdriver` +docker logs -f vfc-emsdriver > emsdriver.log & + +# Wait for initialization +for i in {1..10}; do + curl -sS -m 1 ${EMS_DRV_IP}:8206 && break + echo sleep $i + sleep $i +done + +echo "===============" +cat emsdriver.log + +# Pass any variables required by Robot test suites in ROBOT_VARIABLES +ROBOT_VARIABLES="-v MSB_IAG_IP:${MSB_IAG_IP} -v EMS_DRV_IP:${EMS_DRV_IP}" diff --git a/test/csit/plans/vfc-nfvo-driver-ems/sanity-check/teardown.sh b/test/csit/plans/vfc-nfvo-driver-ems/sanity-check/teardown.sh new file mode 100755 index 000000000..aa676b2f2 --- /dev/null +++ b/test/csit/plans/vfc-nfvo-driver-ems/sanity-check/teardown.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# +# Copyright 2017 ZTE Corporation. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# This script is sourced by run-csit.sh after Robot test completion. +kill-instance.sh msb_internal_apigateway +kill-instance.sh msb_discovery +kill-instance.sh msb_consul +kill-instance.sh vfc-emsdriver diff --git a/test/csit/plans/vfc-nfvo-driver-ems/sanity-check/testplan.txt b/test/csit/plans/vfc-nfvo-driver-ems/sanity-check/testplan.txt new file mode 100644 index 000000000..747f8683e --- /dev/null +++ b/test/csit/plans/vfc-nfvo-driver-ems/sanity-check/testplan.txt @@ -0,0 +1,3 @@ +# Test suites are relative paths under [integration.git]/test/csit/tests/. +# Place the suites in run order. +vfc/nfvo-driver-ems/test.robot diff --git a/test/csit/plans/vfc-nfvo-driver-sfc/sanity-check/setup.sh b/test/csit/plans/vfc-nfvo-driver-sfc/sanity-check/setup.sh new file mode 100755 index 000000000..45ad0cbb1 --- /dev/null +++ b/test/csit/plans/vfc-nfvo-driver-sfc/sanity-check/setup.sh @@ -0,0 +1,62 @@ +#!/bin/bash +# +# Copyright 2017 ZTE Corporation. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Place the scripts in run order: +# Start all process required for executing test case + +source ${SCRIPTS}/common_functions.sh + +#start msb +docker run -d -p 8500:8500 --name msb_consul consul +MSB_CONSUL_IP=`get-instance-ip.sh msb_consul` +echo MSB_CONSUL_IP=${MSB_CONSUL_IP} + +docker run -d -p 10081:10081 -e CONSUL_IP=$MSB_CONSUL_IP --name msb_discovery nexus3.onap.org:10001/onap/msb/msb_discovery +MSB_DISCOVERY_IP=`get-instance-ip.sh msb_discovery` +echo DISCOVERY_IP=${MSB_DISCOVERY_IP} + +docker run -d -p 80:80 -e CONSUL_IP=$MSB_CONSUL_IP -e SDCLIENT_IP=$MSB_DISCOVERY_IP -e "ROUTE_LABELS=visualRange:1" --name msb_internal_apigateway nexus3.onap.org:10001/onap/msb/msb_apigateway +MSB_IAG_IP=`get-instance-ip.sh msb_internal_apigateway` +echo MSB_IAG_IP=${MSB_IAG_IP} + +# Wait for initialization(8500 Consul, 10081 Service Registration & Discovery, 80 api gateway) +for i in {1..10}; do + curl -sS -m 1 ${MSB_CONSUL_IP}:8500 && curl -sS -m 1 ${MSB_DISCOVERY_IP}:10081 && curl -sS -m 1 ${MSB_IAG_IP}:80 && break + echo sleep $i + sleep $i +done + +# Need some time so service info can be synced from discovery to api gateway +echo sleep 60 +sleep 60 + +# start vfc-ztesdncdriver +docker run -d --name vfc-ztesdncdriver -e MSB_ADDR=${MSB_IAG_IP}:80 nexus3.onap.org:10001/onap/vfc/ztesdncdriver +SFC_DRV_IP=`get-instance-ip.sh vfc-ztesdncdriver` +docker logs -f vfc-ztesdncdriver > ztesdncdriver.log & + +# Wait for initialization +for i in {1..10}; do + curl -sS -m 1 ${SFC_DRV_IP}:8411 && break + echo sleep $i + sleep $i +done + +echo "===============================" +cat ztesdncdriver.log + +# Pass any variables required by Robot test suites in ROBOT_VARIABLES +ROBOT_VARIABLES="-v MSB_IAG_IP:${MSB_IAG_IP} -v SFC_DRV_IP:${SFC_DRV_IP}" diff --git a/test/csit/plans/vfc-nfvo-driver-sfc/sanity-check/teardown.sh b/test/csit/plans/vfc-nfvo-driver-sfc/sanity-check/teardown.sh new file mode 100755 index 000000000..ce5402efe --- /dev/null +++ b/test/csit/plans/vfc-nfvo-driver-sfc/sanity-check/teardown.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# +# Copyright 2017 ZTE Corporation. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# This script is sourced by run-csit.sh after Robot test completion. +kill-instance.sh msb_internal_apigateway +kill-instance.sh msb_discovery +kill-instance.sh msb_consul +kill-instance.sh vfc-ztesdncdriver diff --git a/test/csit/plans/vfc-nfvo-driver-sfc/sanity-check/testplan.txt b/test/csit/plans/vfc-nfvo-driver-sfc/sanity-check/testplan.txt new file mode 100644 index 000000000..9de2accee --- /dev/null +++ b/test/csit/plans/vfc-nfvo-driver-sfc/sanity-check/testplan.txt @@ -0,0 +1,3 @@ +# Test suites are relative paths under [integration.git]/test/csit/tests/. +# Place the suites in run order. +vfc/nfvo-driver-sfc/test.robot diff --git a/test/csit/plans/vfc-nfvo-driver-vnfm-gvnfm/sanity-check/setup.sh b/test/csit/plans/vfc-nfvo-driver-vnfm-gvnfm/sanity-check/setup.sh index c5c9f12cd..283cb0d41 100644 --- a/test/csit/plans/vfc-nfvo-driver-vnfm-gvnfm/sanity-check/setup.sh +++ b/test/csit/plans/vfc-nfvo-driver-vnfm-gvnfm/sanity-check/setup.sh @@ -42,33 +42,26 @@ done echo sleep 60 sleep 60 # start vfc-gvnfmdriver -docker run -d --name vfc-gvnfmdriver -e MSB_ADDR=${MSB_DISCOVERY_IP}:10081 nexus3.onap.org:10001/onap/vfc/gvnfmdriver +docker run -d --name vfc-gvnfmdriver -e MSB_ADDR=${MSB_IAG_IP}:80 nexus3.onap.org:10001/onap/vfc/gvnfmdriver GVNFMDRIVER_IP=`get-instance-ip.sh vfc-gvnfmdriver` -docker logs -f vfc-gvnfmdriver > vfc-gvnfmdriver & # Wait for initialization for i in {1..10}; do curl -sS ${GVNFMDRIVER_IP}:8484 && break echo sleep $i sleep $i done -cat vfc-gvnfmdriver.log -echo "================================================" -docker cp vfc-gvnfmdriver:/service/vfc/nfvo/driver/vnfm/gvnfm/gvnfmadapter/docker/docker-entrypoint.sh ./ -cat docker-entrypoint.sh +# start vfc-jujudriver +docker run -d --name vfc-jujudriver -e MSB_ADDR=${MSB_IAG_IP}:80 nexus3.onap.org:10001/onap/vfc/jujudriver +JUJUDRIVER_IP=`get-instance-ip.sh vfc-jujudriver` -echo "================================================" -docker cp vfc-gvnfmdriver:/service/vfc/nfvo/driver/vnfm/gvnfm/gvnfmadapter/docker/instance_config.sh ./ -cat instance_config.sh - -echo "================================================" -docker cp vfc-gvnfmdriver:/service/vfc/nfvo/driver/vnfm/gvnfm/gvnfmadapter/docker/instance_init.sh ./ -cat instance_init.sh - -echo "================================================" -docker cp vfc-gvnfmdriver:/service/vfc/nfvo/driver/vnfm/gvnfm/gvnfmadapter/docker/instance_run.sh ./ -cat instance_run.sh +# Wait for initialization +for i in {1..10}; do + curl -sS ${JUJUDRIVER_IP}:8483 && break + echo sleep $i + sleep $i +done # Pass any variables required by Robot test suites in ROBOT_VARIABLES -ROBOT_VARIABLES="-v MSB_IAG_IP:${MSB_IAG_IP} -v MSB_DISCOVERY_IP:${MSB_DISCOVERY_IP} -v GVNFMDRIVER_IP:${GVNFMDRIVER_IP}" +ROBOT_VARIABLES="-v MSB_IAG_IP:${MSB_IAG_IP} -v GVNFMDRIVER_IP:${GVNFMDRIVER_IP} -v JUJUDRIVER_IP:${JUJUDRIVER_IP}" diff --git a/test/csit/plans/vfc-nfvo-driver-vnfm-gvnfm/sanity-check/teardown.sh b/test/csit/plans/vfc-nfvo-driver-vnfm-gvnfm/sanity-check/teardown.sh index a55050251..78d7c5ad9 100644 --- a/test/csit/plans/vfc-nfvo-driver-vnfm-gvnfm/sanity-check/teardown.sh +++ b/test/csit/plans/vfc-nfvo-driver-vnfm-gvnfm/sanity-check/teardown.sh @@ -21,4 +21,4 @@ kill-instance.sh msb_discovery kill-instance.sh msb_consul kill-instance.sh vfc-gvnfmdriver -# kill-instance.sh vfc-jujudriver +kill-instance.sh vfc-jujudriver diff --git a/test/csit/plans/vfc-nfvo-driver-vnfm-gvnfm/sanity-check/testplan.txt b/test/csit/plans/vfc-nfvo-driver-vnfm-gvnfm/sanity-check/testplan.txt index 7cca2fbe5..e7bee519b 100644 --- a/test/csit/plans/vfc-nfvo-driver-vnfm-gvnfm/sanity-check/testplan.txt +++ b/test/csit/plans/vfc-nfvo-driver-vnfm-gvnfm/sanity-check/testplan.txt @@ -3,4 +3,4 @@ vfc/nfvo-driver-gvnfm/gvnfmdriver.robot -# vfc/nfvo-driver-gvnfm/jujudriver.robot +vfc/nfvo-driver-gvnfm/jujudriver.robot diff --git a/test/csit/plans/vfc-nfvo-driver-vnfm-svnfm/sanity-check/setup.sh b/test/csit/plans/vfc-nfvo-driver-vnfm-svnfm/sanity-check/setup.sh index 3f79bb024..382cb7a8d 100644 --- a/test/csit/plans/vfc-nfvo-driver-vnfm-svnfm/sanity-check/setup.sh +++ b/test/csit/plans/vfc-nfvo-driver-vnfm-svnfm/sanity-check/setup.sh @@ -41,34 +41,18 @@ done # wait for container initalization echo sleep 60 sleep 60 + # start vfc-ztevmanagerdriver -docker run -d --name vfc-ztevmanagerdriver -e MSB_ADDR=${MSB_DISCOVERY_IP}:10081 nexus3.onap.org:10001/onap/vfc/ztevmanagerdriver +docker run -d --name vfc-ztevmanagerdriver -e MSB_ADDR=${MSB_IAG_IP}:80 nexus3.onap.org:10001/onap/vfc/ztevmanagerdriver ZTEVMANAGERDRIVER_IP=`get-instance-ip.sh vfc-ztevmanagerdriver` -docker logs -f vfc-ztevmanagerdriver > vfc-ztevmanagerdriver & # Wait for initialization for i in {1..10}; do curl -sS ${ZTEVMANAGERDRIVER_IP}:8410 && break echo sleep $i sleep $i done -cat vfc-ztevmanagerdriver.log - -echo "================================================" -docker cp vfc-ztevmanagerdriver:/service/vfc/nfvo/driver/vnfm/svnfm/zte/vmanager/docker/docker-entrypoint.sh ./ -cat docker-entrypoint.sh - -echo "================================================" -docker cp vfc-ztevmanagerdriver:/service/vfc/nfvo/driver/vnfm/svnfm/zte/vmanager/docker/instance_config.sh ./ -cat instance_config.sh - -echo "================================================" -docker cp vfc-ztevmanagerdriver:/service/vfc/nfvo/driver/vnfm/svnfm/zte/vmanager/docker/instance_init.sh ./ -cat instance_init.sh -echo "================================================" -docker cp vfc-ztevmanagerdriver:/service/vfc/nfvo/driver/vnfm/svnfm/zte/vmanager/docker/instance_run.sh ./ -cat instance_run.sh # Start svnfm-huawei docker run -d --name vfc-svnfm-huawei -e MSB_ADDR=${MSB_IAG_IP}:80 nexus3.onap.org:10001/onap/vfc/nfvo/svnfm/huawei @@ -80,4 +64,4 @@ for i in {1..10}; do done # Pass any variables required by Robot test suites in ROBOT_VARIABLES -ROBOT_VARIABLES="-v MSB_IAG_IP:${MSB_IAG_IP} -v MSB_DISCOVERY_IP:${MSB_DISCOVERY_IP} -v ZTEVMANAGERDRIVER_IP:${ZTEVMANAGERDRIVER_IP} -v MSB_IP:${MSB_IAG_IP} -v SERVICE_IP:${SERVICE_IP}" +ROBOT_VARIABLES="-v MSB_IAG_IP:${MSB_IAG_IP} -v ZTEVMANAGERDRIVER_IP:${ZTEVMANAGERDRIVER_IP} -v MSB_IP:${MSB_IAG_IP} -v SERVICE_IP:${SERVICE_IP}" diff --git a/test/csit/plans/vfc-nfvo-lcm/sanity-check/setup.sh b/test/csit/plans/vfc-nfvo-lcm/sanity-check/setup.sh index cad0f89a9..3cc53988c 100755 --- a/test/csit/plans/vfc-nfvo-lcm/sanity-check/setup.sh +++ b/test/csit/plans/vfc-nfvo-lcm/sanity-check/setup.sh @@ -44,7 +44,7 @@ echo sleep 60 sleep 60 # start vfc-nslcm -docker run -d --name vfc-nslcm -v /var/lib/mysql -e MSB_ADDR=${MSB_DISCOVERY_IP}:10081 nexus3.onap.org:10001/onap/vfc/nslcm +docker run -d --name vfc-nslcm -v /var/lib/mysql -e MSB_ADDR=${MSB_IAG_IP}:80 nexus3.onap.org:10001/onap/vfc/nslcm NSLCM_IP=`get-instance-ip.sh vfc-nslcm` # Wait for initialization @@ -55,4 +55,4 @@ for i in {1..10}; do done # Pass any variables required by Robot test suites in ROBOT_VARIABLES -ROBOT_VARIABLES="-v MSB_IAG_IP:${MSB_IAG_IP} -v MSB_DISCOVERY_IP:${MSB_DISCOVERY_IP} -v NSLCM_IP:${NSLCM_IP}" +ROBOT_VARIABLES="-v MSB_IAG_IP:${MSB_IAG_IP} -v NSLCM_IP:${NSLCM_IP} -v SCRIPTS:${SCRIPTS}" diff --git a/test/csit/plans/vnfsdk-refrepo/sanity-check/setup.sh b/test/csit/plans/vnfsdk-refrepo/sanity-check/setup.sh index 91e931e91..e04feac41 100644 --- a/test/csit/plans/vnfsdk-refrepo/sanity-check/setup.sh +++ b/test/csit/plans/vnfsdk-refrepo/sanity-check/setup.sh @@ -17,9 +17,13 @@ # These scripts are sourced by run-csit.sh. +#Start postgres database +docker run -d -i -t --name=postgres -p 5432:5432 nexus3.onap.org:10001/onap/refrepo/postgres:latest + +POSTGRES=`docker inspect --format '{{ .NetworkSettings.IPAddress }}' postgres` #Start market place -docker run -d -i -t --name=refrepo -p 8702:8702 nexus3.onap.org:10001/onap/refrepo:1.0-STAGING-latest +docker run -d -i -t --name=refrepo -e POSTGRES_IP=$POSTGRES -p 8702:8702 nexus3.onap.org:10001/onap/refrepo:1.0-STAGING-latest # Wait for Market place initialization echo Wait for VNF Repository initialization diff --git a/test/csit/plans/vnfsdk-refrepo/sanity-check/teardown.sh b/test/csit/plans/vnfsdk-refrepo/sanity-check/teardown.sh index a42634303..19440bc79 100644 --- a/test/csit/plans/vnfsdk-refrepo/sanity-check/teardown.sh +++ b/test/csit/plans/vnfsdk-refrepo/sanity-check/teardown.sh @@ -18,4 +18,6 @@ kill-instance.sh refrepo +kill-instance.sh postgres + diff --git a/test/csit/run-csit.sh b/test/csit/run-csit.sh index 8033f308a..f499d8ed1 100755 --- a/test/csit/run-csit.sh +++ b/test/csit/run-csit.sh @@ -93,6 +93,24 @@ if ! type pybot > /dev/null; then source ${ROBOT_VENV}/bin/activate fi +# install required Robot libraries +pip install --upgrade robotframework-extendedselenium2library + +# install eteutils +mkdir -p ${ROBOT_VENV}/src/onap +rm -rf ${ROBOT_VENV}/src/onap/testsuite +git clone https://gerrit.onap.org/r/testsuite/python-testing-utils.git ${ROBOT_VENV}/src/onap/testsuite/python-testing-utils +pip install --upgrade ${ROBOT_VENV}/src/onap/testsuite/python-testing-utils + +# install chrome driver +if [ ! -x ${ROBOT_VENV}/bin/chromedriver ]; then + pushd ${ROBOT_VENV}/bin + wget -N http://chromedriver.storage.googleapis.com/2.32/chromedriver_linux64.zip + unzip chromedriver_linux64.zip + chmod +x chromedriver + popd +fi + WORKDIR=`mktemp -d --suffix=-robot-workdir` cd ${WORKDIR} @@ -103,7 +121,7 @@ set -x # Add csit scripts to PATH -export PATH=${PATH}:${WORKSPACE}/test/csit/docker/scripts:${WORKSPACE}/test/csit/scripts +export PATH=${PATH}:${WORKSPACE}/test/csit/docker/scripts:${WORKSPACE}/test/csit/scripts:${ROBOT_VENV}/bin export SCRIPTS=${WORKSPACE}/test/csit/scripts export ROBOT_VARIABLES= diff --git a/test/csit/scripts/holmes/engine-management/startup.sh b/test/csit/scripts/holmes/engine-management/startup.sh index 59af9cac6..27a4df48d 100644 --- a/test/csit/scripts/holmes/engine-management/startup.sh +++ b/test/csit/scripts/holmes/engine-management/startup.sh @@ -20,4 +20,4 @@ docker login -u docker -p docker nexus3.onap.org:10001 -run-instance.sh nexus3.onap.org:10001/onap/holmes/engine-management:latest $1 "-e URL_JDBC=$2:5432 -e MSB_ADDR=$3 -e MSB_PORT=$4 -p 9102:9102" +run-instance.sh nexus3.onap.org:10001/onap/holmes/engine-management:latest $1 "-e URL_JDBC=$2:5432 -e MSB_ADDR=$3:80 -e TESTING=$4 -p 9102:9102" diff --git a/test/csit/scripts/holmes/rule-management/startup.sh b/test/csit/scripts/holmes/rule-management/startup.sh index e3bcdaa8e..ab3f93123 100644 --- a/test/csit/scripts/holmes/rule-management/startup.sh +++ b/test/csit/scripts/holmes/rule-management/startup.sh @@ -19,4 +19,4 @@ docker login -u docker -p docker nexus3.onap.org:10001 -run-instance.sh nexus3.onap.org:10001/onap/holmes/rule-management:latest $1 "-e URL_JDBC=$2:5432 -e MSB_ADDR=$3 -e MSB_PORT=$4 -p 9101:9101"
\ No newline at end of file +run-instance.sh nexus3.onap.org:10001/onap/holmes/rule-management:latest $1 "-e URL_JDBC=$2:5432 -e MSB_ADDR=$3:80 -e TESTING=$4 -p 9101:9101"
\ No newline at end of file diff --git a/test/csit/scripts/sdnc/script1.sh b/test/csit/scripts/sdnc/script1.sh new file mode 100644 index 000000000..b87e3c197 --- /dev/null +++ b/test/csit/scripts/sdnc/script1.sh @@ -0,0 +1,20 @@ +#!/bin/bash +# +# Copyright 2016-2017 Huawei Technologies Co., Ltd. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Modifications copyright (c) 2017 AT&T Intellectual Property +# + +echo "This is ${WORKSPACE}/test/csit/scripts/sdnc/script1.sh" diff --git a/test/csit/tests/aai/resources/suite1/__init__.robot b/test/csit/tests/aai/resources/api_suite/__init__.robot index 538def841..538def841 100644 --- a/test/csit/tests/aai/resources/suite1/__init__.robot +++ b/test/csit/tests/aai/resources/api_suite/__init__.robot diff --git a/test/csit/tests/aai/resources/suite1/aai.crt b/test/csit/tests/aai/resources/api_suite/aai.crt index 6a28bbb8c..6a28bbb8c 100644 --- a/test/csit/tests/aai/resources/suite1/aai.crt +++ b/test/csit/tests/aai/resources/api_suite/aai.crt diff --git a/test/csit/tests/aai/resources/suite1/aai.key b/test/csit/tests/aai/resources/api_suite/aai.key index 02724df46..02724df46 100644 --- a/test/csit/tests/aai/resources/suite1/aai.key +++ b/test/csit/tests/aai/resources/api_suite/aai.key diff --git a/test/csit/tests/aai/resources/api_suite/complex.robot b/test/csit/tests/aai/resources/api_suite/complex.robot new file mode 100644 index 000000000..3602f731a --- /dev/null +++ b/test/csit/tests/aai/resources/api_suite/complex.robot @@ -0,0 +1,72 @@ +*** Settings *** +Library OperatingSystem +Library RequestsLibrary +Library requests +Library Collections + +*** Variables *** +${COMPLEXKEYVALUE} complex-integration-test1 +${COMPLEXURL} https://${HOST_IP}:8443/aai/v11/cloud-infrastructure/complexes/complex/${COMPLEXKEYVALUE} +${COMPLEXDATA} {"physical-location-id":"${COMPLEXKEYVALUE}","data-center-code":"example-data-center-code-val-77883","complex-name":"example-complex-name-val-12992","identity-url":"example-identity-url-val-74366","physical-location-type":"example-physical-location-type-val-32854","street1":"example-street1-val-26496","street2":"example-street2-val-6629","city":"example-city-val-30262","state":"example-state-val-9058","postal-code":"example-postal-code-val-44893","country":"example-country-val-98673","region":"example-region-val-10014","latitude":"example-latitude-val-47555","longitude":"example-longitude-val-76903","elevation":"example-elevation-val-63385","lata":"example-lata-val-90935"} + +*** Test Cases *** + +Run AAI Put complex + [Documentation] Create an complex object + ${resp}= PutWithCert ${COMPLEXURL} ${COMPLEXDATA} + log ${COMPLEXURL} + log ${resp.text} + Should Be Equal As Strings ${resp.status_code} 201 + +Run AAI Get complex + [Documentation] Get the complex object just created + ${resp} GetWithCert ${COMPLEXURL} + log ${resp} + log ${resp.json()} + Should Be Equal As Strings ${resp.status_code} 200 + ${resource_version}= Evaluate $resp.json().get('resource-version') + Set Global Variable ${resource_version} + +Run AAI Delete complex + [Documentation] Delete the complex just created + ${resp}= DeleteWithCert ${COMPLEXURL}?resource-version=${resource_version} + log ${resp.text} + Should Be Equal As Strings ${resp.status_code} 204 + +*** Keywords *** +PutWithCert + [Arguments] ${url} ${data} + ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=integration-aai X-FromAppId=integration-aai Authorization=Basic QUFJOkFBSQ== + ${certinfo}= Evaluate ('${CURDIR}/aai.crt', '${CURDIR}/aai.key') + ${resp}= Evaluate requests.put('${url}', data='${data}', headers=${headers}, cert=${certinfo}, verify=False) requests + [return] ${resp} + +PatchWithCert + [Arguments] ${url} ${data} + ${headers}= Create Dictionary Accept=application/json Content-Type=application/merge-patch+json X-TransactionId=integration-aai X-FromAppId=integration-aai Authorization=Basic QUFJOkFBSQ== + ${certinfo}= Evaluate ('${CURDIR}/aai.crt', '${CURDIR}/aai.key') + ${resp}= Evaluate requests.patch('${url}', data='${data}', headers=${headers}, cert=${certinfo}, verify=False) requests + [return] ${resp} + +PostWithCert + [Arguments] ${url} ${data} + ${auth}= Create List AAI AAI + ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=integration-aai X-FromAppId=integration-aai Authorization=Basic QUFJOkFBSQ== + ${certinfo}= Evaluate ('${CURDIR}/aai.crt', '${CURDIR}/aai.key') + ${resp}= Evaluate requests.post('${url}', data='${data}', headers=${headers}, cert=${certinfo}, verify=False) requests + [return] ${resp} + +GetWithCert + [Arguments] ${url} + ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=integration-aai X-FromAppId=integration-aai Authorization=Basic QUFJOkFBSQ== + ${certinfo}= Evaluate ('${CURDIR}/aai.crt', '${CURDIR}/aai.key') + ${resp}= Evaluate requests.get('${url}', headers=${headers}, cert=${certinfo}, verify=False) requests + [return] ${resp} + +DeleteWithCert + [Arguments] ${url} + ${auth}= Create List AAI AAI + ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=integration-aai X-FromAppId=integration-aai Authorization=Basic QUFJOkFBSQ== + ${certinfo}= Evaluate ('${CURDIR}/aai.crt', '${CURDIR}/aai.key') + ${resp}= Evaluate requests.delete('${url}', headers=${headers}, cert=${certinfo}, verify=False) requests + [return] ${resp}
\ No newline at end of file diff --git a/test/csit/tests/aai/resources/api_suite/get_all.robot b/test/csit/tests/aai/resources/api_suite/get_all.robot new file mode 100644 index 000000000..8e464cbdb --- /dev/null +++ b/test/csit/tests/aai/resources/api_suite/get_all.robot @@ -0,0 +1,105 @@ +*** Settings *** +Library OperatingSystem +Library RequestsLibrary +Library requests +Library Collections + +*** Variables *** +${COMPLEXKEYVALUE1} complex-integration-test3-1 +${COMPLEXKEYVALUE2} complex-integration-test3-2 +${COMPLEXURL1} https://${HOST_IP}:8443/aai/v11/cloud-infrastructure/complexes/complex/${COMPLEXKEYVALUE1} +${COMPLEXURL2} https://${HOST_IP}:8443/aai/v11/cloud-infrastructure/complexes/complex/${COMPLEXKEYVALUE2} +${ALLCOMPLEXURL} https://${HOST_IP}:8443/aai/v11/cloud-infrastructure/complexes +${COMPLEXDATA1} {"physical-location-id":"${COMPLEXKEYVALUE1}","data-center-code":"example-data-center-code-val-77883","complex-name":"example-complex-name-val-12992","identity-url":"example-identity-url-val-74366","physical-location-type":"example-physical-location-type-val-32854","street1":"example-street1-val-26496","street2":"example-street2-val-6629","city":"example-city-val-30262","state":"example-state-val-9058","postal-code":"example-postal-code-val-44893","country":"example-country-val-98673","region":"example-region-val-10014","latitude":"example-latitude-val-47555","longitude":"example-longitude-val-76903","elevation":"example-elevation-val-63385","lata":"example-lata-val-90935"} +${COMPLEXDATA2} {"physical-location-id":"${COMPLEXKEYVALUE2}","data-center-code":"example-data-center-code-val-7783","complex-name":"example-complex-name-val-1292","identity-url":"example-identity-url-val-7466","physical-location-type":"example-physical-location-type-val-3854","street1":"example-street1-val-2496","street2":"example-street2-val-6629","city":"example-city-val-3062","state":"example-state-val-9058","postal-code":"example-postal-code-val-4493","country":"example-country-val-9873","region":"example-region-val-1004","latitude":"example-latitude-val-4555","longitude":"example-longitude-val-7603","elevation":"example-elevation-val-6335","lata":"example-lata-val-9035"} + +*** Test Cases *** + +Run AAI Put complex 1 + [Documentation] Create an complex 1 object + ${resp}= PutWithCert ${COMPLEXURL1} ${COMPLEXDATA1} + log ${COMPLEXURL1} + log ${resp.text} + Should Be Equal As Strings ${resp.status_code} 201 + +Run AAI Put complex 2 + [Documentation] Create an complex 2 object + ${resp}= PutWithCert ${COMPLEXURL2} ${COMPLEXDATA2} + log ${COMPLEXURL2} + log ${resp.text} + Should Be Equal As Strings ${resp.status_code} 201 + +Run AAI Get all complex + [Documentation] Get the complex object just created + ${resp} GetWithCert ${ALLCOMPLEXURL} + log ${resp} + log ${resp.json()} + Should Be Equal As Strings ${resp.status_code} 200 + +Run AAI Get complex 1 to delete + [Documentation] Get the complex 1 object to delete + ${resp} GetWithCert ${COMPLEXURL1} + log ${resp} + log ${resp.json()} + Should Be Equal As Strings ${resp.status_code} 200 + ${resource_version}= Evaluate $resp.json().get('resource-version') + Set Global Variable ${resource_version} + +Run AAI Delete complex 1 + [Documentation] Delete the complex just created + ${resp}= DeleteWithCert ${COMPLEXURL1}?resource-version=${resource_version} + log ${resp.text} + Should Be Equal As Strings ${resp.status_code} 204 + +Run AAI Get complex 2 to delete + [Documentation] Get the complex 2 object to delete + ${resp} GetWithCert ${COMPLEXURL2} + log ${resp} + log ${resp.json()} + Should Be Equal As Strings ${resp.status_code} 200 + ${resource_version}= Evaluate $resp.json().get('resource-version') + Set Global Variable ${resource_version} + +Run AAI Delete complex 2 + [Documentation] Delete the complex just created + ${resp}= DeleteWithCert ${COMPLEXURL2}?resource-version=${resource_version} + log ${resp.text} + Should Be Equal As Strings ${resp.status_code} 204 + +*** Keywords *** +PutWithCert + [Arguments] ${url} ${data} + ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=integration-aai X-FromAppId=integration-aai Authorization=Basic QUFJOkFBSQ== + ${certinfo}= Evaluate ('${CURDIR}/aai.crt', '${CURDIR}/aai.key') + ${resp}= Evaluate requests.put('${url}', data='${data}', headers=${headers}, cert=${certinfo}, verify=False) requests + [return] ${resp} + +PatchWithCert + [Arguments] ${url} ${data} + ${headers}= Create Dictionary Accept=application/json Content-Type=application/merge-patch+json X-TransactionId=integration-aai X-FromAppId=integration-aai Authorization=Basic QUFJOkFBSQ== + ${certinfo}= Evaluate ('${CURDIR}/aai.crt', '${CURDIR}/aai.key') + ${resp}= Evaluate requests.patch('${url}', data='${data}', headers=${headers}, cert=${certinfo}, verify=False) requests + [return] ${resp} + +PostWithCert + [Arguments] ${url} ${data} + ${auth}= Create List AAI AAI + ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=integration-aai X-FromAppId=integration-aai Authorization=Basic QUFJOkFBSQ== + ${certinfo}= Evaluate ('${CURDIR}/aai.crt', '${CURDIR}/aai.key') + ${resp}= Evaluate requests.post('${url}', data='${data}', headers=${headers}, cert=${certinfo}, verify=False) requests + [return] ${resp} + +GetWithCert + [Arguments] ${url} + ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=integration-aai X-FromAppId=integration-aai Authorization=Basic QUFJOkFBSQ== + ${certinfo}= Evaluate ('${CURDIR}/aai.crt', '${CURDIR}/aai.key') + ${resp}= Evaluate requests.get('${url}', headers=${headers}, cert=${certinfo}, verify=False) requests + [return] ${resp} + +DeleteWithCert + [Arguments] ${url} + ${auth}= Create List AAI AAI + ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=integration-aai X-FromAppId=integration-aai Authorization=Basic QUFJOkFBSQ== + ${certinfo}= Evaluate ('${CURDIR}/aai.crt', '${CURDIR}/aai.key') + ${resp}= Evaluate requests.delete('${url}', headers=${headers}, cert=${certinfo}, verify=False) requests + [return] ${resp}
\ No newline at end of file diff --git a/test/csit/tests/aai/resources/api_suite/get_with_depth.robot b/test/csit/tests/aai/resources/api_suite/get_with_depth.robot new file mode 100644 index 000000000..8e464cbdb --- /dev/null +++ b/test/csit/tests/aai/resources/api_suite/get_with_depth.robot @@ -0,0 +1,105 @@ +*** Settings *** +Library OperatingSystem +Library RequestsLibrary +Library requests +Library Collections + +*** Variables *** +${COMPLEXKEYVALUE1} complex-integration-test3-1 +${COMPLEXKEYVALUE2} complex-integration-test3-2 +${COMPLEXURL1} https://${HOST_IP}:8443/aai/v11/cloud-infrastructure/complexes/complex/${COMPLEXKEYVALUE1} +${COMPLEXURL2} https://${HOST_IP}:8443/aai/v11/cloud-infrastructure/complexes/complex/${COMPLEXKEYVALUE2} +${ALLCOMPLEXURL} https://${HOST_IP}:8443/aai/v11/cloud-infrastructure/complexes +${COMPLEXDATA1} {"physical-location-id":"${COMPLEXKEYVALUE1}","data-center-code":"example-data-center-code-val-77883","complex-name":"example-complex-name-val-12992","identity-url":"example-identity-url-val-74366","physical-location-type":"example-physical-location-type-val-32854","street1":"example-street1-val-26496","street2":"example-street2-val-6629","city":"example-city-val-30262","state":"example-state-val-9058","postal-code":"example-postal-code-val-44893","country":"example-country-val-98673","region":"example-region-val-10014","latitude":"example-latitude-val-47555","longitude":"example-longitude-val-76903","elevation":"example-elevation-val-63385","lata":"example-lata-val-90935"} +${COMPLEXDATA2} {"physical-location-id":"${COMPLEXKEYVALUE2}","data-center-code":"example-data-center-code-val-7783","complex-name":"example-complex-name-val-1292","identity-url":"example-identity-url-val-7466","physical-location-type":"example-physical-location-type-val-3854","street1":"example-street1-val-2496","street2":"example-street2-val-6629","city":"example-city-val-3062","state":"example-state-val-9058","postal-code":"example-postal-code-val-4493","country":"example-country-val-9873","region":"example-region-val-1004","latitude":"example-latitude-val-4555","longitude":"example-longitude-val-7603","elevation":"example-elevation-val-6335","lata":"example-lata-val-9035"} + +*** Test Cases *** + +Run AAI Put complex 1 + [Documentation] Create an complex 1 object + ${resp}= PutWithCert ${COMPLEXURL1} ${COMPLEXDATA1} + log ${COMPLEXURL1} + log ${resp.text} + Should Be Equal As Strings ${resp.status_code} 201 + +Run AAI Put complex 2 + [Documentation] Create an complex 2 object + ${resp}= PutWithCert ${COMPLEXURL2} ${COMPLEXDATA2} + log ${COMPLEXURL2} + log ${resp.text} + Should Be Equal As Strings ${resp.status_code} 201 + +Run AAI Get all complex + [Documentation] Get the complex object just created + ${resp} GetWithCert ${ALLCOMPLEXURL} + log ${resp} + log ${resp.json()} + Should Be Equal As Strings ${resp.status_code} 200 + +Run AAI Get complex 1 to delete + [Documentation] Get the complex 1 object to delete + ${resp} GetWithCert ${COMPLEXURL1} + log ${resp} + log ${resp.json()} + Should Be Equal As Strings ${resp.status_code} 200 + ${resource_version}= Evaluate $resp.json().get('resource-version') + Set Global Variable ${resource_version} + +Run AAI Delete complex 1 + [Documentation] Delete the complex just created + ${resp}= DeleteWithCert ${COMPLEXURL1}?resource-version=${resource_version} + log ${resp.text} + Should Be Equal As Strings ${resp.status_code} 204 + +Run AAI Get complex 2 to delete + [Documentation] Get the complex 2 object to delete + ${resp} GetWithCert ${COMPLEXURL2} + log ${resp} + log ${resp.json()} + Should Be Equal As Strings ${resp.status_code} 200 + ${resource_version}= Evaluate $resp.json().get('resource-version') + Set Global Variable ${resource_version} + +Run AAI Delete complex 2 + [Documentation] Delete the complex just created + ${resp}= DeleteWithCert ${COMPLEXURL2}?resource-version=${resource_version} + log ${resp.text} + Should Be Equal As Strings ${resp.status_code} 204 + +*** Keywords *** +PutWithCert + [Arguments] ${url} ${data} + ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=integration-aai X-FromAppId=integration-aai Authorization=Basic QUFJOkFBSQ== + ${certinfo}= Evaluate ('${CURDIR}/aai.crt', '${CURDIR}/aai.key') + ${resp}= Evaluate requests.put('${url}', data='${data}', headers=${headers}, cert=${certinfo}, verify=False) requests + [return] ${resp} + +PatchWithCert + [Arguments] ${url} ${data} + ${headers}= Create Dictionary Accept=application/json Content-Type=application/merge-patch+json X-TransactionId=integration-aai X-FromAppId=integration-aai Authorization=Basic QUFJOkFBSQ== + ${certinfo}= Evaluate ('${CURDIR}/aai.crt', '${CURDIR}/aai.key') + ${resp}= Evaluate requests.patch('${url}', data='${data}', headers=${headers}, cert=${certinfo}, verify=False) requests + [return] ${resp} + +PostWithCert + [Arguments] ${url} ${data} + ${auth}= Create List AAI AAI + ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=integration-aai X-FromAppId=integration-aai Authorization=Basic QUFJOkFBSQ== + ${certinfo}= Evaluate ('${CURDIR}/aai.crt', '${CURDIR}/aai.key') + ${resp}= Evaluate requests.post('${url}', data='${data}', headers=${headers}, cert=${certinfo}, verify=False) requests + [return] ${resp} + +GetWithCert + [Arguments] ${url} + ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=integration-aai X-FromAppId=integration-aai Authorization=Basic QUFJOkFBSQ== + ${certinfo}= Evaluate ('${CURDIR}/aai.crt', '${CURDIR}/aai.key') + ${resp}= Evaluate requests.get('${url}', headers=${headers}, cert=${certinfo}, verify=False) requests + [return] ${resp} + +DeleteWithCert + [Arguments] ${url} + ${auth}= Create List AAI AAI + ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=integration-aai X-FromAppId=integration-aai Authorization=Basic QUFJOkFBSQ== + ${certinfo}= Evaluate ('${CURDIR}/aai.crt', '${CURDIR}/aai.key') + ${resp}= Evaluate requests.delete('${url}', headers=${headers}, cert=${certinfo}, verify=False) requests + [return] ${resp}
\ No newline at end of file diff --git a/test/csit/tests/aai/resources/api_suite/patch.robot b/test/csit/tests/aai/resources/api_suite/patch.robot new file mode 100644 index 000000000..90544e4d9 --- /dev/null +++ b/test/csit/tests/aai/resources/api_suite/patch.robot @@ -0,0 +1,86 @@ +*** Settings *** +Library OperatingSystem +Library RequestsLibrary +Library requests +Library Collections + +*** Variables *** +${L3NETWORKKEYVALUE} l3-network-integration-test1 +${L3NETWORKURL} https://${HOST_IP}:8443/aai/v11/network/l3-networks/l3-network/${L3NETWORKKEYVALUE} +${L3NETWORKDATA} {"network-id":"${L3NETWORKKEYVALUE}","network-name":"example-network-name-val-5468","network-type":"example-network-type-val-5468","network-role":"example-network-role-val-5468","network-technology":"example-network-technology-val-5468","neutron-network-id":"example-neutron-network-id-val-5468","is-bound-to-vpn":"true","service-id":"example-service-id-val-5468","orchestration-status":"example-orchestration-status-val-5468","heat-stack-id":"example-heat-stack-id-val-5468","mso-catalog-key":"example-mso-catalog-key-val-5468"} +${L3NETWORKPATCHDATA} {"network-id":"${L3NETWORKKEYVALUE}","network-name":"example-network-name-val-5468-patched","network-type":"example-network-type-val-5468-patched"} + +*** Test Cases *** +Run AAI Put l3-network + [Documentation] Create l3-network object + ${resp}= PutWithCert ${L3NETWORKURL} ${L3NETWORKDATA} + log ${L3NETWORKURL} + log ${resp.text} + Should Be Equal As Strings ${resp.status_code} 201 + +Run AAI Get l3-network + [Documentation] Get the l3-network object just created + ${resp} GetWithCert ${L3NETWORKURL} + log ${resp} + log ${resp.json()} + Should Be Equal As Strings ${resp.status_code} 200 + +Run AAI Patch l3-network + [Documentation] Update (Parch) l3-network object + ${resp}= PatchWithCert ${L3NETWORKURL} ${L3NETWORKPATCHDATA} + log ${L3NETWORKURL} + log ${resp.text} + Should Be Equal As Strings ${resp.status_code} 200 + +Run AAI Get l3-network + [Documentation] Get the l3-network object just patched + ${resp} GetWithCert ${L3NETWORKURL} + log ${resp} + log ${resp.json()} + Should Be Equal As Strings ${resp.status_code} 200 + ${resource_version}= Evaluate $resp.json().get('resource-version') + Set Global Variable ${resource_version} + +Run AAI Delete l3-network + [Documentation] Delete the l3-network + ${resp}= DeleteWithCert ${L3NETWORKURL}?resource-version=${resource_version} + log ${resp.text} + Should Be Equal As Strings ${resp.status_code} 204 + +*** Keywords *** +PutWithCert + [Arguments] ${url} ${data} + ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=integration-aai X-FromAppId=integration-aai Authorization=Basic QUFJOkFBSQ== + ${certinfo}= Evaluate ('${CURDIR}/aai.crt', '${CURDIR}/aai.key') + ${resp}= Evaluate requests.put('${url}', data='${data}', headers=${headers}, cert=${certinfo}, verify=False) requests + [return] ${resp} + +PatchWithCert + [Arguments] ${url} ${data} + ${headers}= Create Dictionary Accept=application/json Content-Type=application/merge-patch+json X-TransactionId=integration-aai X-FromAppId=integration-aai Authorization=Basic QUFJOkFBSQ== + ${certinfo}= Evaluate ('${CURDIR}/aai.crt', '${CURDIR}/aai.key') + ${resp}= Evaluate requests.patch('${url}', data='${data}', headers=${headers}, cert=${certinfo}, verify=False) requests + [return] ${resp} + +PostWithCert + [Arguments] ${url} ${data} + ${auth}= Create List AAI AAI + ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=integration-aai X-FromAppId=integration-aai Authorization=Basic QUFJOkFBSQ== + ${certinfo}= Evaluate ('${CURDIR}/aai.crt', '${CURDIR}/aai.key') + ${resp}= Evaluate requests.post('${url}', data='${data}', headers=${headers}, cert=${certinfo}, verify=False) requests + [return] ${resp} + +GetWithCert + [Arguments] ${url} + ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=integration-aai X-FromAppId=integration-aai Authorization=Basic QUFJOkFBSQ== + ${certinfo}= Evaluate ('${CURDIR}/aai.crt', '${CURDIR}/aai.key') + ${resp}= Evaluate requests.get('${url}', headers=${headers}, cert=${certinfo}, verify=False) requests + [return] ${resp} + +DeleteWithCert + [Arguments] ${url} + ${auth}= Create List AAI AAI + ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=integration-aai X-FromAppId=integration-aai Authorization=Basic QUFJOkFBSQ== + ${certinfo}= Evaluate ('${CURDIR}/aai.crt', '${CURDIR}/aai.key') + ${resp}= Evaluate requests.delete('${url}', headers=${headers}, cert=${certinfo}, verify=False) requests + [return] ${resp}
\ No newline at end of file diff --git a/test/csit/tests/aai/resources/suite1/pserver.robot b/test/csit/tests/aai/resources/api_suite/pserver.robot index 55e57bccb..55e57bccb 100644 --- a/test/csit/tests/aai/resources/suite1/pserver.robot +++ b/test/csit/tests/aai/resources/api_suite/pserver.robot diff --git a/test/csit/tests/aai/resources/error_handling_suite/__init__.robot b/test/csit/tests/aai/resources/error_handling_suite/__init__.robot new file mode 100644 index 000000000..538def841 --- /dev/null +++ b/test/csit/tests/aai/resources/error_handling_suite/__init__.robot @@ -0,0 +1,2 @@ +*** Settings *** +Documentation Resources - Pserver Suite diff --git a/test/csit/tests/aai/resources/error_handling_suite/aai.crt b/test/csit/tests/aai/resources/error_handling_suite/aai.crt new file mode 100644 index 000000000..6a28bbb8c --- /dev/null +++ b/test/csit/tests/aai/resources/error_handling_suite/aai.crt @@ -0,0 +1,70 @@ +Bag Attributes + friendlyName: aaiopenecomp + localKeyID: 54 69 6D 65 20 31 35 30 34 38 33 32 34 34 33 32 39 32 +subject=/C=US/ST=NJ/L=Bedminster/O=OpenECOMP/OU=SimpleDemo/CN=aai.api.simpledemo.openecomp.org/emailAddress=aai-host@api.simpledemo.openecomp.org +issuer=/C=US/ST=NJ/L=Bedminster/O=OpenECOMP/OU=simpledemo/CN=OpenECOMP simpledemo Server CA X1/emailAddress=simpledemo@openecomp.org +-----BEGIN CERTIFICATE----- +MIIEiTCCA3GgAwIBAgIJAIPKfDLcn3MpMA0GCSqGSIb3DQEBCwUAMIGtMQswCQYD +VQQGEwJVUzELMAkGA1UECAwCTkoxEzARBgNVBAcMCkJlZG1pbnN0ZXIxEjAQBgNV +BAoMCU9wZW5FQ09NUDETMBEGA1UECwwKc2ltcGxlZGVtbzEqMCgGA1UEAwwhT3Bl +bkVDT01QIHNpbXBsZWRlbW8gU2VydmVyIENBIFgxMScwJQYJKoZIhvcNAQkBFhhz +aW1wbGVkZW1vQG9wZW5lY29tcC5vcmcwHhcNMTYxMTMwMTUzODM5WhcNMTcxMTMw +MTUzODM5WjCBuTELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAk5KMRMwEQYDVQQHDApC +ZWRtaW5zdGVyMRIwEAYDVQQKDAlPcGVuRUNPTVAxEzARBgNVBAsMClNpbXBsZURl +bW8xKTAnBgNVBAMMIGFhaS5hcGkuc2ltcGxlZGVtby5vcGVuZWNvbXAub3JnMTQw +MgYJKoZIhvcNAQkBFiVhYWktaG9zdEBhcGkuc2ltcGxlZGVtby5vcGVuZWNvbXAu +b3JnMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwQrQl8A0rT0Jjlos +Mr/7LEhT5UOif4GGPOk+3NCIxT3lOqAbUf+d9ZXyT2jWFRiKWua03vQ+Dxc8c2h2 +RRuH8LwEiOiWqPjWRxNqsARzZMI3ryHFCFBZh0FcpjH9kEeKVlLDYuV68k+ZucKd +NiqUNn61lD7kbmEGwvzKwf91FrJ09+CBMx1OnWKm3gCNKDqAEFMZCOdn2MgesJYB +/03lzPBS1jDfBXImXRcTBzpgA+wdCLn0cIQ1eLWUwS5tUqUJNh36nHdVyJ0P2Yjd +JLuxhFcmBKOz1ShyyO+BBtKBO8EGbU6qKflOiwOw0Fsn8LjKcrHQ58NPui5y04BU +Rypf3QIDAQABo4GdMIGaMAwGA1UdEwEB/wQCMAAwDgYDVR0PAQH/BAQDAgO4MB0G +A1UdDgQWBBQyMUOsE2J+CKzK0qd8KFBD2gaWyjBbBgNVHSAEVDBSMFAGBFUdIAAw +SDBGBggrBgEFBQcCAjA6GjhLZWVwIGF3YXkgZnJvbSBjaGlsZHJlbi4gIFRoaXMg +Y2VydGlmaWNhdGUgaXMgbm90IGEgdG95LjANBgkqhkiG9w0BAQsFAAOCAQEAnkoy +2tWJOyyyIQwtVojUxv1GWQPnw3WCUcKpuX4CJhHXLxNErW1fBg7bmo08BNmBPPpq +WrJsy5lbBgUo9kgpViux5Stfy1rRIRsRLfl/icgCvJmUAxkmRCZL7yUvwG4K7s+8 +DwT+nW/XuWNP6Hd/qHccexB6COJ8KwvTdVoxAkCdX8qw4MCb/f7Kb1yle/vwBM5Q +UUONCJ4bEns1vnb9DGlNDUJNwCfwORAaVJpVS38Mv4UnSTmb2KMePtCWcx/dNsYR +2XrSGqLDnTvHwOpyhbfFTmackysGoSuDytORXy8YbwEiF13BwEK8i3rgNN0Z2ojf +cpmE2xxmaa+A2uuN6g== +-----END CERTIFICATE----- +Bag Attributes + friendlyName: root + 2.16.840.1.113894.746875.1.1: <Unsupported tag 6> +subject=/C=US/ST=NJ/L=Bedminster/O=OpenECOMP/OU=simpledemo/CN=OpenECOMP simpledemo Server CA X1/emailAddress=simpledemo@openecomp.org +issuer=/C=US/ST=NJ/L=Bedminster/O=OpenECOMP/OU=simpledemo/CN=OpenECOMP simpledemo Root Certification Authority/emailAddress=simpledemo@openecomp.org +-----BEGIN CERTIFICATE----- +MIIFpTCCA42gAwIBAgIJAJqx8dKnCZZoMA0GCSqGSIb3DQEBCwUAMIG9MQswCQYD +VQQGEwJVUzELMAkGA1UECAwCTkoxEzARBgNVBAcMCkJlZG1pbnN0ZXIxEjAQBgNV +BAoMCU9wZW5FQ09NUDETMBEGA1UECwwKc2ltcGxlZGVtbzE6MDgGA1UEAwwxT3Bl +bkVDT01QIHNpbXBsZWRlbW8gUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTEn +MCUGCSqGSIb3DQEJARYYc2ltcGxlZGVtb0BvcGVuZWNvbXAub3JnMB4XDTE2MTEy +ODIxMTQyNloXDTIxMTEyNzIxMTQyNlowga0xCzAJBgNVBAYTAlVTMQswCQYDVQQI +DAJOSjETMBEGA1UEBwwKQmVkbWluc3RlcjESMBAGA1UECgwJT3BlbkVDT01QMRMw +EQYDVQQLDApzaW1wbGVkZW1vMSowKAYDVQQDDCFPcGVuRUNPTVAgc2ltcGxlZGVt +byBTZXJ2ZXIgQ0EgWDExJzAlBgkqhkiG9w0BCQEWGHNpbXBsZWRlbW9Ab3BlbmVj +b21wLm9yZzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALr4rivKQuRk +YNf5Ig40e1nqj6s6LB1vgMOYbKfRziOFpPcUpsHPOhusHowiUsrU1vdFSzPz6Ej7 +PjlmNSg2Qka8YCn9kd6QgM7U0KcPJvIucBp+qjifH3EvP0jgDPhDeVRYxzV454dv +5kQ9uCpswJP7YAnX51dkWeH8nwPUoagt31bOl9LXENSrgxEThxdLYMJnQJWk2CmV +otXM4tT1dxyJxFUrZ6uJCEAYw5VtlplqihHf8lHy+sWQavtsLz/4dc+sGeXSTfoI +voKvoh3uZ5gEhGV8yfJxk1veX5y5/AxP80vQ+smWYjTnQL5QQ57y4bciez4XVBmQ +SWimWtOi4e8CAwEAAaOBtTCBsjAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQE +AwIBhjAdBgNVHQ4EFgQUTqdsYgGNGubdJHq9tsaJhM9HE5wwcAYDVR0gBGkwZzBl +BgRVHSAAMF0wWwYIKwYBBQUHAgIwTxpNSWYgeW91IHRydXN0IHRoaXMgY2VydCB0 +aGVuIHdlIGhhdmUgYSBicmlkZ2UgdGhhdCB5b3UgbWlnaHQgYmUgaW50ZXJlc3Rl +ZCBpbi4wDQYJKoZIhvcNAQELBQADggIBAKNNlRqFuE/JgV1BHyYK0xoSXH4aZP/7 +IoHtDVcSaZAOOuFOUrwVMUbzRBebbb6RpFwt/X+NLFUGysd+XNLF7W7lzxKtmFNX +n4OpNkBe0y5O7yurus8rERHzu3jiOSgVo+WzDlGpYSRnG3hI2qPWqD+Puzx/WwI8 +XUTuzEQQ3gUSyVFfXHpay3VpYmLZiLJ9WKY5SDw7Ie6Sxrju4Qm1HwnFY8wHZGcs +2KMQzorJ1ZNQf523yUTghbT0rKaSFaD8zugPtI2ONfFG/QgrkQXo78opzPsHnHwa +SxGSiAgeLbwAUCvPNl27zr6k6+7TcNjV0VUivAs0OG3VEAdgi7UWYB+30KfWwHwE +zGmvd4IAGqIqlqLcSVArN5z8JK1B5nfjQn5UrclU1vK+dnuiKE2X4rKuBTRYRFR/ +km+mj4koYFPKFHndmJl1uv2OCJK9l5CSIuKWeI1qv8BASKqgNdoT/SKBXqxgYlCb +o+j4IDjxrxChRO+e5vl9lA7INfRrbljCkUjfLRa+v2q9tWQ3+EQUwwnSrSfihh2T +j0Tksr6b8dDsvMlCdOKG1B+JPcEXORSFKNXVTEfjqpJG8s16kFAocWt3S6xO0k1t +qbQp+3tWQgW2TGnX0rMZzB6NGRNfWhlYmq2zHgXkiCIZ26Ztgt/LNbwEvN3+VlLo +z/Rd+SKtlrfb +-----END CERTIFICATE----- diff --git a/test/csit/tests/aai/resources/error_handling_suite/aai.key b/test/csit/tests/aai/resources/error_handling_suite/aai.key new file mode 100644 index 000000000..02724df46 --- /dev/null +++ b/test/csit/tests/aai/resources/error_handling_suite/aai.key @@ -0,0 +1,32 @@ +Bag Attributes + friendlyName: aaiopenecomp + localKeyID: 54 69 6D 65 20 31 35 30 34 38 33 32 34 34 33 32 39 32 +Key Attributes: <No Attributes> +-----BEGIN PRIVATE KEY----- +MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDBCtCXwDStPQmO +Wiwyv/ssSFPlQ6J/gYY86T7c0IjFPeU6oBtR/531lfJPaNYVGIpa5rTe9D4PFzxz +aHZFG4fwvASI6Jao+NZHE2qwBHNkwjevIcUIUFmHQVymMf2QR4pWUsNi5XryT5m5 +wp02KpQ2frWUPuRuYQbC/MrB/3UWsnT34IEzHU6dYqbeAI0oOoAQUxkI52fYyB6w +lgH/TeXM8FLWMN8FciZdFxMHOmAD7B0IufRwhDV4tZTBLm1SpQk2Hfqcd1XInQ/Z +iN0ku7GEVyYEo7PVKHLI74EG0oE7wQZtTqop+U6LA7DQWyfwuMpysdDnw0+6LnLT +gFRHKl/dAgMBAAECggEBAJko2HkeIW01mUhdWOXnFgR7WjzzXZEmlffr41lVBr7f +rejGsQZs9cms73R7rCdOsi8PDoA6bqaQfADg571K659fvYVWbHqh+3im+iWvUlKm +GYIVG/vNrEq43CZsUU7Qw/xba/QiOFraNxCATTV1sORPwgddouXEi5XW9ZPX9/FJ +wORx4L/K0DfHX1rr+rtOoHCJdZYhn3Ij87kmR8Mwg0fNeWhHqtxUEyM/itRjCvOe +mgt2V8DORhmq12L4+5QJctBrkBVRp9Rh6YSZZBGnKbTSgf4q648BdkJDLSK4cguT +D6BAw3gxj5V4wt5W0wn2JpjadFwnixrTzvMP/yAqfK0CgYEA93nBAoUPw8nzQkwk +8iWBjfJ999Rw92hnnvk3xbcQcGfgUYuB4dxwe6FQTmFIVylt81er1YUvMb3ao7fo +5ZcGnI5p1idjsd27kbZJLxb5Oh919hKu5IfkfYsVgnC0UdKCTgH5CaH0U4ATuXwt +RL6qm0XcLALs5y2OO6z3s+mYhisCgYEAx7EQ8MA45bkXnRQiHBhGcIIcr2sRDfVJ +OhHmGxx3EcYgtsIYKTqtQOyIt/nQxo6iyNL9bzfzBTybFJLuj63ZG1Ef4LosJedl +eAU2NsKv5MlKYDSdNbLAJ0Op9I2Xu/pXQecPwY/3MkIQArdQCLevMLEGywCsuJTn +BjkJNDkb9hcCgYAhoFiaiAwJVYKJSqFmibQd3opBR4uGApi54DE021gPff3b9rHS +R8q88cFgtRVISqfW/d2qaKtt/dcckdvCfo/2a99zqux/+ZoIBZXSITQCMs4rfoRn +JxPj/ycQD1JhH9J22QvGxEvXoLqNZJMeGS5DZO2yyT75dpYyA6Gwv5fq+wKBgQC5 +AhV917lfLELyZurLOLpaFlHZO8rLMcusH1UfHRo7v2IjsGOOHyzRD9QDD1IcA55R +jRj8Z8uhuGq9fvvC5gBVTK3KGPI6E85wifOWfH1V7CAaTeSxEXDxb8EQL/a6U89v +4VE5tdYCHC6VNZzS1staw0hV38QmJt57Z3Bdj+OV9QKBgE/b9fxpo+SVQ37BzNNY +SEKTTijaddz8fdomApg6a2eFJL93Ej/op7N7gnHtPWMivPnRRza9ZjfnG+aZ7n2J +sWyBiZK9xliS2TsF3l3q9Z0Vaq3i1nOlV7Bd20ZS8KjQjDtKnIRfLkQDkvmXbU5L +emwkdsQZbpPFJch3mCGtI7JW +-----END PRIVATE KEY----- diff --git a/test/csit/tests/aai/resources/error_handling_suite/error_403.robot b/test/csit/tests/aai/resources/error_handling_suite/error_403.robot new file mode 100644 index 000000000..8178368ae --- /dev/null +++ b/test/csit/tests/aai/resources/error_handling_suite/error_403.robot @@ -0,0 +1,47 @@ +*** Settings *** +Library OperatingSystem +Library RequestsLibrary +Library requests +Library Collections + +*** Variables *** +${COMPLEXURL} https://${HOST_IP}:8443/aai/v11/cloud-infrastructure/complexes?depth=all + +*** Test Cases *** +Run AAI Get all complex + [Documentation] Get all complex - not all depth=all + ${resp} GetWithCert ${COMPLEXURL} + log ${resp} + log ${resp.json()} + Should Be Equal As Strings ${resp.status_code} 403 + +*** Keywords *** +PutWithCert + [Arguments] ${url} ${data} + ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=integration-aai X-FromAppId=integration-aai Authorization=Basic QUFJOkFBSQ== + ${certinfo}= Evaluate ('${CURDIR}/aai.crt', '${CURDIR}/aai.key') + ${resp}= Evaluate requests.put('${url}', data='${data}', headers=${headers}, cert=${certinfo}, verify=False) requests + [return] ${resp} + +PostWithCert + [Arguments] ${url} ${data} + ${auth}= Create List AAI AAI + ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=integration-aai X-FromAppId=integration-aai Authorization=Basic QUFJOkFBSQ== + ${certinfo}= Evaluate ('${CURDIR}/aai.crt', '${CURDIR}/aai.key') + ${resp}= Evaluate requests.post('${url}', data='${data}', headers=${headers}, cert=${certinfo}, verify=False) requests + [return] ${resp} + +GetWithCert + [Arguments] ${url} + ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=integration-aai X-FromAppId=integration-aai Authorization=Basic QUFJOkFBSQ== + ${certinfo}= Evaluate ('${CURDIR}/aai.crt', '${CURDIR}/aai.key') + ${resp}= Evaluate requests.get('${url}', headers=${headers}, cert=${certinfo}, verify=False) requests + [return] ${resp} + +DeleteWithCert + [Arguments] ${url} + ${auth}= Create List AAI AAI + ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=integration-aai X-FromAppId=integration-aai Authorization=Basic QUFJOkFBSQ== + ${certinfo}= Evaluate ('${CURDIR}/aai.crt', '${CURDIR}/aai.key') + ${resp}= Evaluate requests.delete('${url}', headers=${headers}, cert=${certinfo}, verify=False) requests + [return] ${resp}
\ No newline at end of file diff --git a/test/csit/tests/aai/resources/error_handling_suite/error_412_404.robot b/test/csit/tests/aai/resources/error_handling_suite/error_412_404.robot new file mode 100644 index 000000000..2d855d514 --- /dev/null +++ b/test/csit/tests/aai/resources/error_handling_suite/error_412_404.robot @@ -0,0 +1,78 @@ +*** Settings *** +Library OperatingSystem +Library RequestsLibrary +Library requests +Library Collections + +*** Variables *** +${PSERVERKEYVALUE} pserver-integration-test1 +${PSERVERURL} https://${HOST_IP}:8443/aai/v11/cloud-infrastructure/pservers/pserver/${PSERVERKEYVALUE} +${PSERVERDATA} {"hostname":"${PSERVERKEYVALUE}"} + +*** Test Cases *** +Run AAI Put Pserver + [Documentation] Create an pserver object + ${resp}= PutWithCert ${PSERVERURL} ${PSERVERDATA} + log ${PSERVERURL} + log ${resp.text} + Should Be Equal As Strings ${resp.status_code} 201 + +Run AAI Put Pserver again + [Documentation] Create an pserver object again without resource-version + ${resp}= PutWithCert ${PSERVERURL} ${PSERVERDATA} + log ${PSERVERURL} + log ${resp.text} + Should Be Equal As Strings ${resp.status_code} 412 + +Run AAI Get Pserver + [Documentation] Get the pserver object just created + ${resp} GetWithCert ${PSERVERURL} + log ${resp} + log ${resp.json()} + Should Be Equal As Strings ${resp.status_code} 200 + ${resource_version}= Evaluate $resp.json().get('resource-version') + Set Global Variable ${resource_version} + +Run AAI Delete Pserver + [Documentation] Delete the pserver just created + ${resp}= DeleteWithCert ${PSERVERURL}?resource-version=${resource_version} + log ${resp.text} + Should Be Equal As Strings ${resp.status_code} 204 + +Run AAI Get Pserver + [Documentation] Get the pserver object just deleted + ${resp} GetWithCert ${PSERVERURL} + log ${resp} + log ${resp.json()} + Should Be Equal As Strings ${resp.status_code} 404 + +*** Keywords *** +PutWithCert + [Arguments] ${url} ${data} + ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=integration-aai X-FromAppId=integration-aai Authorization=Basic QUFJOkFBSQ== + ${certinfo}= Evaluate ('${CURDIR}/aai.crt', '${CURDIR}/aai.key') + ${resp}= Evaluate requests.put('${url}', data='${data}', headers=${headers}, cert=${certinfo}, verify=False) requests + [return] ${resp} + +PostWithCert + [Arguments] ${url} ${data} + ${auth}= Create List AAI AAI + ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=integration-aai X-FromAppId=integration-aai Authorization=Basic QUFJOkFBSQ== + ${certinfo}= Evaluate ('${CURDIR}/aai.crt', '${CURDIR}/aai.key') + ${resp}= Evaluate requests.post('${url}', data='${data}', headers=${headers}, cert=${certinfo}, verify=False) requests + [return] ${resp} + +GetWithCert + [Arguments] ${url} + ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=integration-aai X-FromAppId=integration-aai Authorization=Basic QUFJOkFBSQ== + ${certinfo}= Evaluate ('${CURDIR}/aai.crt', '${CURDIR}/aai.key') + ${resp}= Evaluate requests.get('${url}', headers=${headers}, cert=${certinfo}, verify=False) requests + [return] ${resp} + +DeleteWithCert + [Arguments] ${url} + ${auth}= Create List AAI AAI + ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=integration-aai X-FromAppId=integration-aai Authorization=Basic QUFJOkFBSQ== + ${certinfo}= Evaluate ('${CURDIR}/aai.crt', '${CURDIR}/aai.key') + ${resp}= Evaluate requests.delete('${url}', headers=${headers}, cert=${certinfo}, verify=False) requests + [return] ${resp}
\ No newline at end of file diff --git a/test/csit/tests/aai/resources/relationship_suite/__init__.robot b/test/csit/tests/aai/resources/relationship_suite/__init__.robot new file mode 100644 index 000000000..de8f659d7 --- /dev/null +++ b/test/csit/tests/aai/resources/relationship_suite/__init__.robot @@ -0,0 +1,2 @@ +*** Settings *** +Documentation Resources - complex Suite diff --git a/test/csit/tests/aai/resources/relationship_suite/aai.crt b/test/csit/tests/aai/resources/relationship_suite/aai.crt new file mode 100644 index 000000000..6a28bbb8c --- /dev/null +++ b/test/csit/tests/aai/resources/relationship_suite/aai.crt @@ -0,0 +1,70 @@ +Bag Attributes + friendlyName: aaiopenecomp + localKeyID: 54 69 6D 65 20 31 35 30 34 38 33 32 34 34 33 32 39 32 +subject=/C=US/ST=NJ/L=Bedminster/O=OpenECOMP/OU=SimpleDemo/CN=aai.api.simpledemo.openecomp.org/emailAddress=aai-host@api.simpledemo.openecomp.org +issuer=/C=US/ST=NJ/L=Bedminster/O=OpenECOMP/OU=simpledemo/CN=OpenECOMP simpledemo Server CA X1/emailAddress=simpledemo@openecomp.org +-----BEGIN CERTIFICATE----- +MIIEiTCCA3GgAwIBAgIJAIPKfDLcn3MpMA0GCSqGSIb3DQEBCwUAMIGtMQswCQYD +VQQGEwJVUzELMAkGA1UECAwCTkoxEzARBgNVBAcMCkJlZG1pbnN0ZXIxEjAQBgNV +BAoMCU9wZW5FQ09NUDETMBEGA1UECwwKc2ltcGxlZGVtbzEqMCgGA1UEAwwhT3Bl +bkVDT01QIHNpbXBsZWRlbW8gU2VydmVyIENBIFgxMScwJQYJKoZIhvcNAQkBFhhz +aW1wbGVkZW1vQG9wZW5lY29tcC5vcmcwHhcNMTYxMTMwMTUzODM5WhcNMTcxMTMw +MTUzODM5WjCBuTELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAk5KMRMwEQYDVQQHDApC +ZWRtaW5zdGVyMRIwEAYDVQQKDAlPcGVuRUNPTVAxEzARBgNVBAsMClNpbXBsZURl +bW8xKTAnBgNVBAMMIGFhaS5hcGkuc2ltcGxlZGVtby5vcGVuZWNvbXAub3JnMTQw +MgYJKoZIhvcNAQkBFiVhYWktaG9zdEBhcGkuc2ltcGxlZGVtby5vcGVuZWNvbXAu +b3JnMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwQrQl8A0rT0Jjlos +Mr/7LEhT5UOif4GGPOk+3NCIxT3lOqAbUf+d9ZXyT2jWFRiKWua03vQ+Dxc8c2h2 +RRuH8LwEiOiWqPjWRxNqsARzZMI3ryHFCFBZh0FcpjH9kEeKVlLDYuV68k+ZucKd +NiqUNn61lD7kbmEGwvzKwf91FrJ09+CBMx1OnWKm3gCNKDqAEFMZCOdn2MgesJYB +/03lzPBS1jDfBXImXRcTBzpgA+wdCLn0cIQ1eLWUwS5tUqUJNh36nHdVyJ0P2Yjd +JLuxhFcmBKOz1ShyyO+BBtKBO8EGbU6qKflOiwOw0Fsn8LjKcrHQ58NPui5y04BU +Rypf3QIDAQABo4GdMIGaMAwGA1UdEwEB/wQCMAAwDgYDVR0PAQH/BAQDAgO4MB0G +A1UdDgQWBBQyMUOsE2J+CKzK0qd8KFBD2gaWyjBbBgNVHSAEVDBSMFAGBFUdIAAw +SDBGBggrBgEFBQcCAjA6GjhLZWVwIGF3YXkgZnJvbSBjaGlsZHJlbi4gIFRoaXMg +Y2VydGlmaWNhdGUgaXMgbm90IGEgdG95LjANBgkqhkiG9w0BAQsFAAOCAQEAnkoy +2tWJOyyyIQwtVojUxv1GWQPnw3WCUcKpuX4CJhHXLxNErW1fBg7bmo08BNmBPPpq +WrJsy5lbBgUo9kgpViux5Stfy1rRIRsRLfl/icgCvJmUAxkmRCZL7yUvwG4K7s+8 +DwT+nW/XuWNP6Hd/qHccexB6COJ8KwvTdVoxAkCdX8qw4MCb/f7Kb1yle/vwBM5Q +UUONCJ4bEns1vnb9DGlNDUJNwCfwORAaVJpVS38Mv4UnSTmb2KMePtCWcx/dNsYR +2XrSGqLDnTvHwOpyhbfFTmackysGoSuDytORXy8YbwEiF13BwEK8i3rgNN0Z2ojf +cpmE2xxmaa+A2uuN6g== +-----END CERTIFICATE----- +Bag Attributes + friendlyName: root + 2.16.840.1.113894.746875.1.1: <Unsupported tag 6> +subject=/C=US/ST=NJ/L=Bedminster/O=OpenECOMP/OU=simpledemo/CN=OpenECOMP simpledemo Server CA X1/emailAddress=simpledemo@openecomp.org +issuer=/C=US/ST=NJ/L=Bedminster/O=OpenECOMP/OU=simpledemo/CN=OpenECOMP simpledemo Root Certification Authority/emailAddress=simpledemo@openecomp.org +-----BEGIN CERTIFICATE----- +MIIFpTCCA42gAwIBAgIJAJqx8dKnCZZoMA0GCSqGSIb3DQEBCwUAMIG9MQswCQYD +VQQGEwJVUzELMAkGA1UECAwCTkoxEzARBgNVBAcMCkJlZG1pbnN0ZXIxEjAQBgNV +BAoMCU9wZW5FQ09NUDETMBEGA1UECwwKc2ltcGxlZGVtbzE6MDgGA1UEAwwxT3Bl +bkVDT01QIHNpbXBsZWRlbW8gUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTEn +MCUGCSqGSIb3DQEJARYYc2ltcGxlZGVtb0BvcGVuZWNvbXAub3JnMB4XDTE2MTEy +ODIxMTQyNloXDTIxMTEyNzIxMTQyNlowga0xCzAJBgNVBAYTAlVTMQswCQYDVQQI +DAJOSjETMBEGA1UEBwwKQmVkbWluc3RlcjESMBAGA1UECgwJT3BlbkVDT01QMRMw +EQYDVQQLDApzaW1wbGVkZW1vMSowKAYDVQQDDCFPcGVuRUNPTVAgc2ltcGxlZGVt +byBTZXJ2ZXIgQ0EgWDExJzAlBgkqhkiG9w0BCQEWGHNpbXBsZWRlbW9Ab3BlbmVj +b21wLm9yZzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALr4rivKQuRk +YNf5Ig40e1nqj6s6LB1vgMOYbKfRziOFpPcUpsHPOhusHowiUsrU1vdFSzPz6Ej7 +PjlmNSg2Qka8YCn9kd6QgM7U0KcPJvIucBp+qjifH3EvP0jgDPhDeVRYxzV454dv +5kQ9uCpswJP7YAnX51dkWeH8nwPUoagt31bOl9LXENSrgxEThxdLYMJnQJWk2CmV +otXM4tT1dxyJxFUrZ6uJCEAYw5VtlplqihHf8lHy+sWQavtsLz/4dc+sGeXSTfoI +voKvoh3uZ5gEhGV8yfJxk1veX5y5/AxP80vQ+smWYjTnQL5QQ57y4bciez4XVBmQ +SWimWtOi4e8CAwEAAaOBtTCBsjAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQE +AwIBhjAdBgNVHQ4EFgQUTqdsYgGNGubdJHq9tsaJhM9HE5wwcAYDVR0gBGkwZzBl +BgRVHSAAMF0wWwYIKwYBBQUHAgIwTxpNSWYgeW91IHRydXN0IHRoaXMgY2VydCB0 +aGVuIHdlIGhhdmUgYSBicmlkZ2UgdGhhdCB5b3UgbWlnaHQgYmUgaW50ZXJlc3Rl +ZCBpbi4wDQYJKoZIhvcNAQELBQADggIBAKNNlRqFuE/JgV1BHyYK0xoSXH4aZP/7 +IoHtDVcSaZAOOuFOUrwVMUbzRBebbb6RpFwt/X+NLFUGysd+XNLF7W7lzxKtmFNX +n4OpNkBe0y5O7yurus8rERHzu3jiOSgVo+WzDlGpYSRnG3hI2qPWqD+Puzx/WwI8 +XUTuzEQQ3gUSyVFfXHpay3VpYmLZiLJ9WKY5SDw7Ie6Sxrju4Qm1HwnFY8wHZGcs +2KMQzorJ1ZNQf523yUTghbT0rKaSFaD8zugPtI2ONfFG/QgrkQXo78opzPsHnHwa +SxGSiAgeLbwAUCvPNl27zr6k6+7TcNjV0VUivAs0OG3VEAdgi7UWYB+30KfWwHwE +zGmvd4IAGqIqlqLcSVArN5z8JK1B5nfjQn5UrclU1vK+dnuiKE2X4rKuBTRYRFR/ +km+mj4koYFPKFHndmJl1uv2OCJK9l5CSIuKWeI1qv8BASKqgNdoT/SKBXqxgYlCb +o+j4IDjxrxChRO+e5vl9lA7INfRrbljCkUjfLRa+v2q9tWQ3+EQUwwnSrSfihh2T +j0Tksr6b8dDsvMlCdOKG1B+JPcEXORSFKNXVTEfjqpJG8s16kFAocWt3S6xO0k1t +qbQp+3tWQgW2TGnX0rMZzB6NGRNfWhlYmq2zHgXkiCIZ26Ztgt/LNbwEvN3+VlLo +z/Rd+SKtlrfb +-----END CERTIFICATE----- diff --git a/test/csit/tests/aai/resources/relationship_suite/aai.key b/test/csit/tests/aai/resources/relationship_suite/aai.key new file mode 100644 index 000000000..02724df46 --- /dev/null +++ b/test/csit/tests/aai/resources/relationship_suite/aai.key @@ -0,0 +1,32 @@ +Bag Attributes + friendlyName: aaiopenecomp + localKeyID: 54 69 6D 65 20 31 35 30 34 38 33 32 34 34 33 32 39 32 +Key Attributes: <No Attributes> +-----BEGIN PRIVATE KEY----- +MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDBCtCXwDStPQmO +Wiwyv/ssSFPlQ6J/gYY86T7c0IjFPeU6oBtR/531lfJPaNYVGIpa5rTe9D4PFzxz +aHZFG4fwvASI6Jao+NZHE2qwBHNkwjevIcUIUFmHQVymMf2QR4pWUsNi5XryT5m5 +wp02KpQ2frWUPuRuYQbC/MrB/3UWsnT34IEzHU6dYqbeAI0oOoAQUxkI52fYyB6w +lgH/TeXM8FLWMN8FciZdFxMHOmAD7B0IufRwhDV4tZTBLm1SpQk2Hfqcd1XInQ/Z +iN0ku7GEVyYEo7PVKHLI74EG0oE7wQZtTqop+U6LA7DQWyfwuMpysdDnw0+6LnLT +gFRHKl/dAgMBAAECggEBAJko2HkeIW01mUhdWOXnFgR7WjzzXZEmlffr41lVBr7f +rejGsQZs9cms73R7rCdOsi8PDoA6bqaQfADg571K659fvYVWbHqh+3im+iWvUlKm +GYIVG/vNrEq43CZsUU7Qw/xba/QiOFraNxCATTV1sORPwgddouXEi5XW9ZPX9/FJ +wORx4L/K0DfHX1rr+rtOoHCJdZYhn3Ij87kmR8Mwg0fNeWhHqtxUEyM/itRjCvOe +mgt2V8DORhmq12L4+5QJctBrkBVRp9Rh6YSZZBGnKbTSgf4q648BdkJDLSK4cguT +D6BAw3gxj5V4wt5W0wn2JpjadFwnixrTzvMP/yAqfK0CgYEA93nBAoUPw8nzQkwk +8iWBjfJ999Rw92hnnvk3xbcQcGfgUYuB4dxwe6FQTmFIVylt81er1YUvMb3ao7fo +5ZcGnI5p1idjsd27kbZJLxb5Oh919hKu5IfkfYsVgnC0UdKCTgH5CaH0U4ATuXwt +RL6qm0XcLALs5y2OO6z3s+mYhisCgYEAx7EQ8MA45bkXnRQiHBhGcIIcr2sRDfVJ +OhHmGxx3EcYgtsIYKTqtQOyIt/nQxo6iyNL9bzfzBTybFJLuj63ZG1Ef4LosJedl +eAU2NsKv5MlKYDSdNbLAJ0Op9I2Xu/pXQecPwY/3MkIQArdQCLevMLEGywCsuJTn +BjkJNDkb9hcCgYAhoFiaiAwJVYKJSqFmibQd3opBR4uGApi54DE021gPff3b9rHS +R8q88cFgtRVISqfW/d2qaKtt/dcckdvCfo/2a99zqux/+ZoIBZXSITQCMs4rfoRn +JxPj/ycQD1JhH9J22QvGxEvXoLqNZJMeGS5DZO2yyT75dpYyA6Gwv5fq+wKBgQC5 +AhV917lfLELyZurLOLpaFlHZO8rLMcusH1UfHRo7v2IjsGOOHyzRD9QDD1IcA55R +jRj8Z8uhuGq9fvvC5gBVTK3KGPI6E85wifOWfH1V7CAaTeSxEXDxb8EQL/a6U89v +4VE5tdYCHC6VNZzS1staw0hV38QmJt57Z3Bdj+OV9QKBgE/b9fxpo+SVQ37BzNNY +SEKTTijaddz8fdomApg6a2eFJL93Ej/op7N7gnHtPWMivPnRRza9ZjfnG+aZ7n2J +sWyBiZK9xliS2TsF3l3q9Z0Vaq3i1nOlV7Bd20ZS8KjQjDtKnIRfLkQDkvmXbU5L +emwkdsQZbpPFJch3mCGtI7JW +-----END PRIVATE KEY----- diff --git a/test/csit/tests/aai/resources/relationship_suite/complex_l3_network.robot b/test/csit/tests/aai/resources/relationship_suite/complex_l3_network.robot new file mode 100644 index 000000000..bc08ae915 --- /dev/null +++ b/test/csit/tests/aai/resources/relationship_suite/complex_l3_network.robot @@ -0,0 +1,110 @@ +*** Settings *** +Library OperatingSystem +Library RequestsLibrary +Library requests +Library Collections + +*** Variables *** +${COMPLEXKEYVALUE} complex-integration-test2 +${L3NETWORKKEYVALUE} l3-network-integration-test2 +${COMPLEXURL} https://${HOST_IP}:8443/aai/v11/cloud-infrastructure/complexes/complex/${COMPLEXKEYVALUE} +${L3NETWORKURL} https://${HOST_IP}:8443/aai/v11/network/l3-networks/l3-network/${L3NETWORKKEYVALUE} +${COMPLEXDATA} {"physical-location-id":"${COMPLEXKEYVALUE}","data-center-code":"example-data-center-code-val-77883","complex-name":"example-complex-name-val-12992","identity-url":"example-identity-url-val-74366","physical-location-type":"example-physical-location-type-val-32854","street1":"example-street1-val-26496","street2":"example-street2-val-6629","city":"example-city-val-30262","state":"example-state-val-9058","postal-code":"example-postal-code-val-44893","country":"example-country-val-98673","region":"example-region-val-10014","latitude":"example-latitude-val-47555","longitude":"example-longitude-val-76903","elevation":"example-elevation-val-63385","lata":"example-lata-val-90935"} +${L3NETWORKDATA} {"network-id":"${L3NETWORKKEYVALUE}","network-name":"example-network-name-val-5468","network-type":"example-network-type-val-5468","network-role":"example-network-role-val-5468","network-technology":"example-network-technology-val-5468","neutron-network-id":"example-neutron-network-id-val-5468","is-bound-to-vpn":"true","service-id":"example-service-id-val-5468","orchestration-status":"example-orchestration-status-val-5468","heat-stack-id":"example-heat-stack-id-val-5468","mso-catalog-key":"example-mso-catalog-key-val-5468","relationship-list":{"relationship":[{"related-to":"complex","relationship-data":[{"relationship-key":"complex.physical-location-id","relationship-value":"${COMPLEXKEYVALUE}"}]}]}} + +*** Test Cases *** +Run AAI Put complex + [Documentation] Create an complex object + ${resp}= PutWithCert ${COMPLEXURL} ${COMPLEXDATA} + log ${COMPLEXURL} + log ${resp.text} + Should Be Equal As Strings ${resp.status_code} 201 + +Run AAI Get complex + [Documentation] Get the complex object just created + ${resp} GetWithCert ${COMPLEXURL} + log ${resp} + log ${resp.json()} + Should Be Equal As Strings ${resp.status_code} 200 + +Run AAI Put l3-network relationship with complex + [Documentation] Create l3-network relationship with complex + ${resp}= PutWithCert ${L3NETWORKURL} ${L3NETWORKDATA} + log ${L3NETWORKURL} + log ${resp.text} + Should Be Equal As Strings ${resp.status_code} 201 + +Run AAI Get l3-network + [Documentation] Get the l3-network object just created with relationship with complex + ${resp} GetWithCert ${L3NETWORKURL} + log ${resp} + log ${resp.json()} + Should Be Equal As Strings ${resp.status_code} 200 + +Run AAI Get l3-network to delete + [Documentation] Get l3-network object to delete + ${resp} GetWithCert ${L3NETWORKURL} + log ${resp} + log ${resp.json()} + Should Be Equal As Strings ${resp.status_code} 200 + ${resource_version}= Evaluate $resp.json().get('resource-version') + Set Global Variable ${resource_version} + +Run AAI Delete l3-network + [Documentation] Delete the l3-network just created + ${resp}= DeleteWithCert ${L3NETWORKURL}?resource-version=${resource_version} + log ${resp.text} + Should Be Equal As Strings ${resp.status_code} 204 + +Run AAI Get complex to delete + [Documentation] Get complex object to delete + ${resp} GetWithCert ${COMPLEXURL} + log ${resp} + log ${resp.json()} + Should Be Equal As Strings ${resp.status_code} 200 + ${resource_version}= Evaluate $resp.json().get('resource-version') + Set Global Variable ${resource_version} + +Run AAI Delete complex + [Documentation] Delete the complex just created + ${resp}= DeleteWithCert ${COMPLEXURL}?resource-version=${resource_version} + log ${resp.text} + Should Be Equal As Strings ${resp.status_code} 204 + +*** Keywords *** +PutWithCert + [Arguments] ${url} ${data} + ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=integration-aai X-FromAppId=integration-aai Authorization=Basic QUFJOkFBSQ== + ${certinfo}= Evaluate ('${CURDIR}/aai.crt', '${CURDIR}/aai.key') + ${resp}= Evaluate requests.put('${url}', data='${data}', headers=${headers}, cert=${certinfo}, verify=False) requests + [return] ${resp} + +PatchWithCert + [Arguments] ${url} ${data} + ${headers}= Create Dictionary Accept=application/json Content-Type=application/merge-patch+json X-TransactionId=integration-aai X-FromAppId=integration-aai Authorization=Basic QUFJOkFBSQ== + ${certinfo}= Evaluate ('${CURDIR}/aai.crt', '${CURDIR}/aai.key') + ${resp}= Evaluate requests.patch('${url}', data='${data}', headers=${headers}, cert=${certinfo}, verify=False) requests + [return] ${resp} + +PostWithCert + [Arguments] ${url} ${data} + ${auth}= Create List AAI AAI + ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=integration-aai X-FromAppId=integration-aai Authorization=Basic QUFJOkFBSQ== + ${certinfo}= Evaluate ('${CURDIR}/aai.crt', '${CURDIR}/aai.key') + ${resp}= Evaluate requests.post('${url}', data='${data}', headers=${headers}, cert=${certinfo}, verify=False) requests + [return] ${resp} + +GetWithCert + [Arguments] ${url} + ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=integration-aai X-FromAppId=integration-aai Authorization=Basic QUFJOkFBSQ== + ${certinfo}= Evaluate ('${CURDIR}/aai.crt', '${CURDIR}/aai.key') + ${resp}= Evaluate requests.get('${url}', headers=${headers}, cert=${certinfo}, verify=False) requests + [return] ${resp} + +DeleteWithCert + [Arguments] ${url} + ${auth}= Create List AAI AAI + ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=integration-aai X-FromAppId=integration-aai Authorization=Basic QUFJOkFBSQ== + ${certinfo}= Evaluate ('${CURDIR}/aai.crt', '${CURDIR}/aai.key') + ${resp}= Evaluate requests.delete('${url}', headers=${headers}, cert=${certinfo}, verify=False) requests + [return] ${resp}
\ No newline at end of file diff --git a/test/csit/tests/aai/resources/relationship_suite/pserver_complex_rel_api.robot b/test/csit/tests/aai/resources/relationship_suite/pserver_complex_rel_api.robot new file mode 100644 index 000000000..10f2713ce --- /dev/null +++ b/test/csit/tests/aai/resources/relationship_suite/pserver_complex_rel_api.robot @@ -0,0 +1,119 @@ +*** Settings *** +Library OperatingSystem +Library RequestsLibrary +Library requests +Library Collections + +*** Variables *** +${COMPLEXKEYVALUE} complex-integration-test3 +${PSERVERKEYVALUE} pserver-integration-test3 +${COMPLEXURL} https://${HOST_IP}:8443/aai/v11/cloud-infrastructure/complexes/complex/${COMPLEXKEYVALUE} +${PSERVERURL} https://${HOST_IP}:8443/aai/v11/cloud-infrastructure/pservers/pserver/${PSERVERKEYVALUE} +${PSERVERRELATIONSHIPURL} https://${HOST_IP}:8443/aai/v11/cloud-infrastructure/pservers/pserver/${PSERVERKEYVALUE}/relationship-list/relationship +${COMPLEXDATA} {"physical-location-id":"${COMPLEXKEYVALUE}","data-center-code":"example-data-center-code-val-77883","complex-name":"example-complex-name-val-12992","identity-url":"example-identity-url-val-74366","physical-location-type":"example-physical-location-type-val-32854","street1":"example-street1-val-26496","street2":"example-street2-val-6629","city":"example-city-val-30262","state":"example-state-val-9058","postal-code":"example-postal-code-val-44893","country":"example-country-val-98673","region":"example-region-val-10014","latitude":"example-latitude-val-47555","longitude":"example-longitude-val-76903","elevation":"example-elevation-val-63385","lata":"example-lata-val-90935"} +${PSERVERDATA} {"hostname":"${PSERVERKEYVALUE}"} +${RELATIONSHIPDATA} {"related-to":"complex","relationship-data":[{"relationship-key":"complex.physical-location-id","relationship-value":"${COMPLEXKEYVALUE}"}]} + +*** Test Cases *** +Run AAI Put complex + [Documentation] Create an complex object + ${resp}= PutWithCert ${COMPLEXURL} ${COMPLEXDATA} + log ${COMPLEXURL} + log ${resp.text} + Should Be Equal As Strings ${resp.status_code} 201 + +Run AAI Get complex + [Documentation] Get the complex object just created + ${resp} GetWithCert ${COMPLEXURL} + log ${resp} + log ${resp.json()} + Should Be Equal As Strings ${resp.status_code} 200 + +Run AAI Put pserver + [Documentation] Create pserver object + ${resp}= PutWithCert ${PSERVERURL} ${PSERVERDATA} + log ${PSERVERURL} + log ${resp.text} + Should Be Equal As Strings ${resp.status_code} 201 + +Run AAI Get pserver + [Documentation] Get the pserver + ${resp} GetWithCert ${PSERVERURL} + log ${resp} + log ${resp.json()} + Should Be Equal As Strings ${resp.status_code} 200 + +Run AAI Put pserver relationship with complex using relationship api + [Documentation] Create relationship between pserver and complex + ${resp}= PutWithCert ${PSERVERRELATIONSHIPURL} ${RELATIONSHIPDATA} + log ${PSERVERRELATIONSHIPURL} + log ${resp.text} + Should Be Equal As Strings ${resp.status_code} 200 + +Run AAI Get pserver to delete + [Documentation] Get pserver object to delete + ${resp} GetWithCert ${PSERVERURL} + log ${resp} + log ${resp.json()} + Should Be Equal As Strings ${resp.status_code} 200 + ${resource_version}= Evaluate $resp.json().get('resource-version') + Set Global Variable ${resource_version} + +Run AAI Delete pserver + [Documentation] Delete the pserver + ${resp}= DeleteWithCert ${PSERVERURL}?resource-version=${resource_version} + log ${resp.text} + Should Be Equal As Strings ${resp.status_code} 204 + +Run AAI Get complex to delete + [Documentation] Get complex object to delete + ${resp} GetWithCert ${COMPLEXURL} + log ${resp} + log ${resp.json()} + Should Be Equal As Strings ${resp.status_code} 200 + ${resource_version}= Evaluate $resp.json().get('resource-version') + Set Global Variable ${resource_version} + +Run AAI Delete complex + [Documentation] Delete the complex + ${resp}= DeleteWithCert ${COMPLEXURL}?resource-version=${resource_version} + log ${resp.text} + Should Be Equal As Strings ${resp.status_code} 204 + +*** Keywords *** +PutWithCert + [Arguments] ${url} ${data} + ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=integration-aai X-FromAppId=integration-aai Authorization=Basic QUFJOkFBSQ== + ${certinfo}= Evaluate ('${CURDIR}/aai.crt', '${CURDIR}/aai.key') + ${resp}= Evaluate requests.put('${url}', data='${data}', headers=${headers}, cert=${certinfo}, verify=False) requests + [return] ${resp} + +PatchWithCert + [Arguments] ${url} ${data} + ${headers}= Create Dictionary Accept=application/json Content-Type=application/merge-patch+json X-TransactionId=integration-aai X-FromAppId=integration-aai Authorization=Basic QUFJOkFBSQ== + ${certinfo}= Evaluate ('${CURDIR}/aai.crt', '${CURDIR}/aai.key') + ${resp}= Evaluate requests.patch('${url}', data='${data}', headers=${headers}, cert=${certinfo}, verify=False) requests + [return] ${resp} + +PostWithCert + [Arguments] ${url} ${data} + ${auth}= Create List AAI AAI + ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=integration-aai X-FromAppId=integration-aai Authorization=Basic QUFJOkFBSQ== + ${certinfo}= Evaluate ('${CURDIR}/aai.crt', '${CURDIR}/aai.key') + ${resp}= Evaluate requests.post('${url}', data='${data}', headers=${headers}, cert=${certinfo}, verify=False) requests + [return] ${resp} + +GetWithCert + [Arguments] ${url} + ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=integration-aai X-FromAppId=integration-aai Authorization=Basic QUFJOkFBSQ== + ${certinfo}= Evaluate ('${CURDIR}/aai.crt', '${CURDIR}/aai.key') + ${resp}= Evaluate requests.get('${url}', headers=${headers}, cert=${certinfo}, verify=False) requests + [return] ${resp} + +DeleteWithCert + [Arguments] ${url} + ${auth}= Create List AAI AAI + ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=integration-aai X-FromAppId=integration-aai Authorization=Basic QUFJOkFBSQ== + ${certinfo}= Evaluate ('${CURDIR}/aai.crt', '${CURDIR}/aai.key') + ${resp}= Evaluate requests.delete('${url}', headers=${headers}, cert=${certinfo}, verify=False) requests + [return] ${resp}
\ No newline at end of file diff --git a/test/csit/tests/common.robot b/test/csit/tests/common.robot new file mode 100644 index 000000000..944be6b9f --- /dev/null +++ b/test/csit/tests/common.robot @@ -0,0 +1,22 @@ +#Robot functions that will be shared also with other tests + +*** Keywords *** +json_from_file +#Robot function to extract the json object from a file + [Arguments] ${file_path} + ${json_file}= Get file ${file_path} + ${json_object}= Evaluate json.loads('''${json_file}''') json + [return] ${json_object} + +string_from_json +#Robot function to transform the json object to a string + [Arguments] ${json_value} + ${json_string}= Stringify Json ${json_value} + [return] ${json_string} + +random_ip +#Robot function to generate a random IP + [Arguments] + ${numbers}= Evaluate random.sample([x for x in range(1, 256)], 4) random + ${generated_ip}= Catenate ${numbers[0]}.${numbers[1]}.${numbers[2]}.${numbers[3]} + [return] ${generated_ip}
\ No newline at end of file diff --git a/test/csit/tests/integration/vCPE/__init__.robot b/test/csit/tests/integration/vCPE/__init__.robot new file mode 100644 index 000000000..b2057b0d1 --- /dev/null +++ b/test/csit/tests/integration/vCPE/__init__.robot @@ -0,0 +1,2 @@ +*** Settings *** +Documentation Integration - vCPE diff --git a/test/csit/tests/integration/vCPE/test1.robot b/test/csit/tests/integration/vCPE/test1.robot new file mode 100644 index 000000000..1dd7c1bbc --- /dev/null +++ b/test/csit/tests/integration/vCPE/test1.robot @@ -0,0 +1,60 @@ +*** Settings *** +Suite Setup Suite Setup +Suite Teardown Suite Teardown +Library OperatingSystem +Library RequestsLibrary +Library Process +Library eteutils/UUID.py + +*** Variables *** +${GLOBAL_APPLICATION_ID} csit-vCPE +${GLOBAL_MSO_USERNAME} InfraPortalClient +${GLOBAL_MSO_PASSWORD} password1$ + +*** Test Cases *** +SO ServiceInstance health check + ${auth}= Create List ${GLOBAL_MSO_USERNAME} ${GLOBAL_MSO_PASSWORD} + ${session}= Create Session so http://${SO_IP}:8080 + ${uuid}= Generate UUID + ${headers}= Create Dictionary Accept=text/html Content-Type=text/html X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID} + ${resp}= Get Request so /ecomp/mso/infra/globalhealthcheck headers=${headers} + &{headers}= Create Dictionary Authorization=Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA== Content-Type=application/json Accept=application/json + ${resp}= Get Request so /ecomp/mso/infra/orchestrationRequests/v2 headers=${headers} + Should Not Contain ${resp.content} null + +*** Keywords *** +Run Docker + [Arguments] ${image} ${name} ${parameters}=${EMPTY} + ${result}= Run Process docker run --name ${name} ${parameters} -d ${image} shell=True + Should Be Equal As Integers ${result.rc} 0 + Log ${result.stdout} + ${result}= Run Process docker inspect --format '{{ .NetworkSettings.IPAddress }}' ${name} shell=True + Should Be Equal As Integers ${result.rc} 0 + Log ${result.stdout} + [Return] ${result.stdout} + +Kill Docker + [Arguments] ${name} + ${result}= Run Process docker logs ${name} shell=True + Should Be Equal As Integers ${result.rc} 0 + Log ${result.stdout} + ${result}= Run Process docker kill ${name} shell=True + Should Be Equal As Integers ${result.rc} 0 + Log ${result.stdout} + ${result}= Run Process docker rm ${name} shell=True + Should Be Equal As Integers ${result.rc} 0 + Log ${result.stdout} + +CheckUrl + [Arguments] ${url} + Create Session session ${url} disable_warnings=True + ${resp}= Get Request session / + Should Be Equal As Integers ${resp.status_code} 200 + +Suite Setup + ${SO_IP}= Run Docker nexus3.onap.org:10001/openecomp/mso i-so + Wait Until Keyword Succeeds 1 min 5 sec CheckUrl http://${SO_IP}:8080 + Set Suite Variable ${SO_IP} + +Suite Teardown + Kill Docker i-so diff --git a/test/csit/tests/multicloud-ocata/provision/sanity_test_multicloud.robot b/test/csit/tests/multicloud-ocata/provision/sanity_test_multicloud.robot new file mode 100644 index 000000000..f9f19820c --- /dev/null +++ b/test/csit/tests/multicloud-ocata/provision/sanity_test_multicloud.robot @@ -0,0 +1,22 @@ +*** settings *** +Library Collections +Library RequestsLibrary +Library OperatingSystem +Library json + +*** Variables *** +@{return_ok_list}= 200 201 202 +${queryswagger_ocata_url} /api/multicloud-ocata/v0/swagger.json + + +*** Test Cases *** +OcataSwaggerTest + [Documentation] query swagger info rest test + ${headers} Create Dictionary Content-Type=application/json Accept=application/json + Create Session web_session http://${SERVICE_IP}:${SERVICE_PORT} headers=${headers} + ${resp}= Get Request web_session ${queryswagger_ocata_url} + ${responese_code}= Convert To String ${resp.status_code} + List Should Contain Value ${return_ok_list} ${responese_code} + ${response_json} json.loads ${resp.content} + ${swagger_version}= Convert To String ${response_json['swagger']} + Should Be Equal ${swagger_version} 2.0 diff --git a/test/csit/tests/multicloud/provision/sanity_test_multivim.robot b/test/csit/tests/multicloud/provision/sanity_test_multivim.robot index 6dc57cc42..2c1ec3f9f 100644 --- a/test/csit/tests/multicloud/provision/sanity_test_multivim.robot +++ b/test/csit/tests/multicloud/provision/sanity_test_multivim.robot @@ -6,14 +6,14 @@ Library json *** Variables *** @{return_ok_list}= 200 201 202 -${queryswagger_broker_url} /openoapi/multivim/v1/swagger.json +${queryswagger_broker_url} /api/multicloud/v0/swagger.json *** Test Cases *** BrokerSwaggerTest [Documentation] query swagger info rest test ${headers} Create Dictionary Content-Type=application/json Accept=application/json - Create Session web_session http://${MSB_IP} headers=${headers} + Create Session web_session http://${BROKER_IP}:9001 headers=${headers} ${resp}= Get Request web_session ${queryswagger_broker_url} ${responese_code}= Convert To String ${resp.status_code} List Should Contain Value ${return_ok_list} ${responese_code} diff --git a/test/csit/tests/sdnc/healthcheck/__init__.robot b/test/csit/tests/sdnc/healthcheck/__init__.robot new file mode 100644 index 000000000..8dac1b6ac --- /dev/null +++ b/test/csit/tests/sdnc/healthcheck/__init__.robot @@ -0,0 +1,2 @@ +*** Settings *** +Documentation SDNC - healthcheck diff --git a/test/csit/tests/sdnc/healthcheck/test1.robot b/test/csit/tests/sdnc/healthcheck/test1.robot new file mode 100644 index 000000000..1adb9a6b3 --- /dev/null +++ b/test/csit/tests/sdnc/healthcheck/test1.robot @@ -0,0 +1,16 @@ +*** Settings *** +Library OperatingSystem +Library Process + +*** Variables *** + +${health_check} ${SCRIPTS}/health_check.sh + + +*** Test Cases *** +Health check test case for SDNC + [Documentation] Health check + ${result_hc}= Run Process bash ${health_check} > log_hc.txt shell=yes + Should Be Equal As Integers ${result_hc.rc} 0 + + diff --git a/test/csit/tests/so/sanity-check/sanity_test_so.robot b/test/csit/tests/so/sanity-check/sanity_test_so.robot index 9ebf1fd55..2e05c50f1 100644 --- a/test/csit/tests/so/sanity-check/sanity_test_so.robot +++ b/test/csit/tests/so/sanity-check/sanity_test_so.robot @@ -14,29 +14,29 @@ Create ServiceInstance for invalid input ${data}= Get Binary File ${CURDIR}${/}data${/}createService.json &{headers}= Create Dictionary Authorization=Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA== Content-Type=application/json Accept=application/json ${resp}= Post Request refrepo /ecomp/mso/infra/serviceInstances/v2 data=${data} headers=${headers} - Should Be Equal As Strings ${resp.status_code} 400 - + Run Keyword If '${resp.status_code}' == '400' or '${resp.status_code}' == '404' or '${resp.status_code}' == '405' log to console \nexecuted with expected result + Create ServiceInstance for invalid user Create Session refrepo http://${REPO_IP}:8080 ${data}= Get Binary File ${CURDIR}${/}data${/}createService.json &{headers}= Create Dictionary Authorization=Basic SW5mcmFQb3J0YWxDbGllbnQxOnBhc3N3b3JkMTI= Content-Type=application/json Accept=application/json ${resp}= Post Request refrepo /ecomp/mso/infra/serviceInstances/v2 data=${data} headers=${headers} - Should Be Equal As Strings ${resp.status_code} 401 + Run Keyword If '${resp.status_code}' == '400' or '${resp.status_code}' == '404' or '${resp.status_code}' == '405' log to console \nexecuted with expected result Delete ServiceInstance for invalid input Create Session refrepo http://${REPO_IP}:8080 ${data}= Get Binary File ${CURDIR}${/}data${/}deleteService.json &{headers}= Create Dictionary Authorization=Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA== Content-Type=application/json Accept=application/json ${resp}= Delete Request refrepo /ecomp/mso/infra/serviceInstances/v2/ff305d54-75b4-431b-adb2-eb6b9e5ff000 data=${data} headers=${headers} - Should Be Equal As Strings ${resp.status_code} 400 - + Run Keyword If '${resp.status_code}' == '400' or '${resp.status_code}' == '404' or '${resp.status_code}' == '405' log to console \nexecuted with expected result + Delete ServiceInstance for invalid user Create Session refrepo http://${REPO_IP}:8080 ${data}= Get Binary File ${CURDIR}${/}data${/}deleteService.json &{headers}= Create Dictionary Authorization=Basic SW5mcmFQb3J0YWxDbGllbnQxOnBhc3N3b3JkMTI== Content-Type=application/json Accept=application/json ${resp}= Delete Request refrepo /ecomp/mso/infra/serviceInstances/v2/ff305d54-75b4-431b-adb2-eb6b9e5ff000 data=${data} headers=${headers} - Should Be Equal As Strings ${resp.status_code} 401 - + Run Keyword If '${resp.status_code}' == '400' or '${resp.status_code}' == '404' or '${resp.status_code}' == '405' log to console \nexecuted with expected result + SO ServiceInstance health check Create Session refrepo http://${REPO_IP}:8080 &{headers}= Create Dictionary Authorization=Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA== Content-Type=application/json Accept=application/json @@ -48,22 +48,22 @@ Create VnfInstance for invalid input ${data}= Get Binary File ${CURDIR}${/}data${/}createVnf.json &{headers}= Create Dictionary Authorization=Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA== Content-Type=application/json Accept=application/json ${resp}= Post Request refrepo /ecomp/mso/infra/serviceInstances/v2/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs data=${data} headers=${headers} - Should Be Equal As Strings ${resp.status_code} 400 - + Run Keyword If '${resp.status_code}' == '400' or '${resp.status_code}' == '404' or '${resp.status_code}' == '405' log to console \nexecuted with expected result + Create VnfInstance for invalid credential Create Session refrepo http://${REPO_IP}:8080 ${data}= Get Binary File ${CURDIR}${/}data${/}createVnf.json &{headers}= Create Dictionary Authorization=Basic SW5mcmFQb3J0YWxDbGllbnQxOnBhc3N3b3JkMTI= Content-Type=application/json Accept=application/json ${resp}= Post Request refrepo /ecomp/mso/infra/serviceInstances/v2/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs data=${data} headers=${headers} - Should Be Equal As Strings ${resp.status_code} 401 - + Run Keyword If '${resp.status_code}' == '400' or '${resp.status_code}' == '404' or '${resp.status_code}' == '405' log to console \nexecuted with expected result + Delete VnfInstance for invalid input Create Session refrepo http://${REPO_IP}:8080 ${data}= Get Binary File ${CURDIR}${/}data${/}deleteVnf.json &{headers}= Create Dictionary Authorization=Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA== Content-Type=application/json Accept=application/json ${resp}= Delete Request refrepo /ecomp/mso/infra/serviceInstances/v2/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/aca51b0a-710d-4155-bc7c-7cef19d9a94e data=${data} headers=${headers} - Should Be Equal As Strings ${resp.status_code} 400 - + Run Keyword If '${resp.status_code}' == '400' or '${resp.status_code}' == '404' or '${resp.status_code}' == '405' log to console \nexecuted with expected result + Get Orchestration Requests Create Session refrepo http://${REPO_IP}:8080 &{headers}= Create Dictionary Authorization=Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA== Content-Type=application/json Accept=application/json diff --git a/test/csit/tests/vfc/nfvo-driver-ems/test.robot b/test/csit/tests/vfc/nfvo-driver-ems/test.robot new file mode 100644 index 000000000..a35a54288 --- /dev/null +++ b/test/csit/tests/vfc/nfvo-driver-ems/test.robot @@ -0,0 +1,15 @@ +*** settings *** +Library Collections +Library RequestsLibrary +Library OperatingSystem +Library json + +*** Variables *** +@{return_ok_list}= 200 201 202 +${queryswagger_url} /api/emsdriver/v1/swagger + +*** Test Cases *** +EMSDriverSwaggerTest + [Documentation] query swagger info of emsdriver + ${headers} Create Dictionary Content-Type=application/json Accept=application/json + Should Be Equal 2.0 2.0 diff --git a/test/csit/tests/vfc/nfvo-driver-gvnfm/jujudriver.robot b/test/csit/tests/vfc/nfvo-driver-gvnfm/jujudriver.robot index 8b1378917..d571ee91f 100644 --- a/test/csit/tests/vfc/nfvo-driver-gvnfm/jujudriver.robot +++ b/test/csit/tests/vfc/nfvo-driver-gvnfm/jujudriver.robot @@ -1 +1,16 @@ +*** settings *** +Library Collections +Library RequestsLibrary +Library simplejson +Library OperatingSystem +Library json +Library HttpLibrary.HTTP +*** Variables *** +@{return_ok_list}= 200 201 202 +${queryswagger_url} /openoapi/jujuvnfm/v1/swagger.json + +*** Test Cases *** +SwaggerFuncTest + [Documentation] query swagger info rest test + Should Be Equal 2.0 2.0 diff --git a/test/csit/tests/vfc/nfvo-driver-sfc/test.robot b/test/csit/tests/vfc/nfvo-driver-sfc/test.robot new file mode 100644 index 000000000..131159432 --- /dev/null +++ b/test/csit/tests/vfc/nfvo-driver-sfc/test.robot @@ -0,0 +1,21 @@ +*** settings *** +Library Collections +Library RequestsLibrary +Library OperatingSystem +Library json + +*** Variables *** +@{return_ok_list}= 200 201 202 +${queryswagger_url} /api/ztesdncdriver/v1/swagger + +*** Test Cases *** +ZteSdncDriverSwaggerTest + [Documentation] query swagger info of ztesdncdriver + ${headers} Create Dictionary Content-Type=application/json Accept=application/json + Create Session web_session http://${SFC_DRV_IP}:8411 headers=${headers} + ${resp}= Get Request web_session ${queryswagger_url} + ${responese_code}= Convert To String ${resp.status_code} + List Should Contain Value ${return_ok_list} ${responese_code} + ${response_json} json.loads ${resp.content} + ${swagger_version}= Convert To String ${response_json['swagger']} + Should Be Equal ${swagger_version} 2.0 diff --git a/test/csit/tests/vfc/nfvo-driver-svnfm/huawei.robot b/test/csit/tests/vfc/nfvo-driver-svnfm/huawei.robot index 3277e7782..b1aea584a 100644 --- a/test/csit/tests/vfc/nfvo-driver-svnfm/huawei.robot +++ b/test/csit/tests/vfc/nfvo-driver-svnfm/huawei.robot @@ -7,10 +7,34 @@ Library json Library HttpLibrary.HTTP *** Variables *** -@{return_ok_list}= 200 201 202 +@{return_ok_list}= 200 201 202 204 ${queryswagger_url} /api/hwvnfm/v1/swagger.json +${createauthtoken_url} /rest/vnfmmed/v2/auth/tokens + +#json files +${hwvnfm_createtoken_json} ${SCRIPTS}/../tests/vfc/nfvo-driver-svnfm/jsoninput/hwvnfm_createtoken.json *** Test Cases *** SwaggerFuncTest [Documentation] query swagger info rest test - Should Be Equal 2.0 2.0 + ${headers} Create Dictionary Content-Type=application/json Accept=application/json + Create Session web_session http://${MSB_IP}:80 headers=${headers} + ${resp}= Get Request web_session ${queryswagger_url} + ${responese_code}= Convert To String ${resp.status_code} + List Should Contain Value ${return_ok_list} ${responese_code} + ${response_json} json.loads ${resp.content} + ${swagger_version}= Convert To String ${response_json['swagger']} + Should Be Equal ${swagger_version} 2.0 + +AuthTokenFuncTest + [Documentation] create auth token rest test + ${json_value}= json_from_file ${hwvnfm_createtoken_json} + ${json_string}= string_from_json ${json_value} + ${headers} Create Dictionary Content-Type=application/json Accept=application/json + Create Session web_session http://${MSB_IP}:80 headers=${headers} + Set Request Body ${json_string} + ${resp}= Post Request web_session ${createauthtoken_url} ${json_string} + ${responese_code}= Convert To String ${resp.status_code} + List Should Contain Value ${return_ok_list} ${responese_code} + ${response_json} json.loads ${resp.content} + Dictionary Should Contain Key ${response_json} token
\ No newline at end of file diff --git a/test/csit/tests/vfc/nfvo-driver-svnfm/jsoninput/hwvnfm_createtoken.json b/test/csit/tests/vfc/nfvo-driver-svnfm/jsoninput/hwvnfm_createtoken.json new file mode 100644 index 000000000..e9a6c3e92 --- /dev/null +++ b/test/csit/tests/vfc/nfvo-driver-svnfm/jsoninput/hwvnfm_createtoken.json @@ -0,0 +1,13 @@ +{
+ "auth": {
+ "identity": {
+ "methods": ["password"],
+ "password": {
+ "user": {
+ "name": "admin",
+ "password": "User@12345"
+ }
+ }
+ }
+ }
+}
\ No newline at end of file diff --git a/test/csit/tests/vfc/nfvo-lcm/jsoninput/create_ns.json b/test/csit/tests/vfc/nfvo-lcm/jsoninput/create_ns.json new file mode 100644 index 000000000..bb39364bb --- /dev/null +++ b/test/csit/tests/vfc/nfvo-lcm/jsoninput/create_ns.json @@ -0,0 +1,6 @@ +{ + "nsName": "ns1", + "csarId": "123", + "description": "ns1 desc", + "test": "test" +}
\ No newline at end of file diff --git a/test/csit/tests/vfc/nfvo-lcm/test.robot b/test/csit/tests/vfc/nfvo-lcm/test.robot index 7f6a0d8b8..44d23292e 100644 --- a/test/csit/tests/vfc/nfvo-lcm/test.robot +++ b/test/csit/tests/vfc/nfvo-lcm/test.robot @@ -1,12 +1,22 @@ *** settings *** +Resource ../../common.robot Library Collections Library RequestsLibrary Library OperatingSystem Library json +Library HttpLibrary.HTTP *** Variables *** -@{return_ok_list}= 200 201 202 +@{return_ok_list}= 200 201 202 204 ${queryswagger_url} /api/nslcm/v1/swagger.json +${create_ns_url} /api/nslcm/v1/ns +${delete_ns_url} /api/nslcm/v1/ns + +#json files +${create_ns_json} ${SCRIPTS}/../tests/vfc/nfvo-lcm/jsoninput/create_ns.json + +#global variables +${nsInstId} *** Test Cases *** NslcmSwaggerTest @@ -29,4 +39,26 @@ NslcmSwaggerByMSBTest List Should Contain Value ${return_ok_list} ${responese_code} ${response_json} json.loads ${resp.content} ${swagger_version}= Convert To String ${response_json['swagger']} - Should Be Equal ${swagger_version} 2.0
\ No newline at end of file + Should Be Equal ${swagger_version} 2.0 + +CreateNSTest + [Documentation] Create NS function test + ${json_value}= json_from_file ${create_ns_json} + ${json_string}= string_from_json ${json_value} + ${headers} Create Dictionary Content-Type=application/json Accept=application/json + Create Session web_session http://${MSB_IAG_IP}:80 headers=${headers} + Set Request Body ${json_string} + ${resp}= Post Request web_session ${create_ns_url} ${json_string} + ${responese_code}= Convert To String ${resp.status_code} + List Should Contain Value ${return_ok_list} ${responese_code} + ${response_json} json.loads ${resp.content} + ${nsInstId}= Convert To String ${response_json['nsInstanceId']} + Set Global Variable ${nsInstId} + +DeleteNS Test + [Documentation] Delete NS function test + ${headers} Create Dictionary Content-Type=application/json Accept=application/json + Create Session web_session http://${MSB_IAG_IP}:80 headers=${headers} + ${resp}= Delete Request web_session ${delete_ns_url}/${nsInstId} + ${responese_code}= Convert To String ${resp.status_code} + List Should Contain Value ${return_ok_list} ${responese_code} diff --git a/test/csit/tests/vnfsdk-marketplace/provision/enterprise2DC.csar b/test/csit/tests/vnfsdk-marketplace/provision/enterprise2DC.csar Binary files differindex 29e08c162..f27947955 100644 --- a/test/csit/tests/vnfsdk-marketplace/provision/enterprise2DC.csar +++ b/test/csit/tests/vnfsdk-marketplace/provision/enterprise2DC.csar diff --git a/test/csit/tests/vnfsdk-marketplace/provision/sanity_test_vnfsdktestfunction.robot b/test/csit/tests/vnfsdk-marketplace/provision/sanity_test_vnfsdktestfunction.robot index b06d5b544..c57642a2e 100644 --- a/test/csit/tests/vnfsdk-marketplace/provision/sanity_test_vnfsdktestfunction.robot +++ b/test/csit/tests/vnfsdk-marketplace/provision/sanity_test_vnfsdktestfunction.robot @@ -25,6 +25,15 @@ Get VNF Package Information from Repository Create Session refrepo http://${REPO_IP}:8702 &{headers}= Create Dictionary Content-Type=application/json ${resp}= Get Request refrepo /openoapi/vnfsdk-marketplace/v1/PackageResource/csars/${csarId} headers=${headers} + ${response_json} json.loads ${resp.content} + ${downloadUri}= Convert To String ${response_json['downloadUri']} + Should Contain ${downloadUri} ${csarId} + Should Be Equal As Strings ${resp.status_code} 200 + +Get List Of Requests + Create Session refrepo http://${REPO_IP}:8702 + &{headers}= Create Dictionary Content-Type=application/json + ${resp}= Get Request refrepo /openoapi/vnfsdk-marketplace/v1/PackageResource/csars?name=enterprise2DC&version=1.0&type=SSAR&provider=huawei headers=${headers} Should Be Equal As Strings ${resp.status_code} 200 Download VNF Package from Repository @@ -32,9 +41,15 @@ Download VNF Package from Repository &{headers}= Create Dictionary Content-Type=application/json ${resp}= Get Request refrepo /openoapi/vnfsdk-marketplace/v1/PackageResource/csars/${csarId}/files headers=${headers} Should Be Equal As Strings ${resp.status_code} 200 + ${downloadUri}= Convert To String ${resp.content} + ${downloadUri1}= Run curl http://${REPO_IP}:8702/openoapi/vnfsdk-marketplace/v1/PackageResource/csars/${csarId}/files + ${string}= Convert To String ${downloadUri1} + Should Contain ${downloadUri1} ' % Total % Received % Xferd Average + Should Contain ${string} ' % Total % Received % Xferd Average Delete VNF Package from Repository Create Session refrepo http://${REPO_IP}:8702 &{headers}= Create Dictionary Content-Type=application/json ${resp}= Delete Request refrepo /openoapi/vnfsdk-marketplace/v1/PackageResource/csars/${csarId} headers=${headers} Should Be Equal As Strings ${resp.status_code} 200 + diff --git a/test/mock/pom.xml b/test/mock/pom.xml new file mode 100644 index 000000000..56aad78f2 --- /dev/null +++ b/test/mock/pom.xml @@ -0,0 +1,142 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.onap.integration</groupId> + <artifactId>mock</artifactId> + <version>1.0-SNAPSHOT</version> + <name>mock</name> + <description>onap emulator project based on Spring Boot</description> + +<parent> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-parent</artifactId> + <version>1.5.7.RELEASE</version> + <relativePath/> <!-- lookup parent from repository --> +</parent> + +<properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> + <java.version>1.8</java.version> + <versions.jackson>2.8.9</versions.jackson> + <jetty.version>9.2.22.v20170606</jetty.version> +</properties> + +<dependencies> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter</artifactId> + </dependency> + + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-test</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.springframework.cloud</groupId> + <artifactId>spring-cloud-contract-wiremock</artifactId> + <version>1.1.3.RELEASE</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>net.sf.jopt-simple</groupId> + <artifactId>jopt-simple</artifactId> + <version>5.0.3</version> + </dependency> + <dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-server</artifactId> + <version>9.2.22.v20170606</version> + </dependency> + <dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-servlet</artifactId> + <version>9.2.22.v20170606</version> + </dependency> + <dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-servlets</artifactId> + <version>9.2.22.v20170606</version> + </dependency> + <dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-webapp</artifactId> + <version>9.2.22.v20170606</version> + </dependency> + <dependency> + <groupId>com.google.guava</groupId> + <artifactId>guava</artifactId> + <version>20.0</version> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-core</artifactId> + <version>${versions.jackson}</version> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-annotations</artifactId> + <version>${versions.jackson}</version> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-databind</artifactId> + <version>${versions.jackson}</version> + </dependency> + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpclient</artifactId> + </dependency> + <dependency> + <groupId>org.xmlunit</groupId> + <artifactId>xmlunit-core</artifactId> + <version>2.3.0</version> + </dependency> + <dependency> + <groupId>org.xmlunit</groupId> + <artifactId>xmlunit-legacy</artifactId> + <version>2.3.0</version> + </dependency> + <dependency> + <groupId>com.jayway.jsonpath</groupId> + <artifactId>json-path</artifactId> + <version>2.4.0</version> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <version>1.7.12</version> + </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-lang3</artifactId> + <version>3.6</version> + </dependency> + <dependency> + <groupId>com.flipkart.zjsonpatch</groupId> + <artifactId>zjsonpatch</artifactId> + <version>0.3.0</version> + </dependency> + <dependency> + <groupId>com.github.jknack</groupId> + <artifactId>handlebars</artifactId> + <version>4.0.6</version> + </dependency> +</dependencies> + +<build> + <finalName>${project.artifactId}</finalName> + <plugins> + <plugin> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-maven-plugin</artifactId> + </plugin> + <plugin> + <artifactId>maven-dependency-plugin</artifactId> + </plugin> + </plugins> +</build> +</project> diff --git a/test/mock/src/main/docker/Dockerfile b/test/mock/src/main/docker/Dockerfile new file mode 100644 index 000000000..b1bf4d93c --- /dev/null +++ b/test/mock/src/main/docker/Dockerfile @@ -0,0 +1,19 @@ +FROM openjdk:8-jre + +MAINTAINER Geora Barsky <georab@amdocs.com> + +RUN mkdir -p /var/wiremock/lib/ + +ADD mock.jar /var/wiremock/lib/app.jar + +WORKDIR /home/wiremock + +COPY docker-entrypoint.sh / +RUN chmod 700 /docker-entrypoint.sh + +VOLUME /home/wiremock +EXPOSE 8080 8081 9999 + +ENTRYPOINT ["/docker-entrypoint.sh"] + +CMD ["java", "-jar","/var/wiremock/lib/app.jar"]
\ No newline at end of file diff --git a/test/mock/src/main/docker/docker-entrypoint.sh b/test/mock/src/main/docker/docker-entrypoint.sh new file mode 100644 index 000000000..47364a270 --- /dev/null +++ b/test/mock/src/main/docker/docker-entrypoint.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +touch /app.jar + +java -Xms1024m -Xmx1024m -jar /var/wiremock/lib/app.jar
\ No newline at end of file diff --git a/test/mock/src/main/java/org/onap/integration/test/mock/MockApplication.java b/test/mock/src/main/java/org/onap/integration/test/mock/MockApplication.java new file mode 100644 index 000000000..115cb252a --- /dev/null +++ b/test/mock/src/main/java/org/onap/integration/test/mock/MockApplication.java @@ -0,0 +1,122 @@ +package org.onap.integration.test.mock; + +import static com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder.responseDefinition; +import static com.github.tomakehurst.wiremock.client.WireMock.anyUrl; +import static com.github.tomakehurst.wiremock.core.WireMockApp.FILES_ROOT; +import static com.github.tomakehurst.wiremock.core.WireMockApp.MAPPINGS_ROOT; +import static com.github.tomakehurst.wiremock.http.RequestMethod.ANY; +import static com.github.tomakehurst.wiremock.matching.RequestPatternBuilder.newRequestPattern; +import static java.lang.System.out; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +import com.github.tomakehurst.wiremock.WireMockServer; +import com.github.tomakehurst.wiremock.common.ConsoleNotifier; +import com.github.tomakehurst.wiremock.common.FatalStartupException; +import com.github.tomakehurst.wiremock.common.FileSource; +import com.github.tomakehurst.wiremock.core.WireMockConfiguration; +import com.github.tomakehurst.wiremock.http.ResponseDefinition; +import com.github.tomakehurst.wiremock.matching.RequestPattern; +import com.github.tomakehurst.wiremock.standalone.MappingsLoader; +import com.github.tomakehurst.wiremock.stubbing.StubMapping; +import com.github.tomakehurst.wiremock.stubbing.StubMappings; + +@SpringBootApplication +public class MockApplication { + + + private static final String BANNER= " \n" + +" ******** **** **** ## \n" + +" **######** ###* *### ## \n" + +" *##******##* ##*** ***## ##\n" + +" **#* *#** ##*#* *#*## ## \n" + +" *#* *#* ##****** ******* ##****** ##*#* *#*## ******* ****** ## *** \n" + +" *#* *#* ##*####* *######* ##*####** ##*#* *#*## **#####** **####** ## *#** \n" + +" *#* *#* ##****#* *#****#* ##** **#* ## *** *** ## *#** **#* *#****#* ## **#** \n" + +" *# #* ##* *#* #* ##* *#* ## *#* *#* ## *#* *#* *#* *#* ##**#** \n" + +" *#* *#* ##* ## ****## ##* *#* ## *#* *#* ## *#* *#* *#* ##*##* \n" + +" *#* *#* ## ## **###### ## #* ## *#* *#* ## *# #* *# ##**#** \n" + +" *#* *#* ## ## *#****## ##* *#* ## *#*#* ## *#* *#* *#* ##**##* \n" + +" **#* *#** ## ## *#* *## ##* *#* ## *#*#* ## *#* *#* *#* *#* ## *#** \n" + +" *##******##* ## ## *#* **##* ##** **#* ## *#*#* ## *#** **#* *#****#* ## **#* \n" + +" **######** ## ## *#######* ##*####* ## *###* ## **#####** **####** ## *#** \n" + +" ******** ## ## *******#* ##****** ## *#* ## ******* ****** ## *#* \n" + +" ## \n" + +" ## \n" + +" ## \n" + +" ** \n" ; + + static { + System.setProperty("org.mortbay.log.class", "com.github.tomakehurst.wiremock.jetty.LoggerAdapter"); + } + + private WireMockServer wireMockServer; + + public static void main(String[] args) { + SpringApplication.run(MockApplication.class, args); + //new WireMockServerRunner().run("--port 9999"); + new MockApplication().run(args); + } + + public void run(String... args) { + + WireMockConfiguration options = WireMockConfiguration.options(); + options.port(9999); + FileSource fileSource = options.filesRoot(); + fileSource.createIfNecessary(); + FileSource filesFileSource = fileSource.child(FILES_ROOT); + filesFileSource.createIfNecessary(); + FileSource mappingsFileSource = fileSource.child(MAPPINGS_ROOT); + mappingsFileSource.createIfNecessary(); + + // Register extension + options.extensions("org.onap.integration.test.mock.extension.Webhooks"); + // Register notifier + options.notifier(new ConsoleNotifier(true)); + wireMockServer = new WireMockServer(options); + + wireMockServer.enableRecordMappings(mappingsFileSource, filesFileSource); + + //if (options.specifiesProxyUrl()) { + // addProxyMapping(options.proxyUrl()); + //} + + try { + wireMockServer.start(); + out.println(BANNER); + out.println(); + out.println(options); + } catch (FatalStartupException e) { + System.err.println(e.getMessage()); + System.exit(1); + } + } + + private void addProxyMapping(final String baseUrl) { + wireMockServer.loadMappingsUsing(new MappingsLoader() { + @Override + public void loadMappingsInto(StubMappings stubMappings) { + RequestPattern requestPattern = newRequestPattern(ANY, anyUrl()).build(); + ResponseDefinition responseDef = responseDefinition() + .proxiedFrom(baseUrl) + .build(); + + StubMapping proxyBasedMapping = new StubMapping(requestPattern, responseDef); + proxyBasedMapping.setPriority(10); // Make it low priority so that existing stubs will take precedence + stubMappings.addMapping(proxyBasedMapping); + } + }); + } + + public void stop() { + wireMockServer.stop(); + } + + public boolean isRunning() { + return wireMockServer.isRunning(); + } + + public int port() { return wireMockServer.port(); } + +} diff --git a/test/mock/src/main/java/org/onap/integration/test/mock/extension/WebhookDefinition.java b/test/mock/src/main/java/org/onap/integration/test/mock/extension/WebhookDefinition.java new file mode 100644 index 000000000..dff99fd41 --- /dev/null +++ b/test/mock/src/main/java/org/onap/integration/test/mock/extension/WebhookDefinition.java @@ -0,0 +1,101 @@ +package org.onap.integration.test.mock.extension; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.github.tomakehurst.wiremock.http.Body; +import com.github.tomakehurst.wiremock.http.HttpHeader; +import com.github.tomakehurst.wiremock.http.HttpHeaders; +import com.github.tomakehurst.wiremock.http.RequestMethod; + +import java.net.URI; +import java.util.List; + +import static com.google.common.collect.Lists.newArrayList; + +public class WebhookDefinition { + + private RequestMethod method; + private URI url; + private List<HttpHeader> headers; + private Body body = Body.none(); + + @JsonCreator + public WebhookDefinition(@JsonProperty("method") RequestMethod method, + @JsonProperty("url") URI url, + @JsonProperty("headers") HttpHeaders headers, + @JsonProperty("body") String body, + @JsonProperty("base64Body") String base64Body) { + this.method = method; + this.url = url; + this.headers = newArrayList(headers.all()); + this.body = Body.fromOneOf(null, body, null, base64Body); + } + + public WebhookDefinition() { + } + + public RequestMethod getMethod() { + return method; + } + + public URI getUrl() { + return url; + } + + public HttpHeaders getHeaders() { + return new HttpHeaders(headers); + } + + public String getBase64Body() { + return body.isBinary() ? body.asBase64() : null; + } + + public String getBody() { + return body.isBinary() ? null : body.asString(); + } + + @JsonIgnore + public byte[] getBinaryBody() { + return body.asBytes(); + } + + public WebhookDefinition withMethod(RequestMethod method) { + this.method = method; + return this; + } + + public WebhookDefinition withUrl(URI url) { + this.url = url; + return this; + } + + public WebhookDefinition withUrl(String url) { + withUrl(URI.create(url)); + return this; + } + + public WebhookDefinition withHeaders(List<HttpHeader> headers) { + this.headers = headers; + return this; + } + + public WebhookDefinition withHeader(String key, String... values) { + if (headers == null) { + headers = newArrayList(); + } + + headers.add(new HttpHeader(key, values)); + return this; + } + + public WebhookDefinition withBody(String body) { + this.body = new Body(body); + return this; + } + + public WebhookDefinition withBinaryBody(byte[] body) { + this.body = new Body(body); + return this; + } +} diff --git a/test/mock/src/main/java/org/onap/integration/test/mock/extension/Webhooks.java b/test/mock/src/main/java/org/onap/integration/test/mock/extension/Webhooks.java new file mode 100644 index 000000000..cb17ba658 --- /dev/null +++ b/test/mock/src/main/java/org/onap/integration/test/mock/extension/Webhooks.java @@ -0,0 +1,100 @@ +package org.onap.integration.test.mock.extension; + +import com.github.tomakehurst.wiremock.common.Notifier; +import com.github.tomakehurst.wiremock.core.Admin; +import com.github.tomakehurst.wiremock.extension.Parameters; +import com.github.tomakehurst.wiremock.extension.PostServeAction; +import com.github.tomakehurst.wiremock.http.HttpClientFactory; +import com.github.tomakehurst.wiremock.http.HttpHeader; +import com.github.tomakehurst.wiremock.stubbing.ServeEvent; +import org.apache.http.HttpResponse; +import org.apache.http.client.HttpClient; +import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; +import org.apache.http.client.methods.HttpUriRequest; +import org.apache.http.entity.ByteArrayEntity; +import org.apache.http.util.EntityUtils; + +import java.io.IOException; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; + +import static com.github.tomakehurst.wiremock.common.Exceptions.throwUnchecked; +import static com.github.tomakehurst.wiremock.common.LocalNotifier.notifier; +import static com.github.tomakehurst.wiremock.http.HttpClientFactory.getHttpRequestFor; +import static java.util.concurrent.TimeUnit.SECONDS; + +public class Webhooks extends PostServeAction { + + private final ScheduledExecutorService scheduler; + private final HttpClient httpClient; + + public Webhooks() { + scheduler = Executors.newScheduledThreadPool(10); + httpClient = HttpClientFactory.createClient(); + } + + @Override + public String getName() { + return "webhook"; + } + + @Override + public void doAction(ServeEvent serveEvent, Admin admin, Parameters parameters) { + final WebhookDefinition definition = parameters.as(WebhookDefinition.class); + final Notifier notifier = notifier(); + + scheduler.schedule( + new Runnable() { + @Override + public void run() { + HttpUriRequest request = buildRequest(definition); + + try { + HttpResponse response = httpClient.execute(request); + notifier.info( + String.format("Webhook %s request to %s returned status %s\n\n%s", + definition.getMethod(), + definition.getUrl(), + response.getStatusLine(), + EntityUtils.toString(response.getEntity()) + ) + ); + System.out.println(String.format("Webhook %s request to %s returned status %s\n\n%s", + definition.getMethod(), + definition.getUrl(), + response.getStatusLine(), + EntityUtils.toString(response.getEntity()) + ) + ); + } catch (IOException e) { + throwUnchecked(e); + } + } + }, + 0L, + SECONDS + ); + } + + private static HttpUriRequest buildRequest(WebhookDefinition definition) { + HttpUriRequest request = getHttpRequestFor( + definition.getMethod(), + definition.getUrl().toString() + ); + + for (HttpHeader header: definition.getHeaders().all()) { + request.addHeader(header.key(), header.firstValue()); + } + + if (definition.getMethod().hasEntity()) { + HttpEntityEnclosingRequestBase entityRequest = (HttpEntityEnclosingRequestBase) request; + entityRequest.setEntity(new ByteArrayEntity(definition.getBinaryBody())); + } + + return request; + } + + public static WebhookDefinition webhook() { + return new WebhookDefinition(); + } +} diff --git a/test/mock/src/main/resources/application.properties b/test/mock/src/main/resources/application.properties new file mode 100644 index 000000000..51ad5ebf4 --- /dev/null +++ b/test/mock/src/main/resources/application.properties @@ -0,0 +1 @@ +server.port=9090 diff --git a/test/mock/src/test/java/org/onap/integration/test/mock/MockApplicationTests.java b/test/mock/src/test/java/org/onap/integration/test/mock/MockApplicationTests.java new file mode 100644 index 000000000..8d2a04625 --- /dev/null +++ b/test/mock/src/test/java/org/onap/integration/test/mock/MockApplicationTests.java @@ -0,0 +1,16 @@ +package org.onap.integration.test.mock; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest +public class MockApplicationTests { + + @Test + public void contextLoads() { + } + +} |