Add extra test cases for drools-pdp 35/139035/2
authoradheli.tavares <adheli.tavares@est.tech>
Thu, 26 Sep 2024 13:16:09 +0000 (14:16 +0100)
committeradheli.tavares <adheli.tavares@est.tech>
Fri, 27 Sep 2024 08:36:18 +0000 (09:36 +0100)
- 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>
26 files changed:
compose/config/drools-applications/env/base-mariadb.conf
compose/config/drools-applications/env/base-postgres.conf
compose/config/drools-pdp/env/base-mariadb.conf
compose/config/drools-pdp/env/base-postgres.conf
csit/resources/tests/apex-pdp-common.robot
csit/resources/tests/apex-pdp-test.robot
csit/resources/tests/apex-slas-10.robot
csit/resources/tests/apex-slas-3.robot
csit/resources/tests/apex-slas.robot
csit/resources/tests/api-slas.robot
csit/resources/tests/api-test.robot
csit/resources/tests/clamp-slas.robot
csit/resources/tests/common-library.robot
csit/resources/tests/data/drools/deploy.drools.policies.json [moved from csit/resources/tests/data/deploy.drools.policies.json with 100% similarity]
csit/resources/tests/data/drools/deploy.xacml.policies.json [moved from csit/resources/tests/data/deploy.xacml.policies.json with 100% similarity]
csit/resources/tests/data/drools/vcpeOnset.json [moved from csit/resources/tests/data/vcpeOnset.json with 100% similarity]
csit/resources/tests/data/drools/vdnsOnset.json [moved from csit/resources/tests/data/vdnsOnset.json with 100% similarity]
csit/resources/tests/data/drools/vfwOnset.json [moved from csit/resources/tests/data/vfwOnset.json with 100% similarity]
csit/resources/tests/distribution-test.robot
csit/resources/tests/drools-applications-test.robot
csit/resources/tests/kafka_consumer.py
csit/resources/tests/kafka_producer.py
csit/resources/tests/make_topics.py
csit/resources/tests/pap-slas.robot
csit/resources/tests/pap-test.robot
csit/resources/tests/xacml-pdp-test.robot

index b7e2c8f..20b290a 100644 (file)
@@ -105,7 +105,7 @@ PDP_HTTPS=false
 
 # DCAE Kafka
 
-DCAE_TOPIC=unauthenticated.dcae_cl_output
+DCAE_TOPIC=dcae_topic
 DCAE_SERVERS=kafka:9092
 DCAE_CONSUMER_GROUP=dcae.policy.shared
 
index 1e82d0e..2abb5e2 100644 (file)
@@ -102,7 +102,7 @@ PDP_HTTPS=false
 
 # DCAE Kafka
 
-DCAE_TOPIC=unauthenticated.dcae_cl_output
+DCAE_TOPIC=dcae_topic
 DCAE_SERVERS=kafka:9092
 DCAE_CONSUMER_GROUP=dcae.policy.shared
 
index 0e0156b..95aac74 100644 (file)
@@ -95,7 +95,7 @@ GUARD_DISABLED=false
 
 # DCAE Kafka
 
-DCAE_TOPIC=unauthenticated.dcae_cl_output
+DCAE_TOPIC=dcae_topic
 DCAE_SERVERS=
 DCAE_CONSUMER_GROUP=dcae.policy.shared
 
index a883f3f..64a1d57 100644 (file)
@@ -95,7 +95,7 @@ GUARD_DISABLED=false
 
 # DCAE Kafka
 
-DCAE_TOPIC=unauthenticated.dcae_cl_output
+DCAE_TOPIC=dcae_topic
 DCAE_SERVERS=
 DCAE_CONSUMER_GROUP=dcae.policy.shared
 
index e645831..958f690 100644 (file)
@@ -4,7 +4,7 @@ Library     RequestsLibrary
 Library     OperatingSystem
 Library     json
 Library     Process
-Resource    ${CURDIR}/common-library.robot
+Resource    common-library.robot
 
 *** Keywords ***
 
index 6e42685..3989ec4 100644 (file)
@@ -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 ***
 
index e2338c6..2a56a66 100644 (file)
@@ -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
index 9322f17..1ceb9b7 100644 (file)
@@ -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
index 08d5006..f6e64b8 100644 (file)
@@ -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
index 1c549aa..165f14a 100644 (file)
@@ -3,7 +3,7 @@ Library    Collections
 Library    RequestsLibrary
 Library    OperatingSystem
 Library    json
-Resource    ${CURDIR}/common-library.robot
+Resource    common-library.robot
 
 *** Keywords ***
 ValidateResponseTimeForApi
index 3554bb1..29c2fba 100644 (file)
@@ -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}
index 71656e4..18a83d7 100644 (file)
@@ -3,7 +3,7 @@ Library    Collections
 Library    RequestsLibrary
 Library    OperatingSystem
 Library    json
-Resource    ${CURDIR}/common-library.robot
+Resource    common-library.robot
 
 *** Keywords ***
 ValidateResponseTimeForClamp
index a98b99a..4d69b34 100644 (file)
@@ -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}
index b8b4924..d5fc10e 100644 (file)
@@ -3,7 +3,7 @@ Library     Collections
 Library     RequestsLibrary
 Library     OperatingSystem
 Library     json
-Resource    ${CURDIR}/common-library.robot
+Resource    common-library.robot
 
 *** Test Cases ***
 
index 8b0a369..4ceb288 100644 (file)
@@ -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}
index fa173f4..53a2e39 100755 (executable)
@@ -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)
index a7d4564..e960b93 100755 (executable)
@@ -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])
index 82b1dc3..bf6d6e3 100755 (executable)
 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)
index 4a04467..e241ee9 100644 (file)
@@ -3,7 +3,7 @@ Library    Collections
 Library    RequestsLibrary
 Library    OperatingSystem
 Library    json
-Resource    ${CURDIR}/common-library.robot
+Resource    common-library.robot
 
 *** Keywords ***
 ValidateResponseTimeForPap
index 7ca4e5d..e66820c 100644 (file)
@@ -3,7 +3,7 @@ Library    Collections
 Library    RequestsLibrary
 Library    OperatingSystem
 Library    json
-Resource    ${CURDIR}/common-library.robot
+Resource    common-library.robot
 
 *** Keywords ***
 GetReq
index 9d6227c..4eaca60 100644 (file)
@@ -4,7 +4,7 @@ Library     RequestsLibrary
 Library     OperatingSystem
 Library     Process
 Library     json
-Resource    ${CURDIR}/common-library.robot
+Resource    common-library.robot
 
 *** Test Cases ***
 Healthcheck