summaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authorsebdet <sebastien.determe@intl.att.com>2021-01-24 16:40:18 +0100
committerS�bastien Determe <sebastien.determe@intl.att.com>2021-02-08 14:41:24 +0000
commit9d04a9cc8c6f4b12ae60cc0d4d42f71085f72328 (patch)
treea6767d8304537ea649b75e4bf90987369ae2de6d /src/test
parentd2178bc9f7d6c06f60a3a8afecd83e428d84cd78 (diff)
Add new Camel route
Add the new rest endpoint in camel + add new permission type + add robot test for that route + small refactoring of trst files Issue-ID: POLICY-2924 Signed-off-by: sebdet <sebastien.determe@intl.att.com> Change-Id: I623cc8ec1724513cdb92eeea000adca5c2433bae
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/org/onap/policy/clamp/clds/it/RobotItCase.java11
-rw-r--r--src/test/java/org/onap/policy/clamp/policy/pdpgroup/PoliciesPdpMergerTest.java4
-rw-r--r--src/test/resources/application.properties16
-rw-r--r--src/test/resources/example/policy/policy-merger.json215
-rw-r--r--src/test/resources/https/https-test.properties3
-rw-r--r--src/test/resources/robotframework/robotframework-test.properties15
-rw-r--r--src/test/resources/robotframework/tests/02_policy_queries.robot21
7 files changed, 267 insertions, 18 deletions
diff --git a/src/test/java/org/onap/policy/clamp/clds/it/RobotItCase.java b/src/test/java/org/onap/policy/clamp/clds/it/RobotItCase.java
index 8c06929e1..2f17c61bf 100644
--- a/src/test/java/org/onap/policy/clamp/clds/it/RobotItCase.java
+++ b/src/test/java/org/onap/policy/clamp/clds/it/RobotItCase.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,6 +23,8 @@
package org.onap.policy.clamp.clds.it;
+import static org.apache.commons.io.FileUtils.copyInputStreamToFile;
+
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
import com.github.dockerjava.api.DockerClient;
@@ -111,6 +113,13 @@ public class RobotItCase {
} catch (InterruptedException e) {
throw new Exception("Failed to retrieve logs of container " + id, e);
}
+
+ copyInputStreamToFile(client.copyArchiveFromContainerCmd(id, "/opt/robotframework/reports/output.xml").exec(),
+ new File("target/robotframework/output.xml"));
+ copyInputStreamToFile(client.copyArchiveFromContainerCmd(id, "/opt/robotframework/reports/log.html").exec(),
+ new File("target/robotframework/log.html"));
+ copyInputStreamToFile(client.copyArchiveFromContainerCmd(id, "/opt/robotframework/reports/report.html").exec(),
+ new File("target/robotframework/report.html"));
client.stopContainerCmd(id);
}
}
diff --git a/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PoliciesPdpMergerTest.java b/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PoliciesPdpMergerTest.java
index b3fd3f19a..5da68f47f 100644
--- a/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PoliciesPdpMergerTest.java
+++ b/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PoliciesPdpMergerTest.java
@@ -94,8 +94,8 @@ public class PoliciesPdpMergerTest {
@Test
public void testUpdatePdpGroupOfPolicyModels() throws IOException {
- JSONAssert.assertEquals(ResourceFileUtils.getResourceAsString("clds/policy-merger.json"), PoliciesPdpMerger
- .mergePoliciesAndPdpGroupStates(
+ JSONAssert.assertEquals(ResourceFileUtils.getResourceAsString("example/policy/policy-merger.json"),
+ PoliciesPdpMerger.mergePoliciesAndPdpGroupStates(
ResourceFileUtils.getResourceAsString("http-cache/example/policy/api/v1/policies/.file"),
pdpGroupsJson), true);
}
diff --git a/src/test/resources/application.properties b/src/test/resources/application.properties
index 5a668dcf4..2a4caee98 100644
--- a/src/test/resources/application.properties
+++ b/src/test/resources/application.properties
@@ -2,7 +2,7 @@
# ============LICENSE_START=======================================================
# ONAP CLAMP
# ================================================================================
-# Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
+# Copyright (C) 2017-2018, 2021 AT&T Intellectual Property. All rights
# reserved.
# ================================================================================
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -152,15 +152,17 @@ clamp.config.dcae.deployment.userName=test
clamp.config.dcae.deployment.password=test
#Define user permission related parameters, the permission type can be changed but MUST be redefined in clds-users.properties in that case !
-clamp.config.security.permission.type.cl=permission-type-cl
-clamp.config.security.permission.type.cl.manage=permission-type-cl-manage
-clamp.config.security.permission.type.cl.event=permission-type-cl-event
-clamp.config.security.permission.type.filter.vf=permission-type-filter-vf
-clamp.config.security.permission.type.template=permission-type-template
-clamp.config.security.permission.type.tosca=permission-type-tosca
+clamp.config.security.permission.type.cl=org.onap.clamp.clds.cl
+clamp.config.security.permission.type.cl.manage=org.onap.clamp.clds.cl.manage
+clamp.config.security.permission.type.cl.event=org.onap.clamp.clds.cl.event
+clamp.config.security.permission.type.filter.vf=org.onap.clamp.clds.filter.vf
+clamp.config.security.permission.type.template=org.onap.clamp.clds.template
+clamp.config.security.permission.type.tosca=org.onap.clamp.clds.tosca
+clamp.config.security.permission.type.policies=org.onap.clamp.clds.policies
#This one indicates the type of instances (dev|prod|perf...), this must be set accordingly in clds-users.properties
clamp.config.security.permission.instance=dev
clamp.config.security.authentication.class=org.onap.aaf.cadi.principal.X509Principal, org.onap.aaf.cadi.principal.CachedBasicPrincipal
+
# Configuration settings for CDS
clamp.config.cds.url=http4://localhost:${docker.http-cache.port.host}
clamp.config.cds.userName=ccsdkapps
diff --git a/src/test/resources/example/policy/policy-merger.json b/src/test/resources/example/policy/policy-merger.json
new file mode 100644
index 000000000..5c6bd5b6b
--- /dev/null
+++ b/src/test/resources/example/policy/policy-merger.json
@@ -0,0 +1,215 @@
+{
+ "policies": [
+ {
+ "MICROSERVICE_vLoadBalancerMS_v1_0_tcagen2_1_0_0_AV0": {
+ "type": "onap.policies.monitoring.tcagen2",
+ "type_version": "1.0.0",
+ "properties": {
+ "tca.policy": {
+ "domain": "measurementsForVfScaling",
+ "metricsPerEventName": [
+ {
+ "policyScope": "DCAE",
+ "thresholds": [
+ {
+ "version": "1.0.2",
+ "severity": "MAJOR",
+ "thresholdValue": 200,
+ "closedLoopEventStatus": "ONSET",
+ "closedLoopControlName": "LOOP_test",
+ "direction": "LESS_OR_EQUAL",
+ "fieldPath": "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedTotalPacketsDelta"
+ }
+ ],
+ "eventName": "vLoadBalancer",
+ "policyVersion": "v0.0.1",
+ "controlLoopSchemaType": "VM",
+ "policyName": "DCAE.Config_tca-hi-lo"
+ }
+ ]
+ }
+ },
+ "name": "MICROSERVICE_vLoadBalancerMS_v1_0_tcagen2_1_0_0_AV0",
+ "version": "1.0.0",
+ "metadata": {
+ "policy-id": "MICROSERVICE_vLoadBalancerMS_v1_0_tcagen2_1_0_0_AV0",
+ "policy-version": "1.0.0"
+ },
+ "pdpGroupInfo": {
+ "pdpGroup": "pdpGroup2",
+ "pdpSubGroup": "subGroup2"
+ },
+ "supportedPdpGroups": [
+ {
+ "pdpGroup2": [
+ "subGroup2",
+ "subGroup3"
+ ]
+ }
+ ]
+ }
+ },
+ {
+ "OPERATIONAL_vLoadBalancerMS_v1_0_Drools_1_0_0_7xd": {
+ "type": "onap.policies.controlloop.operational.common.Drools",
+ "type_version": "1.0.0",
+ "properties": {
+ "abatement": false,
+ "operations": [
+ {
+ "failure_retries": "final_failure_retries",
+ "id": "test1",
+ "failure_timeout": "final_failure_timeout",
+ "failure": "final_failure",
+ "operation": {
+ "payload": {
+ "artifact_name": "baseconfiguration",
+ "artifact_version": "1.0.0",
+ "mode": "async",
+ "data": "{\"resource-assignment-properties\":{\"request-id\":\"\",\"service-instance-id\":\"\",\"hostname\":\"\",\"request-info\":{\"prop1\":\"\",\"prop2\":\"\"}}}"
+ },
+ "target": {
+ "entityIds": {
+ "resourceID": "Vloadbalancerms..vdns..module-3",
+ "modelInvariantId": "4c10ba9b-f88f-415e-9de3-5d33336047fa",
+ "modelVersionId": "4fa73b49-8a6c-493e-816b-eb401567b720",
+ "modelName": "Vloadbalancerms..vdns..module-3",
+ "modelVersion": "1",
+ "modelCustomizationId": "bafcdab0-801d-4d81-9ead-f464640a38b1"
+ },
+ "targetType": "VNF"
+ },
+ "actor": "SDNR",
+ "operation": "BandwidthOnDemand"
+ },
+ "failure_guard": "final_failure_guard",
+ "retries": 0,
+ "timeout": 0,
+ "failure_exception": "final_failure_exception",
+ "description": "test",
+ "success": "final_success"
+ }
+ ],
+ "trigger": "test1",
+ "timeout": 0,
+ "id": "LOOP_test"
+ },
+ "name": "OPERATIONAL_vLoadBalancerMS_v1_0_Drools_1_0_0_7xd",
+ "version": "1.0.0",
+ "metadata": {
+ "policy-id": "OPERATIONAL_vLoadBalancerMS_v1_0_Drools_1_0_0_7xd",
+ "policy-version": "1.0.0"
+ },
+ "pdpGroupInfo": {
+ "pdpGroup": "pdpGroup2",
+ "pdpSubGroup": "subGroup3"
+ },
+ "supportedPdpGroups": [
+ {
+ "pdpGroup2": [
+ "subGroup2",
+ "subGroup3"
+ ]
+ }
+ ]
+ }
+ },
+ {
+ "SDNC_Policy.ONAP_NF_NAMING_TIMESTAMP": {
+ "type": "onap.policies.Naming",
+ "type_version": "1.0.0",
+ "properties": {
+ "naming-models": [
+ {
+ "naming-type": "VNF",
+ "naming-recipe": "AIC_CLOUD_REGION|DELIMITER|CONSTANT|DELIMITER|TIMESTAMP",
+ "name-operation": "to_lower_case()",
+ "naming-properties": [
+ {
+ "property-name": "AIC_CLOUD_REGION"
+ },
+ {
+ "property-name": "CONSTANT",
+ "property-value": "onap-nf"
+ },
+ {
+ "property-name": "TIMESTAMP"
+ },
+ {
+ "property-value": "-",
+ "property-name": "DELIMITER"
+ }
+ ]
+ },
+ {
+ "naming-type": "VNFC",
+ "naming-recipe": "VNF_NAME|DELIMITER|NFC_NAMING_CODE|DELIMITER|SEQUENCE",
+ "name-operation": "to_lower_case()",
+ "naming-properties": [
+ {
+ "property-name": "VNF_NAME"
+ },
+ {
+ "property-name": "SEQUENCE",
+ "increment-sequence": {
+ "max": "zzz",
+ "scope": "ENTIRETY",
+ "start-value": "1",
+ "length": "3",
+ "increment": "1",
+ "sequence-type": "alpha-numeric"
+ }
+ },
+ {
+ "property-name": "NFC_NAMING_CODE"
+ },
+ {
+ "property-value": "-",
+ "property-name": "DELIMITER"
+ }
+ ]
+ },
+ {
+ "naming-type": "VF-MODULE",
+ "naming-recipe": "VNF_NAME|DELIMITER|VF_MODULE_LABEL|DELIMITER|VF_MODULE_TYPE|DELIMITER|SEQUENCE",
+ "name-operation": "to_lower_case()",
+ "naming-properties": [
+ {
+ "property-name": "VNF_NAME"
+ },
+ {
+ "property-value": "-",
+ "property-name": "DELIMITER"
+ },
+ {
+ "property-name": "VF_MODULE_LABEL"
+ },
+ {
+ "property-name": "VF_MODULE_TYPE"
+ },
+ {
+ "property-name": "SEQUENCE",
+ "increment-sequence": {
+ "max": "zzz",
+ "scope": "PRECEEDING",
+ "start-value": "1",
+ "length": "3",
+ "increment": "1",
+ "sequence-type": "alpha-numeric"
+ }
+ }
+ ]
+ }
+ ],
+ "policy-instance-name": "ONAP_NF_NAMING_TIMESTAMP"
+ },
+ "name": "SDNC_Policy.ONAP_NF_NAMING_TIMESTAMP",
+ "version": "1.0.0",
+ "metadata": {
+ "policy-id": "SDNC_Policy.ONAP_NF_NAMING_TIMESTAMP",
+ "policy-version": "1.0.0"
+ }
+ }
+ }
+ ]
+} \ No newline at end of file
diff --git a/src/test/resources/https/https-test.properties b/src/test/resources/https/https-test.properties
index aeae64036..b52b16db4 100644
--- a/src/test/resources/https/https-test.properties
+++ b/src/test/resources/https/https-test.properties
@@ -2,7 +2,7 @@
# ============LICENSE_START=======================================================
# ONAP CLAMP
# ================================================================================
-# Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
+# Copyright (C) 2017-2018, 2021 AT&T Intellectual Property. All rights
# reserved.
# ================================================================================
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -114,6 +114,7 @@ clamp.config.security.permission.type.cl.event=org.onap.clamp.clds.cl.event
clamp.config.security.permission.type.filter.vf=org.onap.clamp.clds.filter.vf
clamp.config.security.permission.type.template=org.onap.clamp.clds.template
clamp.config.security.permission.type.tosca=org.onap.clamp.clds.tosca
+clamp.config.security.permission.type.policies=org.onap.clamp.clds.policies
#This one indicates the type of instances (dev|prod|perf...), this must be set accordingly in clds-users.properties
clamp.config.security.permission.instance=dev
clamp.config.security.authentication.class=org.onap.aaf.cadi.principal.X509Principal, org.onap.aaf.cadi.principal.CachedBasicPrincipal
diff --git a/src/test/resources/robotframework/robotframework-test.properties b/src/test/resources/robotframework/robotframework-test.properties
index 665842b84..1e173f961 100644
--- a/src/test/resources/robotframework/robotframework-test.properties
+++ b/src/test/resources/robotframework/robotframework-test.properties
@@ -2,7 +2,7 @@
# ============LICENSE_START=======================================================
# ONAP CLAMP
# ================================================================================
-# Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
+# Copyright (C) 2017-2018, 2021 AT&T Intellectual Property. All rights
# reserved.
# ================================================================================
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -152,12 +152,13 @@ clamp.config.dcae.deployment.userName=test
clamp.config.dcae.deployment.password=test
#Define user permission related parameters, the permission type can be changed but MUST be redefined in clds-users.properties in that case !
-clamp.config.security.permission.type.cl=permission-type-cl
-clamp.config.security.permission.type.cl.manage=permission-type-cl-manage
-clamp.config.security.permission.type.cl.event=permission-type-cl-event
-clamp.config.security.permission.type.filter.vf=permission-type-filter-vf
-clamp.config.security.permission.type.template=permission-type-template
-clamp.config.security.permission.type.tosca=permission-type-tosca
+clamp.config.security.permission.type.cl=org.onap.clamp.clds.cl
+clamp.config.security.permission.type.cl.manage=org.onap.clamp.clds.cl.manage
+clamp.config.security.permission.type.cl.event=org.onap.clamp.clds.cl.event
+clamp.config.security.permission.type.filter.vf=org.onap.clamp.clds.filter.vf
+clamp.config.security.permission.type.template=org.onap.clamp.clds.template
+clamp.config.security.permission.type.tosca=org.onap.clamp.clds.tosca
+clamp.config.security.permission.type.policies=org.onap.clamp.clds.policies
#This one indicates the type of instances (dev|prod|perf...), this must be set accordingly in clds-users.properties
clamp.config.security.permission.instance=dev
clamp.config.security.authentication.class=org.onap.aaf.cadi.principal.X509Principal, org.onap.aaf.cadi.principal.CachedBasicPrincipal
diff --git a/src/test/resources/robotframework/tests/02_policy_queries.robot b/src/test/resources/robotframework/tests/02_policy_queries.robot
new file mode 100644
index 000000000..e62e03476
--- /dev/null
+++ b/src/test/resources/robotframework/tests/02_policy_queries.robot
@@ -0,0 +1,21 @@
+*** Settings ***
+Library Collections
+Library RequestsLibrary
+Library OperatingSystem
+Library json
+Library OperatingSystem
+*** Variables ***
+${login} admin
+${passw} password
+${reponse_pdp_group} pdpGroupInfo
+*** Keywords ***
+Create the sessions
+*** Test Cases ***
+Get Requests policies list ok
+ ${port} = Get Environment Variable CLAMP_PORT
+ ${auth} = Create List ${login} ${passw}
+ Create Session clamp http://localhost:${port} auth=${auth} disable_warnings=1
+ Set Global Variable ${clamp_session} clamp
+ ${response_query}= Get Request ${clamp_session} /restservices/clds/v2/policies/list
+ Should Be Equal As Strings ${response_query.status_code} 200
+ Should Contain ${response_query.text} ${reponse_pdp_group} \ No newline at end of file