Xacml-PDP CSIT tests with DmaaP Simulator 50/88950/3
authorMichael Mokry <michael.mokry@att.com>
Mon, 13 May 2019 18:09:17 +0000 (13:09 -0500)
committerBilal A <bilal@research.att.com>
Mon, 3 Jun 2019 17:52:23 +0000 (17:52 +0000)
1. Added test cases for creating policy, deploying policy, and getting a
decision for monitoring policies
2. Included statistics check between some tests
3. Modified to use dmaap simulator, policy-pap, and policy-api for end
to end tests
5. UPDATE:  made changes per Ajith's review
6. Removed most config overrides and changed dmaap to message-router
where appropriate

Change-Id: Ia9935193f189f249e11f23b2ffe49f87090b7b54
Issue-ID: POLICY-1767
Signed-off-by: Jim Hahn <jrh3@att.com>
(Adding to dublin branch)
Signed-off-by: Bilal A <bilal@research.att.com>
plans/policy/xacml-pdp/setup.sh
plans/policy/xacml-pdp/teardown.sh
scripts/policy/policy-xacml-pdp/config/db/db.conf [new file with mode: 0644]
scripts/policy/policy-xacml-pdp/config/db/db.sh [new file with mode: 0644]
scripts/policy/policy-xacml-pdp/docker-compose-pdpx.yml [new file with mode: 0644]
tests/policy/xacml-pdp/data/onap.policies.monitoring.cdap.tca.hi.lo.app.json [new file with mode: 0644]
tests/policy/xacml-pdp/data/onap.policy.monitoring.decision.request.json [new file with mode: 0644]
tests/policy/xacml-pdp/data/vCPE.policy.monitoring.input.tosca.deploy.json [new file with mode: 0644]
tests/policy/xacml-pdp/data/vCPE.policy.monitoring.input.tosca.json [new file with mode: 0644]
tests/policy/xacml-pdp/xacml-pdp-test.robot

index e788282..96ae471 100644 (file)
 # SPDX-License-Identifier: Apache-2.0
 # ============LICENSE_END=========================================================
 
-docker run -d --name policy-xacml-pdp -p 6969:6969 -it nexus3.onap.org:10001/onap/policy-xacml-pdp:2.0.0-SNAPSHOT-latest 
-docker ps -a
-sleep 5
+echo "Uninstall docker-py and reinstall docker."
+pip uninstall -y docker-py
+pip uninstall -y docker
+pip install -U docker==2.7.0
+
+# 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 ..
+
+git clone http://gerrit.onap.org/r/oparent
+git clone --depth 1 https://gerrit.onap.org/r/policy/models -b master
+cd models/models-sim/models-sim-dmaap
+${WORK_DIR}/maven/apache-maven-3.3.9/bin/mvn clean install -DskipTests  --settings ${WORK_DIR}/oparent/settings.xml
+bash ./src/main/package/docker/docker_build.sh
+cd ${WORKSPACE}
+rm -rf ${WORK_DIR}
+sleep 3
+
+# 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
+docker-compose -f ${WORKSPACE}/scripts/policy/policy-xacml-pdp/docker-compose-pdpx.yml up -d
+
+unset http_proxy https_proxy
+
+POLICY_API_IP=`get-instance-ip.sh policy-api`
+MARIADB_IP=`get-instance-ip.sh mariadb`
 POLICY_PDPX_IP=`get-instance-ip.sh policy-xacml-pdp`
-echo PDP-X IP IS ${POLICY_PDPX_IP}
+DMAAP_IP=`get-instance-ip.sh dmaap-simulator`
+POLICY_PAP_IP=`get-instance-ip.sh policy-pap`
+
+
+echo PDP IP IS ${POLICY_PDPX_IP}
+echo API IP IS ${POLICY_API_IP}
+echo PAP IP IS ${POLICY_PAP_IP}
+echo MARIADB IP IS ${MARIADB_IP}
+echo DMAAP_IP IS ${DMAAP_IP}
+
 # Wait for initialization
