From e38164bcd2a6d4e14c980fed52c510c8b6759f94 Mon Sep 17 00:00:00 2001 From: ma987d Date: Thu, 28 Sep 2017 16:33:03 -0500 Subject: Policy CSIT test files with latest changes Issue-Id: POLICY-77 Signed-off-by: ma987d Change-Id: I6704704b676c0c99817a61ca614e49ba980d79bd --- test/csit/plans/policy/health/setup.sh | 17 +- test/csit/plans/policy/health/teardown.sh | 19 +- test/csit/scripts/policy/script1.sh | 127 +++++++++++ test/csit/tests/policy/suite1/Policy-CSIT.robot | 247 +++++++++++++++++++++ .../tests/policy/suite1/configpolicy_vCPE.template | 6 + .../tests/policy/suite1/configpolicy_vDNS.template | 6 + .../tests/policy/suite1/configpolicy_vFW.template | 6 + .../csit/tests/policy/suite1/createpolicy.template | 21 ++ .../csit/tests/policy/suite1/deletepolicy.template | 5 + .../tests/policy/suite1/getconfigpolicy.template | 8 + .../tests/policy/suite1/global_properties.robot | 30 +++ test/csit/tests/policy/suite1/json_templater.robot | 21 ++ .../tests/policy/suite1/opspolicy_VDNS.template | 26 +++ .../tests/policy/suite1/opspolicy_VDNS_R1.template | 16 ++ .../tests/policy/suite1/opspolicy_VFW.template | 24 ++ .../tests/policy/suite1/opspolicy_VFW_R1.template | 17 ++ .../tests/policy/suite1/policy_interface.robot | 60 +++++ test/csit/tests/policy/suite1/pushpolicy.template | 5 + 18 files changed, 658 insertions(+), 3 deletions(-) create mode 100644 test/csit/tests/policy/suite1/Policy-CSIT.robot create mode 100644 test/csit/tests/policy/suite1/configpolicy_vCPE.template create mode 100644 test/csit/tests/policy/suite1/configpolicy_vDNS.template create mode 100644 test/csit/tests/policy/suite1/configpolicy_vFW.template create mode 100644 test/csit/tests/policy/suite1/createpolicy.template create mode 100644 test/csit/tests/policy/suite1/deletepolicy.template create mode 100644 test/csit/tests/policy/suite1/getconfigpolicy.template create mode 100644 test/csit/tests/policy/suite1/global_properties.robot create mode 100644 test/csit/tests/policy/suite1/json_templater.robot create mode 100644 test/csit/tests/policy/suite1/opspolicy_VDNS.template create mode 100644 test/csit/tests/policy/suite1/opspolicy_VDNS_R1.template create mode 100644 test/csit/tests/policy/suite1/opspolicy_VFW.template create mode 100644 test/csit/tests/policy/suite1/opspolicy_VFW_R1.template create mode 100644 test/csit/tests/policy/suite1/policy_interface.robot create mode 100644 test/csit/tests/policy/suite1/pushpolicy.template diff --git a/test/csit/plans/policy/health/setup.sh b/test/csit/plans/policy/health/setup.sh index 241d78b22..bfea1ac1c 100755 --- a/test/csit/plans/policy/health/setup.sh +++ b/test/csit/plans/policy/health/setup.sh @@ -15,10 +15,13 @@ # limitations under the License. # # Place the scripts in run order: -source ${WORKSPACE}/test/csit/scripts/policy/script1.sh +source ${SCRIPTS}/common_functions.sh docker run --name i-mock -d jamesdbloom/mockserver MOCK_IP=`get-instance-ip.sh i-mock` +echo ${MOCK_IP} + +docker inspect i-mock # Wait for initialization for i in {1..10}; do @@ -29,6 +32,16 @@ done ${WORKSPACE}/test/csit/scripts/policy/mock-hello.sh ${MOCK_IP} +source ${WORKSPACE}/test/csit/scripts/policy/script1.sh + +sleep 3m + # Pass any variables required by Robot test suites in ROBOT_VARIABLES -ROBOT_VARIABLES="-v MOCK_IP:${MOCK_IP}" +ROBOT_VARIABLES="-v MOCK_IP:${MOCK_IP} -v IP:${IP} -v POLICY_IP:${POLICY_IP} -v PDP_IP:${PDP_IP} -v DOCKER_IP:${DOCKER_IP}" +export PDP_IP=${PDP_IP} +export POLICY_IP=${POLICY_IP} +export DOCKER_IP=${DOCKER_IP} +#Get current IP of VM +HOST_IP=$(ip route get 8.8.8.8 | awk '/8.8.8.8/ {print $NF}') +export HOST_IP=${HOST_IP} \ No newline at end of file diff --git a/test/csit/plans/policy/health/teardown.sh b/test/csit/plans/policy/health/teardown.sh index 4214c8279..f79e75d89 100755 --- a/test/csit/plans/policy/health/teardown.sh +++ b/test/csit/plans/policy/health/teardown.sh @@ -15,6 +15,23 @@ # limitations under the License. # -kill-instance.sh i-mock +function kill_instance() { +local name=$1 +docker logs "${name}" >> "${WORKSPACE}"/archives/"${name}".log +docker kill "${name}" +docker rm -v "${name}" +} + +mkdir -p "${WORKSPACE}"/archives + +kill_instance i-mock +kill_instance drools +kill_instance pdp +kill_instance brmsgw +kill_instance pap +kill_instance nexus +kill_instance mariadb + +rm -fr "${WORK_DIR}" diff --git a/test/csit/scripts/policy/script1.sh b/test/csit/scripts/policy/script1.sh index a005c3a84..473ef0dd8 100755 --- a/test/csit/scripts/policy/script1.sh +++ b/test/csit/scripts/policy/script1.sh @@ -15,3 +15,130 @@ # limitations under the License. # echo "This is ${WORKSPACE}/test/csit/scripts/policy/script1.sh" + + +# the directory of the script +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +echo ${DIR} + +# the temp directory used, within $DIR +# omit the -p parameter to create a temporal directory in the default location +WORK_DIR=`mktemp -d -p "$DIR"` +echo ${WORK_DIR} + +cd ${WORK_DIR} + +# check if tmp dir was created +if [[ ! "$WORK_DIR" || ! -d "$WORK_DIR" ]]; then + echo "Could not create temp dir" + exit 1 +fi + +# bring down maven +mkdir maven +cd maven +curl -O http://apache.claz.org/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz +tar -xzvf apache-maven-3.3.9-bin.tar.gz +ls -l +export PATH=${PATH}:${WORK_DIR}/maven/apache-maven-3.3.9/bin +${WORK_DIR}/maven/apache-maven-3.3.9/bin/mvn -v +cd .. + +ifconfig + +if ! ifconfig eth0; then + if ! ifconfig ens3; then + echo "Could not determine IP address" + exit 1 + fi + export IP=`ifconfig ens3 | awk -F: '/inet addr/ {gsub(/ .*/,"",$2); print $2}'` +else + export IP=`ifconfig eth0 | awk -F: '/inet addr/ {gsub(/ .*/,"",$2); print $2}'` +fi +echo $IP + +if ! ifconfig docker0; then + if ! ifconfig ens3; then + echo "Could not determine IP address" + exit 1 + fi + export DOCKER_IP_IP=`ifconfig ens3 | awk -F: '/inet addr/ {gsub(/ .*/,"",$2); print $2}'` +else + export DOCKER_IP=`ifconfig docker0 | awk -F: '/inet addr/ {gsub(/ .*/,"",$2); print $2}'` +fi +echo $DOCKER_IP + +git clone http://gerrit.onap.org/r/oparent + +git clone http://gerrit.onap.org/r/policy/docker +cd docker + +${WORK_DIR}/maven/apache-maven-3.3.9/bin/mvn clean install prepare-package --settings ../oparent/settings.xml +cp policy-pe/* target/policy-pe +cp policy-drools/* target/policy-drools + +docker build -t onap/policy/policy-os policy-os +docker build -t onap/policy/policy-db policy-db +docker build -t onap/policy/policy-nexus policy-nexus +docker build -t onap/policy/policy-base policy-base +docker build -t onap/policy/policy-pe target/policy-pe +docker build -t onap/policy/policy-drools target/policy-drools + +chmod +x config/drools/drools-tweaks.sh + +echo $IP > config/pe/ip_addr.txt +ls -l config/pe/ip_addr.txt +cat config/pe/ip_addr.txt + +export MTU=9126 + +docker-compose -f docker-compose-integration.yml up -d + +docker ps + +docker inspect drools + +POLICY_IP=`docker inspect --format '{{ .NetworkSettings.Networks.docker_default.IPAddress}}' drools` +echo ${POLICY_IP} + +sleep 3m + +docker inspect pdp + +PDP_IP=`docker inspect --format '{{ .NetworkSettings.Networks.docker_default.IPAddress}}' pdp` +echo ${PDP_IP} + +sleep 3m + +#for i in {1..60}; do +TIME_OUT=6000 +INTERVAL=20 +TIME=0 +while [ "$TIME" -lt "$TIME_OUT" ]; do + curl -i --user healthcheck:zb!XztG34 -H "ContentType: application/json" -H "Accept: application/json" ${POLICY_IP}:6969/healthcheck && break + echo sleep $i + sleep $i + +echo Sleep: $INTERVAL seconds before testing if Policy is up. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds + sleep $INTERVAL + TIME=$(($TIME+$INTERVAL)) + +done + +#curl -v --silent -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'ClientAuth: cHl0aG9uOnRlc3Q=' -H 'Authorization: Basic dGVzdHBkcDphbHBoYTEyMw==' -H 'Environment: TEST' -X POST -d '{"policyName": "*.*"}' + +TIME_OUT=6000 +INTERVAL=20 +TIME=0 +while [ "$TIME" -lt "$TIME_OUT" ]; do + + curl -v --silent -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'ClientAuth: cHl0aG9uOnRlc3Q=' -H 'Authorization: Basic dGVzdHBkcDphbHBoYTEyMw==' -H 'Environment: TEST' -X POST -d '{"policyName": "*.*"}' http://${PDP_IP}:8081/pdp/api/getConfig && break + echo sleep $i + sleep $i + +echo Sleep: $INTERVAL seconds before testing if Policy is up. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds + sleep $INTERVAL + TIME=$(($TIME+$INTERVAL)) + +done + diff --git a/test/csit/tests/policy/suite1/Policy-CSIT.robot b/test/csit/tests/policy/suite1/Policy-CSIT.robot new file mode 100644 index 000000000..be52cd2ea --- /dev/null +++ b/test/csit/tests/policy/suite1/Policy-CSIT.robot @@ -0,0 +1,247 @@ +*** Settings *** +Documentation Policy ONAP CSIT Test cases +Library String +Library HttpLibrary.HTTP +LIbrary Process +Resource policy_interface.robot +Resource json_templater.robot + +*** Variables *** +${RESOURCE_PATH_CREATE} /pdp/createPolicy +${RESOURCE_PATH_CREATE_PUSH} /pdp/pushPolicy +${RESOURCE_PATH_CREATE_DELETE} /pdp/deletePolicy +${RESOURCE_PATH_GET_CONFIG} /pdp/getConfig +${CREATE_CONFIG_VFW_TEMPLATE} ${CURDIR}/configpolicy_vFW.template +${CREATE_CONFIG_VDNS_TEMPLATE} ${CURDIR}/configpolicy_vDNS.template +${CREATE_CONFIG_VCPE_TEMPLATE} ${CURDIR}/configpolicy_vCPE.template +${CREATE_OPS_VFW_TEMPLATE} ${CURDIR}/opspolicy_VFW.template +${PUSH_POLICY_TEMPLATE} ${CURDIR}/pushpolicy.template +${CREATE_OPS_VDNS_TEMPLATE} ${CURDIR}/opspolicy_VDNS.template +${DEL_POLICY_TEMPLATE} ${CURDIR}/deletepolicy.template +${GETCONFIG_TEMPLATE} ${CURDIR}/getconfigpolicy.template +${CONFIG_POLICY_VFW_NAME} vFirewall +${CONFIG_POLICY_VFW_TYPE} MicroService +${CONFIG_POLICY_VDNS_NAME} vLoadBalancer +${CONFIG_POLICY_VDNS_TYPE} MicroService +${OPS_POLICY_VFW_NAME} vFirewall +${OPS_POLICY_VFW_TYPE} BRMS_PARAM +${OPS_POLICY_VDNS_NAME} vLoadBalancer +${OPS_POLICY_VDNS_TYPE} BRMS_PARAM +${CONFIG_POLICY_VCPE_NAME} vCPE +${CONFIG_POLICY_VCPE_TYPE} MicroService +${OPS_POLICY_VCPE_NAME} vCPE +${OPS_POLICY_VCPE_TYPE} BRMS_PARAM +${OPS_POLICY_VOLTE_NAME} VoLTE +${OPS_POLICY_VOLTE_TYPE} BRMS_PARAM +${file_path} ../testsuite/robot/assets/templates/ControlLoopDemo__closedLoopControlName.drl +${RESOURCE_PATH_UPLOAD} /pdp/api/policyEngineImport?importParametersJson=%7B%22serviceName%22%3A%22Manyu456%22%2C%20%22serviceType%22%3A%22BRMSPARAM%22%7D +${CREATE_OPS_VCPE_TEMPLATE} ${CURDIR}/opspolicy_vCPE.template +${CREATE_OPS_VOLTE_TEMPLATE} ${CURDIR}/opspolicy_vOLTE.template + + +*** Test Cases *** +Policy Health check + Run Policy Health Check + +VFW Config Policy + ${CONFIG_POLICY_VFW_NAME}= Create Config VFW Policy + Push Config Policy ${CONFIG_POLICY_VFW_NAME} ${CONFIG_POLICY_VFW_TYPE} +VFW Get Configs Policy + Get Configs VFW Policy + #VFW Policy Tests + +VDNS Config Policy + ${CONFIG_POLICY_VDNS_NAME}= Create Config VDNS Policy + Push Config Policy ${CONFIG_POLICY_VDNS_NAME} ${CONFIG_POLICY_VDNS_TYPE} + #VDNS Policy Tests + +VCPE Config Policy + ${CONFIG_POLICY_VCPE_NAME}= Create Config VCPE Policy + Push Config Policy ${CONFIG_POLICY_VCPE_NAME} ${CONFIG_POLICY_VCPE_TYPE} + #VCPE Policy Tests + +#VOLTE Policy + #VOLTE Policy Tests + +*** Keywords *** + +VFW Policy Tests + ${CONFIG_POLICY_VFW_NAME}= Create Config VFW Policy + Push Config Policy ${CONFIG_POLICY_VFW_NAME} ${CONFIG_POLICY_VFW_TYPE} + Get Configs VFW Policy + ${OPS_POLICY_VFW_NAME}= Create Ops VFW Policy + Push Ops Policy ${OPS_POLICY_VFW_NAME} ${OPS_POLICY_VFW_TYPE} + +VDNS Policy Tests + ${CONFIG_POLICY_VDNS_NAME}= Create Config VDNS Policy + Push Config Policy ${CONFIG_POLICY_VDNS_NAME} ${CONFIG_POLICY_VDNS_TYPE} + Get Configs VDNS Policy + ${OPS_POLICY_VDNS_NAME}= Create Ops VDNS Policy + Push Ops Policy ${OPS_POLICY_VDNS_NAME} ${OPS_POLICY_VDNS_TYPE} + +VCPE Policy Tests + ${CONFIG_POLICY_VCPE_NAME}= Create Config VCPE Policy + Push Config Policy ${CONFIG_POLICY_VCPE_NAME} ${CONFIG_POLICY_VCPE_TYPE} + Get Configs VCPE Policy + ${OPS_POLICY_VCPE_NAME}= Create Ops VCPE Policy + Push Ops Policy ${OPS_POLICY_VCPE_NAME} ${OPS_POLICY_VCPE_TYPE} + +VOLTE Policy Tests + ${OPS_POLICY_VOLTE_NAME}= Create Ops VOLTE Policy + Push Ops Policy ${OPS_POLICY_VOLTE_NAME} ${OPS_POLICY_VOLTE_TYPE} + +Get Configs VFW Policy + [Documentation] Get Config Policy for VFW + ${getconfigpolicy}= Catenate .*${CONFIG_POLICY_VFW_NAME}* + ${configpolicy_name}= Create Dictionary config_policy_name=${getconfigpolicy} + ${output} = Fill JSON Template File ${GETCONFIG_TEMPLATE} ${configpolicy_name} + ${get_resp} = Run Policy Get Configs Request ${RESOURCE_PATH_GET_CONFIG} ${output} + Should Be Equal As Strings ${get_resp.status_code} 200 + +Create Config VFW Policy + [Documentation] Create Config Policy + ${randompolicyname} = Create Policy Name + ${policyname1}= Catenate com.${randompolicyname}_vFirewall + ${CONFIG_POLICY_VFW_NAME}= Set Test Variable ${policyname1} + ${configpolicy}= Create Dictionary policy_name=${policyname1} + ${output} = Fill JSON Template File ${CREATE_CONFIG_VFW_TEMPLATE} ${configpolicy} + ${put_resp} = Run Policy Put Request ${RESOURCE_PATH_CREATE} ${output} + Should Be Equal As Strings ${put_resp.status_code} 200 + [Return] ${policyname1} + + Create Policy Name + [Documentation] Generate Policy Name + [Arguments] ${prefix}=CSIT_ + ${random}= Generate Random String 15 [LOWER][NUMBERS] + ${policyname}= Catenate ${prefix}${random} + [Return] ${policyname} + +Create Ops VFW Policy + [Documentation] Create Opertional Policy + ${randompolicyname} = Create Policy Name + ${policyname1}= Catenate com.${randompolicyname}_vFirewall + ${OPS_POLICY_VFW_NAME}= Set Test Variable ${policyname1} + ${dict}= Create Dictionary policy_name=${policyname1} + ${output} = Fill JSON Template File ${CREATE_OPS_VFW_TEMPLATE} ${dict} + ${put_resp} = Run Policy Put Request ${RESOURCE_PATH_CREATE} ${output} + Log ${put_resp} + Should Be Equal As Strings ${put_resp.status_code} 200 + [Return] ${policyname1} + +Push Ops Policy + [Documentation] Push Ops Policy + [Arguments] ${policyname} ${policytype} + ${dict}= Create Dictionary policy_name=${policyname} policy_type=${policytype} + ${output} = Fill JSON Template File ${PUSH_POLICY_TEMPLATE} ${dict} + ${put_resp} = Run Policy Put Request ${RESOURCE_PATH_CREATE_PUSH} ${output} + Should Be Equal As Strings ${put_resp.status_code} 200 + +Push Config Policy + [Documentation] Push Config Policy + [Arguments] ${policyname} ${policytype} + ${dict}= Create Dictionary policy_name=${policyname} policy_type=${policytype} + ${output} = Fill JSON Template File ${PUSH_POLICY_TEMPLATE} ${dict} + ${put_resp} = Run Policy Put Request ${RESOURCE_PATH_CREATE_PUSH} ${output} + Should Be Equal As Strings ${put_resp.status_code} 200 + +Delete Ops Policy + [Documentation] Delete Config Policy + [Arguments] ${policy_name} + ${policyname3}= Catenate com.Config_BRMS_Param_${policyname}.1.xml + ${dict}= Create Dictionary policy_name=${policyname3} + ${output} = Fill JSON Template ${DEL_POLICY_TEMPLATE} ${dict} + ${put_resp} = Run Policy Delete Request ${RESOURCE_PATH_CREATE_DELETE} ${output} + Should Be Equal As Strings ${put_resp.status_code} 200 + +Delete Config Policy + [Documentation] Delete Ops Policy + [Arguments] ${policy_name} + ${policyname3}= Catenate com.Config_MS_com.${policy_name}.1.xml + ${dict}= Create Dictionary policy_name=${policyname3} + ${output} = Fill JSON Template ${DEL_POLICY_TEMPLATE} ${dict} + ${put_resp} = Run Policy Delete Request ${RESOURCE_PATH_CREATE_DELETE} ${output} + Should Be Equal As Strings ${put_resp.status_code} 200 + +Get Configs VDNS Policy + [Documentation] Get Config Policy for VDNS + ${getconfigpolicy}= Catenate .*${CONFIG_POLICY_VDNS_NAME}* + ${configpolicy_name}= Create Dictionary config_policy_name=${getconfigpolicy} + ${output} = Fill JSON Template File ${GETCONFIG_TEMPLATE} ${configpolicy_name} + ${get_resp} = Run Policy Get Configs Request ${RESOURCE_PATH_GET_CONFIG} ${output} + Should Be Equal As Strings ${get_resp.status_code} 200 + +Create Config VDNS Policy + [Documentation] Create Config Policy + ${randompolicyname} = Create Policy Name + ${policyname1}= Catenate com.${randompolicyname}_vLoadBalancer + ${CONFIG_POLICY_VDNS_NAME}= Set Test Variable ${policyname1} + ${configpolicy}= Create Dictionary policy_name=${policyname1} + ${output} = Fill JSON Template File ${CREATE_CONFIG_VDNS_TEMPLATE} ${configpolicy} + ${put_resp} = Run Policy Put Request ${RESOURCE_PATH_CREATE} ${output} + Should Be Equal As Strings ${put_resp.status_code} 200 + [Return] ${policyname1} + +Create Ops VDNS Policy + [Documentation] Create Opertional Policy + ${randompolicyname} = Create Policy Name + ${policyname1}= Catenate com.${randompolicyname}_vLoadBalancer + ${OPS_POLICY_VDNS_NAME}= Set Test Variable ${policyname1} + ${dict}= Create Dictionary policy_name=${policyname1} + ${output} = Fill JSON Template File ${CREATE_OPS_VDNS_TEMPLATE} ${dict} + ${put_resp} = Run Policy Put Request ${RESOURCE_PATH_CREATE} ${output} + Log ${put_resp} + Should Be Equal As Strings ${put_resp.status_code} 200 + [Return] ${policyname1} + +Create Config VCPE Policy + [Documentation] Create Config Policy + ${randompolicyname} = Create Policy Name + ${policyname1}= Catenate com.${randompolicyname}_vFirewall + ${CONFIG_POLICY_VCPE_NAME}= Set Test Variable ${policyname1} + ${configpolicy}= Create Dictionary policy_name=${policyname1} + ${output} = Fill JSON Template File ${CREATE_CONFIG_VCPE_TEMPLATE} ${configpolicy} + ${put_resp} = Run Policy Put Request ${RESOURCE_PATH_CREATE} ${output} + Should Be Equal As Strings ${put_resp.status_code} 200 + [Return] ${policyname1} + +Get Configs VCPE Policy + [Documentation] Get Config Policy for VCPE + ${getconfigpolicy}= Catenate .*${CONFIG_POLICY_VCPE_NAME}* + ${configpolicy_name}= Create Dictionary config_policy_name=${getconfigpolicy} + ${output} = Fill JSON Template File ${GETCONFIG_TEMPLATE} ${configpolicy_name} + ${get_resp} = Run Policy Get Configs Request ${RESOURCE_PATH_GET_CONFIG} ${output} + Should Be Equal As Strings ${get_resp.status_code} 200 + +Create Ops vCPE Policy + [Documentation] Create Opertional Policy + ${randompolicyname} = Create Policy Name + ${policyname1}= Catenate com.${randompolicyname} + ${OPS_POLICY_NAME}= Set Test Variable ${policyname1} + ${dict}= Create Dictionary policy_name=${OPS_POLICY_NAME} + ${NEWPOLICY1}= Create Dictionary policy_name=com.${OPS_POLICY_NAME} + ${output} = Fill JSON Template File ${CREATE_OPS_VCPE_TEMPLATE} ${dict} + ${put_resp} = Run Policy Put Request ${RESOURCE_PATH_CREATE} ${output} + Log ${put_resp} + Should Be Equal As Strings ${put_resp.status_code} 200 + +Create Ops VolTE Policy + [Documentation] Create Opertional Policy + ${randompolicyname} = Create Policy Name + ${policyname2}= Catenate com.${randompolicyname} + #${OPS_POLICY_VOLTE_NAME}= Set Test Variable ${policyname2} + ${dict}= Create Dictionary policy_name=${policyname2} + #${NEWPOLICY1}= Create Dictionary policy_name=com.${OPS_POLICY_NAME} + ${output} = Fill JSON Template File ${CREATE_OPS_VOLTE_TEMPLATE} ${dict} + ${put_resp} = Run Policy Put Request ${RESOURCE_PATH_CREATE} ${output} + Log ${put_resp} + Should Be Equal As Strings ${put_resp.status_code} 200 + +Upload DRL file + [Documentation] Upload DRL file1 + ${file_data}= Get Binary File ${file_path} + ${files}= Create Dictionary file=${file_data} + #${CONFIG_POLICY_VDNS_NAME}= Set Test Variable ${policyname1} + # ${files2} = {'file': open('../testsuite/robot/assets/templates/ControlLoopDemo__closedLoopControlName.drl', 'rb')} + # ${files}= Create Dictionary file ${file_data} + ${put_resp} = Run Policy Post form Request ${RESOURCE_PATH_UPLOAD} ${files} + Should Be Equal As Strings ${put_resp.status_code} 200 \ No newline at end of file diff --git a/test/csit/tests/policy/suite1/configpolicy_vCPE.template b/test/csit/tests/policy/suite1/configpolicy_vCPE.template new file mode 100644 index 000000000..e3e3a2d0b --- /dev/null +++ b/test/csit/tests/policy/suite1/configpolicy_vCPE.template @@ -0,0 +1,6 @@ +{ +"configBody": "{ \"service\": \"policy_tosca_tca\", \"location\": \"SampleServiceLocation\", \"uuid\": \"test\", \"policyName\": \"MicroServicevCPE\", \"description\": \"MicroService vCPE Policy\", \"configName\": \"SampleConfigName\", \"templateVersion\": \"OpenSource.version.1\", \"version\": \"1.0.0\", \"priority\": \"1\", \"policyScope\": \"resource=SampleResource,service=SampleService,type=SampleType,closedLoopControlName=SampleClosedLoop\", \"riskType\": \"SampleRiskType\", \"riskLevel\": \"1\", \"guard\": \"False\", \"content\": { \"policyVersion\": \"v0.0.1\", \"threshholds\": [{ \"severity\": \"MAJOR\", \"fieldPath\": \"$$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedDiscardedPacketsDelta\", \"thresholdValue\": \"0\", \"closedLoopEventStatus\": \"ABATED\", \"closedLoopControlName\": \"CL-vCPEvGMUX-TRAFFIC-SIG-FB480F95-A453-6F24-B767-FD703241ABA1\", \"version\": \"1.0.2\", \"direction\": \"EQUAL\" }, { \"severity\": \"CRITICAL\", \"fieldPath\": \"$$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedDiscardedPacketsDelta\", \"thresholdValue\": \"1000\", \"closedLoopEventStatus\": \"ONSET\", \"closedLoopControlName\": \"CL-vCPEvGMUX-TRAFFIC-SIG-FB480F95-A453-6F24-B767-FD703241ABA1\", \"version\": \"1.0.2\", \"direction\": \"GREATER_OR_EQUAL\" }], \"policyName\": \"DCAE.Config_tca-hi-lo\", \"controlLoopSchemaType\": \"VM\", \"policyScope\": \"DCAE\", \"eventName\": \"vCPEvGMUXPacketLoss\" } }", +"policyConfigType": "MicroService", +"policyName": "${policy_name}", +"ecompName": "DCAE" +} diff --git a/test/csit/tests/policy/suite1/configpolicy_vDNS.template b/test/csit/tests/policy/suite1/configpolicy_vDNS.template new file mode 100644 index 000000000..ab1d2e0dd --- /dev/null +++ b/test/csit/tests/policy/suite1/configpolicy_vDNS.template @@ -0,0 +1,6 @@ +{ +"configBody": "{\"service\": \"policy_tosca_tca\",\"location\": \"TestMSLocation\",\"uuid\": \"/services/cdap-tca-hi-lo/instances/dfw1/configuration/metricsPerFunctionalRole/vLoadBalancer\",\"policyName\": \"vLoadBalancer\",\"description\": \"vLoadBalancer\",\"configName\": \"TestConfigName\",\"templateVersion\": \"1607\",\"version\": \"8.7.6.5\",\"priority\": \"1\",\"policyScope\": \"resource=TestResource,service=TestService,type=TestType,closedLoopControlName=TestClosedLoop\",\"riskType\": \"test\",\"riskLevel\": \"2\",\"guard\": \"False\",\"content\": {\"policyVersion\": \"v0.0.1\",\"threshholds\": [{\"severity\": \"MAJOR\",\"fieldPath\": \"$$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\": \"500\",\"closedLoopControlName\": \"CL-LBAL-LOW-TRAFFIC-SIG-FB480F95-A453-6F24-B767-FD703241AB1A\",\"version\": \"1.0.2\",\"direction\": \"LESS_OR_EQUAL\"}, {\"severity\": \"CRITICAL\",\"fieldPath\": \"$$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\": \"5000\",\"closedLoopControlName\": \"CL-LBAL-HIGH-TRAFFIC-SIG-0C5920A6-B564-8035-C878-0E814352BC2B\",\"version\": \"1.0.2\",\"direction\": \"GREATER_OR_EQUAL\"}],\"policyName\": \"configuration.ae.microservice.tca.xml\",\"functionalRole\": \"ClosedLoop_F5-d925ed73-8231-4d02-9545-db4e101f88f8\"}}", +"policyConfigType": "MicroService", +"policyName": "${policy_name}", +"ecompName": "DCAE" +} \ No newline at end of file diff --git a/test/csit/tests/policy/suite1/configpolicy_vFW.template b/test/csit/tests/policy/suite1/configpolicy_vFW.template new file mode 100644 index 000000000..39e99e7b2 --- /dev/null +++ b/test/csit/tests/policy/suite1/configpolicy_vFW.template @@ -0,0 +1,6 @@ +{ +"configBody": "{\"service\": \"policy_tosca_tca\",\"location\": \"Ravi\",\"uuid\": \"/services/cdap-tca-hi-lo/instances/dfw1/configuration/metricsPerFunctionalRole/vFireWall\",\"policyName\": \"vFireWall\",\"description\": \"vFireWall\",\"configName\": \"TestConfigName\",\"templateVersion\": \"1607\",\"version\": \"8.7.6.5\",\"priority\": \"1\",\"policyScope\": \"resource=TestResource,service=TestService,type=TestType,closedLoopControlName=TestClosedLoop\",\"riskType\": \"test\",\"riskLevel\": \"2\",\"guard\": \"False\",\"content\": {\"policyVersion\": \"v0.0.1\",\"threshholds\": [{\"severity\": \"MAJOR\",\"fieldPath\": \"$$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\": \"4000\",\"closedLoopControlName\": \"CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8\",\"version\": \"1.0.2\",\"direction\": \"LESS_OR_EQUAL\"}, {\"severity\": \"CRITICAL\",\"fieldPath\": \"$$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\": \"20000\",\"closedLoopControlName\": \"CL-FRWL-HIGH-TRAFFIC-SIG-EA36FE84-9342-5E13-A656-EC5F21309A09\",\"version\": \"1.0.2\",\"direction\": \"GREATER_OR_EQUAL\"}],\"policyName\": \"configuration.ae.microservice.tca.xml\",\"functionalRole\": \"ClosedLoop_F5-d925ed73-8231-4d02-9545-db4e101f88f8\"}}", +"policyConfigType": "MicroService", +"policyName": "${policy_name}", +"ecompName": "DCAE" +} \ No newline at end of file diff --git a/test/csit/tests/policy/suite1/createpolicy.template b/test/csit/tests/policy/suite1/createpolicy.template new file mode 100644 index 000000000..7c693e840 --- /dev/null +++ b/test/csit/tests/policy/suite1/createpolicy.template @@ -0,0 +1,21 @@ +{ + "policyConfigType": "BRMS_PARAM", + "policyName": "${policy_name}", + "policyDescription": "Create BRMS Param policy", + "attributes": { + "RULE": { + "templateName": "ClosedLoopDemo_closedLoopControlName", + "aaiNamedQueryUUID": "2", + "aaiPassword": "2", + "aaiPatternMatch": "2", + "aaiURL": "2", + "actor": "2", + "appcTopic": "2", + "closedLoopControlName": "2", + "msoPassword": "2", + "msoURL": "2", + "msoUsername": "2", + "aaiUsername": "3" + } + } +} diff --git a/test/csit/tests/policy/suite1/deletepolicy.template b/test/csit/tests/policy/suite1/deletepolicy.template new file mode 100644 index 000000000..55510102f --- /dev/null +++ b/test/csit/tests/policy/suite1/deletepolicy.template @@ -0,0 +1,5 @@ +{ + "pdpGroup": "default", + "policyComponent": "PDP", + "policyName": "${policy_name}" +} diff --git a/test/csit/tests/policy/suite1/getconfigpolicy.template b/test/csit/tests/policy/suite1/getconfigpolicy.template new file mode 100644 index 000000000..611e65d0e --- /dev/null +++ b/test/csit/tests/policy/suite1/getconfigpolicy.template @@ -0,0 +1,8 @@ +{ + "configAttributes" : { + }, + "configName" : ".*", + "ecompName" : "DCAE", + "policyName" : "${config_policy_name}", + "unique" : false +} \ No newline at end of file diff --git a/test/csit/tests/policy/suite1/global_properties.robot b/test/csit/tests/policy/suite1/global_properties.robot new file mode 100644 index 000000000..f406bbf3d --- /dev/null +++ b/test/csit/tests/policy/suite1/global_properties.robot @@ -0,0 +1,30 @@ +*** Settings *** +Documentation store all properties that can change or are used in multiple places here +... format is all caps with underscores between words and prepended with GLOBAL +... make sure you prepend them with GLOBAL so that other files can easily see it is from this file. + + +*** Variables *** +${GLOBAL_APPLICATION_ID} robot-ete +${GLOBAL_MSO_STATUS_PATH} /ecomp/mso/infra/orchestrationRequests/v2/ +${GLOBAL_SELENIUM_BROWSER} chrome +${GLOBAL_SELENIUM_BROWSER_CAPABILITIES} Create Dictionary +${GLOBAL_SELENIUM_DELAY} 0 +${GLOBAL_SELENIUM_BROWSER_IMPLICIT_WAIT} 5 +${GLOBAL_SELENIUM_BROWSER_WAIT_TIMEOUT} 15 +${GLOBAL_OPENSTACK_HEAT_SERVICE_TYPE} orchestration +${GLOBAL_OPENSTACK_CINDER_SERVICE_TYPE} volume +${GLOBAL_OPENSTACK_NOVA_SERVICE_TYPE} compute +${GLOBAL_OPENSTACK_NEUTRON_SERVICE_TYPE} network +${GLOBAL_OPENSTACK_GLANCE_SERVICE_TYPE} image +${GLOBAL_OPENSTACK_KEYSTONE_SERVICE_TYPE} identity +${GLOBAL_AAI_CLOUD_OWNER} Rackspace +${GLOBAL_BUILD_NUMBER} 31 +${GLOBAL_VM_PRIVATE_KEY} ${EXECDIR}/robot/assets/keys/robot_ssh_private_key.pvt +# policy info - everything is from the private oam network (also called ecomp private network) +${GLOBAL_POLICY_SERVER_URL} http://%{PDP_IP}:8081 +${GLOBAL_POLICY_AUTH} dGVzdHBkcDphbHBoYTEyMw== +${GLOBAL_POLICY_CLIENTAUTH} cHl0aG9uOnRlc3Q= +${GLOBAL_POLICY_HEALTHCHECK_URL} http://%{POLICY_IP}:6969 +${GLOBAL_POLICY_USERNAME} healthcheck +${GLOBAL_POLICY_PASSWORD} zb!XztG34 \ No newline at end of file diff --git a/test/csit/tests/policy/suite1/json_templater.robot b/test/csit/tests/policy/suite1/json_templater.robot new file mode 100644 index 000000000..a1cc7e35d --- /dev/null +++ b/test/csit/tests/policy/suite1/json_templater.robot @@ -0,0 +1,21 @@ +*** Settings *** +Documentation This resource is filling out json string templates and returning the json back +Library RequestsLibrary +Library eteutils/StringTemplater.py +Library OperatingSystem +Resource global_properties.robot + +*** Keywords *** +Fill JSON Template + [Documentation] Runs substitution on template to return a filled in json + [Arguments] ${json} ${arguments} + ${returned_string}= Template String ${json} ${arguments} + ${returned_json}= To Json ${returned_string} + [Return] ${returned_json} + +Fill JSON Template File + [Documentation] Runs substitution on template to return a filled in json + [Arguments] ${json_file} ${arguments} + ${json}= OperatingSystem.Get File ${json_file} + ${returned_json}= Fill JSON Template ${json} ${arguments} + [Return] ${returned_json} \ No newline at end of file diff --git a/test/csit/tests/policy/suite1/opspolicy_VDNS.template b/test/csit/tests/policy/suite1/opspolicy_VDNS.template new file mode 100644 index 000000000..801773d57 --- /dev/null +++ b/test/csit/tests/policy/suite1/opspolicy_VDNS.template @@ -0,0 +1,26 @@ +{ + "policyConfigType": "BRMS_PARAM", + "policyName": "${policy_name}", + "policyDescription": "Create BRMS Param policy for vLB", + "attributes": { + "MATCHING": { + "controller": "vDNS" + }, + "RULE": { + "templateName": "ControlLoopDemo__closedLoopControlName", + "closedLoopControlName": "CL-DNS-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8", + "policyVersion": "v1.0", + "actor": "MSO", + "aaiNamedQueryUUID": "4ff56a54-9e3f-46b7-a337-07a1d3c6b469", + "aaiURL": "https://aai.api.simpledemo.openecomp.org:8443/aai/search/named-query", + "aaiUsername": "POLICY", + "aaiPassword": "POLICY", + "msoURL": "http://vm1.mso.simpledemo.openecomp.org:8080/ecomp/mso/infra", + "msoUsername": "InfraPortalClient", + "msoPassword": "password11", + "aaiPatternMatch": 0, + "notificationTopic": "POLICY-CL-MGT", + "appcTopic": "APPC-CL" + } + } +} \ No newline at end of file diff --git a/test/csit/tests/policy/suite1/opspolicy_VDNS_R1.template b/test/csit/tests/policy/suite1/opspolicy_VDNS_R1.template new file mode 100644 index 000000000..cfd43c0c8 --- /dev/null +++ b/test/csit/tests/policy/suite1/opspolicy_VDNS_R1.template @@ -0,0 +1,16 @@ +{ + "policyConfigType": "BRMS_PARAM", + "policyName": "${policy_name}", + "policyDescription": "BRMS Param vDNS policy", + "policyScope": "com", + "attributes": { + "MATCHING": { + "controller" : "amsterdam" + }, + "RULE": { + "templateName": "policy_ops_1", + "closedLoopControlName": "ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3", + "controlLoopYaml": "controlLoop%3A%0D%0A++version%3A+2.0.0%0D%0A++controlLoopName%3A+ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3%0D%0A++services%3A%0D%0A++++-+serviceName%3A+d4738992-6497-4dca-9db9%0D%0A++++++serviceInvariantUUID%3A+dc112d6e-7e73-4777-9c6f-1a7fb5fd1b6f%0D%0A++++++serviceUUID%3A+2eea06c6-e1d3-4c3a-b9c4-478c506eeedf%0D%0A++trigger_policy%3A+unique-policy-id-1-scale-up%0D%0A++timeout%3A+1200%0D%0A+%0D%0Apolicies%3A%0D%0A++-+id%3A+unique-policy-id-1-scale-up%0D%0A++++name%3A+Create+a+new+VF+Module%0D%0A++++description%3A%0D%0A++++actor%3A+MSO%0D%0A++++recipe%3A+VF+Module+Create%0D%0A++++target%3A%0D%0A++++++type%3A+VNF%0D%0A++++retry%3A+0%0D%0A++++timeout%3A+1200%0D%0A++++success%3A+final_success%0D%0A++++failure%3A+final_failure%0D%0A++++failure_timeout%3A+final_failure_timeout%0D%0A++++failure_retries%3A+final_failure_retries%0D%0A++++failure_exception%3A+final_failure_exception%0D%0A++++failure_guard%3A+final_failure_guard" + } + } +} \ No newline at end of file diff --git a/test/csit/tests/policy/suite1/opspolicy_VFW.template b/test/csit/tests/policy/suite1/opspolicy_VFW.template new file mode 100644 index 000000000..224f5cf41 --- /dev/null +++ b/test/csit/tests/policy/suite1/opspolicy_VFW.template @@ -0,0 +1,24 @@ +{ + "policyConfigType": "BRMS_PARAM", + "policyName": "${policy_name}", + "policyDescription": "Create BRMS Param policy for vFW", + "attributes": { + "RULE": { + "templateName": "ControlLoopDemo__closedLoopControlName", + "closedLoopControlName": "ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a", + "policyVersion": "v1.0", + "aaiNamedQueryUUID": "null", + "aaiPassword": "null", + "aaiURL": "null", + "actor": "APPC", + "appcTopic": "APPC-CL", + "msoPassword": "null", + "msoURL": "null", + "msoUsername": "null", + "aaiUsername": "null", + "notificationTopic": "POLICY-CL-MGT", + "aaiPatternMatch": 1 + } + } +} + diff --git a/test/csit/tests/policy/suite1/opspolicy_VFW_R1.template b/test/csit/tests/policy/suite1/opspolicy_VFW_R1.template new file mode 100644 index 000000000..94820d431 --- /dev/null +++ b/test/csit/tests/policy/suite1/opspolicy_VFW_R1.template @@ -0,0 +1,17 @@ +{ + "policyConfigType": "BRMS_PARAM", + "policyName": "${policy_name}", + "policyDescription": "BRMS Param vFirewall policy", + "policyScope": "com", + "attributes": { + "MATCHING": { + "controller" : "amsterdam" + }, + "RULE": { + "templateName": "policy_ops_1", + "closedLoopControlName": "ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a", + "controlLoopYaml": "controlLoop%3A%0D%0A++version%3A+2.0.0%0D%0A++controlLoopName%3A+ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a%0D%0A++services%3A%0D%0A++++-+serviceInvariantUUID%3A+5cfe6f4a-41bc-4247-8674-ebd4b98e35cc%0D%0A++++++serviceUUID%3A+0f40bba5-986e-4b3c-803f-ddd1b7b25f24%0D%0A++++++serviceName%3A+57e66ea7-0ed6-45c7-970f%0D%0A++trigger_policy%3A+unique-policy-id-1-modifyConfig%0D%0A++timeout%3A+1200%0D%0A+%0D%0Apolicies%3A%0D%0A++-+id%3A+unique-policy-id-1-modifyConfig%0D%0A++++name%3A+modify+packet+gen+config%0D%0A++++description%3A%0D%0A++++actor%3A+APPC%0D%0A++++recipe%3A+ModifyConfig%0D%0A++++target%3A%0D%0A++++++resourceID%3A+Eace933104d443b496b8.nodes.heat.vpg%0D%0A++++++type%3A+VNF%0D%0A++++retry%3A+0%0D%0A++++timeout%3A+300%0D%0A++++success%3A+final_success%0D%0A++++failure%3A+final_failure%0D%0A++++failure_timeout%3A+final_failure_timeout%0D%0A++++failure_retries%3A+final_failure_retries%0D%0A++++failure_exception%3A+final_failure_exception%0D%0A++++failure_guard%3A+final_failure_guard" + } + } +} + diff --git a/test/csit/tests/policy/suite1/policy_interface.robot b/test/csit/tests/policy/suite1/policy_interface.robot new file mode 100644 index 000000000..791787081 --- /dev/null +++ b/test/csit/tests/policy/suite1/policy_interface.robot @@ -0,0 +1,60 @@ +*** Settings *** +Documentation The main interface for interacting with Policy. It handles low level stuff like managing the http request library and Policy required fields +Library eteutils/RequestsClientCert.py +#Library RequestsClientCert +Library RequestsLibrary +Library String +Library eteutils/JSONUtils.py +#Library JSONUtils +Library Collections +Resource global_properties.robot + +*** Variables *** +${POLICY_HEALTH_CHECK_PATH} /healthcheck + +*** Keywords *** + +Run Policy Health Check + [Documentation] Runs Policy Health check + ${auth}= Create List ${GLOBAL_POLICY_USERNAME} ${GLOBAL_POLICY_PASSWORD} + Log Creating session ${GLOBAL_POLICY_SERVER_URL} + ${session}= Create Session policy ${GLOBAL_POLICY_HEALTHCHECK_URL} auth=${auth} + ${headers}= Create Dictionary Accept=application/json Content-Type=application/json + ${resp}= Get Request policy ${POLICY_HEALTH_CHECK_PATH} headers=${headers} + Log Received response from policy ${resp.text} + Should Be Equal As Strings ${resp.status_code} 200 + Should Be True ${resp.json()['healthy']} + @{ITEMS}= Copy List ${resp.json()['details']} + :FOR ${ELEMENT} IN @{ITEMS} + \ Should Be Equal As Strings ${ELEMENT['code']} 200 + \ Should Be True ${ELEMENT['healthy']} + +Run Policy Put Request + [Documentation] Runs Policy Put request + [Arguments] ${data_path} ${data} + Log Creating session ${GLOBAL_POLICY_SERVER_URL} + ${session}= Create Session policy ${GLOBAL_POLICY_SERVER_URL} + ${headers}= Create Dictionary Accept=application/json Content-Type=application/json Authorization=Basic ${GLOBAL_POLICY_AUTH} ClientAuth=${GLOBAL_POLICY_CLIENTAUTH} Environment=TEST + ${resp}= Put Request policy ${data_path} data=${data} headers=${headers} + Log Received response from policy ${resp.text} + [Return] ${resp} + +Run Policy Delete Request + [Documentation] Runs Policy Delete request + [Arguments] ${data_path} ${data} + Log Creating session ${GLOBAL_POLICY_SERVER_URL} + ${session}= Create Session policy ${GLOBAL_POLICY_SERVER_URL} + ${headers}= Create Dictionary Accept=application/json Content-Type=application/json Authorization=Basic ${GLOBAL_POLICY_AUTH} ClientAuth=${GLOBAL_POLICY_CLIENTAUTH} Environment=TEST + ${resp}= Delete Request policy ${data_path} data=${data} headers=${headers} + Log Received response from policy ${resp.text} + [Return] ${resp} + +Run Policy Get Configs Request + [Documentation] Runs Policy Get Configs request + [Arguments] ${data_path} ${data} + Log Creating session ${GLOBAL_POLICY_SERVER_URL} + ${session}= Create Session policy ${GLOBAL_POLICY_SERVER_URL} + ${headers}= Create Dictionary Accept=application/json Content-Type=application/json Authorization=Basic ${GLOBAL_POLICY_AUTH} ClientAuth=${GLOBAL_POLICY_CLIENTAUTH} + ${resp}= Post Request policy ${data_path} data=${data} headers=${headers} + Log Received response from policy ${resp.text} + [Return] ${resp} \ No newline at end of file diff --git a/test/csit/tests/policy/suite1/pushpolicy.template b/test/csit/tests/policy/suite1/pushpolicy.template new file mode 100644 index 000000000..7e236e3d4 --- /dev/null +++ b/test/csit/tests/policy/suite1/pushpolicy.template @@ -0,0 +1,5 @@ +{ + "policyName":"${policy_name}", + "policyType":"${policy_type}", + "pdpGroup":"default" +} \ No newline at end of file -- cgit 1.2.3-korg