diff options
author | sebdet <sebastien.determe@intl.att.com> | 2019-03-15 15:50:06 +0100 |
---|---|---|
committer | sebdet <sebastien.determe@intl.att.com> | 2019-03-15 18:25:37 +0100 |
commit | 3d51989fd3559babafeb0ca1d0d0ca8b40ee46a3 (patch) | |
tree | 966b05f283e633acda8d17761d6e31683a63c4b8 /src/test | |
parent | 2e4242e58dbc659e11df212115b9c8827d548167 (diff) |
Fix policy Tosca converter
Fix converter so that it can understand the new Policy Yaml model
Issue-ID: CLAMP-306
Change-Id: I4d2f8640b2344e7ceee2cfec2d7e3175777f591b
Signed-off-by: sebdet <sebastien.determe@intl.att.com>
Diffstat (limited to 'src/test')
4 files changed, 351 insertions, 81 deletions
diff --git a/src/test/java/org/onap/clamp/clds/tosca/ToscaYamlToJsonConvertorTest.java b/src/test/java/org/onap/clamp/clds/tosca/ToscaYamlToJsonConvertorTest.java index d94ffabaf..199d05370 100644 --- a/src/test/java/org/onap/clamp/clds/tosca/ToscaYamlToJsonConvertorTest.java +++ b/src/test/java/org/onap/clamp/clds/tosca/ToscaYamlToJsonConvertorTest.java @@ -47,8 +47,7 @@ public class ToscaYamlToJsonConvertorTest { String parsedJsonSchema = convertor.parseToscaYaml(toscaModelYaml); assertNotNull(parsedJsonSchema); - JSONAssert.assertEquals( - ResourceFileUtil.getResourceAsString("example/json-editor-schema/tca-policy-json-editor-schema.json"), + JSONAssert.assertEquals(ResourceFileUtil.getResourceAsString("tosca/policy-yaml-to-json.json"), parsedJsonSchema, true); } } diff --git a/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java b/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java index afa07236d..fcef5b79e 100644 --- a/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java +++ b/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java @@ -135,7 +135,7 @@ public class CsarInstallerItCase { // Mockito.when(csarHandler.getSdcCsarHelper()).thenReturn(csarHelper); Mockito.when(csarHandler.getPolicyModelYaml()) - .thenReturn(Optional.ofNullable(ResourceFileUtil.getResourceAsString("tosca/tca-policy-test.yaml"))); + .thenReturn(Optional.ofNullable(ResourceFileUtil.getResourceAsString("tosca/tosca_example.yaml"))); return csarHandler; } @@ -173,6 +173,7 @@ public class CsarInstallerItCase { assertThat(loop.getSvgRepresentation()).startsWith("<svg "); assertThat(loop.getGlobalPropertiesJson().get("dcaeDeployParameters")).isNotNull(); assertThat(loop.getMicroServicePolicies()).hasSize(1); + assertThat(loop.getOperationalPolicies()).hasSize(1); assertThat(loop.getModelPropertiesJson().get("serviceDetails")).isNotNull(); assertThat(loop.getModelPropertiesJson().get("resourceDetails")).isNotNull(); diff --git a/src/test/resources/tosca/policy-yaml-to-json.json b/src/test/resources/tosca/policy-yaml-to-json.json new file mode 100644 index 000000000..dd6a9ff3b --- /dev/null +++ b/src/test/resources/tosca/policy-yaml-to-json.json @@ -0,0 +1,192 @@ +{ + "schema": { + "uniqueItems": "true", + "format": "tabs-top", + "type": "array", + "title": "TCA Policy JSON", + "items": { + "type": "object", + "title": "TCA Policy JSON", + "required": [ + "domain", + "metricsPerEventName" + ], + "properties": { + "domain": { + "propertyOrder": 1001, + "default": "measurementsForVfScaling", + "title": "Domain name to which TCA needs to be applied", + "type": "string" + }, + "metricsPerEventName": { + "propertyOrder": 1002, + "uniqueItems": "true", + "format": "tabs-top", + "title": "Contains eventName and threshold details that need to be applied to given eventName", + "type": "array", + "items": { + "type": "object", + "required": [ + "controlLoopSchemaType", + "eventName", + "policyName", + "policyScope", + "policyVersion", + "thresholds" + ], + "properties": { + "policyVersion": { + "propertyOrder": 1007, + "title": "TCA Policy Scope Version", + "type": "string" + }, + "thresholds": { + "propertyOrder": 1008, + "uniqueItems": "true", + "format": "tabs-top", + "title": "Thresholds associated with eventName", + "type": "array", + "items": { + "type": "object", + "required": [ + "closedLoopControlName", + "closedLoopEventStatus", + "direction", + "fieldPath", + "severity", + "thresholdValue", + "version" + ], + "properties": { + "severity": { + "propertyOrder": 1013, + "title": "Threshold Event Severity", + "type": "string", + "enum": [ + "CRITICAL", + "MAJOR", + "MINOR", + "WARNING", + "NORMAL" + ] + }, + "fieldPath": { + "propertyOrder": 1012, + "title": "Json field Path as per CEF message which needs to be analyzed for TCA", + "type": "string", + "enum": [ + "$.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" + ] + }, + "thresholdValue": { + "propertyOrder": 1014, + "title": "Threshold value for the field Path inside CEF message", + "type": "integer" + }, + "closedLoopEventStatus": { + "propertyOrder": 1010, + "title": "Closed Loop Event Status of the threshold", + "type": "string", + "enum": [ + "ONSET", + "ABATED" + ] + }, + "closedLoopControlName": { + "propertyOrder": 1009, + "title": "Closed Loop Control Name associated with the threshold", + "type": "string" + }, + "version": { + "propertyOrder": 1015, + "title": "Version number associated with the threshold", + "type": "string" + }, + "direction": { + "propertyOrder": 1011, + "title": "Direction of the threshold", + "type": "string", + "enum": [ + "LESS", + "LESS_OR_EQUAL", + "GREATER", + "GREATER_OR_EQUAL", + "EQUAL" + ] + } + } + } + }, + "policyName": { + "propertyOrder": 1005, + "title": "TCA Policy Scope Name", + "type": "string" + }, + "controlLoopSchemaType": { + "propertyOrder": 1003, + "title": "Specifies Control Loop Schema Type for the event Name e.g. VNF, VM", + "type": "string", + "enum": [ + "VM", + "VNF" + ] + }, + "policyScope": { + "propertyOrder": 1006, + "title": "TCA Policy Scope", + "type": "string" + }, + "eventName": { + "propertyOrder": 1004, + "title": "Event name to which thresholds need to be applied", + "type": "string" + } + } + } + } + } + } + } +}
\ No newline at end of file diff --git a/src/test/resources/tosca/tosca_example.yaml b/src/test/resources/tosca/tosca_example.yaml index 3c5afb01d..571986cda 100644 --- a/src/test/resources/tosca/tosca_example.yaml +++ b/src/test/resources/tosca/tosca_example.yaml @@ -1,80 +1,158 @@ tosca_definitions_version: tosca_simple_yaml_1_0_0 -node_types: - policy.nodes.cdap.tca.hi.lo.app: - derived_from: policy.nodes.Root - properties: - domain: - type: string - description: Domain - constraints: - - equal: measurementsForVfScaling - functionalRole: - type: string - description: Function of the event source e.g., vnf1, vnf2, vnf3 - thresholds: - type: list - description: Thresholds - entry_schema: - type: policy.data.thresholds +policy_types: + onap.policies.Monitoring: + derived_from: tosca.policies.Root + description: a base policy type for all policies that governs monitoring provisioning + onap.policy.monitoring.cdap.tca.hi.lo.app: + derived_from: onap.policies.Monitoring + version: 1.0.0 + properties: + tca_policy: + type: list + description: TCA Policy JSON + entry_schema: + type: onap.datatypes.monitoring.tca_policy data_types: - policy.data.thresholds: - properties: - closedLoopControlName: - type: string - description: A UNIQUE string identifying the Closed Loop ID this event is for. - direction: - type: string - constraints: - - valid_values: [ LESS, LESS_OR_EQUAL, GREATER, GREATER_OR_EQUAL] - fieldPath: - description: Field Path - type: string - severity: - type: string - description: event severity or priority - constraints: - - valid_values: [CRITICAL, MAJOR, MINOR, WARNING, NORMAL] - thresholdValue: - type: integer - description: ThresholdValue - default: 0 - constraints: - - in_range: [ 0, 65535 ] - version: - type: string - description: Version for the closed loop message - constraints: - - min_length: 1 - dummySignatures: - type: list - description: dummy Signatures - required: true - entry_schema: - type: policy.data.dummySignatureTraversal - policy.data.dummySignatureTraversal: - derived_from: tosca.nodes.Root - properties: - signature: - type: policy.data.DUMMY_Signature_FM - required: true - traversal: - type: policy.data.traverse - required: true - policy.data.traverse: - derived_from: tosca.nodes.Root - properties: - traversal: - type: string - description: Dummy Traverse - required: true - constraints: - - valid_values: [ ONE, TWO, THREE ] - policy.data.DUMMY_Signature_FM: - derived_from: tosca.nodes.Root - properties: - filter_clause: - type: string - description: Filter Clause - required: true - constraints: - - valid_values: [ OR, AND, NOT ] + 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 |