Move policy preload to robot script 20/105020/1
authorJim Hahn <jrh3@att.com>
Thu, 2 Apr 2020 17:32:01 +0000 (13:32 -0400)
committerJim Hahn <jrh3@att.com>
Thu, 2 Apr 2020 17:34:49 +0000 (13:34 -0400)
Moved the policy preload for the PAP CSIT from setup.sh to
the robot script; policy type preload isn't needed, so it
was removed altogether.
Also cleaned up some unneeded entries related to networking
and ports in the docker yml files.

Issue-ID: POLICY-2464
Change-Id: I1794dd905f2dcbdbe5f8da8c106b43b98d9a97ea
Signed-off-by: Jim Hahn <jrh3@att.com>
plans/policy/pap/setup.sh
scripts/policy/config/pap/onap.policies.monitoring.cdap.tca.hi.lo.app.json [deleted file]
scripts/policy/docker-compose-api.yml
scripts/policy/docker-compose-pap.yml
scripts/policy/policy-xacml-pdp/docker-compose-pdpx.yml
tests/policy/pap/data/vCPE.policy.monitoring.input.tosca.json [moved from scripts/policy/config/pap/vCPE.policy.monitoring.input.tosca.json with 100% similarity]
tests/policy/pap/pap-test.robot

index 8a613bc..a5350b2 100644 (file)
@@ -1,7 +1,7 @@
 #!/bin/bash
 # ============LICENSE_START=======================================================
 #  Copyright (C) 2019 Nordix Foundation.
-#  Modifications Copyright (C) 2019 AT&T Intellectual Property.
+#  Modifications Copyright (C) 2019-2020 AT&T Intellectual Property.
 # ================================================================================
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -57,19 +57,6 @@ echo PAP IP IS ${POLICY_PAP_IP}
 echo API IP IS ${POLICY_API_IP}
 echo MARIADB IP IS ${MARIADB_IP}
 
-#Add policy type and policy to the database via the Policy Api
-AUTH="healthcheck:zb!XztG34"
-CONTYPE="Content-Type: application/json"
-URL=https://${POLICY_API_IP}:6969/policy/api/v1/policytypes
-CONFIGDIR=${WORKSPACE}/scripts/policy/config/pap
-POLTYPE=onap.policies.monitoring.cdap.tca.hi.lo.app
-
-SRCFILE=${CONFIGDIR}/${POLTYPE}.json
-curl -sS -k --user "${AUTH}" -H "${CONTYPE}" -d @${SRCFILE} $URL
-
-URL2=${URL}/${POLTYPE}/versions/1.0.0/policies
-SRCFILE=${CONFIGDIR}/vCPE.policy.monitoring.input.tosca.json
-curl -sS -k --user "${AUTH}" -H "${CONTYPE}" -d @${SRCFILE} $URL2
-
-
-ROBOT_VARIABLES="-v POLICY_PAP_IP:${POLICY_PAP_IP}"
+ROBOT_VARIABLES=""
+ROBOT_VARIABLES="${ROBOT_VARIABLES} -v POLICY_PAP_IP:${POLICY_PAP_IP}"
+ROBOT_VARIABLES="${ROBOT_VARIABLES} -v POLICY_API_IP:${POLICY_API_IP}"
diff --git a/scripts/policy/config/pap/onap.policies.monitoring.cdap.tca.hi.lo.app.json b/scripts/policy/config/pap/onap.policies.monitoring.cdap.tca.hi.lo.app.json
deleted file mode 100644 (file)
index 0657473..0000000
+++ /dev/null
@@ -1,210 +0,0 @@
-{
-  "tosca_definitions_version": "tosca_simple_yaml_1_1_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": "onap.datatypes.monitoring.tca_policy",
-          "description": "TCA Policy JSON"
-        }
-      }
-    }
-  },
-  "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"
-        }
-      }
-    }
-  }
-}
index 1bab189..e32190f 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 2019 AT&T Intellectual Property. All rights reserved
+# 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.
@@ -12,9 +12,6 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 version: '2'
-networks:
-  default:
-    driver: bridge
 services:
    mariadb:
       image: mariadb:${POLICY_MARIADB_VER}