+for i in {1..10}; do
+   curl -sS ${MARIADB_IP}:3306 && break
+   echo sleep $i
+   sleep $i
+done
 for i in {1..10}; do
    curl -sS ${POLICY_PDPX_IP}:6969 && break
    echo sleep $i
    sleep $i
 done
+for i in {1..10}; do
+   curl -sS ${DMAAP_IP}:3904 && break
+   echo sleep $i
+   sleep $i
+done
+
+#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
 
-ROBOT_VARIABLES="-v POLICY_PDPX_IP:${POLICY_PDPX_IP}"
+ROBOT_VARIABLES="-v POLICY_PDPX_IP:${POLICY_PDPX_IP} -v POLICY_API_IP:${POLICY_API_IP} -v POLICY_PAP_IP:${POLICY_PAP_IP}"
index a81ee6b..270d6cc 100644 (file)
@@ -18,3 +18,7 @@
 # ============LICENSE_END=========================================================
 
 kill-instance.sh policy-xacml-pdp
+kill-instance.sh policy-pap
+kill-instance.sh policy-api
+kill-instance.sh mariadb
+kill-instance.sh dmaap-simulator
diff --git a/scripts/policy/policy-xacml-pdp/config/db/db.conf b/scripts/policy/policy-xacml-pdp/config/db/db.conf
new file mode 100644 (file)
index 0000000..b444911
--- /dev/null
@@ -0,0 +1,20 @@
+# ============LICENSE_START=======================================================
+#  Copyright (C) 2019 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.
+#
+# SPDX-License-Identifier: Apache-2.0
+# ============LICENSE_END=========================================================
+MYSQL_ROOT_PASSWORD=secret
+MYSQL_USER=policy_user
+MYSQL_PASSWORD=policy_user
\ No newline at end of file
diff --git a/scripts/policy/policy-xacml-pdp/config/db/db.sh b/scripts/policy/policy-xacml-pdp/config/db/db.sh
new file mode 100644 (file)
index 0000000..ac150a0
--- /dev/null
@@ -0,0 +1,26 @@
+#!/bin/bash -xv
+# ============LICENSE_START=======================================================
+#  Copyright (C) 2019 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.
+#
+# SPDX-License-Identifier: Apache-2.0
+# ============LICENSE_END=========================================================
+
+for db in policyadmin
+do
+     mysql -uroot -p"${MYSQL_ROOT_PASSWORD}" --execute "CREATE DATABASE IF NOT EXISTS ${db};"
+     mysql -uroot -p"${MYSQL_ROOT_PASSWORD}" --execute "GRANT ALL PRIVILEGES ON \`${db}\`.* TO '${MYSQL_USER}'@'%' ;"
+done
+
+mysql -uroot -p"${MYSQL_ROOT_PASSWORD}" --execute "FLUSH PRIVILEGES;"
\ No newline at end of file
diff --git a/scripts/policy/policy-xacml-pdp/docker-compose-pdpx.yml b/scripts/policy/policy-xacml-pdp/docker-compose-pdpx.yml
new file mode 100644 (file)
index 0000000..62e0ce2
--- /dev/null
@@ -0,0 +1,72 @@
+# ============LICENSE_START=======================================================
+#  Copyright (C) 2019 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.
+#
+# SPDX-License-Identifier: Apache-2.0
+# ============LICENSE_END=========================================================
+version: '2'
+networks:
+  default:
+    driver: bridge
+services:
+   mariadb:
+      image: mariadb:10.2.14
+      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
+      ports:
+       - "3306:3306"
+   message-router:
+      image: dmaap/simulator
+      container_name: dmaap-simulator
+      hostname: dmaap-simulator
+      ports:
+       - "3904:3904"
+   pap:
+      image: nexus3.onap.org:10001/onap/policy-pap:2.0.0-SNAPSHOT-latest
+      container_name: policy-pap
+      depends_on:
+       - mariadb
+       - message-router
+      hostname: policy-pap
+   api:
+      image: nexus3.onap.org:10001/onap/policy-api
+      container_name: policy-api
+      depends_on:
+       - mariadb
+      hostname: policy-api
+   xacml-pdp:
+      image: nexus3.onap.org:10001/onap/policy-xacml-pdp:2.0.0-SNAPSHOT-latest 
+      container_name: policy-xacml-pdp
+      depends_on:
+       - mariadb
+       - message-router
+       - pap
+       - api
+      hostname: policy-xacml-pdp
+      ports:
+       - "6969:6969"
+   start_dependencies:
+      image: dadarek/wait-for-dependencies
+      container_name: policy-wait
+      depends_on:
+        - mariadb
+        - message-router
+      hostname: policy-wait
+      command:
+        - mariadb:3306
+        - message-router:3904
diff --git a/tests/policy/xacml-pdp/data/onap.policies.monitoring.cdap.tca.hi.lo.app.json b/tests/policy/xacml-pdp/data/onap.policies.monitoring.cdap.tca.hi.lo.app.json
new file mode 100644 (file)
index 0000000..1d1a4d6
--- /dev/null
@@ -0,0 +1,223 @@
+{
+    "tosca_definitions_version": "tosca_simple_yaml_1_0_0",
+    "policy_types": [
+        {
+            "onap.policies.Monitoring": {
+                "derived_from": "tosca.policies.Root",
+                "description": "a base policy type for all policies that governs monitoring provisioning"
+            }
+        },
+        {
+            "onap.policies.monitoring.cdap.tca.hi.lo.app": {
+                "derived_from": "onap.policies.Monitoring",
+                "version": "1.0.0",
+                "properties": {
+                    "tca_policy": {
+                        "type": "map",
+                        "description": "TCA Policy JSON",
+                        "entry_schema": {
+                            "type": "onap.datatypes.monitoring.tca_policy"
+                        }
+                    }
+                }
+            }
+        }
+    ],
+    "data_types": [
+        {
+            "onap.datatypes.monitoring.metricsPerEventName": {
+                "derived_from": "tosca.datatypes.Root",
+                "properties": {
+                    "controlLoopSchemaType": {
+                        "type": "string",
+                        "required": true,
+                        "description": "Specifies Control Loop Schema Type for the event Name e.g. VNF, VM",
+                        "constraints": [
+                            {
+                                "valid_values": [
+                                    "VM",
+                                    "VNF"
+                                ]
+                            }
+                        ]
+                    },
+                    "eventName": {
+                        "type": "string",
+                        "required": true,
+                        "description": "Event name to which thresholds need to be applied"
+                    },
+                    "policyName": {
+                        "type": "string",
+                        "required": true,
+                        "description": "TCA Policy Scope Name"
+                    },
+                    "policyScope": {
+                        "type": "string",
+                        "required": true,
+                        "description": "TCA Policy Scope"
+                    },
+                    "policyVersion": {
+                        "type": "string",
+                        "required": true,
+                        "description": "TCA Policy Scope Version"
+                    },
+                    "thresholds": {
+                        "type": "list",
+                        "required": true,
+                        "description": "Thresholds associated with eventName",
+                        "entry_schema": {
+                            "type": "onap.datatypes.monitoring.thresholds"
+                        }
+                    }
+                }
+            }
+        },
+        {
+            "onap.datatypes.monitoring.tca_policy": {
+                "derived_from": "tosca.datatypes.Root",
+                "properties": {
+                    "domain": {
+                        "type": "string",
+                        "required": true,
+                        "description": "Domain name to which TCA needs to be applied",
+                        "default": "measurementsForVfScaling",
+                        "constraints": [
+                            {
+                                "equal": "measurementsForVfScaling"
+                            }
+                        ]
+                    },
+                    "metricsPerEventName": {
+                        "type": "list",
+                        "required": true,
+                        "description": "Contains eventName and threshold details that need to be applied to given eventName",
+                        "entry_schema": {
+                            "type": "onap.datatypes.monitoring.metricsPerEventName"
+                        }
+                    }
+                }
+            }
+        },
+        {
+            "onap.datatypes.monitoring.thresholds": {
+                "derived_from": "tosca.datatypes.Root",
+                "properties": {
+                    "closedLoopControlName": {
+                        "type": "string",
+                        "required": true,
+                        "description": "Closed Loop Control Name associated with the threshold"
+                    },
+                    "closedLoopEventStatus": {
+                        "type": "string",
+                        "required": true,
+                        "description": "Closed Loop Event Status of the threshold",
+                        "constraints": [
+                            {
+                                "valid_values": [
+                                    "ONSET",
+                                    "ABATED"
+                                ]
+                            }
+                        ]
+                    },
+                    "direction": {
+                        "type": "string",
+                        "required": true,
+                        "description": "Direction of the threshold",
+                        "constraints": [
+                            {
+                                "valid_values": [
+                                    "LESS",
+                                    "LESS_OR_EQUAL",
+                                    "GREATER",
+                                    "GREATER_OR_EQUAL",
+                                    "EQUAL"
+                                ]
+                            }
+                        ]
+                    },
+                    "fieldPath": {
+                        "type": "string",
+                        "required": true,
+                        "description": "Json field Path as per CEF message which needs to be analyzed for TCA",
+                        "constraints": [
+                            {
+                                "valid_values": [
+                                    "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedTotalPacketsDelta",
+                                    "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedOctetsDelta",
+                                    "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedUnicastPacketsDelta",
+                                    "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedMulticastPacketsDelta",
+                                    "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsDelta",
+                                    "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedDiscardedPacketsDelta",
+                                    "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedErrorPacketsDelta",
+                                    "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedTotalPacketsAccumulated",
+                                    "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedOctetsAccumulated",
+                                    "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedUnicastPacketsAccumulated",
+                                    "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedMulticastPacketsAccumulated",
+                                    "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated",
+                                    "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedDiscardedPacketsAccumulated",
+                                    "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedErrorPacketsAccumulated",
+                                    "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedTotalPacketsDelta",
+                                    "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedOctetsDelta",
+                                    "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedUnicastPacketsDelta",
+                                    "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedMulticastPacketsDelta",
+                                    "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedBroadcastPacketsDelta",
+                                    "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedDiscardedPacketsDelta",
+                                    "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedErrorPacketsDelta",
+                                    "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedTotalPacketsAccumulated",
+                                    "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedOctetsAccumulated",
+                                    "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedUnicastPacketsAccumulated",
+                                    "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedMulticastPacketsAccumulated",
+                                    "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedBroadcastPacketsAccumulated",
+                                    "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedDiscardedPacketsAccumulated",
+                                    "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedErrorPacketsAccumulated",
+                                    "$.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuIdle",
+                                    "$.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuUsageInterrupt",
+                                    "$.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuUsageNice",
+                                    "$.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuUsageSoftIrq",
+                                    "$.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuUsageSteal",
+                                    "$.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuUsageSystem",
+                                    "$.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuWait",
+                                    "$.event.measurementsForVfScalingFields.cpuUsageArray[*].percentUsage",
+                                    "$.event.measurementsForVfScalingFields.meanRequestLatency",
+                                    "$.event.measurementsForVfScalingFields.memoryUsageArray[*].memoryBuffered",
+                                    "$.event.measurementsForVfScalingFields.memoryUsageArray[*].memoryCached",
+                                    "$.event.measurementsForVfScalingFields.memoryUsageArray[*].memoryConfigured",
+                                    "$.event.measurementsForVfScalingFields.memoryUsageArray[*].memoryFree",
+                                    "$.event.measurementsForVfScalingFields.memoryUsageArray[*].memoryUsed",
+                                    "$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value"
+                                ]
+                            }
+                        ]
+                    },
+                    "severity": {
+                        "type": "string",
+                        "required": true,
+                        "description": "Threshold Event Severity",
+                        "constraints": [
+                            {
+                                "valid_values": [
+                                    "CRITICAL",
+                                    "MAJOR",
+                                    "MINOR",
+                                    "WARNING",
+                                    "NORMAL"
+                                ]
+                            }
+                        ]
+                    },
+                    "thresholdValue": {
+                        "type": "integer",
+                        "required": true,
+                        "description": "Threshold value for the field Path inside CEF message"
+                    },
+                    "version": {
+                        "type": "string",
+                        "required": true,
+                        "description": "Version number associated with the threshold"
+                    }
+                }
+            }
+        }
+    ]
+}
\ No newline at end of file
diff --git a/tests/policy/xacml-pdp/data/onap.policy.monitoring.decision.request.json b/tests/policy/xacml-pdp/data/onap.policy.monitoring.decision.request.json
new file mode 100644 (file)
index 0000000..f79f4eb
--- /dev/null
@@ -0,0 +1,9 @@
+{
+  "ONAPName": "DCAE",
+  "ONAPComponent": "PolicyHandler",
+  "ONAPInstance": "622431a4-9dea-4eae-b443-3b2164639c64",
+  "action": "configure",
+  "resource": {
+      "policy-id": "onap.restart.tca"
+  }
+}
\ No newline at end of file
diff --git a/tests/policy/xacml-pdp/data/vCPE.policy.monitoring.input.tosca.deploy.json b/tests/policy/xacml-pdp/data/vCPE.policy.monitoring.input.tosca.deploy.json
new file mode 100644 (file)
index 0000000..c0d157c
--- /dev/null
@@ -0,0 +1 @@
+{"policies":[{"policy-id":"onap.restart.tca"}]}
\ No newline at end of file
diff --git a/tests/policy/xacml-pdp/data/vCPE.policy.monitoring.input.tosca.json b/tests/policy/xacml-pdp/data/vCPE.policy.monitoring.input.tosca.json
new file mode 100644 (file)
index 0000000..fac5cfa
--- /dev/null
@@ -0,0 +1,51 @@
+{
+    "tosca_definitions_version": "tosca_simple_yaml_1_0_0",
+    "topology_template": {
+        "policies": [
+            {
+                "onap.restart.tca": {
+                    "type": "onap.policies.monitoring.cdap.tca.hi.lo.app",
+                    "version": "1.0.0",
+                    "type_version": "1.0.0",
+                    "metadata": {
+                        "policy-id": "onap.restart.tca"
+                    },
+                    "properties": {
+                        "tca_policy": {
+                            "domain": "measurementsForVfScaling",
+                            "metricsPerEventName": [
+                                {
+                                    "eventName": "Measurement_vGMUX",
+                                    "controlLoopSchemaType": "VNF",
+                                    "policyScope": "DCAE",
+                                    "policyName": "DCAE.Config_tca-hi-lo",
+                                    "policyVersion": "v0.0.1",
+                                    "thresholds": [
+                                        {
+                                            "closedLoopControlName": "ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e",
+                                            "version": "1.0.2",
+                                            "fieldPath": "$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value",
+                                            "thresholdValue": 0,
+                                            "direction": "EQUAL",
+                                            "severity": "MAJOR",
+                                            "closedLoopEventStatus": "ABATED"
+                                        },
+                                        {
+                                            "closedLoopControlName": "ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e",
+                                            "version": "1.0.2",
+                                            "fieldPath": "$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value",
+                                            "thresholdValue": 0,
+                                            "direction": "GREATER",
+                                            "severity": "CRITICAL",
+                                            "closedLoopEventStatus": "ONSET"
+                                        }
+                                    ]
+                                }
+                            ]
+                        }
+                    }
+                }
+            }
+        ]
+    }
+}
index 1a626c0..86463c3 100644 (file)
@@ -26,3 +26,110 @@ Statistics
      Log    Received response from policy ${resp.text}
      Should Be Equal As Strings    ${resp.status_code}     200
      Should Be Equal As Strings    ${resp.json()['code']}  200
