diff options
25 files changed, 1034 insertions, 171 deletions
diff --git a/plans/appc/healthcheck/bundle_query.sh b/plans/appc/healthcheck/bundle_query.sh index 3801d0a1..2c9da710 100755 --- a/plans/appc/healthcheck/bundle_query.sh +++ b/plans/appc/healthcheck/bundle_query.sh @@ -17,19 +17,15 @@ SCRIPTS="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" echo $SCRIPTS +num_active_bundles=$(docker exec --tty appc_controller_container /opt/opendaylight/current/bin/client bundle:list | grep Active | wc -l) +num_failed_bundles=$(docker exec --tty appc_controller_container /opt/opendaylight/current/bin/client bundle:list | grep Failure | wc -l) +failed_bundles=$(docker exec --tty appc_controller_container /opt/opendaylight/current/bin/client bundle:list | grep Failure) -num_bundles=$(docker exec appc_controller_container /opt/opendaylight/current/bin/client bundle:list | tail -1 | cut -d\| -f1) -#num_failed_bundles=$(docker exec appc_controller_container /opt/opendaylight/current/bin/client bundle:list | grep Failure | wc -l) -num_failed_bundles=$(docker exec appc_controller_container /opt/opendaylight/current/bin/client bundle:list | grep Failure | wc -l) -failed_bundles=$(docker exec appc_controller_container /opt/opendaylight/current/bin/client bundle:list | grep Failure) +echo "There are $num_failed_bundles failed bundles and $num_active_bundles active bundles." -echo "There are $num_failed_bundles failed bundles out of $num_bundles installed bundles." - -if [ "$num_failed_bundles" -ge 1 ] || [ "$num_bundles" == "" ]; then - echo "There are $num_bundles bundles with $num_failed_bundles in a failed state. " +if [ "$num_failed_bundles" -ge 1 ] || [ "$num_active_bundles" == "" ]; then echo "The following bundle(s) are in a failed state: " echo " $failed_bundles" exit 1; fi - exit 0 diff --git a/plans/appc/healthcheck/setup.sh b/plans/appc/healthcheck/setup.sh index c78f4a82..9a145f86 100755 --- a/plans/appc/healthcheck/setup.sh +++ b/plans/appc/healthcheck/setup.sh @@ -20,9 +20,9 @@ SCRIPTS="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" source ${WORKSPACE}/scripts/appc/script1.sh -export APPC_DOCKER_IMAGE_VERSION=1.6.2-SNAPSHOT-latest +export APPC_DOCKER_IMAGE_VERSION=1.7.2-SNAPSHOT-latest export DGBUILDER_DOCKER_IMAGE_VERSION=0.6.0 -export ANSIBLE_DOCKER_IMAGE_VERSION=0.6.1-STAGING-latest +export ANSIBLE_DOCKER_IMAGE_VERSION=0.4.4 export BRANCH=master export SOLUTION_NAME=onap @@ -63,16 +63,13 @@ docker tag $NEXUS_DOCKER_REPO/${SOLUTION_NAME}/appc-cdt-image:$APPC_DOCKER_IMAGE # start APPC containers with docker compose and configuration from docker-compose.yml docker-compose up -d # WAIT 5 minutes maximum and test every 5 seconds if APPC is up using HealthCheck API -TIME_OUT=2000 +TIME_OUT=1000 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-appc" -H "X-TransactionId: csit-appc" -H "Accept: application/json" -H "Content-Type: application/json" http://localhost:8282/restconf/operations/SLI-API:healthcheck ); echo $response -startODL_status=$(docker exec appc_controller_container ps -e | grep startODL | wc -l) -waiting_bundles=$(docker exec appc_controller_container /opt/opendaylight/current/bin/client bundle:list | grep Waiting | wc -l) -run_level=$(docker exec appc_controller_container /opt/opendaylight/current/bin/client system:start-level) - - if [ "$run_level" == "Level 100" ] && [ "$startODL_status" -lt "1" ] && [ "$waiting_bundles" -lt "1" ] ; then + if [ "$response" == "200" ]; then echo APPC started in $TIME seconds break; fi @@ -83,9 +80,52 @@ run_level=$(docker exec appc_controller_container /opt/opendaylight/current/bin/ done if [ "$TIME" -ge "$TIME_OUT" ]; then - echo TIME OUT: Docker containers not started in $TIME_OUT seconds... Could cause problems for testing activities... + echo TIME OUT: APPC Docker containers not started in $TIME_OUT seconds... Could cause problems for testing activities... +fi + +TIME_OUT=1000 +INTERVAL=60 +TIME=0 +while [ "$TIME" -lt "$TIME_OUT" ]; do + response=$(docker exec --tty appc_controller_container /opt/opendaylight/current/bin/client system:start-level) + + if grep -q 'Level 100' <<< ${response}; then + echo APPC karaf started in $TIME seconds + break; + fi + + echo Sleep: $INTERVAL seconds before testing if APPC 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 + +TIME_OUT=1000 +INTERVAL=60 +TIME=0 +while [ "$TIME" -lt "$TIME_OUT" ]; do + response=$(docker exec --tty appc_controller_container /opt/opendaylight/current/bin/client bundle:list | grep appc-design-services-provider) + + if grep -q 'appc-design-services-provider' <<< ${response}; then + echo APPC features started in $TIME seconds + break; + fi + + echo Sleep: $INTERVAL seconds before testing if APPC 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 + + +# Sleep additional 5 minutes (300 secs) to give application time to finish sleep 300 # Pass any variables required by Robot test suites in ROBOT_VARIABLES diff --git a/plans/policy/drools-applications/setup.sh b/plans/policy/drools-applications/setup.sh index c66c4929..1a1dc331 100755 --- a/plans/policy/drools-applications/setup.sh +++ b/plans/policy/drools-applications/setup.sh @@ -1,7 +1,8 @@ #!/bin/bash -# ============LICENSE_START======================================================= +# +# ===========LICENSE_START==================================================== # Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. -# ================================================================================ +# ============================================================================ # 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 @@ -13,9 +14,8 @@ # 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. +# ============LICENSE_END===================================================== # -# SPDX-License-Identifier: Apache-2.0 -# ============LICENSE_END========================================================= # OS upgrades @@ -24,41 +24,67 @@ export POLICY_MARIADB_VER echo ${GERRIT_BRANCH} echo ${POLICY_MARIADB_VER} +SCR2=${WORKSPACE}/scripts/policy/drools-apps + echo "Uninstall docker-py and reinstall docker." pip uninstall -y docker-py pip uninstall -y docker pip install -U docker==2.7.0 sudo apt-get -y install libxml2-utils +${SCRIPTS}/policy/policy-models-simulators.sh + +POLICY_API_VERSION_EXTRACT="$(curl -q --silent https://git.onap.org/policy/api/plain/pom.xml?h=${GERRIT_BRANCH} | xmllint --xpath '/*[local-name()="project"]/*[local-name()="version"]/text()' -)" +export POLICY_API_VERSION="${POLICY_API_VERSION_EXTRACT:0:3}-SNAPSHOT-latest" +POLICY_PAP_VERSION_EXTRACT="$(curl -q --silent https://git.onap.org/policy/pap/plain/pom.xml?h=${GERRIT_BRANCH} | xmllint --xpath '/*[local-name()="project"]/*[local-name()="version"]/text()' -)" +export POLICY_PAP_VERSION="${POLICY_PAP_VERSION_EXTRACT:0:3}-SNAPSHOT-latest" +POLICY_XACML_PDP_VERSION_EXTRACT="$(curl -q --silent https://git.onap.org/policy/xacml-pdp/plain/pom.xml?h=${GERRIT_BRANCH} | xmllint --xpath '/*[local-name()="project"]/*[local-name()="version"]/text()' -)" +export POLICY_XACML_PDP_VERSION="${POLICY_XACML_PDP_VERSION_EXTRACT:0:3}-SNAPSHOT-latest" POLICY_DROOLS_APPS_VERSION_EXTRACT="$(curl -q --silent https://git.onap.org/policy/drools-applications/plain/pom.xml?h=${GERRIT_BRANCH} | xmllint --xpath '/*[local-name()="project"]/*[local-name()="version"]/text()' -)" echo ${POLICY_DROOLS_APPS_VERSION_EXTRACT} export POLICY_DROOLS_APPS_VERSION="${POLICY_DROOLS_APPS_VERSION_EXTRACT:0:3}-SNAPSHOT-latest" + +echo ${POLICY_XACML_PDP_VERSION} echo ${POLICY_DROOLS_APPS_VERSION} echo "user information: $(id)" echo "docker and docker-compose versions:" docker -v && docker-compose -v -docker container ls -a +# Adding this waiting container due to race condition between drools and mariadb +docker-compose -f ${SCR2}/docker-compose-drools-apps.yml run --rm start_dependencies + +# Adding this waiting container due to race condition between pap and xacml +docker-compose -f ${SCR2}/docker-compose-drools-apps.yml run --rm start_pap -docker-compose -f ${WORKSPACE}/scripts/policy/docker-compose-drools-apps.yml up -d -sleep 2m +# now bring everything else up +docker-compose -f ${SCR2}/docker-compose-drools-apps.yml run --rm start_all -docker container ls -a +unset http_proxy https_proxy -POLICY_DROOLS_IP=`get-instance-ip.sh drools` -MARIADB_IP=`get-instance-ip.sh mariadb` +DROOLS_IP=`get-instance-ip.sh drools` +API_IP=`get-instance-ip.sh policy-api` +PAP_IP=`get-instance-ip.sh policy-pap` +XACML_IP=`get-instance-ip.sh policy-xacml-pdp` +SIM_IP=`get-instance-ip.sh policy.api.simpledemo.onap.org` +export SIM_IP -echo DROOLS IP IS ${POLICY_DROOLS_IP} -echo MARIADB IP IS ${MARIADB_IP} +echo DROOLS IP IS ${DROOLS_IP} +echo API IP IS ${API_IP} +echo PAP IP IS ${PAP_IP} +echo XACML IP IS ${XACML_IP} +echo SIMULATORS IP IS ${SIM_IP} -for i in {1..10}; do - curl -sS ${POLICY_DROOLS_IP}:6969 && break - echo sleep $i - sleep $i -done +# give enough time for the controllers to come up +sleep 15 -# to give enough time to the usecases controller to come up -sleep 2m +DATA=${WORKSPACE}/simulators/models/models-examples/src/main/resources/policies -ROBOT_VARIABLES="-v POLICY_DROOLS_IP:${POLICY_DROOLS_IP}" +ROBOT_VARIABLES="" +ROBOT_VARIABLES="${ROBOT_VARIABLES} -v SCR2:${SCR2}" +ROBOT_VARIABLES="${ROBOT_VARIABLES} -v DATA:${DATA}" +ROBOT_VARIABLES="${ROBOT_VARIABLES} -v DROOLS_IP:${DROOLS_IP}" +ROBOT_VARIABLES="${ROBOT_VARIABLES} -v API_IP:${API_IP}" +ROBOT_VARIABLES="${ROBOT_VARIABLES} -v PAP_IP:${PAP_IP}" +ROBOT_VARIABLES="${ROBOT_VARIABLES} -v XACML_IP:${XACML_IP}" +ROBOT_VARIABLES="${ROBOT_VARIABLES} -v SIM_IP:${SIM_IP}" diff --git a/plans/policy/drools-applications/teardown.sh b/plans/policy/drools-applications/teardown.sh index 886b1ea3..8b577d8e 100755 --- a/plans/policy/drools-applications/teardown.sh +++ b/plans/policy/drools-applications/teardown.sh @@ -1,21 +1,23 @@ #!/bin/bash # -# Copyright 2020 AT&T Intellectual Property. All rights reserved. -# +# ===========LICENSE_START==================================================== +# Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. +# ============================================================================ # 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 +# 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. +# ============LICENSE_END===================================================== # mkdir -p $WORKSPACE/archives/ +docker-compose -f ${WORKSPACE}/scripts/policy/drools-apps/docker-compose-drools-apps.yml logs > $WORKSPACE/archives/docker-compose-drools-apps.log -docker-compose -f ${WORKSPACE}/scripts/policy/docker-compose-drools-apps.yml logs > $WORKSPACE/archives/docker-compose-drools-apps.log -docker-compose -f ${WORKSPACE}/scripts/policy/docker-compose-drools-apps.yml down -v +docker-compose -f ${WORKSPACE}/scripts/policy/drools-apps/docker-compose-drools-apps.yml down -v diff --git a/plans/policy/xacml-pdp/setup.sh b/plans/policy/xacml-pdp/setup.sh index 79c43070..72d1115e 100644 --- a/plans/policy/xacml-pdp/setup.sh +++ b/plans/policy/xacml-pdp/setup.sh @@ -61,10 +61,6 @@ echo ${POLICY_XACML_PDP_VERSION} # Adding this waiting container due to race condition between pap and mariadb docker-compose -f ${WORKSPACE}/scripts/policy/policy-xacml-pdp/docker-compose-pdpx.yml run --rm start_dependencies -#Configure the database -docker exec -it mariadb chmod +x /docker-entrypoint-initdb.d/db.sh -docker exec -it mariadb /docker-entrypoint-initdb.d/db.sh - # now bring everything else up docker-compose -f ${WORKSPACE}/scripts/policy/policy-xacml-pdp/docker-compose-pdpx.yml run --rm start_all diff --git a/scripts/policy/config/drools-apps/custom/features.pre.sh b/scripts/policy/config/drools-apps/custom/features.pre.sh index 93d6c6b9..e9c77a0f 100755 --- a/scripts/policy/config/drools-apps/custom/features.pre.sh +++ b/scripts/policy/config/drools-apps/custom/features.pre.sh @@ -1,7 +1,7 @@ #!/bin/bash -x -# ============LICENSE_START======================================================= +# ============LICENSE_START=================================================== # Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. -# ================================================================================ +# ============================================================================ # 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 @@ -13,7 +13,6 @@ # 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. -# ============LICENSE_END========================================================= +# ============LICENSE_END===================================================== -features disable distributed-locking -features enable controlloop-utils +bash -c "features disable distributed-locking" diff --git a/scripts/policy/config/drools-apps/env/base.conf b/scripts/policy/config/drools-apps/env/base.conf index b5e7cbd1..673cfaf3 100644 --- a/scripts/policy/config/drools-apps/env/base.conf +++ b/scripts/policy/config/drools-apps/env/base.conf @@ -1,6 +1,6 @@ -# ============LICENSE_START======================================================= +# ============LICENSE_START================================================== # Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. -# ================================================================================ +# =========================================================================== # 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 @@ -12,7 +12,7 @@ # 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. -# ============LICENSE_END========================================================= +# ============LICENSE_END==================================================== # JVM options @@ -78,55 +78,55 @@ PAP_PASSWORD=alpha123 # PDP-X -PDP_HOST=pdp +GUARD_DISABLED=false +PDP_HOST=policy-xacml-pdp PDP_PORT=6969 PDP_CONTEXT_URI=policy/pdpx/v1/ -PDP_USERNAME=testpdp -PDP_PASSWORD=alpha123 +PDP_USERNAME=healthcheck +PDP_PASSWORD=zb!XztG34 PDP_CLIENT_USERNAME=python PDP_CLIENT_PASSWORD=test PDP_ENVIRONMENT=TEST -GUARD_DISABLED=false # DCAE DMaaP DCAE_TOPIC=unauthenticated.DCAE_CL_OUTPUT -DCAE_SERVERS=mr.api.simpledemo.onap.org +DCAE_SERVERS=policy.api.simpledemo.onap.org DCAE_CONSUMER_GROUP=dcae.policy.shared # Open DMaaP -DMAAP_SERVERS=mr.api.simpledemo.onap.org +DMAAP_SERVERS=policy.api.simpledemo.onap.org # AAI -AAI_HOST=aai.api.simpledemo.onap.org -AAI_PORT=8443 +AAI_HOST=policy.api.simpledemo.onap.org +AAI_PORT=6666 AAI_CONTEXT_URI= AAI_USERNAME=policy@policy.onap.org AAI_PASSWORD=demo123456! # MSO -SO_HOST=vm1.mso.simpledemo.onap.org -SO_PORT=8080 -SO_CONTEXT_URI=onap/so/infra/ -SO_URL=http://vm1.mso.simpledemo.onap.org:8080/onap/so/infra +SO_HOST=policy.api.simpledemo.onap.org +SO_PORT=6669 +SO_CONTEXT_URI= +SO_URL=https://policy.api.simpledemo.onap.org:6669/ SO_USERNAME=InfraPortalClient SO_PASSWORD=password1$ # VFC -VFC_HOST= -VFC_PORT= -VFC_CONTEXT_URI=api/nslcm/v1/ +VFC_HOST=policy.api.simpledemo.onap.org +VFC_PORT=6670 +VFC_CONTEXT_URI= VFC_USERNAME= VFC_PASSWORD= # SDNC -SDNC_HOST= -SDNC_PORT= -SDNC_CONTEXT_URI=restconf/operations/ +SDNC_HOST=policy.api.simpledemo.onap.org +SDNC_PORT=6668 +SDNC_CONTEXT_URI= SDNC_USERNAME= SDNC_PASSWORD= diff --git a/scripts/policy/config/sim-all/simParameters.json b/scripts/policy/config/sim-all/simParameters.json new file mode 100644 index 00000000..cd347337 --- /dev/null +++ b/scripts/policy/config/sim-all/simParameters.json @@ -0,0 +1,98 @@ +{ + "dmaapProvider": { + "name": "DMaaP simulator", + "topicSweepSec": 300, + "restServerParameters": { } + }, + "restServers": [ + { + "name": "DMaaP simulator", + "providerClass": "org.onap.policy.models.sim.dmaap.rest.DmaapSimRestControllerV1", + "host": "0.0.0.0", + "port": 3905, + "https": true + }, + { + "name": "A&AI simulator", + "providerClass": "org.onap.policy.simulators.AaiSimulatorJaxRs", + "host": "0.0.0.0", + "port": 6666, + "https": true, + "userName": "policy@policy.onap.org", + "password": "demo123456!" + }, + { + "name": "SDNC simulator", + "providerClass": "org.onap.policy.simulators.SdncSimulatorJaxRs", + "host": "0.0.0.0", + "port": 6668, + "https": true + }, + { + "name": "SO simulator", + "providerClass": "org.onap.policy.simulators.SoSimulatorJaxRs", + "host": "0.0.0.0", + "port": 6669, + "https": true, + "userName": "InfraPortalClient", + "password": "password1$" + }, + { + "name": "VFC simulator", + "providerClass": "org.onap.policy.simulators.VfcSimulatorJaxRs", + "host": "0.0.0.0", + "port": 6670, + "https": true + } + ], + "topicSinks": [ + { + "topic": "APPC-CL", + "servers": ["${HOST_NAME}"], + "topicCommInfrastructure": "DMAAP", + "useHttps": true, + "apiKey": "some-key", + "apiSecret": "some-secret" + }, + { + "topic": "APPC-LCM-WRITE", + "servers": ["${HOST_NAME}"], + "topicCommInfrastructure": "DMAAP", + "useHttps": true, + "apiKey": "some-key", + "apiSecret": "some-secret" + } + ], + "topicSources": [ + { + "topic": "APPC-CL", + "servers": ["${HOST_NAME}"], + "topicCommInfrastructure": "DMAAP", + "useHttps": true, + "apiKey": "some-key", + "apiSecret": "some-secret" + }, + { + "topic": "APPC-LCM-READ", + "servers": ["${HOST_NAME}"], + "topicCommInfrastructure": "DMAAP", + "useHttps": true, + "apiKey": "some-key", + "apiSecret": "some-secret" + } + ], + "topicServers": [ + { + "name": "APPC Legacy simulator", + "providerClass": "org.onap.policy.simulators.AppcLegacyTopicServer", + "sink": "APPC-CL", + "source": "APPC-CL" + }, + { + "name": "APPC-LCM simulator", + "providerClass": "org.onap.policy.simulators.AppcLcmTopicServer", + "sink": "APPC-LCM-WRITE", + "source": "APPC-LCM-READ" + } + ] +} diff --git a/scripts/policy/docker-compose-drools-apps.yml b/scripts/policy/docker-compose-drools-apps.yml deleted file mode 100644 index 704de81b..00000000 --- a/scripts/policy/docker-compose-drools-apps.yml +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright 2019-2020 AT&T Intellectual Property. All rights reserved -# -# 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. -version: '2' -services: - mariadb: - image: mariadb:${POLICY_MARIADB_VER} - container_name: mariadb - hostname: mariadb - command: ['--lower-case-table-names=1', '--wait_timeout=28800'] - env_file: - - ${WORKSPACE}/scripts/policy/config/db/db.conf - volumes: - - ${WORKSPACE}/scripts/policy/config/db:/docker-entrypoint-initdb.d - expose: - - 3306 - drools: - image: nexus3.onap.org:10001/onap/policy-pdpd-cl:${POLICY_DROOLS_APPS_VERSION} - container_name: drools - depends_on: - - mariadb - hostname: drools - expose: - - 6969 - - 9696 - volumes: - - ${WORKSPACE}/scripts/policy/config/drools-apps/custom:/tmp/policy-install/config - env_file: - - ${WORKSPACE}/scripts/policy/config/drools-apps/env/base.conf - - ${WORKSPACE}/scripts/policy/config/drools-apps/env/feature-healthcheck.conf - - ${WORKSPACE}/scripts/policy/config/drools-apps/env/feature-pooling-dmaap.conf diff --git a/scripts/policy/drools-apps/custom/papDefaultConfig.json b/scripts/policy/drools-apps/custom/papDefaultConfig.json new file mode 100644 index 00000000..2575d8a5 --- /dev/null +++ b/scripts/policy/drools-apps/custom/papDefaultConfig.json @@ -0,0 +1,64 @@ +{ + "name": "PapGroup", + "restServerParameters": { + "host": "0.0.0.0", + "port": 6969, + "userName": "healthcheck", + "password": "zb!XztG34", + "https": true, + "aaf": false + }, + "pdpParameters": { + "heartBeatMs": 120000, + "updateParameters": { + "maxRetryCount": 1, + "maxWaitMs": 30000 + }, + "stateChangeParameters": { + "maxRetryCount": 1, + "maxWaitMs": 30000 + } + }, + "databaseProviderParameters": { + "name": "PolicyProviderParameterGroup", + "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl", + "databaseDriver": "org.mariadb.jdbc.Driver", + "databaseUrl": "jdbc:mariadb://mariadb:3306/policyadmin", + "databaseUser": "policy_user", + "databasePassword": "cG9saWN5X3VzZXI=", + "persistenceUnit": "PolicyMariaDb" + }, + "topicParameterGroup": { + "topicSources" : [{ + "topic" : "POLICY-PDP-PAP", + "servers" : [ "policy.api.simpledemo.onap.org" ], + "topicCommInfrastructure" : "dmaap", + "useHttps": true, + "allowSelfSignedCerts" : true + }], + "topicSinks" : [{ + "topic" : "POLICY-PDP-PAP", + "servers" : [ "policy.api.simpledemo.onap.org" ], + "topicCommInfrastructure" : "dmaap", + "useHttps": true, + "allowSelfSignedCerts" : true + }, + { + "topic" : "POLICY-NOTIFICATION", + "servers" : [ "policy.api.simpledemo.onap.org" ], + "topicCommInfrastructure" : "dmaap", + "useHttps": true, + "allowSelfSignedCerts" : true + }] + }, + "healthCheckRestClientParameters":[{ + "clientName": "api", + "hostname": "policy-api", + "port": 6969, + "userName": "healthcheck", + "password": "zb!XztG34", + "useHttps": true, + "allowSelfSignedCerts" : true, + "basePath": "policy/api/v1/healthcheck" + }] +} diff --git a/scripts/policy/drools-apps/custom/xacmlDefaultConfig.json b/scripts/policy/drools-apps/custom/xacmlDefaultConfig.json new file mode 100644 index 00000000..5a6573a3 --- /dev/null +++ b/scripts/policy/drools-apps/custom/xacmlDefaultConfig.json @@ -0,0 +1,37 @@ +{ + "name": "XacmlPdpParameters", + "pdpGroup": "defaultGroup", + "restServerParameters": { + "host": "0.0.0.0", + "port": 6969, + "userName": "healthcheck", + "password": "zb!XztG34", + "https": true, + "aaf": false + }, + "policyApiParameters": { + "host": "policy-api", + "port": 6969, + "userName": "healthcheck", + "password": "zb!XztG34", + "https": true, + "aaf": false + }, + "applicationPath": "/opt/app/policy/pdpx/apps", + "topicParameterGroup": { + "topicSources" : [{ + "topic" : "POLICY-PDP-PAP", + "servers" : [ "policy.api.simpledemo.onap.org" ], + "topicCommInfrastructure" : "dmaap", + "useHttps" : true, + "allowSelfSignedCerts" : true + }], + "topicSinks" : [{ + "topic" : "POLICY-PDP-PAP", + "servers" : [ "policy.api.simpledemo.onap.org" ], + "topicCommInfrastructure" : "dmaap", + "useHttps" : true, + "allowSelfSignedCerts" : true + }] + } +} diff --git a/scripts/policy/drools-apps/deploy.drools.policies.json b/scripts/policy/drools-apps/deploy.drools.policies.json new file mode 100644 index 00000000..24c90d0d --- /dev/null +++ b/scripts/policy/drools-apps/deploy.drools.policies.json @@ -0,0 +1,27 @@ +{ + "groups": [ + { + "name": "defaultGroup", + "deploymentSubgroups": [ + { + "pdpType": "drools", + "action": "POST", + "policies": [ + { + "name": "operational.restart", + "version": "1.0.0" + }, + { + "name": "operational.scaleout", + "version": "1.0.0" + }, + { + "name": "operational.modifyconfig", + "version": "1.0.0" + } + ] + } + ] + } + ] +} diff --git a/scripts/policy/drools-apps/deploy.xacml.policies.json b/scripts/policy/drools-apps/deploy.xacml.policies.json new file mode 100644 index 00000000..46da9021 --- /dev/null +++ b/scripts/policy/drools-apps/deploy.xacml.policies.json @@ -0,0 +1,27 @@ +{ + "groups": [ + { + "name": "defaultGroup", + "deploymentSubgroups": [ + { + "pdpType": "xacml", + "action": "POST", + "policies": [ + { + "name": "onap.restart.tca", + "version": "1.0.0" + }, + { + "name": "onap.scaleout.tca", + "version": "1.0.0" + }, + { + "name": "onap.vfirewall.tca", + "version": "1.0.0" + } + ] + } + ] + } + ] +} diff --git a/scripts/policy/drools-apps/docker-compose-drools-apps.yml b/scripts/policy/drools-apps/docker-compose-drools-apps.yml new file mode 100644 index 00000000..5098a177 --- /dev/null +++ b/scripts/policy/drools-apps/docker-compose-drools-apps.yml @@ -0,0 +1,139 @@ +# +# ===========LICENSE_START==================================================== +# Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. +# ============================================================================ +# 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. +# ============LICENSE_END===================================================== +# +version: '2' +services: + mariadb: + image: mariadb:${POLICY_MARIADB_VER} + container_name: mariadb + hostname: mariadb + command: ['--lower-case-table-names=1', '--wait_timeout=28800'] + env_file: ../config/db/db.conf + volumes: + - ../config/db:/docker-entrypoint-initdb.d:ro + expose: + - 3306 + policy.api.simpledemo.onap.org: + image: policy/simulators + container_name: policy.api.simpledemo.onap.org + hostname: policy.api.simpledemo.onap.org + volumes: + - ../config/sim-all:/opt/app/policy/simulators/etc/parameters:ro + expose: + - 6666 + - 6668 + - 6669 + - 6670 + - 3905 + api: + image: nexus3.onap.org:10001/onap/policy-api:${POLICY_API_VERSION} + container_name: policy-api + depends_on: + - mariadb + hostname: policy-api + expose: + - 6969 + pap: + image: nexus3.onap.org:10001/onap/policy-pap:${POLICY_PAP_VERSION} + container_name: policy-pap + depends_on: + - mariadb + hostname: policy-pap + expose: + - 6969 + volumes: + - ./custom/papDefaultConfig.json:/opt/app/policy/pap/etc/defaultConfig.json:ro + policy-xacml-pdp: + image: nexus3.onap.org:10001/onap/policy-xacml-pdp:${POLICY_XACML_PDP_VERSION} + container_name: policy-xacml-pdp + depends_on: + - mariadb + - policy.api.simpledemo.onap.org + hostname: policy-xacml-pdp + expose: + - 6969 + volumes: + - ./custom/xacmlDefaultConfig.json:/opt/app/policy/pdpx/etc/defaultConfig.json:ro + drools: + image: nexus3.onap.org:10001/onap/policy-pdpd-cl:${POLICY_DROOLS_APPS_VERSION} + container_name: drools + depends_on: + - mariadb + - policy.api.simpledemo.onap.org + hostname: drools + expose: + - 6969 + - 9696 + volumes: + - ../config/drools-apps/custom:/tmp/policy-install/config:ro + env_file: + - ../config/drools-apps/env/base.conf + - ../config/drools-apps/env/feature-healthcheck.conf + - ../config/drools-apps/env/feature-pooling-dmaap.conf + start_dependencies: + image: dadarek/wait-for-dependencies + environment: + TIMEOUT_LENGTH: 60 + container_name: policy-wait + depends_on: + - mariadb + - policy.api.simpledemo.onap.org + hostname: policy-wait + command: + mariadb:3306 + policy.api.simpledemo.onap.org:6666 + policy.api.simpledemo.onap.org:6668 + policy.api.simpledemo.onap.org:6669 + policy.api.simpledemo.onap.org:6670 + policy.api.simpledemo.onap.org:3905 + start_pap: + image: dadarek/wait-for-dependencies + environment: + TIMEOUT_LENGTH: 120 + container_name: policy-wait-pap + depends_on: + - mariadb + - policy.api.simpledemo.onap.org + - pap + hostname: policy-wait-pap + command: + mariadb:3306 + policy.api.simpledemo.onap.org:3905 + pap:6969 + start_all: + image: dadarek/wait-for-dependencies + environment: + TIMEOUT_LENGTH: 120 + container_name: policy-wait-all + depends_on: + - mariadb + - policy.api.simpledemo.onap.org + - api + - pap + - policy-xacml-pdp + - drools + hostname: policy-wait-all + command: + mariadb:3306 + policy.api.simpledemo.onap.org:6666 + policy.api.simpledemo.onap.org:6668 + policy.api.simpledemo.onap.org:6669 + policy.api.simpledemo.onap.org:6670 + policy.api.simpledemo.onap.org:3905 + api:6969 + pap:6969 + drools:6969 diff --git a/scripts/policy/config/drools-apps/custom/noop.pre.sh b/scripts/policy/drools-apps/make_topic.sh index 4b0c2199..36d43e9d 100755 --- a/scripts/policy/config/drools-apps/custom/noop.pre.sh +++ b/scripts/policy/drools-apps/make_topic.sh @@ -1,7 +1,8 @@ -#!/bin/bash -x -# ============LICENSE_START======================================================= -# Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. -# ================================================================================ +#!/bin/bash +# +# ===========LICENSE_START==================================================== +# Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. +# ============================================================================ # 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 @@ -13,13 +14,20 @@ # 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. -# ============LICENSE_END========================================================= +# ============LICENSE_END===================================================== +# + +# +# Creates a topic, which happens as a side-effect of polling it. +# + +if [ $# -ne 1 ] +then + echo "arg(s): topic-name" >&2 + exit 1 +fi -sed -i "s/^dmaap/noop/g" \ - ${POLICY_HOME}/config/engine.properties \ - ${POLICY_HOME}/config/feature-lifecycle.properties \ - ${POLICY_HOME}/config/frankfurt-controller.properties +topic="${1}" -chmod 644 ${POLICY_HOME}/config/engine.properties \ - ${POLICY_HOME}/config/feature-lifecycle.properties \ - ${POLICY_HOME}/config/frankfurt-controller.properties +curl -s -k "https://${SIM_IP}:3905/events/${topic}/script/1?limit=1&timeout=0" +echo diff --git a/scripts/policy/drools-apps/onset.sh b/scripts/policy/drools-apps/onset.sh new file mode 100755 index 00000000..f2918a68 --- /dev/null +++ b/scripts/policy/drools-apps/onset.sh @@ -0,0 +1,32 @@ +#!/bin/bash +# +# ===========LICENSE_START==================================================== +# Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. +# ============================================================================ +# 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. +# ============LICENSE_END===================================================== +# + +# +# Injects an ONSET event on the DCAE_CL_OUTPUT topic. +# + +if [ $# -ne 1 ] +then + echo "arg(s): json-message-file-name" >&2 + exit 1 +fi + +curl -k -H "Content-type: application/json" --data-binary @$1 \ + https://${SIM_IP}:3905/events/unauthenticated.DCAE_CL_OUTPUT +echo diff --git a/scripts/policy/drools-apps/vcpeOnset.json b/scripts/policy/drools-apps/vcpeOnset.json new file mode 100644 index 00000000..7dd9d5a0 --- /dev/null +++ b/scripts/policy/drools-apps/vcpeOnset.json @@ -0,0 +1,16 @@ +{ + "closedLoopControlName": "ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e", + "closedLoopAlarmStart": 1463679805324, + "closedLoopEventClient": "DCAE_INSTANCE_ID.dcae-tca", + "closedLoopEventStatus": "ONSET", + "requestID": "664be3d2-6c12-4f4b-a3e7-c349acced200", + "target_type": "VNF", + "target": "generic-vnf.vnf-id", + "AAI": { + "vserver.is-closed-loop-disabled": "false", + "vserver.prov-status": "ACTIVE", + "generic-vnf.vnf-id": "vCPE_Infrastructure_vGMUX_demo_app" + }, + "from": "DCAE", + "version": "1.0.2" +} diff --git a/scripts/policy/drools-apps/vdnsOnset.json b/scripts/policy/drools-apps/vdnsOnset.json new file mode 100644 index 00000000..13f69095 --- /dev/null +++ b/scripts/policy/drools-apps/vdnsOnset.json @@ -0,0 +1,16 @@ +{ + "closedLoopControlName": "ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3", + "closedLoopAlarmStart": 1463679805324, + "closedLoopEventClient": "microservice.stringmatcher", + "closedLoopEventStatus": "ONSET", + "requestID": "c7c6a4aa-bb61-4a15-b831-ba1472dd4a65", + "target_type": "VNF", + "target": "vserver.vserver-name", + "AAI": { + "vserver.is-closed-loop-disabled": "false", + "vserver.prov-status": "ACTIVE", + "vserver.vserver-name": "OzVServer" + }, + "from": "DCAE", + "version": "1.0.2" +} diff --git a/scripts/policy/drools-apps/vfwOnset.json b/scripts/policy/drools-apps/vfwOnset.json new file mode 100644 index 00000000..7782867a --- /dev/null +++ b/scripts/policy/drools-apps/vfwOnset.json @@ -0,0 +1,17 @@ +{ + "closedLoopControlName": "ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a", + "closedLoopAlarmStart": 1463679805324, + "closedLoopEventClient": "microservice.stringmatcher", + "closedLoopEventStatus": "ONSET", + "requestID": "c7c6a4aa-bb61-4a15-b831-ba1472dd4a65", + "target_type": "VNF", + "target": "generic-vnf.vnf-name", + "AAI": { + "vserver.is-closed-loop-disabled": "false", + "vserver.prov-status": "ACTIVE", + "generic-vnf.vnf-name": "fw0002vm002fw002", + "vserver.vserver-name": "OzVServer" + }, + "from": "DCAE", + "version": "1.0.2" +} diff --git a/scripts/policy/drools-apps/wait_topic.sh b/scripts/policy/drools-apps/wait_topic.sh new file mode 100755 index 00000000..4271abc6 --- /dev/null +++ b/scripts/policy/drools-apps/wait_topic.sh @@ -0,0 +1,61 @@ +#!/bin/bash +# +# ===========LICENSE_START==================================================== +# Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. +# ============================================================================ +# 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. +# ============LICENSE_END===================================================== +# + +# +# Polls a topic for a message. Additional text items can be specified, +# in which case, it discards messages that do not contain all of the +# specified text items. +# +# Exits with a non-zero status if no matching message is received on the +# topic before the timeout. +# + +if [ $# -lt 1 ] +then + echo "arg(s): topic-name [text-to-match1 [text-to-match2 ...]]" >&2 + exit 1 +fi + +topic="${1}" +shift + +matched=no + +while [ ${matched} = "no" ] +do + msg=`curl -s -k "https://${SIM_IP}:3905/events/${topic}/script/1?limit=1"` + if [ $? -ne 0 -o "${msg}" = "[]" ] + then + echo not found >&2 + exit 2 + fi + + matched=yes + for text in "$@" + do + echo "${msg}" | grep -q "${text}" + if [ $? -ne 0 ] + then + matched=no + break + fi + done +done + +echo "${msg}" diff --git a/scripts/policy/policy-models-dmaap-sim.sh b/scripts/policy/policy-models-dmaap-sim.sh index 0abd9f94..2839e5c3 100644 --- a/scripts/policy/policy-models-dmaap-sim.sh +++ b/scripts/policy/policy-models-dmaap-sim.sh @@ -19,6 +19,10 @@ source ${SCRIPTS}/policy/config/policy-csit.conf +rm -rf ${WORKSPACE}/dmaap-sim +mkdir ${WORKSPACE}/dmaap-sim +cd ${WORKSPACE}/dmaap-sim + POLICY_MODELS_VERSION_EXTRACT="$(curl -q --silent https://git.onap.org/policy/models/plain/pom.xml?h=${GERRIT_BRANCH} | xmllint --xpath '/*[local-name()="project"]/*[local-name()="version"]/text()' -)" export POLICY_MODELS_VERSION="${POLICY_MODELS_VERSION_EXTRACT}" echo ${POLICY_MODELS_VERSION} @@ -31,5 +35,3 @@ mkdir target curl -L $item -o target/policy-models-sim-dmaap-${POLICY_MODELS_VERSION}-tarball.tar.gz bash ./src/main/package/docker/docker_build.sh cd ${WORKSPACE} -rm -rf ${WORK_DIR} - diff --git a/scripts/policy/policy-models-simulators.sh b/scripts/policy/policy-models-simulators.sh new file mode 100755 index 00000000..9e67d487 --- /dev/null +++ b/scripts/policy/policy-models-simulators.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# +# ============LICENSE_START=================================================== +# Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. +# ============================================================================ +# 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. +# ============LICENSE_END===================================================== +# + +source ${SCRIPTS}/policy/config/policy-csit.conf + +rm -rf ${WORKSPACE}/simulators +mkdir ${WORKSPACE}/simulators +cd ${WORKSPACE}/simulators + +POLICY_MODELS_VERSION_EXTRACT="$(curl -q --silent https://git.onap.org/policy/models/plain/pom.xml?h=${GERRIT_BRANCH} | xmllint --xpath '/*[local-name()="project"]/*[local-name()="version"]/text()' -)" +export POLICY_MODELS_VERSION="${POLICY_MODELS_VERSION_EXTRACT}" +echo ${POLICY_MODELS_VERSION} + +# download simulators tarball and build docker image +git clone --depth 1 https://gerrit.onap.org/r/policy/models -b ${GERRIT_BRANCH} +cd models/models-sim/policy-models-simulators +item=`curl --silent -L ${NEXUS_URL}/org/onap/policy/models/sim/policy-models-simulators/${POLICY_MODELS_VERSION} | egrep 'policy-models-simulators-.*tarball' | cut '-d"' -f2 | egrep 'gz$' | sort | tail -1` +mkdir target +curl -L $item -o target/policy-models-simulators-${POLICY_MODELS_VERSION}-tarball.tar.gz +bash ./src/main/package/docker/docker_build.sh + +cd ${WORKSPACE} diff --git a/tests/policy/drools-applications/drools-applications-test.robot b/tests/policy/drools-applications/drools-applications-test.robot index c3586cfa..2104566a 100644 --- a/tests/policy/drools-applications/drools-applications-test.robot +++ b/tests/policy/drools-applications/drools-applications-test.robot @@ -1,40 +1,275 @@ *** Settings *** Library Collections +Library String Library RequestsLibrary Library OperatingSystem +Library Process Library json *** Test Cases *** Alive - [Documentation] Runs Policy PDP Alive Check - ${auth}= Create List demo@people.osaaf.org demo123456! - Log Creating session https://${POLICY_DROOLS_IP}:9696 - ${session}= Create Session policy https://${POLICY_DROOLS_IP}:9696 auth=${auth} - ${headers}= Create Dictionary Accept=application/json Content-Type=application/json - ${resp}= Get Request policy /policy/pdp/engine headers=${headers} - Log Received response from policy ${resp.text} - Should Be Equal As Strings ${resp.status_code} 200 - Should Be Equal As Strings ${resp.json()['alive']} True + [Documentation] Runs Policy PDP Alive Check + ${auth}= Create List demo@people.osaaf.org demo123456! + Log Creating session https://${DROOLS_IP}:9696 + ${session}= Create Session policy https://${DROOLS_IP}:9696 auth=${auth} + ${headers}= Create Dictionary Accept=application/json Content-Type=application/json + ${resp}= Get Request policy /policy/pdp/engine headers=${headers} + Log Received response from policy ${resp.text} + Should Be Equal As Strings ${resp.status_code} 200 + Should Be Equal As Strings ${resp.json()['alive']} True Healthcheck - [Documentation] Runs Policy PDP-D Health check - ${auth}= Create List demo@people.osaaf.org demo123456! - Log Creating session https://${POLICY_DROOLS_IP}:6969/healthcheck - ${session}= Create Session policy https://${POLICY_DROOLS_IP}:6969 auth=${auth} - ${headers}= Create Dictionary Accept=application/json Content-Type=application/json - ${resp}= Get Request policy /healthcheck headers=${headers} - Log Received response from policy ${resp.text} - Should Be Equal As Strings ${resp.status_code} 200 - Should Be Equal As Strings ${resp.json()['healthy']} True - -Frankfurt - [Documentation] Checks frankfurt controller is up - ${auth}= Create List demo@people.osaaf.org demo123456! - Log Creating session https://${POLICY_DROOLS_IP}:9696 - ${session}= Create Session policy https://${POLICY_DROOLS_IP}:9696 auth=${auth} - ${headers}= Create Dictionary Accept=application/json Content-Type=application/json - ${resp}= Get Request policy /policy/pdp/engine/controllers/frankfurt/drools/facts headers=${headers} - Log Received response from policy ${resp.text} - Should Be Equal As Strings ${resp.status_code} 200 - Should Be Equal As Strings ${resp.json()['frankfurt']} 0 + [Documentation] Runs Policy PDP-D Health check + ${auth}= Create List demo@people.osaaf.org demo123456! + Log Creating session https://${DROOLS_IP}:6969/healthcheck + ${session}= Create Session policy https://${DROOLS_IP}:6969 auth=${auth} + ${headers}= Create Dictionary Accept=application/json Content-Type=application/json + ${resp}= Get Request policy /healthcheck headers=${headers} + Log Received response from policy ${resp.text} + Should Be Equal As Strings ${resp.status_code} 200 + Should Be Equal As Strings ${resp.json()['healthy']} True +Controller + [Documentation] Checks controller is up + ${auth}= Create List demo@people.osaaf.org demo123456! + Log Creating session https://${DROOLS_IP}:9696 + ${session}= Create Session policy https://${DROOLS_IP}:9696 auth=${auth} + ${headers}= Create Dictionary Accept=application/json Content-Type=application/json + ${resp}= Get Request policy /policy/pdp/engine/controllers/frankfurt/drools/facts headers=${headers} + Log Received response from policy ${resp.text} + Should Be Equal As Strings ${resp.status_code} 200 + Should Be Equal As Strings ${resp.json()['frankfurt']} 0 + +MakeTopics + [Documentation] Creates the Policy topics + ${result}= Run Process ${SCR2}/make_topic.sh POLICY-PDP-PAP + Should Be Equal As Integers ${result.rc} 0 + ${result}= Run Process ${SCR2}/make_topic.sh POLICY-CL-MGT + Should Be Equal As Integers ${result.rc} 0 + +CreateVcpeXacmlPolicy + [Documentation] Create VCPE Policy for Xacml + ${auth}= Create List healthcheck zb!XztG34 + ${postyaml}= Get file ${DATA}/vCPE.policy.monitoring.input.tosca.yaml + Log Creating session https://${API_IP}:6969 + ${session}= Create Session policy https://${API_IP}:6969 auth=${auth} + ${headers}= Create Dictionary Accept=application/yaml Content-Type=application/yaml + ${resp}= Post Request policy /policy/api/v1/policies data=${postyaml} headers=${headers} + Log Received response from api ${resp.text} + Should Be Equal As Strings ${resp.status_code} 200 + +CreateVcpeDroolsPolicy + [Documentation] Create VCPE Policy for Drools + ${auth}= Create List healthcheck zb!XztG34 + ${postyaml}= Get file ${DATA}/vCPE.policy.operational.input.tosca.yaml + Log Creating session https://${API_IP}:6969 + ${session}= Create Session policy https://${API_IP}:6969 auth=${auth} + ${headers}= Create Dictionary Accept=application/yaml Content-Type=application/yaml + ${resp}= Post Request policy /policy/api/v1/policies data=${postyaml} headers=${headers} + Log Received response from api ${resp.text} + Should Be Equal As Strings ${resp.status_code} 200 + +CreateVdnsXacmlPolicy + [Documentation] Create VDNS Policy for Xacml + ${auth}= Create List healthcheck zb!XztG34 + ${postyaml}= Get file ${DATA}/vDNS.policy.monitoring.input.tosca.yaml + Log Creating session https://${API_IP}:6969 + ${session}= Create Session policy https://${API_IP}:6969 auth=${auth} + ${headers}= Create Dictionary Accept=application/yaml Content-Type=application/yaml + ${resp}= Post Request policy /policy/api/v1/policies data=${postyaml} headers=${headers} + Log Received response from api ${resp.text} + Should Be Equal As Strings ${resp.status_code} 200 + +CreateVdnsDroolsPolicy + [Documentation] Create VDNS Policy for Drools + ${auth}= Create List healthcheck zb!XztG34 + ${postjson}= Get file ${DATA}/vDNS.policy.operational.input.tosca.json + Log Creating session https://${API_IP}:6969 + ${session}= Create Session policy https://${API_IP}:6969 auth=${auth} + ${headers}= Create Dictionary Accept=application/json Content-Type=application/json + ${resp}= Post Request policy /policy/api/v1/policies data=${postjson} headers=${headers} + Log Received response from api ${resp.text} + Should Be Equal As Strings ${resp.status_code} 200 + +CreateVfwXacmlPolicy + [Documentation] Create VFW Policy for Xacml + ${auth}= Create List healthcheck zb!XztG34 + ${postyaml}= Get file ${DATA}/vFirewall.policy.monitoring.input.tosca.yaml + Log Creating session https://${API_IP}:6969 + ${session}= Create Session policy https://${API_IP}:6969 auth=${auth} + ${headers}= Create Dictionary Accept=application/yaml Content-Type=application/yaml + ${resp}= Post Request policy /policy/api/v1/policies data=${postyaml} headers=${headers} + Log Received response from api ${resp.text} + Should Be Equal As Strings ${resp.status_code} 200 + +CreateVfwDroolsPolicy + [Documentation] Create VFW Policy for Drools + ${auth}= Create List healthcheck zb!XztG34 + ${postjson}= Get file ${DATA}/vFirewall.policy.operational.input.tosca.json + Log Creating session https://${API_IP}:6969 + ${session}= Create Session policy https://${API_IP}:6969 auth=${auth} + ${headers}= Create Dictionary Accept=application/json Content-Type=application/json + ${resp}= Post Request policy /policy/api/v1/policies data=${postjson} headers=${headers} + Log Received response from api ${resp.text} + Should Be Equal As Strings ${resp.status_code} 200 + +DeployXacmlPolicies + [Documentation] Deploys the Policies to Xacml + ${auth}= Create List healthcheck zb!XztG34 + Log Creating session https://${PAP_IP}:6969 + ${postjson}= Get file ${SCR2}/deploy.xacml.policies.json + ${session}= Create Session policy https://${PAP_IP}:6969 auth=${auth} + ${headers}= Create Dictionary Accept=application/json Content-Type=application/json + ${resp}= Post Request policy /policy/pap/v1/pdps/deployments/batch data=${postjson} headers=${headers} + Log Received response from pap ${resp.text} + Should Be Equal As Strings ${resp.status_code} 200 + ${result}= Run Process ${SCR2}/wait_topic.sh POLICY-PDP-PAP + ... responseTo xacml ACTIVE + Log Received status ${result.stdout} + Should Be Equal As Integers ${result.rc} 0 + Should Contain ${result.stdout} onap.restart.tca + Should Contain ${result.stdout} onap.scaleout.tca + Should Contain ${result.stdout} onap.vfirewall.tca + +DeployDroolsPolicies + [Documentation] Deploys the Policies to Drools + ${auth}= Create List healthcheck zb!XztG34 + Log Creating session https://${PAP_IP}:6969 + ${postjson}= Get file ${SCR2}/deploy.drools.policies.json + ${session}= Create Session policy https://${PAP_IP}:6969 auth=${auth} + ${headers}= Create Dictionary Accept=application/json Content-Type=application/json + ${resp}= Post Request policy /policy/pap/v1/pdps/deployments/batch data=${postjson} headers=${headers} + Log Received response from pap ${resp.text} + Should Be Equal As Strings ${resp.status_code} 200 + ${result}= Run Process ${SCR2}/wait_topic.sh POLICY-PDP-PAP + ... responseTo drools ACTIVE + Log Received status ${result.stdout} + Sleep 3s + Should Be Equal As Integers ${result.rc} 0 + Should Contain ${result.stdout} operational.restart + Should Contain ${result.stdout} operational.scaleout + Should Contain ${result.stdout} operational.modifyconfig + +VcpeExecute + [Documentation] Executes VCPE Policy + ${result}= Run Process ${SCR2}/onset.sh ${SCR2}/vcpeOnset.json + Should Be Equal As Integers ${result.rc} 0 + ${result}= Run Process ${SCR2}/wait_topic.sh POLICY-CL-MGT + ... ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e + Log Received notification ${result.stdout} + Should Be Equal As Integers ${result.rc} 0 + Should Contain ${result.stdout} ACTIVE + ${result}= Run Process ${SCR2}/wait_topic.sh POLICY-CL-MGT + ... ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e + Log Received notification ${result.stdout} + Should Be Equal As Integers ${result.rc} 0 + Should Contain ${result.stdout} OPERATION + Should Contain ${result.stdout} Sending guard query for APPC Restart + Should Be Equal As Integers ${result.rc} 0 + ${result}= Run Process ${SCR2}/wait_topic.sh POLICY-CL-MGT + ... ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e + Log Received notification ${result.stdout} + Should Be Equal As Integers ${result.rc} 0 + Should Contain ${result.stdout} OPERATION + Should Contain ${result.stdout} Guard result for APPC Restart is Permit + ${result}= Run Process ${SCR2}/wait_topic.sh POLICY-CL-MGT + ... ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e + Log Received notification ${result.stdout} + Should Be Equal As Integers ${result.rc} 0 + Should Contain ${result.stdout} OPERATION + Should Contain ${result.stdout} actor=APPC,operation=Restart + ${result}= Run Process ${SCR2}/wait_topic.sh POLICY-CL-MGT + ... ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e + Log Received notification ${result.stdout} + Should Be Equal As Integers ${result.rc} 0 + Should Contain ${result.stdout} OPERATION: SUCCESS + Should Contain ${result.stdout} actor=APPC,operation=Restart + ${result}= Run Process ${SCR2}/wait_topic.sh POLICY-CL-MGT + ... ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e + Log Received notification ${result.stdout} + Should Be Equal As Integers ${result.rc} 0 + Should Contain ${result.stdout} FINAL: SUCCESS + Should Contain ${result.stdout} APPC + Should Contain ${result.stdout} Restart + +VdnsExecute + [Documentation] Executes VDNS Policy + ${result}= Run Process ${SCR2}/onset.sh ${SCR2}/vdnsOnset.json + Should Be Equal As Integers ${result.rc} 0 + ${result}= Run Process ${SCR2}/wait_topic.sh POLICY-CL-MGT + ... ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3 + Log Received notification ${result.stdout} + Should Be Equal As Integers ${result.rc} 0 + Should Contain ${result.stdout} ACTIVE + ${result}= Run Process ${SCR2}/wait_topic.sh POLICY-CL-MGT + ... ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3 + Log Received notification ${result.stdout} + Should Be Equal As Integers ${result.rc} 0 + Should Contain ${result.stdout} OPERATION + Should Contain ${result.stdout} Sending guard query for SO VF Module Create + ${result}= Run Process ${SCR2}/wait_topic.sh POLICY-CL-MGT + ... ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3 + Log Received notification ${result.stdout} + Should Be Equal As Integers ${result.rc} 0 + Should Contain ${result.stdout} OPERATION + Should Contain ${result.stdout} Guard result for SO VF Module Create is Permit + ${result}= Run Process ${SCR2}/wait_topic.sh POLICY-CL-MGT + ... ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3 + Log Received notification ${result.stdout} + Should Be Equal As Integers ${result.rc} 0 + Should Contain ${result.stdout} OPERATION + Should Contain ${result.stdout} actor=SO,operation=VF Module Create + ${result}= Run Process ${SCR2}/wait_topic.sh POLICY-CL-MGT + ... ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3 + Log Received notification ${result.stdout} + Should Be Equal As Integers ${result.rc} 0 + Should Contain ${result.stdout} OPERATION: SUCCESS + Should Contain ${result.stdout} actor=SO,operation=VF Module Create + ${result}= Run Process ${SCR2}/wait_topic.sh POLICY-CL-MGT + ... ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3 + Log Received notification ${result.stdout} + Should Be Equal As Integers ${result.rc} 0 + Should Contain ${result.stdout} FINAL: SUCCESS + Should Contain ${result.stdout} SO + Should Contain ${result.stdout} VF Module Create + +VfwExecute + [Documentation] Executes VFW Policy + ${result}= Run Process ${SCR2}/onset.sh ${SCR2}/vfwOnset.json + Should Be Equal As Integers ${result.rc} 0 + ${result}= Run Process ${SCR2}/wait_topic.sh POLICY-CL-MGT + ... ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a + Log Received notification ${result.stdout} + Should Be Equal As Integers ${result.rc} 0 + Should Contain ${result.stdout} ACTIVE + ${result}= Run Process ${SCR2}/wait_topic.sh POLICY-CL-MGT + ... ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a + Log Received notification ${result.stdout} + Should Be Equal As Integers ${result.rc} 0 + Should Contain ${result.stdout} OPERATION + Should Contain ${result.stdout} Sending guard query for APPC ModifyConfig + ${result}= Run Process ${SCR2}/wait_topic.sh POLICY-CL-MGT + ... ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a + Log Received notification ${result.stdout} + Should Be Equal As Integers ${result.rc} 0 + Should Contain ${result.stdout} OPERATION + Should Contain ${result.stdout} Guard result for APPC ModifyConfig is Permit + ${result}= Run Process ${SCR2}/wait_topic.sh POLICY-CL-MGT + ... ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a + Log Received notification ${result.stdout} + Should Be Equal As Integers ${result.rc} 0 + Should Contain ${result.stdout} OPERATION + Should Contain ${result.stdout} actor=APPC,operation=ModifyConfig + ${result}= Run Process ${SCR2}/wait_topic.sh POLICY-CL-MGT + ... ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a + Log Received notification ${result.stdout} + Should Be Equal As Integers ${result.rc} 0 + Should Contain ${result.stdout} OPERATION: SUCCESS + Should Contain ${result.stdout} actor=APPC,operation=ModifyConfig + ${result}= Run Process ${SCR2}/wait_topic.sh POLICY-CL-MGT + ... ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a + Log Received notification ${result.stdout} + Should Be Equal As Integers ${result.rc} 0 + Should Contain ${result.stdout} FINAL: SUCCESS + Should Contain ${result.stdout} APPC + Should Contain ${result.stdout} ModifyConfig diff --git a/tests/policy/xacml-pdp/data/onap.policy.naming.decision.request.json b/tests/policy/xacml-pdp/data/onap.policy.naming.decision.request.json new file mode 100644 index 00000000..d30e0e27 --- /dev/null +++ b/tests/policy/xacml-pdp/data/onap.policy.naming.decision.request.json @@ -0,0 +1,13 @@ +{ + "ONAPName": "SDNC", + "ONAPComponent": "SNDC-component", + "ONAPInstance": "SDNC-component-instance", + "requestId": "unique-request-sdnc-1", + "action": "naming", + "resource": { + "nfRole": [], + "naming-type": [], + "property-name": [], + "policy-type": ["onap.policies.Naming"] + } +} diff --git a/tests/policy/xacml-pdp/xacml-pdp-test.robot b/tests/policy/xacml-pdp/xacml-pdp-test.robot index 0305af8e..5144f966 100644 --- a/tests/policy/xacml-pdp/xacml-pdp-test.robot +++ b/tests/policy/xacml-pdp/xacml-pdp-test.robot @@ -7,7 +7,7 @@ Library json *** Test Cases *** Healthcheck [Documentation] Runs Policy Xacml PDP Health check - ${auth}= Create List healthcheck zb!XztG34 + ${auth}= Create List healthcheck zb!XztG34 Log Creating session https://${POLICY_PDPX_IP}:6969 ${session}= Create Session policy https://${POLICY_PDPX_IP}:6969 auth=${auth} ${headers}= Create Dictionary Accept=application/json Content-Type=application/json @@ -28,10 +28,11 @@ Statistics Should Be Equal As Strings ${resp.json()['code']} 200 ExecuteXacmlPolicy - Wait Until Keyword Succeeds 2 min 5 sec CreateNewMonitorPolicy - Wait Until Keyword Succeeds 2 min 5 sec DeployMonitorPolicy - Wait Until Keyword Succeeds 2 min 10 sec GetAbbreviatedDecisionResult - Wait Until Keyword Succeeds 2 min 10 sec GetDecision + Wait Until Keyword Succeeds 0 min 15 sec CreateNewMonitorPolicy + Wait Until Keyword Succeeds 0 min 15 sec DeployMonitorPolicy + Wait Until Keyword Succeeds 0 min 15 sec GetAbbreviatedDecisionResult + Wait Until Keyword Succeeds 0 min 15 sec GetMonitoringDecision + Wait Until Keyword Succeeds 0 min 15 sec GetNamingDecision *** Keywords *** @@ -92,8 +93,8 @@ GetAbbreviatedDecisionResult Dictionary Should Not Contain Key ${policy} name Dictionary Should Not Contain Key ${policy} version -GetDecision - [Documentation] Get Decision from Policy Xacml PDP +GetMonitoringDecision + [Documentation] Get Decision from Monitoring Policy Xacml PDP ${auth}= Create List healthcheck zb!XztG34 ${postjson}= Get file ${CURDIR}/data/onap.policy.monitoring.decision.request.json Log Creating session https://${POLICY_PDPX_IP}:6969 @@ -109,10 +110,26 @@ GetDecision Dictionary Should Contain Key ${policy} properties Dictionary Should Contain Key ${policy} name Dictionary Should Contain Key ${policy} version - + +GetNamingDecision + [Documentation] Get Decision from Naming Policy Xacml PDP + ${auth}= Create List healthcheck zb!XztG34 + ${postjson}= Get file ${CURDIR}/data/onap.policy.naming.decision.request.json + Log Creating session https://${POLICY_PDPX_IP}:6969 + ${session}= Create Session policy https://${POLICY_PDPX_IP}:6969 auth=${auth} + ${headers}= Create Dictionary Accept=application/json Content-Type=application/json + ${resp}= Post Request policy /policy/pdpx/v1/decision data=${postjson} headers=${headers} + Log Received response from policy ${resp.text} + ${policy}= Get From Dictionary ${resp.json()['policies']} SDNC_Policy.ONAP_VNF_NAMING_TIMESTAMP + Should Be Equal As Strings ${resp.status_code} 200 + Dictionary Should Contain Key ${policy} type + Dictionary Should Contain Key ${policy} type_version + Dictionary Should Contain Key ${policy} properties + Dictionary Should Contain Key ${policy} name + GetStatisticsAfterDecision [Documentation] Runs Policy Xacml PDP Statistics after Decision request - ${auth}= Create List healthcheck zb!XztG34 + ${auth}= Create List healthcheck zb!XztG34 Log Creating session https://${POLICY_PDPX_IP}:6969 ${session}= Create Session policy https://${POLICY_PDPX_IP}:6969 auth=${auth} ${headers}= Create Dictionary Accept=application/json Content-Type=application/json @@ -121,7 +138,7 @@ GetStatisticsAfterDecision Should Be Equal As Strings ${resp.status_code} 200 Should Be Equal As Strings ${resp.json()['code']} 200 Should Be Equal As Strings ${resp.json()['totalDecisionsCount'] 1 - + UndeployMonitorPolicy [Documentation] Runs Policy PAP to undeploy a policy ${auth}= Create List healthcheck zb!XztG34 @@ -131,10 +148,10 @@ UndeployMonitorPolicy ${resp}= Delete Request policy /policy/pap/v1/pdps/policies/onap.restart.tca headers=${headers} Log Received response from policy ${resp.text} Should Be Equal As Strings ${resp.status_code} 200 - + GetStatisticsAfterUndeploy [Documentation] Runs Policy Xacml PDP Statistics after policy is undeployed - ${auth}= Create List healthcheck zb!XztG34 + ${auth}= Create List healthcheck zb!XztG34 Log Creating session https://${POLICY_PDPX_IP}:6969 ${session}= Create Session policy https://${POLICY_PDPX_IP}:6969 auth=${auth} ${headers}= Create Dictionary Accept=application/json Content-Type=application/json @@ -143,5 +160,3 @@ GetStatisticsAfterUndeploy Should Be Equal As Strings ${resp.status_code} 200 Should Be Equal As Strings ${resp.json()['code']} 200 Should Be Equal As Strings ${resp.json()['totalPoliciesCount'] 0 - - |