diff options
author | adheli.tavares <adheli.tavares@est.tech> | 2024-09-26 14:16:09 +0100 |
---|---|---|
committer | adheli.tavares <adheli.tavares@est.tech> | 2024-09-27 09:36:18 +0100 |
commit | a3d2dc6ac57903b4fd970043732159a59f1cb2ae (patch) | |
tree | 91d07d6a0c02e587df94159531f31ce5582ec4fa /csit | |
parent | c4497b791b8d60137a07d0639437e78d9e158bf0 (diff) |
Add extra test cases for drools-pdp
- fix some references on robot files
- drools policy execution not completing because of issues with
AppcLcm simulator - uncommenting the executions
- dcae_topic having topic name and effective topic now are the same
Issue-ID: POLICY-4955
Change-Id: Ia45730c6ba2b473acfc5b317424a0a46b3660485
Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
Diffstat (limited to 'csit')
22 files changed, 247 insertions, 193 deletions
diff --git a/csit/resources/tests/apex-pdp-common.robot b/csit/resources/tests/apex-pdp-common.robot index e6458318..958f6901 100644 --- a/csit/resources/tests/apex-pdp-common.robot +++ b/csit/resources/tests/apex-pdp-common.robot @@ -4,7 +4,7 @@ Library RequestsLibrary Library OperatingSystem Library json Library Process -Resource ${CURDIR}/common-library.robot +Resource common-library.robot *** Keywords *** diff --git a/csit/resources/tests/apex-pdp-test.robot b/csit/resources/tests/apex-pdp-test.robot index 6e426851..3989ec46 100644 --- a/csit/resources/tests/apex-pdp-test.robot +++ b/csit/resources/tests/apex-pdp-test.robot @@ -4,8 +4,8 @@ Library RequestsLibrary Library OperatingSystem Library json Library Process -Resource ${CURDIR}/common-library.robot -Resource ${CURDIR}/apex-pdp-common.robot +Resource common-library.robot +Resource apex-pdp-common.robot *** Test Cases *** diff --git a/csit/resources/tests/apex-slas-10.robot b/csit/resources/tests/apex-slas-10.robot index e2338c60..2a56a665 100644 --- a/csit/resources/tests/apex-slas-10.robot +++ b/csit/resources/tests/apex-slas-10.robot @@ -5,8 +5,8 @@ Library OperatingSystem Library DateTime Library Process Library json -Resource ${CURDIR}/common-library.robot -Resource ${CURDIR}/apex-pdp-common.robot +Resource common-library.robot +Resource apex-pdp-common.robot *** Test Cases *** Healthcheck diff --git a/csit/resources/tests/apex-slas-3.robot b/csit/resources/tests/apex-slas-3.robot index 9322f177..1ceb9b77 100644 --- a/csit/resources/tests/apex-slas-3.robot +++ b/csit/resources/tests/apex-slas-3.robot @@ -5,8 +5,8 @@ Library OperatingSystem Library DateTime Library Process Library json -Resource ${CURDIR}/common-library.robot -Resource ${CURDIR}/apex-pdp-common.robot +Resource common-library.robot +Resource apex-pdp-common.robot *** Test Cases *** Healthcheck diff --git a/csit/resources/tests/apex-slas.robot b/csit/resources/tests/apex-slas.robot index 08d50062..f6e64b89 100644 --- a/csit/resources/tests/apex-slas.robot +++ b/csit/resources/tests/apex-slas.robot @@ -5,8 +5,8 @@ Library OperatingSystem Library DateTime Library Process Library json -Resource ${CURDIR}/common-library.robot -Resource ${CURDIR}/apex-pdp-common.robot +Resource common-library.robot +Resource apex-pdp-common.robot *** Test Cases *** Healthcheck diff --git a/csit/resources/tests/api-slas.robot b/csit/resources/tests/api-slas.robot index 1c549aa9..165f14a3 100644 --- a/csit/resources/tests/api-slas.robot +++ b/csit/resources/tests/api-slas.robot @@ -3,7 +3,7 @@ Library Collections Library RequestsLibrary Library OperatingSystem Library json -Resource ${CURDIR}/common-library.robot +Resource common-library.robot *** Keywords *** ValidateResponseTimeForApi diff --git a/csit/resources/tests/api-test.robot b/csit/resources/tests/api-test.robot index 3554bb15..29c2fba4 100644 --- a/csit/resources/tests/api-test.robot +++ b/csit/resources/tests/api-test.robot @@ -3,106 +3,106 @@ Library Collections Library RequestsLibrary Library OperatingSystem Library json -Resource ${CURDIR}/common-library.robot +Resource common-library.robot *** Test Cases *** Healthcheck - [Documentation] Verify policy api health check - ${resp}= GetReq /policy/api/v1/healthcheck - Should Be Equal As Strings ${resp.json()['code']} 200 - Should Be Equal As Strings ${resp.json()['healthy']} True - Should Be Equal As Strings ${resp.json()['message']} alive + [Documentation] Verify policy api health check + ${resp}= GetReq /policy/api/v1/healthcheck + Should Be Equal As Strings ${resp.json()['code']} 200 + Should Be Equal As Strings ${resp.json()['healthy']} True + Should Be Equal As Strings ${resp.json()['message']} alive RetrievePolicyTypes - [Documentation] Retrieve all policy types - FetchPolicyTypes /policy/api/v1/policytypes 37 + [Documentation] Retrieve all policy types + FetchPolicyTypes /policy/api/v1/policytypes 37 CreateTCAPolicyTypeV1 - [Documentation] Create an existing policy type with modification and keeping the same version should result in error. - CreatePolicyType /policy/api/v1/policytypes 406 onap.policy.monitoring.tcagen2.v1.json null null + [Documentation] Create an existing policy type with modification and keeping the same version should result in error. + CreatePolicyType /policy/api/v1/policytypes 406 onap.policy.monitoring.tcagen2.v1.json null null CreateTCAPolicyTypeV2 - [Documentation] Create an existing policy type with modification and keeping the same version should result in error. - CreatePolicyType /policy/api/v1/policytypes 406 onap.policy.monitoring.tcagen2.v2.json null null + [Documentation] Create an existing policy type with modification and keeping the same version should result in error. + CreatePolicyType /policy/api/v1/policytypes 406 onap.policy.monitoring.tcagen2.v2.json null null CreateTCAPolicyTypeV3 - [Documentation] Create a policy type named 'onap.policies.monitoring.tcagen2' and version '3.0.0' - CreatePolicyType /policy/api/v1/policytypes 201 onap.policy.monitoring.tcagen2.v3.json onap.policies.monitoring.tcagen2 3.0.0 + [Documentation] Create a policy type named 'onap.policies.monitoring.tcagen2' and version '3.0.0' + CreatePolicyType /policy/api/v1/policytypes 201 onap.policy.monitoring.tcagen2.v3.json onap.policies.monitoring.tcagen2 3.0.0 RetrieveMonitoringPolicyTypes - [Documentation] Retrieve all monitoring related policy types - FetchPolicyTypes /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2 2 + [Documentation] Retrieve all monitoring related policy types + FetchPolicyTypes /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2 2 CreateNewMonitoringPolicyV1 - [Documentation] Create a policy named 'onap.restart.tca' and version '1.0.0' using specific api - ${postjson}= Get file ${DATA}/vCPE.policy.monitoring.input.tosca.json - CreatePolicySuccessfully /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/1.0.0/policies ${postjson} onap.restart.tca 1.0.0 + [Documentation] Create a policy named 'onap.restart.tca' and version '1.0.0' using specific api + ${postjson}= Get file ${DATA}/vCPE.policy.monitoring.input.tosca.json + CreatePolicySuccessfully /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/1.0.0/policies ${postjson} onap.restart.tca 1.0.0 CreateNewMonitoringPolicyV1Again - [Documentation] Create an existing policy with modification and keeping the same version should result in error. - ${postjson}= Get file ${DATA}/vCPE.policy.monitoring.input.tosca.v1_2.json - CreatePolicy /policy/api/v1/policies 406 ${postjson} null null + [Documentation] Create an existing policy with modification and keeping the same version should result in error. + ${postjson}= Get file ${DATA}/vCPE.policy.monitoring.input.tosca.v1_2.json + CreatePolicy /policy/api/v1/policies 406 ${postjson} null null CreateNewMonitoringPolicyV2 - [Documentation] Create a policy named 'onap.restart.tca' and version '2.0.0' using generic api - ${postjson}= Get file ${DATA}/vCPE.policy.monitoring.input.tosca.v2.json - CreatePolicySuccessfully /policy/api/v1/policies ${postjson} onap.restart.tca 2.0.0 + [Documentation] Create a policy named 'onap.restart.tca' and version '2.0.0' using generic api + ${postjson}= Get file ${DATA}/vCPE.policy.monitoring.input.tosca.v2.json + CreatePolicySuccessfully /policy/api/v1/policies ${postjson} onap.restart.tca 2.0.0 CreateNodeTemplates - [Documentation] Create node templates in database using specific api - ${postjson}= Get file ${NODETEMPLATES}/nodetemplates.metadatasets.input.tosca.json - CreateNodeTemplate /policy/api/v1/nodetemplates 201 ${postjson} 3 + [Documentation] Create node templates in database using specific api + ${postjson}= Get file ${NODETEMPLATES}/nodetemplates.metadatasets.input.tosca.json + CreateNodeTemplate /policy/api/v1/nodetemplates 201 ${postjson} 3 RetrievePoliciesOfType - [Documentation] Retrieve all policies belonging to a specific Policy Type - FetchPolicies /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/1.0.0/policies 2 + [Documentation] Retrieve all policies belonging to a specific Policy Type + FetchPolicies /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/1.0.0/policies 2 RetrieveAllPolicies - [Documentation] Retrieve all policies - FetchPolicies /policy/api/v1/policies 3 + [Documentation] Retrieve all policies + FetchPolicies /policy/api/v1/policies 3 RetrieveSpecificPolicy - [Documentation] Retrieve a policy named 'onap.restart.tca' and version '1.0.0' using generic api - FetchPolicy /policy/api/v1/policies/onap.restart.tca/versions/1.0.0 onap.restart.tca + [Documentation] Retrieve a policy named 'onap.restart.tca' and version '1.0.0' using generic api + FetchPolicy /policy/api/v1/policies/onap.restart.tca/versions/1.0.0 onap.restart.tca RetrieveAllNodeTemplates - [Documentation] Retrieve all node templates - FetchNodeTemplates /policy/api/v1/nodetemplates 3 + [Documentation] Retrieve all node templates + FetchNodeTemplates /policy/api/v1/nodetemplates 3 RetrieveSpecificNodeTemplate - [Documentation] Retrieve a node template named 'apexMetadata_grpc' and version '1.2.1' using generic api - FetchNodeTemplate /policy/api/v1/nodetemplates/apexMetadata_grpc/versions/1.2.1 apexMetadata_grpc + [Documentation] Retrieve a node template named 'apexMetadata_grpc' and version '1.2.1' using generic api + FetchNodeTemplate /policy/api/v1/nodetemplates/apexMetadata_grpc/versions/1.2.1 apexMetadata_grpc DeleteSpecificNodeTemplate - [Documentation] Delete a node template named 'apexMetadata_adaptive' and version '2.3.1' using generic api - DeleteReq /policy/api/v1/nodetemplates/apexMetadata_adaptive/versions/2.3.1 200 - DeleteReq /policy/api/v1/nodetemplates/apexMetadata_adaptive/versions/2.3.1 404 + [Documentation] Delete a node template named 'apexMetadata_adaptive' and version '2.3.1' using generic api + DeleteReq /policy/api/v1/nodetemplates/apexMetadata_adaptive/versions/2.3.1 200 + DeleteReq /policy/api/v1/nodetemplates/apexMetadata_adaptive/versions/2.3.1 404 DeleteSpecificPolicy - [Documentation] Delete a policy named 'onap.restart.tca' and version '1.0.0' using generic api - DeleteReq /policy/api/v1/policies/onap.restart.tca/versions/1.0.0 200 - DeleteReq /policy/api/v1/policies/onap.restart.tca/versions/1.0.0 404 + [Documentation] Delete a policy named 'onap.restart.tca' and version '1.0.0' using generic api + DeleteReq /policy/api/v1/policies/onap.restart.tca/versions/1.0.0 200 + DeleteReq /policy/api/v1/policies/onap.restart.tca/versions/1.0.0 404 DeleteSpecificPolicyV2 - [Documentation] Delete a policy named 'onap.restart.tca' and version '2.0.0' using specific api - DeleteReq /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/1.0.0/policies/onap.restart.tca/versions/2.0.0 200 - DeleteReq /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/1.0.0/policies/onap.restart.tca/versions/2.0.0 404 + [Documentation] Delete a policy named 'onap.restart.tca' and version '2.0.0' using specific api + DeleteReq /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/1.0.0/policies/onap.restart.tca/versions/2.0.0 200 + DeleteReq /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/1.0.0/policies/onap.restart.tca/versions/2.0.0 404 DeleteSpecificPolicyTypeV1 - [Documentation] Delete a policy type named 'onap.policies.monitoring.tcagen2' and version '1.0.0' - DeleteReq /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/1.0.0 200 - DeleteReq /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/1.0.0 404 + [Documentation] Delete a policy type named 'onap.policies.monitoring.tcagen2' and version '1.0.0' + DeleteReq /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/1.0.0 200 + DeleteReq /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/1.0.0 404 DeleteSpecificPolicyTypeV2 - [Documentation] Delete a policy type named 'onap.policies.monitoring.tcagen2' and version '2.0.0' - DeleteReq /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/2.0.0 200 - DeleteReq /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/2.0.0 404 + [Documentation] Delete a policy type named 'onap.policies.monitoring.tcagen2' and version '2.0.0' + DeleteReq /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/2.0.0 200 + DeleteReq /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/2.0.0 404 DeleteSpecificPolicyTypeV3 - [Documentation] Delete a policy type named 'onap.policies.monitoring.tcagen2' and version '3.0.0' - DeleteReq /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/3.0.0 200 - DeleteReq /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/3.0.0 404 + [Documentation] Delete a policy type named 'onap.policies.monitoring.tcagen2' and version '3.0.0' + DeleteReq /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/3.0.0 200 + DeleteReq /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/3.0.0 404 Metrics [Documentation] Verify policy-api is exporting prometheus metrics @@ -128,53 +128,52 @@ Metrics *** Keywords *** GetReq - [Arguments] ${url} - ${auth}= PolicyAdminAuth - ${resp}= PerformGetRequest ${POLICY_API_IP} ${url} 200 null ${auth} - RETURN ${resp} + [Arguments] ${url} + ${auth}= PolicyAdminAuth + ${resp}= PerformGetRequest ${POLICY_API_IP} ${url} 200 null ${auth} + RETURN ${resp} DeleteReq - [Arguments] ${url} ${expectedstatus} - ${auth}= PolicyAdminAuth - ${resp}= PerformDeleteRequest ${POLICY_API_IP} ${url} ${expectedstatus} ${auth} - RETURN ${resp} + [Arguments] ${url} ${expectedstatus} + ${auth}= PolicyAdminAuth + ${resp}= PerformDeleteRequest ${POLICY_API_IP} ${url} ${expectedstatus} ${auth} + RETURN ${resp} CreatePolicyType - [Arguments] ${url} ${expectedstatus} ${jsonfile} ${policytypename} ${policytypeversion} - [Documentation] Create the specific policy type - ${postjson}= Get file ${CURDIR}/data/${jsonfile} - ${auth}= PolicyAdminAuth - ${resp}= PerformPostRequest ${POLICY_API_IP} ${url} ${expectedstatus} ${postjson} null ${auth} - Run Keyword If ${expectedstatus}==200 List Should Contain Value ${resp.json()['policy_types']} ${policytypename} - Run Keyword If ${expectedstatus}==200 Should Be Equal As Strings ${resp.json()['policy_types']['${policytypename}']['version']} ${policytypeversion} + [Arguments] ${url} ${expectedstatus} ${jsonfile} ${policytypename} ${policytypeversion} + [Documentation] Create the specific policy type + ${postjson}= Get file ${CURDIR}/data/${jsonfile} + ${auth}= PolicyAdminAuth + ${resp}= PerformPostRequest ${POLICY_API_IP} ${url} ${expectedstatus} ${postjson} null ${auth} + Run Keyword If ${expectedstatus}==200 List Should Contain Value ${resp.json()['policy_types']} ${policytypename} + Run Keyword If ${expectedstatus}==200 Should Be Equal As Strings ${resp.json()['policy_types']['${policytypename}']['version']} ${policytypeversion} FetchPolicyTypes - [Arguments] ${url} ${expectedLength} - [Documentation] Fetch all policy types - ${resp}= GetReq ${url} - Length Should Be ${resp.json()['policy_types']} ${expectedLength} + [Arguments] ${url} ${expectedLength} + [Documentation] Fetch all policy types + ${resp}= GetReq ${url} + Length Should Be ${resp.json()['policy_types']} ${expectedLength} FetchPolicy - [Arguments] ${url} ${keyword} - [Documentation] Fetch the specific policy - ${resp}= GetReq ${url} - Dictionary Should Contain Key ${resp.json()['topology_template']['policies'][0]} ${keyword} + [Arguments] ${url} ${keyword} + [Documentation] Fetch the specific policy + ${resp}= GetReq ${url} + Dictionary Should Contain Key ${resp.json()['topology_template']['policies'][0]} ${keyword} FetchPolicies - [Arguments] ${url} ${expectedLength} - [Documentation] Fetch all policies - ${resp}= GetReq ${url} - Length Should Be ${resp.json()['topology_template']['policies']} ${expectedLength} - + [Arguments] ${url} ${expectedLength} + [Documentation] Fetch all policies + ${resp}= GetReq ${url} + Length Should Be ${resp.json()['topology_template']['policies']} ${expectedLength} FetchNodeTemplates - [Arguments] ${url} ${expectedLength} - [Documentation] Fetch all node templates - ${resp}= GetReq ${url} - Length Should Be ${resp.json()} ${expectedLength} + [Arguments] ${url} ${expectedLength} + [Documentation] Fetch all node templates + ${resp}= GetReq ${url} + Length Should Be ${resp.json()} ${expectedLength} FetchNodeTemplate - [Arguments] ${url} ${keyword} - [Documentation] Fetch the specific node template - ${resp}= GetReq ${url} - Dictionary Should Contain Value ${resp.json()[0]} ${keyword} + [Arguments] ${url} ${keyword} + [Documentation] Fetch the specific node template + ${resp}= GetReq ${url} + Dictionary Should Contain Value ${resp.json()[0]} ${keyword} diff --git a/csit/resources/tests/clamp-slas.robot b/csit/resources/tests/clamp-slas.robot index 71656e4e..18a83d7a 100644 --- a/csit/resources/tests/clamp-slas.robot +++ b/csit/resources/tests/clamp-slas.robot @@ -3,7 +3,7 @@ Library Collections Library RequestsLibrary Library OperatingSystem Library json -Resource ${CURDIR}/common-library.robot +Resource common-library.robot *** Keywords *** ValidateResponseTimeForClamp diff --git a/csit/resources/tests/common-library.robot b/csit/resources/tests/common-library.robot index a98b99a7..4d69b349 100644 --- a/csit/resources/tests/common-library.robot +++ b/csit/resources/tests/common-library.robot @@ -3,6 +3,7 @@ Library Collections Library RequestsLibrary Library OperatingSystem Library json +Library Process *** Keywords *** @@ -148,9 +149,11 @@ ValidateResponseTime CheckKafkaTopic [Arguments] ${topic} ${expected_status} ${resp}= Run Process ${CURDIR}/kafka_consumer.py ${topic} 60 ${expected_status} ${KAFKA_IP} + Log ${resp.stdout} Should Contain ${resp.stdout} ${expected_status} RETURN ${resp.stdout} GetKafkaTopic [Arguments] ${topic} - ${resp}= Run Process ${CURDIR}/make_topics.py ${topic} ${KAFKA_IP}
\ No newline at end of file + ${resp}= Run Process ${CURDIR}/make_topics.py ${topic} ${KAFKA_IP} + Log ${resp.stdout} diff --git a/csit/resources/tests/data/deploy.drools.policies.json b/csit/resources/tests/data/drools/deploy.drools.policies.json index 24c90d0d..24c90d0d 100644 --- a/csit/resources/tests/data/deploy.drools.policies.json +++ b/csit/resources/tests/data/drools/deploy.drools.policies.json diff --git a/csit/resources/tests/data/deploy.xacml.policies.json b/csit/resources/tests/data/drools/deploy.xacml.policies.json index 46da9021..46da9021 100644 --- a/csit/resources/tests/data/deploy.xacml.policies.json +++ b/csit/resources/tests/data/drools/deploy.xacml.policies.json diff --git a/csit/resources/tests/data/vcpeOnset.json b/csit/resources/tests/data/drools/vcpeOnset.json index 7dd9d5a0..7dd9d5a0 100644 --- a/csit/resources/tests/data/vcpeOnset.json +++ b/csit/resources/tests/data/drools/vcpeOnset.json diff --git a/csit/resources/tests/data/vdnsOnset.json b/csit/resources/tests/data/drools/vdnsOnset.json index 13f69095..13f69095 100644 --- a/csit/resources/tests/data/vdnsOnset.json +++ b/csit/resources/tests/data/drools/vdnsOnset.json diff --git a/csit/resources/tests/data/vfwOnset.json b/csit/resources/tests/data/drools/vfwOnset.json index 7782867a..7782867a 100644 --- a/csit/resources/tests/data/vfwOnset.json +++ b/csit/resources/tests/data/drools/vfwOnset.json diff --git a/csit/resources/tests/distribution-test.robot b/csit/resources/tests/distribution-test.robot index b8b49248..d5fc10e1 100644 --- a/csit/resources/tests/distribution-test.robot +++ b/csit/resources/tests/distribution-test.robot @@ -3,7 +3,7 @@ Library Collections Library RequestsLibrary Library OperatingSystem Library json -Resource ${CURDIR}/common-library.robot +Resource common-library.robot *** Test Cases *** diff --git a/csit/resources/tests/drools-applications-test.robot b/csit/resources/tests/drools-applications-test.robot index 8b0a3694..4ceb288b 100644 --- a/csit/resources/tests/drools-applications-test.robot +++ b/csit/resources/tests/drools-applications-test.robot @@ -10,28 +10,49 @@ Resource common-library.robot *** Test Cases *** Alive [Documentation] Runs Policy PDP Alive Check - ${resp}= PeformGetRequest /policy/pdp/engine ${DROOLS_IP_2} 200 + ${resp}= PerformGetRequestOnDrools /policy/pdp/engine ${DROOLS_IP_2} 200 Should Be Equal As Strings ${resp.json()['alive']} True Metrics [Documentation] Verify drools-apps is exporting metrics - ${resp}= PeformGetRequest /metrics ${DROOLS_IP_2} 200 + ${resp}= PerformGetRequestOnDrools /metrics ${DROOLS_IP_2} 200 Should Contain ${resp.text} jvm_threads_current Healthcheck [Documentation] Runs Policy PDP-D Health check - ${resp}= PeformGetRequest /healthcheck ${DROOLS_IP} 200 + ${resp}= PerformGetRequestOnDrools /healthcheck ${DROOLS_IP} 200 Should Be Equal As Strings ${resp.json()['healthy']} True Controller [Documentation] Checks controller is up Wait Until Keyword Succeeds 2 min 15 sec VerifyController -MakeTopics - [Documentation] Creates the Policy topics +AssertTopicsOnKafkaClient + [Documentation] Verify that the Policy topics policy-pdp-pap and policy-cl-mgt are available on kafka GetKafkaTopic policy-pdp-pap GetKafkaTopic policy-cl-mgt +CheckTopics + [Documentation] List the topics registered with TopicManager + ${resp}= PerformGetRequestOnDrools /policy/pdp/engine/topics ${DROOLS_IP_2} 200 + Should Contain ${resp.text} policy-cl-mgt + Should Contain ${resp.text} policy-pdp-pap + Should Contain ${resp.text} dcae_topic + +CheckEngineFeatures + [Documentation] List the features available in the drools engine + ${resp}= PerformGetRequestOnDrools /policy/pdp/engine/features ${DROOLS_IP_2} 200 + Should Contain ${resp.text} "org.onap.policy.drools.lifecycle.LifecycleFeature" + Should Contain ${resp.text} "org.onap.policy.drools.apps.controlloop.feature.usecases.UsecasesFeature" + Should Contain ${resp.text} "org.onap.policy.drools.healthcheck.HealthCheckFeature" + +CheckPolicyTypes + [Documentation] Check if the needed Policy types are available + ${auth}= PolicyAdminAuth + ${resp}= PerformGetRequest ${POLICY_API_IP} /policy/api/v1/policytypes 200 null ${auth} + Should Contain ${resp.text} onap.policies.monitoring.tcagen2 + Should Contain ${resp.text} onap.policies.controlloop.operational.common.Drools + CreateVcpeXacmlPolicy [Documentation] Create VCPE Policy for Xacml CreatePolicy vCPE.policy.monitoring.input.tosca.yaml yaml @@ -56,14 +77,37 @@ CreateVfwDroolsPolicy [Documentation] Create VFW Policy for Drools CreatePolicy vFirewall.policy.operational.input.tosca.json json +CheckCreatedPolicies + [Documentation] Verify that all created policies are available for deployment + ${auth}= PolicyAdminAuth + ${resp}= PerformGetRequest ${POLICY_API_IP} /policy/api/v1/policies 200 null ${auth} + #vcpe xacml + Should Contain ${resp.text} onap.restart.tca + #vcpe drools + Should Contain ${resp.text} operational.restart + #vnds xacml + Should Contain ${resp.text} onap.scaleout.tca + #vnds drools + Should Contain ${resp.text} operational.scaleout + #vfirewall xacml + Should Contain ${resp.text} onap.vfirewall.tca + #vfirewall drools + Should Contain ${resp.text} operational.modifyconfig + DeployXacmlPolicies [Documentation] Deploys the Policies to Xacml DeployPolicy deploy.xacml.policies.json Sleep 5s - ${result}= CheckKafkaTopic policy-notification onap.vfirewall.tca - Should Contain ${result} deployed-policies - Should Contain ${result} onap.scaleout.tca - Should Contain ${result} onap.restart.tca + @{otherMessages}= Create List deployed-policies onap.scaleout.tca onap.restart.tca + AssertMessageFromTopic policy-notification onap.vfirewall.tca ${otherMessages} + +VerifyDeployedXacmlPolicies + [Documentation] Verify if xacml policies were deployed correctly + ${resp}= GetDeployedPolicies + @{policies}= Create List onap.vfirewall.tca onap.scaleout.tca onap.restart.tca + FOR ${policy} IN @{policies} + Should Contain ${resp.text} ${policy} + END DeployDroolsPolicies [Documentation] Deploys the Policies to Drools @@ -72,23 +116,28 @@ DeployDroolsPolicies @{otherMessages}= Create List deployed-policies operational.scaleout operational.restart AssertMessageFromTopic policy-notification operational.modifyconfig ${otherMessages} +VerifyDeployedDroolsPolicies + [Documentation] Verify if drools policies were deployed correctly + ${resp}= GetDeployedPolicies + @{policies}= Create List operational.modifyconfig operational.scaleout operational.restart + FOR ${policy} IN @{policies} + Should Contain ${resp.text} ${policy} + END + +VcpeExecute + [Documentation] Executes VCPE Policy + OnSet ${CURDIR}/data/drools/vcpeOnset.json + ${policyExecuted}= Set Variable ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e + @{otherMessages}= Create List ACTIVE + AssertMessageFromTopic policy-cl-mgt ${policyExecuted} ${otherMessages} + + @{otherMessages}= Create List ${policyExecuted} OPERATION + AssertMessageFromTopic policy-cl-mgt Sending guard query for APPC Restart ${otherMessages} + + AssertMessageFromTopic policy-cl-mgt Guard result for APPC Restart is Permit ${otherMessages} + + AssertMessageFromTopic policy-cl-mgt actor=APPC,operation=Restart ${otherMessages} -#VcpeExecute -# [Documentation] Executes VCPE Policy -# OnSet ${CURDIR}/data/vcpeOnset.json -# ${policyExecuted}= Set Variable ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e -# @{otherMessages}= Create List ACTIVE -# AssertMessageFromTopic policy-cl-mgt ${policyExecuted} ${otherMessages} -# -# @{otherMessages}= Create List OPERATION Sending guard query for APPC Restart -# AssertMessageFromTopic policy-cl-mgt ${policyExecuted} ${otherMessages} -# -# @{otherMessages}= Create List OPERATION Guard result for APPC Restart is Permit -# AssertMessageFromTopic policy-cl-mgt ${policyExecuted} ${otherMessages} -# -# @{otherMessages}= Create List OPERATION actor=APPC,operation=Restart -# AssertMessageFromTopic policy-cl-mgt ${policyExecuted} ${otherMessages} -# # @{otherMessages}= Create List OPERATION: SUCCESS actor=APPC,operation=Restart # AssertMessageFromTopic policy-cl-mgt ${policyExecuted} ${otherMessages} # @@ -97,46 +146,41 @@ DeployDroolsPolicies VdnsExecute [Documentation] Executes VDNS Policy - OnSet ${CURDIR}/data/vdnsOnset.json + OnSet ${CURDIR}/data/drools/vdnsOnset.json ${policyExecuted}= Set Variable ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3 @{otherMessages}= Create List ACTIVE AssertMessageFromTopic policy-cl-mgt ${policyExecuted} ${otherMessages} - @{otherMessages}= Create List OPERATION Sending guard query for SO VF Module Create - AssertMessageFromTopic policy-cl-mgt ${policyExecuted} ${otherMessages} + @{otherMessages}= Create List ${policyExecuted} OPERATION + AssertMessageFromTopic policy-cl-mgt Sending guard query for SO VF Module Create ${otherMessages} - @{otherMessages}= Create List OPERATION Guard result for SO VF Module Create is Permit - AssertMessageFromTopic policy-cl-mgt ${policyExecuted} ${otherMessages} + AssertMessageFromTopic policy-cl-mgt Guard result for SO VF Module Create is Permit ${otherMessages} - @{otherMessages}= Create List OPERATION actor=SO,operation=VF Module Create - AssertMessageFromTopic policy-cl-mgt ${policyExecuted} ${otherMessages} + AssertMessageFromTopic policy-cl-mgt actor=SO,operation=VF Module Create ${otherMessages} - @{otherMessages}= Create List OPERATION: SUCCESS actor=SO,operation=VF Module Create - AssertMessageFromTopic policy-cl-mgt ${policyExecuted} ${otherMessages} + @{otherMessages}= Create List ${policyExecuted} OPERATION: SUCCESS + AssertMessageFromTopic policy-cl-mgt actor=SO,operation=VF Module Create ${otherMessages} - @{otherMessages}= Create List FINAL: SUCCESS SO VF Module Create + @{otherMessages}= Create List ${policyExecuted} FINAL: SUCCESS SO + AssertMessageFromTopic policy-cl-mgt VF Module Create ${otherMessages} + +VfwExecute + [Documentation] Executes VFW Policy + OnSet ${CURDIR}/data/drools/vfwOnset.json + ${policyExecuted}= Set Variable ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a + @{otherMessages}= Create List ACTIVE AssertMessageFromTopic policy-cl-mgt ${policyExecuted} ${otherMessages} -#VfwExecute -# [Documentation] Executes VFW Policy -# OnSet ${CURDIR}/data/vfwOnset.json -# ${policyExecuted}= Set Variable ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a -# @{otherMessages}= Create List ACTIVE -# AssertMessageFromTopic policy-cl-mgt ${policyExecuted} ${otherMessages} -# -# @{otherMessages}= Create List OPERATION Sending guard query for APPC ModifyConfig -# AssertMessageFromTopic policy-cl-mgt ${policyExecuted} ${otherMessages} -# -# @{otherMessages}= Create List OPERATION Guard result for APPC ModifyConfig is Permit -# AssertMessageFromTopic policy-cl-mgt ${policyExecuted} ${otherMessages} -# -# @{otherMessages}= Create List OPERATION actor=APPC,operation=ModifyConfig -# AssertMessageFromTopic policy-cl-mgt ${policyExecuted} ${otherMessages} -# + @{otherMessages}= Create List ${policyExecuted} OPERATION + AssertMessageFromTopic policy-cl-mgt Sending guard query for APPC ModifyConfig ${otherMessages} + + AssertMessageFromTopic policy-cl-mgt Guard result for APPC ModifyConfig is Permit ${otherMessages} + + AssertMessageFromTopic policy-cl-mgt actor=APPC,operation=ModifyConfig ${otherMessages} + # @{otherMessages}= Create List OPERATION: SUCCESS actor=APPC,operation=ModifyConfig # AssertMessageFromTopic policy-cl-mgt ${policyExecuted} ${otherMessages} # -# Log "Checking if policy execution status is FINAL: SUCCESS" # @{otherMessages}= Create List FINAL: SUCCESS APPC ModifyConfig # AssertMessageFromTopic policy-cl-mgt ${policyExecuted} ${otherMessages} @@ -144,10 +188,10 @@ VdnsExecute *** Keywords *** VerifyController - ${resp}= PeformGetRequest /policy/pdp/engine/controllers/usecases/drools/facts ${DROOLS_IP_2} 200 + ${resp}= PerformGetRequestOnDrools /policy/pdp/engine/controllers/usecases/drools/facts ${DROOLS_IP_2} 200 Should Be Equal As Strings ${resp.json()['usecases']} 1 -PeformGetRequest +PerformGetRequestOnDrools [Arguments] ${url} ${domain} ${expectedstatus} ${auth}= Create List demo@people.osaaf.org demo123456! Log Creating session http://${domain} @@ -171,7 +215,7 @@ PerformPostRequest OnSet [Arguments] ${file} ${data}= Get File ${file} - ${resp}= Run Process ${CURDIR}/kafka_producer.py unauthenticated.dcae_cl_output ${data} ${KAFKA_IP} + ${resp}= Run Process ${CURDIR}/kafka_producer.py dcae_topic ${data} ${KAFKA_IP} Log Response from kafka ${resp.stdout} RETURN ${resp.stdout} @@ -181,7 +225,7 @@ CreatePolicy DeployPolicy [Arguments] ${policyName} - PerformPostRequest /policy/pap/v1/pdps/deployments/batch ${POLICY_PAP_IP} ${policyName} ${CURDIR}/data json 202 + PerformPostRequest /policy/pap/v1/pdps/deployments/batch ${POLICY_PAP_IP} ${policyName} ${CURDIR}/data/drools json 202 AssertMessageFromTopic [Arguments] ${topic} ${topicMessage} ${otherMessages} @@ -189,3 +233,14 @@ AssertMessageFromTopic FOR ${msg} IN @{otherMessages} Should Contain ${response} ${msg} END + +GetDeployedPolicies + ${auth}= PolicyAdminAuth + ${resp}= PerformGetRequest ${POLICY_PAP_IP} /policy/pap/v1/policies/deployed 200 null ${auth} + RETURN ${resp} + +VerifyEventsOnTopic + [Arguments] ${topic} ${type} + ${resp}= PerformGetRequestOnDrools /policy/pdp/engine/topics/${type}/kafka/${topic}/events ${DROOLS_IP_2} 200 + Log Events: ${resp.json()} + RETURN ${resp} diff --git a/csit/resources/tests/kafka_consumer.py b/csit/resources/tests/kafka_consumer.py index fa173f47..53a2e39f 100755 --- a/csit/resources/tests/kafka_consumer.py +++ b/csit/resources/tests/kafka_consumer.py @@ -27,34 +27,28 @@ import sys import time -def consume_kafka_topic(topic, expected_values, timeout, bootstrap_server): +def consume_kafka_topic(topic, expected_msg, sec_timeout, bootstrap_server): config = { - 'bootstrap.servers': bootstrap_server, - 'group.id': 'testgrp', - 'auto.offset.reset': 'earliest' + 'bootstrap.servers': bootstrap_server, + 'group.id': 'testgrp', + 'auto.offset.reset': 'earliest' } consumer = Consumer(config) consumer.subscribe([topic]) try: start_time = time.time() - while time.time() - start_time < timeout: - msg = consumer.poll(1.0) - if msg is None: - continue - if msg.error(): - if msg.error().code() == KafkaException._PARTITION_EOF: - sys.stderr.write(f"Reached end of topic {msg.topic()} / partition {msg.partition()}\n") - print('ERROR') - sys.exit(404) - else: - # Error - raise KafkaException(msg.error()) - else: - # Message received - message = msg.value().decode('utf-8') - if expected_values in message: - print(message) - sys.exit(200) + while time.time() - start_time < sec_timeout: + msg = consumer.poll(1.0) + if msg is None: + continue + if msg.error(): + raise KafkaException(msg.error()) + else: + # Message received + message = msg.value().decode('utf-8') + if expected_msg in message: + print(message) + sys.exit(200) finally: consumer.close() @@ -63,5 +57,5 @@ if __name__ == '__main__': topic_name = sys.argv[1] timeout = int(sys.argv[2]) # timeout in seconds for verifying the kafka topic expected_values = sys.argv[3] - bootstrap_server = sys.argv[4] - consume_kafka_topic(topic_name, expected_values, timeout, bootstrap_server) + server = sys.argv[4] + consume_kafka_topic(topic_name, expected_values, timeout, server) diff --git a/csit/resources/tests/kafka_producer.py b/csit/resources/tests/kafka_producer.py index a7d45647..e960b934 100755 --- a/csit/resources/tests/kafka_producer.py +++ b/csit/resources/tests/kafka_producer.py @@ -24,6 +24,7 @@ from confluent_kafka import Producer import sys + def post_to_kafka(topic, message, bootstrap_server): conf = {'bootstrap.servers': bootstrap_server} @@ -37,5 +38,6 @@ def post_to_kafka(topic, message, bootstrap_server): finally: producer.flush() + if __name__ == '__main__': post_to_kafka(sys.argv[1], sys.argv[2], sys.argv[3]) diff --git a/csit/resources/tests/make_topics.py b/csit/resources/tests/make_topics.py index 82b1dc39..bf6d6e34 100755 --- a/csit/resources/tests/make_topics.py +++ b/csit/resources/tests/make_topics.py @@ -24,18 +24,19 @@ from confluent_kafka.admin import AdminClient, NewTopic import sys + def create_topic(bootstrap_servers, topic_name, num_partitions=2, replication_factor=2): admin_client = AdminClient({'bootstrap.servers': bootstrap_servers}) # Define the topic configuration - topic = NewTopic(topic_name, num_partitions=num_partitions, replication_factor=replication_factor) + new_topic = NewTopic(topic_name, num_partitions=num_partitions, replication_factor=replication_factor) # Create the topic - admin_client.create_topics([topic]) + admin_client.create_topics([new_topic]) if __name__ == '__main__': - topic_name = sys.argv[1] - bootstrap_servers = sys.argv[2] + topic = sys.argv[1] + servers = sys.argv[2] - create_topic(bootstrap_servers, topic_name) + create_topic(servers, topic) diff --git a/csit/resources/tests/pap-slas.robot b/csit/resources/tests/pap-slas.robot index 4a044675..e241ee9f 100644 --- a/csit/resources/tests/pap-slas.robot +++ b/csit/resources/tests/pap-slas.robot @@ -3,7 +3,7 @@ Library Collections Library RequestsLibrary Library OperatingSystem Library json -Resource ${CURDIR}/common-library.robot +Resource common-library.robot *** Keywords *** ValidateResponseTimeForPap diff --git a/csit/resources/tests/pap-test.robot b/csit/resources/tests/pap-test.robot index 7ca4e5dd..e66820c7 100644 --- a/csit/resources/tests/pap-test.robot +++ b/csit/resources/tests/pap-test.robot @@ -3,7 +3,7 @@ Library Collections Library RequestsLibrary Library OperatingSystem Library json -Resource ${CURDIR}/common-library.robot +Resource common-library.robot *** Keywords *** GetReq diff --git a/csit/resources/tests/xacml-pdp-test.robot b/csit/resources/tests/xacml-pdp-test.robot index 9d6227c3..4eaca607 100644 --- a/csit/resources/tests/xacml-pdp-test.robot +++ b/csit/resources/tests/xacml-pdp-test.robot @@ -4,7 +4,7 @@ Library RequestsLibrary Library OperatingSystem Library Process Library json -Resource ${CURDIR}/common-library.robot +Resource common-library.robot *** Test Cases *** Healthcheck |