+     
+ExecuteXacmlPolicy
+     Wait Until Keyword Succeeds    2 min    5 sec    CreateMonitorPolicyType
+     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   GetDecision
+     
+*** Keywords ***
+
+CreateMonitorPolicyType
+     [Documentation]    Create Monitoring Policy Type
+     ${auth}=    Create List    healthcheck    zb!XztG34
+     ${postjson}=  Get file  ${CURDIR}/data/onap.policies.monitoring.cdap.tca.hi.lo.app.json
+     Log    Creating session https://${POLICY_API_IP}:6969
+     ${session}=    Create Session      policy  https://${POLICY_API_IP}:6969   auth=${auth}
+     ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json
+     ${resp}=   Post Request   policy  /policy/api/v1/policytypes  data=${postjson}   headers=${headers}
+     Log    Received response from policy2 ${resp.text}
+     Should Be Equal As Strings    ${resp.status_code}     200
+     ${postjsonobject}   To Json    ${postjson}
+     Dictionary Should Contain Key    ${resp.json()}    tosca_definitions_version
+     Dictionary Should Contain Key    ${postjsonobject}    tosca_definitions_version
+
+CreateNewMonitorPolicy
+     [Documentation]    Create a new Monitoring policy
+     ${auth}=    Create List    healthcheck    zb!XztG34
+     ${postjson}=  Get file  ${CURDIR}/data/vCPE.policy.monitoring.input.tosca.json
+     Log    Creating session https://${POLICY_API_IP}:6969
+     ${session}=    Create Session      policy  https://${POLICY_API_IP}:6969   auth=${auth}
+     ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json
+     ${resp}=   Post Request   policy  /policy/api/v1/policytypes/onap.policies.monitoring.cdap.tca.hi.lo.app/versions/1.0.0/policies  data=${postjson}   headers=${headers}
+     Log    Received response from policy4 ${resp.text}
+     ${postjsonobject}   To Json    ${postjson}
+     Should Be Equal As Strings    ${resp.status_code}     200
+     Dictionary Should Contain Key    ${resp.json()}    tosca_definitions_version
+     Dictionary Should Contain Key    ${postjsonobject}    tosca_definitions_version
+
+DeployMonitorPolicy
+     [Documentation]   Runs Policy PAP to deploy a policy
+     ${auth}=    Create List    healthcheck    zb!XztG34
+     ${postjson}=  Get file  ${CURDIR}/data/vCPE.policy.monitoring.input.tosca.deploy.json
+     Log    Creating session https://${POLICY_PAP_IP}:6969
+     ${session}=    Create Session      policy  https://${POLICY_PAP_IP}:6969   auth=${auth}
+     ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json
+     ${resp}=   Post Request   policy  /policy/pap/v1/pdps/policies  data=${postjson}   headers=${headers}
+     Log    Received response from policy5 ${resp.text}
+     ${postjsonobject}   To Json    ${postjson}
+     Should Be Equal As Strings    ${resp.status_code}     200
+
+GetStatisticsAfterDeployed
+     [Documentation]    Runs Policy Xacml PDP Statistics after policy is deployed
+     ${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
+     ${resp}=   Get Request     policy  /policy/pdpx/v1/statistics     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()['code']}  200
+     Should Be Equal As Strings    ${resp.json()['totalPoliciesCount']     1
+     
+GetDecision
+    [Documentation]    Get Decision from 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
+     ${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}
+     Should Be Equal As Strings    ${resp.status_code}     200
+     
+GetStatisticsAfterDecision
+     [Documentation]    Runs Policy Xacml PDP Statistics after Decision request
+     ${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
+     ${resp}=   Get Request     policy  /policy/pdpx/v1/statistics     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()['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
+     Log    Creating session https://${POLICY_PAP_IP}:6969
+     ${session}=    Create Session      policy  https://${POLICY_PAP_IP}:6969   auth=${auth}
+     ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json
+     ${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 
+     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}=   Get Request     policy  /policy/pdpx/v1/statistics     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()['code']}  200
+     Should Be Equal As Strings    ${resp.json()['totalPoliciesCount']     0
+
+