@@ -24,16 +21,16 @@ services:
       env_file: config/db/db.conf
       volumes:
          - ./config/db:/docker-entrypoint-initdb.d
-      ports:
-       - "3306:3306"
+      expose:
+       - 3306
    api:
       image: nexus3.onap.org:10001/onap/policy-api:${POLICY_API_VERSION}
       container_name: policy-api
       depends_on:
        - mariadb
       hostname: policy-api
-      ports:
-       - "6969:6969"
+      expose:
+       - 6969
    start_dependencies:
       image: dadarek/wait-for-dependencies
       environment:
index 970f116..5438557 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 2019 AT&T Intellectual Property. All rights reserved
+# 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.
@@ -12,9 +12,6 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 version: '2'
-networks:
-  default:
-    driver: bridge
 services:
    mariadb:
       image: mariadb:${POLICY_MARIADB_VER}
@@ -24,24 +21,24 @@ services:
       env_file: config/db/db.conf
       volumes:
          - ./config/db:/docker-entrypoint-initdb.d
-      ports:
-       - "3306:3306"
+      expose:
+       - 3306
    pap:
       image: nexus3.onap.org:10001/onap/policy-pap:${POLICY_PAP_VERSION}
       container_name: policy-pap
       depends_on:
        - mariadb
       hostname: policy-pap
-      ports:
-       - "6969:6969"
+      expose:
+       - 6969
    api:
       image: nexus3.onap.org:10001/onap/policy-api:${POLICY_API_VERSION}
       container_name: policy-api
       depends_on:
        - mariadb
       hostname: policy-api
-      ports:
-       - "9969:6969"
+      expose:
+       - 6969
    start_dependencies:
       image: dadarek/wait-for-dependencies
       environment:
index af1cbae..caf8315 100644 (file)
@@ -1,5 +1,5 @@
 # ============LICENSE_START=======================================================
-#  Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+#  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.
@@ -16,9 +16,6 @@
 # SPDX-License-Identifier: Apache-2.0
 # ============LICENSE_END=========================================================
 version: '2'
-networks:
-  default:
-    driver: bridge
 services:
    mariadb:
       image: mariadb:${POLICY_MARIADB_VER}
@@ -28,14 +25,14 @@ services:
       env_file: config/db/db.conf
       volumes:
          - ./config/db:/docker-entrypoint-initdb.d
-      ports:
-       - "3306:3306"
+      expose:
+       - 3306
    message-router:
       image: dmaap/simulator
       container_name: dmaap-simulator
       hostname: dmaap-simulator
-      ports:
-       - "3904:3904"
+      expose:
+       - 3904
    pap:
       image: nexus3.onap.org:10001/onap/policy-pap:${POLICY_PAP_VERSION}
       container_name: policy-pap
@@ -57,8 +54,8 @@ services:
        - message-router
        - pap
       hostname: policy-xacml-pdp
-      ports:
-       - "6969:6969"
+      expose:
+       - 6969
    start_dependencies:
       image: dadarek/wait-for-dependencies
       environment:
index 36b593c..67a5782 100644 (file)
@@ -5,6 +5,17 @@ Library     OperatingSystem
 Library     json
 
 *** Test Cases ***
+LoadPolicy
+     [Documentation]    Loads prerequisite Policy via API
+     ${auth}=    Create List    healthcheck    zb!XztG34
+     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
+     ${postjson}=  Get file  ${CURDIR}/data/vCPE.policy.monitoring.input.tosca.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 API ${resp.text}
+     Should Be Equal As Strings    ${resp.status_code}     200
+
 Healthcheck
      [Documentation]    Runs Policy PAP Health check
      ${auth}=    Create List    healthcheck    zb!XztG34