diff options
Diffstat (limited to 'csit')
32 files changed, 522 insertions, 358 deletions
diff --git a/csit/resources/scripts/wait_for_rest.sh b/csit/resources/scripts/wait_for_rest.sh index e400bbd4..ce47d600 100755 --- a/csit/resources/scripts/wait_for_rest.sh +++ b/csit/resources/scripts/wait_for_rest.sh @@ -54,7 +54,7 @@ do do if command -v docker > /dev/null 2>&1 then - docker ps --format "table {{ .Names }}\t{{ .Status }}" + docker ps --format "table {{ .Image }}\t{{ .Names }}\t{{ .Status }}" fi curl "http://$host:$port" > /dev/null 2>&1 rc=$? diff --git a/csit/resources/tests/apex-pdp-common.robot b/csit/resources/tests/apex-pdp-common.robot index e6458318..81924604 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 *** @@ -31,14 +31,6 @@ CheckLogMessage ${result}= CheckKafkaTopic ${topic} ${status} Should Contain ${result} ${expectedMsg} -ValidatePolicyExecution - [Arguments] ${url} ${executionTime} - [Documentation] Check that policy execution under X milliseconds - ${resp}= QueryPrometheus ${url} - ${rawNumber}= Evaluate ${resp['data']['result'][0]['value'][1]} - ${actualTime}= Set Variable ${rawNumber * ${1000}} - Should Be True ${actualTime} <= ${executionTime} - ValidateEventExecution [Arguments] ${eventStartTime} ${eventEndTime} ${eventsNo} [Documentation] Check that X amount of events were exeuted per second 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..760bc348 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 @@ -17,7 +17,7 @@ Healthcheck Set Suite Variable ${pdpName} ${resp.json()['name']} ValidatePolicyExecutionAndEventRateLowComplexity - [Documentation] Validate that a moderate complexity policity can be executed in less than 100ms and minimum 10 events triggered per second + [Documentation] Validate that a moderate complexity policy can be executed in less than 100ms and minimum 10 events triggered per second Set Test Variable ${policyName} onap.policies.apex.pnf.Test ${postjson}= Get File ${CURDIR}/data/${policyName}.json CreatePolicySuccessfully /policy/api/v1/policytypes/onap.policies.native.Apex/versions/1.0.0/policies ${postjson} ${policyName} 1.0.0 @@ -31,7 +31,7 @@ ValidatePolicyExecutionAndEventRateLowComplexity ValidateEventExecution ${eventStartTime} ${eventEndTime} 10 ValidatePolicyExecutionAndEventRateModerateComplexity - [Documentation] Validate that a low complexity policity can be executed in less than 1000ms and minimum 1 events triggered per second + [Documentation] Validate that a low complexity policy can be executed in less than 1000ms and minimum 1 events triggered per second Set Test Variable ${policyName} onap.policies.native.apex.Sampledomain ${postjson}= Get File ${CURDIR}/data/${policyName}.json CreatePolicySuccessfully /policy/api/v1/policytypes/onap.policies.native.Apex/versions/1.0.0/policies ${postjson} ${policyName} 1.0.0 @@ -42,7 +42,7 @@ ValidatePolicyExecutionAndEventRateModerateComplexity ValidateEventExecution ${eventStartTime} ${eventEndTime} 1 ValidatePolicyExecutionAndEventRateHighComplexity - [Documentation] Validate that a high complexity policity can be executed in less than 5000ms and minimum 0.2 events triggered per second + [Documentation] Validate that a high complexity policy can be executed in less than 5000ms and minimum 0.2 events triggered per second Set Test Variable ${policyName} onap.policies.apex.pnf.metadataSet.Test ${postjson}= Get File ${CURDIR}/data/${policyName}.json CreatePolicySuccessfully /policy/api/v1/policytypes/onap.policies.native.Apex/versions/1.0.0/policies ${postjson} ${policyName} 1.0.0 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 9c8a5f0b..29c2fba4 100644 --- a/csit/resources/tests/api-test.robot +++ b/csit/resources/tests/api-test.robot @@ -3,121 +3,121 @@ 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 ${auth}= PolicyAdminAuth ${resp}= GetMetrics ${POLICY_API_IP} ${auth} /policy/api/v1/ - Should Contain ${resp.text} http_server_requests_seconds_count{error="none",exception="none",method="GET",outcome="SUCCESS",status="200",uri="/healthcheck",} 1.0 - Should Contain ${resp.text} http_server_requests_seconds_count{error="none",exception="none",method="GET",outcome="SUCCESS",status="200",uri="/policytypes",} 1.0 - Should Contain ${resp.text} http_server_requests_seconds_count{error="none",exception="none",method="GET",outcome="SUCCESS",status="200",uri="/policies",} 1.0 - Should Contain ${resp.text} http_server_requests_seconds_count{error="none",exception="none",method="GET",outcome="SUCCESS",status="200",uri="/policies/{policyId}/versions/{policyVersion}",} 1.0 - Should Contain ${resp.text} http_server_requests_seconds_count{error="none",exception="none",method="GET",outcome="SUCCESS",status="200",uri="/policytypes/{policyTypeId}/versions/{policyTypeVersion}/policies",} 1.0 - Should Contain ${resp.text} http_server_requests_seconds_count{error="none",exception="none",method="POST",outcome="SUCCESS",status="201",uri="/policytypes/{policyTypeId}/versions/{policyTypeVersion}/policies",} 1.0 - Should Contain ${resp.text} http_server_requests_seconds_count{error="none",exception="none",method="POST",outcome="SUCCESS",status="201",uri="/policytypes",} 1.0 - Should Contain ${resp.text} http_server_requests_seconds_count{error="none",exception="none",method="DELETE",outcome="SUCCESS",status="200",uri="/policies/{policyId}/versions/{policyVersion}",} 1.0 - Should Contain ${resp.text} http_server_requests_seconds_count{error="none",exception="none",method="DELETE",outcome="SUCCESS",status="200",uri="/policytypes/{policyTypeId}/versions/{versionId}",} 3.0 - Should Contain ${resp.text} http_server_requests_seconds_count{error="none",exception="none",method="DELETE",outcome="SUCCESS",status="200",uri="/policytypes/{policyTypeId}/versions/{policyTypeVersion}/policies/{policyId}/versions/{policyVersion}",} 1.0 + Should Contain ${resp.text} http_server_requests_seconds_count{error="none",exception="none",method="GET",outcome="SUCCESS",status="200",uri="/healthcheck"} 1 + Should Contain ${resp.text} http_server_requests_seconds_count{error="none",exception="none",method="GET",outcome="SUCCESS",status="200",uri="/policytypes"} 1 + Should Contain ${resp.text} http_server_requests_seconds_count{error="none",exception="none",method="GET",outcome="SUCCESS",status="200",uri="/policies"} 1 + Should Contain ${resp.text} http_server_requests_seconds_count{error="none",exception="none",method="GET",outcome="SUCCESS",status="200",uri="/policies/{policyId}/versions/{policyVersion}"} 1 + Should Contain ${resp.text} http_server_requests_seconds_count{error="none",exception="none",method="GET",outcome="SUCCESS",status="200",uri="/policytypes/{policyTypeId}/versions/{policyTypeVersion}/policies"} 1 + Should Contain ${resp.text} http_server_requests_seconds_count{error="none",exception="none",method="POST",outcome="SUCCESS",status="201",uri="/policytypes/{policyTypeId}/versions/{policyTypeVersion}/policies"} 1 + Should Contain ${resp.text} http_server_requests_seconds_count{error="none",exception="none",method="POST",outcome="SUCCESS",status="201",uri="/policytypes"} 1 + Should Contain ${resp.text} http_server_requests_seconds_count{error="none",exception="none",method="DELETE",outcome="SUCCESS",status="200",uri="/policies/{policyId}/versions/{policyVersion}"} 1 + Should Contain ${resp.text} http_server_requests_seconds_count{error="none",exception="none",method="DELETE",outcome="SUCCESS",status="200",uri="/policytypes/{policyTypeId}/versions/{versionId}"} 3 + Should Contain ${resp.text} http_server_requests_seconds_count{error="none",exception="none",method="DELETE",outcome="SUCCESS",status="200",uri="/policytypes/{policyTypeId}/versions/{policyTypeVersion}/policies/{policyId}/versions/{policyVersion}"} 1 Should Contain ${resp.text} http_server_requests_seconds_sum Should Contain ${resp.text} http_server_requests_seconds_max Should Contain ${resp.text} spring_data_repository_invocations_seconds_count @@ -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 30fd32a2..e0b1c0f1 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 *** @@ -129,28 +130,6 @@ VerifyTracingWorks Log Received response from jaeger ${resp.text} RETURN ${resp} -VerifyKafkaInTraces - [Arguments] ${domain} ${service} - Log Creating session http://${domain} - ${session}= Create Session jaeger http://${domain} - ${tags}= Create Dictionary otel.library.name=io.opentelemetry.kafka-clients-2.6 messaging.system=kafka - ${tags_json}= evaluate json.dumps(${tags}) json - ${params}= Create Dictionary service=${service} tags=${tags_json} operation=policy-acruntime-participant send lookback=1h limit=10 - ${resp}= GET On Session jaeger /api/traces params=${params} expected_status=200 - Log Received response from jaeger ${resp.text} - RETURN ${resp} - -VerifyHttpInTraces - [Arguments] ${domain} ${service} - Log Creating session http://${domain} - ${session}= Create Session jaeger http://${domain} - ${tags}= Create Dictionary uri=/v2/compositions/{compositionId} - ${tags_json}= evaluate json.dumps(${tags}) json - ${params}= Create Dictionary service=${service} tags=${tags_json} operation=http put /v2/compositions/{compositionId} lookback=1h limit=10 - ${resp}= GET On Session jaeger /api/traces params=${params} expected_status=200 - Log Received response from jaeger ${resp.text} - RETURN ${resp} - QueryPrometheus [Arguments] ${query} ${params}= Create Dictionary query=${query} @@ -170,9 +149,19 @@ 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} + +ValidatePolicyExecution + [Arguments] ${url} ${executionTime} + [Documentation] Check that policy execution under X milliseconds + ${resp}= QueryPrometheus ${url} + ${rawNumber}= Evaluate ${resp['data']['result'][0]['value'][1]} + ${actualTime}= Set Variable ${rawNumber * ${1000}} + Should Be True ${actualTime} <= ${executionTime}
\ No newline at end of file diff --git a/csit/resources/tests/data/SettingSimPropertiesFail.json b/csit/resources/tests/data/SettingSimPropertiesFail.json index 0c6402bd..0e0de30e 100644 --- a/csit/resources/tests/data/SettingSimPropertiesFail.json +++ b/csit/resources/tests/data/SettingSimPropertiesFail.json @@ -6,6 +6,9 @@ "deleteSuccess": false, "updateSuccess": false, "migrateSuccess": false, + "migratePrecheck": false, + "prepare": false, + "review": false, "primeSuccess": false, "deprimeSuccess": false, "deployTimerMs": 100, @@ -14,6 +17,9 @@ "unlockTimerMs": 100, "updateTimerMs": 100, "migrateTimerMs": 100, + "migratePrecheckTimerMs": 100, + "prepareTimerMs": 100, + "reviewTimerMs": 100, "deleteTimerMs": 100, "primeTimerMs": 100, "deprimeTimerMs": 100 diff --git a/csit/resources/tests/data/SettingSimPropertiesSuccess.json b/csit/resources/tests/data/SettingSimPropertiesSuccess.json index e0673322..14fbe01a 100644 --- a/csit/resources/tests/data/SettingSimPropertiesSuccess.json +++ b/csit/resources/tests/data/SettingSimPropertiesSuccess.json @@ -6,6 +6,9 @@ "deleteSuccess": true, "updateSuccess": true, "migrateSuccess": true, + "migratePrecheck": true, + "prepare": true, + "review": true, "primeSuccess": true, "deprimeSuccess": true, "deployTimerMs": 100, @@ -14,6 +17,9 @@ "unlockTimerMs": 100, "updateTimerMs": 100, "migrateTimerMs": 100, + "migratePrecheckTimerMs": 100, + "prepareTimerMs": 100, + "reviewTimerMs": 100, "deleteTimerMs": 100, "primeTimerMs": 100, "deprimeTimerMs": 100 diff --git a/csit/resources/tests/data/SettingSimPropertiesTimeout.json b/csit/resources/tests/data/SettingSimPropertiesTimeout.json new file mode 100644 index 00000000..a63c3044 --- /dev/null +++ b/csit/resources/tests/data/SettingSimPropertiesTimeout.json @@ -0,0 +1,26 @@ +{ + "deploySuccess": true, + "undeploySuccess": true, + "lockSuccess": true, + "unlockSuccess": true, + "deleteSuccess": true, + "updateSuccess": true, + "migrateSuccess": true, + "migratePrecheck": true, + "prepare": true, + "review": true, + "primeSuccess": true, + "deprimeSuccess": true, + "deployTimerMs": 260000, + "undeployTimerMs": 260000, + "lockTimerMs": 260000, + "unlockTimerMs": 260000, + "updateTimerMs": 260000, + "migrateTimerMs": 260000, + "migratePrecheckTimerMs": 260000, + "prepareTimerMs": 260000, + "reviewTimerMs": 260000, + "deleteTimerMs": 260000, + "primeTimerMs": 260000, + "deprimeTimerMs": 260000 +} 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-slas.robot b/csit/resources/tests/drools-applications-slas.robot new file mode 100644 index 00000000..a153925d --- /dev/null +++ b/csit/resources/tests/drools-applications-slas.robot @@ -0,0 +1,14 @@ +*** Settings *** +Library OperatingSystem +Resource common-library.robot + +*** Test Cases *** +WaitForPrometheusServer + [Documentation] Sleep time to wait for Prometheus server to gather all metrics + Sleep 1 minute + +ValidatePolicyExecutionTimes + [Documentation] Validate policy execution times using prometheus metrics + ValidatePolicyExecution pdpd_policy_executions_latency_seconds_count{controller="usecases",controlloop="ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3",policy="operational.scaleout:1.0.0",status="SUCCESS", instance="policy-drools-apps:9696", job="drools-apps-metrics"} 1000 + ValidatePolicyExecution pdpd_policy_deployments_total{state="ACTIVE",operation="deploy",status="SUCCESS", instance="policy-drools-apps:9696", job="drools-apps-metrics"} 3000 + diff --git a/csit/resources/tests/drools-applications-test.robot b/csit/resources/tests/drools-applications-test.robot index 3c4303ad..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,40 +77,67 @@ 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 DeployPolicy deploy.drools.policies.json Sleep 5s - ${result}= CheckKafkaTopic policy-notification operational.modifyconfig - Should Contain ${result} deployed-policies - Should Contain ${result} operational.scaleout - Should Contain ${result} operational.restart - -#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 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} + # @{otherMessages}= Create List OPERATION: SUCCESS actor=APPC,operation=Restart # AssertMessageFromTopic policy-cl-mgt ${policyExecuted} ${otherMessages} # @@ -98,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 ${policyExecuted} FINAL: SUCCESS SO + AssertMessageFromTopic policy-cl-mgt VF Module Create ${otherMessages} - @{otherMessages}= Create List FINAL: SUCCESS SO VF Module Create +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} @@ -145,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} @@ -172,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} @@ -182,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} @@ -190,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 58a6a049..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 @@ -46,11 +46,11 @@ Metrics [Documentation] Verify policy pap is exporting prometheus metrics ${auth}= PolicyAdminAuth ${resp}= GetMetrics ${POLICY_PAP_IP} ${auth} /policy/pap/v1/ - Should Contain ${resp.text} http_server_requests_seconds_count{error="none",exception="none",method="GET",outcome="SUCCESS",status="200",uri="/healthcheck",} - Should Contain ${resp.text} http_server_requests_seconds_count{error="none",exception="none",method="GET",outcome="SUCCESS",status="200",uri="/components/healthcheck",} 1.0 - Should Contain ${resp.text} spring_data_repository_invocations_seconds_count{exception="None",method="save",repository="PdpGroupRepository",state="SUCCESS",} 1.0 - Should Contain ${resp.text} spring_data_repository_invocations_seconds_count{exception="None",method="findByKeyName",repository="PdpGroupRepository",state="SUCCESS",} 1.0 - Should Contain ${resp.text} spring_data_repository_invocations_seconds_count{exception="None",method="findAll",repository="PolicyStatusRepository",state="SUCCESS",} + Should Contain ${resp.text} http_server_requests_seconds_count{error="none",exception="none",method="GET",outcome="SUCCESS",status="200",uri="/healthcheck"} + Should Contain ${resp.text} http_server_requests_seconds_count{error="none",exception="none",method="GET",outcome="SUCCESS",status="200",uri="/components/healthcheck"} 1 + Should Contain ${resp.text} spring_data_repository_invocations_seconds_count{exception="None",method="save",repository="PdpGroupRepository",state="SUCCESS"} 1 + Should Contain ${resp.text} spring_data_repository_invocations_seconds_count{exception="None",method="findByKeyName",repository="PdpGroupRepository",state="SUCCESS"} 1 + Should Contain ${resp.text} spring_data_repository_invocations_seconds_count{exception="None",method="findAll",repository="PolicyStatusRepository",state="SUCCESS"} AddPdpGroup [Documentation] Add a new PdpGroup named 'testGroup' in the policy database diff --git a/csit/resources/tests/policy-clamp-test.robot b/csit/resources/tests/policy-clamp-test.robot index f826388d..e765dd4f 100644 --- a/csit/resources/tests/policy-clamp-test.robot +++ b/csit/resources/tests/policy-clamp-test.robot @@ -121,13 +121,30 @@ InstantiateAutomationCompositionMigrationFrom set Suite variable ${instanceMigrationId} ${respyaml["instanceId"]} Should Be Equal As Strings ${resp.status_code} 201 +FailDeployAutomationCompositionMigration + [Documentation] Fail Deploy automation composition. + SetParticipantSimFail + ${auth}= ClampAuth + ${postjson}= Get file ${CURDIR}/data/DeployAC.json + ${resp}= MakeJsonPutRequest ACM ${POLICY_RUNTIME_ACM_IP} /onap/policy/clamp/acm/v2/compositions/${compositionFromId}/instances/${instanceMigrationId} ${postjson} ${auth} + Should Be Equal As Strings ${resp.status_code} 202 + Wait Until Keyword Succeeds 2 min 5 sec VerifyStateChangeResult ${compositionFromId} ${instanceMigrationId} FAILED + +TimeoutDeployAutomationCompositionMigration + [Documentation] Timeout Deploy automation composition. + SetParticipantSimTimeout + ${auth}= ClampAuth + ${postjson}= Get file ${CURDIR}/data/DeployAC.json + ${resp}= MakeJsonPutRequest ACM ${POLICY_RUNTIME_ACM_IP} /onap/policy/clamp/acm/v2/compositions/${compositionFromId}/instances/${instanceMigrationId} ${postjson} ${auth} + Should Be Equal As Strings ${resp.status_code} 202 + PrepareAutomationComposition [Documentation] Prepare automation composition. ${auth}= ClampAuth ${postjson}= Get file ${CURDIR}/data/PrepareAC.json ${resp}= MakeJsonPutRequest ACM ${POLICY_RUNTIME_ACM_IP} /onap/policy/clamp/acm/v2/compositions/${compositionId}/instances/${instanceId} ${postjson} ${auth} Should Be Equal As Strings ${resp.status_code} 202 - Wait Until Keyword Succeeds 10 min 5 sec VerifyDeployStatus ${compositionId} ${instanceId} UNDEPLOYED + Wait Until Keyword Succeeds 10 min 5 sec VerifySubStatus ${compositionId} ${instanceId} DeployAutomationComposition [Documentation] Deploy automation composition. @@ -200,16 +217,11 @@ ReviewAutomationComposition ${postjson}= Get file ${CURDIR}/data/ReviewAC.json ${resp}= MakeJsonPutRequest ACM ${POLICY_RUNTIME_ACM_IP} /onap/policy/clamp/acm/v2/compositions/${compositionId}/instances/${instanceId} ${postjson} ${auth} Should Be Equal As Strings ${resp.status_code} 202 - Wait Until Keyword Succeeds 10 min 5 sec VerifyDeployStatus ${compositionId} ${instanceId} DEPLOYED + Wait Until Keyword Succeeds 10 min 5 sec VerifySubStatus ${compositionId} ${instanceId} -FailDeployAutomationCompositionMigration - [Documentation] Fail Deploy automation composition. - SetParticipantSimFail - ${auth}= ClampAuth - ${postjson}= Get file ${CURDIR}/data/DeployAC.json - ${resp}= MakeJsonPutRequest ACM ${POLICY_RUNTIME_ACM_IP} /onap/policy/clamp/acm/v2/compositions/${compositionFromId}/instances/${instanceMigrationId} ${postjson} ${auth} - Should Be Equal As Strings ${resp.status_code} 202 - Wait Until Keyword Succeeds 2 min 5 sec VerifyFailDeploy ${compositionFromId} ${instanceMigrationId} +CheckTimeoutAutomationComposition + [Documentation] Timeout Deploy automation composition. + Wait Until Keyword Succeeds 5 min 5 sec VerifyStateChangeResult ${compositionFromId} ${instanceMigrationId} TIMEOUT DeployAutomationCompositionMigration [Documentation] Deploy automation composition. @@ -253,7 +265,7 @@ PrecheckAutomationCompositionMigration ${updatedpostyaml}= Replace String ${updatedpostyaml} TEXTPLACEHOLDER TextForMigration ${resp}= MakeYamlPostRequest ACM ${POLICY_RUNTIME_ACM_IP} /onap/policy/clamp/acm/v2/compositions/${compositionFromId}/instances ${updatedpostyaml} ${auth} Should Be Equal As Strings ${resp.status_code} 200 - Wait Until Keyword Succeeds 2 min 5 sec VerifyDeployStatus ${compositionFromId} ${instanceMigrationId} DEPLOYED + Wait Until Keyword Succeeds 2 min 5 sec VerifySubStatus ${compositionFromId} ${instanceMigrationId} AutomationCompositionMigrationTo [Documentation] Migration of an automation composition. @@ -286,7 +298,7 @@ FailUnDeployAutomationCompositionMigrationTo ${postjson}= Get file ${CURDIR}/data/UndeployAC.json ${resp}= MakeJsonPutRequest ACM ${POLICY_RUNTIME_ACM_IP} /onap/policy/clamp/acm/v2/compositions/${compositionToId}/instances/${instanceMigrationId} ${postjson} ${auth} Should Be Equal As Strings ${resp.status_code} 202 - Wait Until Keyword Succeeds 2 min 5 sec VerifyFailDeploy ${compositionToId} ${instanceMigrationId} + Wait Until Keyword Succeeds 2 min 5 sec VerifyStateChangeResult ${compositionToId} ${instanceMigrationId} FAILED UnDeployAutomationCompositionMigrationTo [Documentation] UnDeploy automation composition migrated. @@ -318,7 +330,7 @@ FailUnInstantiateAutomationCompositionMigrationTo ${resp}= DELETE On Session policy /onap/policy/clamp/acm/v2/compositions/${compositionToId}/instances/${instanceMigrationId} headers=${headers} Log Received response from runtime acm ${resp.text} Should Be Equal As Strings ${resp.status_code} 202 - Wait Until Keyword Succeeds 2 min 5 sec VerifyFailDeploy ${compositionToId} ${instanceMigrationId} + Wait Until Keyword Succeeds 2 min 5 sec VerifyStateChangeResult ${compositionToId} ${instanceMigrationId} FAILED UnInstantiateAutomationCompositionMigrationTo [Documentation] Delete automation composition instance migrated. @@ -437,13 +449,22 @@ VerifyDeployStatus Should Be Equal As Strings ${resp.json()['stateChangeResult']} NO_ERROR Run Keyword If ${resp.status_code}==200 Should Be Equal As Strings ${resp.json()['deployState']} ${deploystate} -VerifyFailDeploy +VerifySubStatus [Arguments] ${theCompositionId} ${theInstanceId} + [Documentation] Verify the Sub status of automation composition. + ${auth}= ClampAuth + ${resp}= MakeGetRequest ACM ${POLICY_RUNTIME_ACM_IP} /onap/policy/clamp/acm/v2/compositions/${theCompositionId}/instances/${theInstanceId} ${auth} + Should Be Equal As Strings ${resp.status_code} 200 + Should Be Equal As Strings ${resp.json()['stateChangeResult']} NO_ERROR + Run Keyword If ${resp.status_code}==200 Should Be Equal As Strings ${resp.json()['subState']} NONE + +VerifyStateChangeResult + [Arguments] ${theCompositionId} ${theInstanceId} ${stateChangeResult} [Documentation] Verify the Deploy status of automation composition. ${auth}= ClampAuth ${resp}= MakeGetRequest ACM ${POLICY_RUNTIME_ACM_IP} /onap/policy/clamp/acm/v2/compositions/${theCompositionId}/instances/${theInstanceId} ${auth} Should Be Equal As Strings ${resp.status_code} 200 - Run Keyword If ${resp.status_code}==200 Should Be Equal As Strings ${resp.json()['stateChangeResult']} FAILED + Run Keyword If ${resp.status_code}==200 Should Be Equal As Strings ${resp.json()['stateChangeResult']} ${stateChangeResult} VerifyPropertiesUpdated [Arguments] ${theCompositionId} ${theInstanceId} ${textToFind} @@ -511,6 +532,13 @@ SetParticipantSimSuccess ${resp}= MakeJsonPutRequest participant ${POLICY_PARTICIPANT_SIM_IP} /onap/policy/simparticipant/v2/parameters ${postjson} ${auth} Should Be Equal As Strings ${resp.status_code} 200 +SetParticipantSimTimeout + [Documentation] Set Participant Simulator Timeout. + ${auth}= ParticipantAuth + ${postjson}= Get file ${CURDIR}/data/SettingSimPropertiesTimeout.json + ${resp}= MakeJsonPutRequest participant ${POLICY_PARTICIPANT_SIM_IP} /onap/policy/simparticipant/v2/parameters ${postjson} ${auth} + Should Be Equal As Strings ${resp.status_code} 200 + ClampAuth ${auth}= Create List runtimeUser zb!XztG34 RETURN ${auth} @@ -554,3 +582,25 @@ MakeGetRequest ${resp}= GET On Session ${name} ${url} headers=${headers} Log Received response from ${name} {resp.text} RETURN ${resp} + +VerifyKafkaInTraces + [Arguments] ${domain} ${service} + Log Creating session http://${domain} + ${session}= Create Session jaeger http://${domain} + ${tags}= Create Dictionary otel.library.name=io.opentelemetry.kafka-clients-2.6 messaging.system=kafka + ${tags_json}= evaluate json.dumps(${tags}) json + ${params}= Create Dictionary service=${service} tags=${tags_json} operation=policy-acruntime-participant publish lookback=1h limit=10 + ${resp}= GET On Session jaeger /api/traces params=${params} expected_status=200 + Log Received response from jaeger ${resp.text} + RETURN ${resp} + +VerifyHttpInTraces + [Arguments] ${domain} ${service} + Log Creating session http://${domain} + ${session}= Create Session jaeger http://${domain} + ${tags}= Create Dictionary uri=/v2/compositions/{compositionId} + ${tags_json}= evaluate json.dumps(${tags}) json + ${params}= Create Dictionary service=${service} tags=${tags_json} operation=http put /v2/compositions/{compositionId} lookback=1h limit=10 + ${resp}= GET On Session jaeger /api/traces params=${params} expected_status=200 + Log Received response from jaeger ${resp.text} + RETURN ${resp} diff --git a/csit/resources/tests/xacml-pdp-slas.robot b/csit/resources/tests/xacml-pdp-slas.robot new file mode 100644 index 00000000..e3d2d910 --- /dev/null +++ b/csit/resources/tests/xacml-pdp-slas.robot @@ -0,0 +1,30 @@ +*** Settings *** +Library OperatingSystem +Resource common-library.robot + +*** Test Cases *** +WaitForPrometheusServer + [Documentation] Sleep time to wait for Prometheus server to gather all metrics + Sleep 1 minute + +ValidatePolicyDecisionsGauge + [Documentation] Validate policy execution gauge using prometheus metrics + ValidatePrometheusMetric pdpx_policy_decisions_created{application="optimization",status="permit", instance="policy-xacml-pdp:6969", job="xacml-pdp-metrics"} 1.8E9 + ValidatePrometheusMetric pdpx_policy_decisions_created{application="guard",status="not_applicable", instance="policy-xacml-pdp:6969", job="xacml-pdp-metrics"} 1.8E9 + ValidatePrometheusMetric pdpx_policy_decisions_created{application="monitoring",status="permit", instance="policy-xacml-pdp:6969", job="xacml-pdp-metrics"} 1.8E9 + ValidatePrometheusMetric pdpx_policy_decisions_created{application="naming",status="permit", instance="policy-xacml-pdp:6969", job="xacml-pdp-metrics"} 1.8E9 + +ValidatePolicyDecisionsTotalCounter + [Documentation] Validate policy decision counters using prometheus metrics + ValidatePrometheusMetric pdpx_policy_decisions_total{application="optimization",status="permit", instance="policy-xacml-pdp:6969", job="xacml-pdp-metrics"} 1 + ValidatePrometheusMetric pdpx_policy_decisions_total{application="guard",status="not_applicable", instance="policy-xacml-pdp:6969", job="xacml-pdp-metrics"} 1 + ValidatePrometheusMetric pdpx_policy_decisions_total{application="monitoring",status="permit", instance="policy-xacml-pdp:6969", job="xacml-pdp-metrics"} 2 + ValidatePrometheusMetric pdpx_policy_decisions_total{application="naming",status="permit", instance="policy-xacml-pdp:6969", job="xacml-pdp-metrics"} 1 + +*** Keywords *** +ValidatePrometheusMetric + [Arguments] ${url} ${expectedLimit} + [Documentation] Check that the policy execution is under X limit + ${resp}= QueryPrometheus ${url} + ${actualValue}= Evaluate ${resp['data']['result'][0]['value'][1]} + Should Be True ${actualValue} <= ${expectedLimit} 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 diff --git a/csit/run-acm-regression.sh b/csit/run-acm-regression.sh index 2c91bcb4..19160027 100755 --- a/csit/run-acm-regression.sh +++ b/csit/run-acm-regression.sh @@ -67,10 +67,6 @@ if [ -z "${WORKSPACE}" ]; then export WORKSPACE fi -if [ -z "$ROBOT_LOG_DIR" ]; then - export ROBOT_LOG_DIR=/tmp/ -fi - export SCRIPTS="${WORKSPACE}/csit/resources/scripts" COMPOSE_FOLDER="${WORKSPACE}"/compose REGRESSION_FOLDER="${WORKSPACE}"/policy-regression-tests/policy-clamp-regression/ @@ -128,7 +124,9 @@ cd ${COMPOSE_FOLDER} docker login -u docker -p docker nexus3.onap.org:10001 > /dev/null 2>&1 source export-ports.sh > /dev/null 2>&1 -docker compose -f docker-compose.yml up -d "policy-clamp-runtime-acm" +export CONTAINER_LOCATION="nexus3.onap.org:10001/" + +docker compose up -d "policy-clamp-runtime-acm" # wait for the app to start up "${SCRIPTS}"/wait_for_rest.sh localhost "${ACM_PORT}" @@ -138,3 +136,8 @@ cd ${REGRESSION_FOLDER} # Invoke the regression test cases mvn clean test -Dtests.skip=false +cd ${COMPOSE_FOLDER} +source stop-compose.sh clamp +mv ${COMPOSE_FOLDER}/*.log ${REGRESSION_FOLDER} + +cd ${REGRESSION_FOLDER} diff --git a/csit/run-k8s-csit.sh b/csit/run-k8s-csit.sh index eaaa8b48..feab0437 100755 --- a/csit/run-k8s-csit.sh +++ b/csit/run-k8s-csit.sh @@ -32,7 +32,7 @@ POLICY_CLAMP_ROBOT="policy-clamp-test.robot clamp-slas.robot" POLICY_API_ROBOT="api-test.robot api-slas.robot" POLICY_PAP_ROBOT="pap-test.robot pap-slas.robot" POLICY_APEX_PDP_ROBOT="apex-pdp-test.robot apex-slas.robot" -POLICY_XACML_PDP_ROBOT="xacml-pdp-test.robot" +POLICY_XACML_PDP_ROBOT="xacml-pdp-test.robot xacml-pdp-slas.robot" POLICY_DROOLS_PDP_ROBOT="drools-pdp-test.robot" POLICY_DISTRIBUTION_ROBOT="distribution-test.robot" @@ -141,17 +141,17 @@ function install_kafka() { function uninstall_policy() { echo "Removing the policy helm deployment" - sudo helm uninstall csit-policy - sudo helm uninstall prometheus - sudo helm uninstall csit-robot - sudo kubectl delete deploy $ZK_CONTAINER $KAFKA_CONTAINER + helm uninstall csit-policy + helm uninstall prometheus + helm uninstall csit-robot + kubectl delete deploy $ZK_CONTAINER $KAFKA_CONTAINER rm -rf ${WORKSPACE}/helm/policy/Chart.lock if [ "$PROJECT" == "clamp" ] || [ "$PROJECT" == "policy-clamp" ]; then - sudo helm uninstall policy-chartmuseum - sudo helm repo remove chartmuseum-git policy-chartmuseum + helm uninstall policy-chartmuseum + helm repo remove chartmuseum-git policy-chartmuseum fi sudo rm -rf /dockerdata-nfs/mariadb-galera/ - sudo kubectl delete pvc --all + kubectl delete pvc --all echo "Policy deployment deleted" echo "Clean up docker" docker image prune -f @@ -195,14 +195,14 @@ function start_csit() { while [[ ${POD_READY_STATUS} != "1/1" ]]; do echo "Waiting for chartmuseum pod to come up..." sleep 5 - POD_READY_STATUS=$(sudo kubectl get pods | grep -e "policy-chartmuseum" | awk '{print $2}') + POD_READY_STATUS=$(kubectl get pods | grep -e "policy-chartmuseum" | awk '{print $2}') done push_acelement_chart fi echo "Installing Robot framework pod for running CSIT" cd ${WORKSPACE}/helm mkdir -p ${ROBOT_LOG_DIR} - sudo helm install csit-robot robot --set robot="$ROBOT_FILE" --set "readiness={${READINESS_CONTAINERS[*]}}" --set robotLogDir=$ROBOT_LOG_DIR + helm install csit-robot robot --set robot="$ROBOT_FILE" --set "readiness={${READINESS_CONTAINERS[*]}}" --set robotLogDir=$ROBOT_LOG_DIR print_robot_log fi } @@ -212,17 +212,17 @@ function print_robot_log() { while [[ ${count_pods} -eq 0 ]]; do echo "Waiting for pods to come up..." sleep 5 - count_pods=$(sudo kubectl get pods --output name | wc -l) + count_pods=$(kubectl get pods --output name | wc -l) done - robotpod=$(sudo kubectl get po | grep policy-csit) + robotpod=$(kubectl get po | grep policy-csit) podName=$(echo "$robotpod" | awk '{print $1}') echo "The robot tests will begin once the policy components {${READINESS_CONTAINERS[*]}} are up and running..." - sudo kubectl wait --for=jsonpath='{.status.phase}'=Running --timeout=18m pod/"$podName" + kubectl wait --for=jsonpath='{.status.phase}'=Running --timeout=18m pod/"$podName" echo "Policy deployment status:" - sudo kubectl get po - sudo kubectl get all -A + kubectl get po + kubectl get all -A echo "Robot Test logs:" - sudo kubectl logs -f "$podName" + kubectl logs -f "$podName" } function clone_models() { @@ -320,22 +320,22 @@ function set_project_config() { function install_chartmuseum () { echo "---------------------------------------------" echo "Installing Chartmuseum helm repository..." - sudo helm repo add chartmuseum-git https://chartmuseum.github.io/charts - sudo helm repo update - sudo helm install policy-chartmuseum chartmuseum-git/chartmuseum --set env.open.DISABLE_API=false --set service.type=NodePort --set service.nodePort=30208 - sudo helm plugin install https://github.com/chartmuseum/helm-push + helm repo add chartmuseum-git https://chartmuseum.github.io/charts + helm repo update + helm install policy-chartmuseum chartmuseum-git/chartmuseum --set env.open.DISABLE_API=false --set service.type=NodePort --set service.nodePort=30208 + helm plugin install https://github.com/chartmuseum/helm-push echo "---------------------------------------------" } function push_acelement_chart() { echo "Pushing acelement chart to the chartmuseum repo..." - sudo helm repo add policy-chartmuseum http://localhost:30208 + helm repo add policy-chartmuseum http://localhost:30208 # download clamp repo git clone -b "${GERRIT_BRANCH}" --single-branch https://github.com/onap/policy-clamp.git "${WORKSPACE}"/csit/resources/tests/clamp ACELEMENT_CHART=${WORKSPACE}/csit/resources/tests/clamp/examples/src/main/resources/clamp/acm/acelement-helm/acelement - sudo helm cm-push $ACELEMENT_CHART policy-chartmuseum - sudo helm repo update + helm cm-push $ACELEMENT_CHART policy-chartmuseum + helm repo update rm -rf ${WORKSPACE}/csit/resources/tests/clamp/ echo "-------------------------------------------" } @@ -437,9 +437,9 @@ if [ $OPERATION == "install" ]; then ${WORKSPACE}/compose/loaddockerimage.sh fi cd ${WORKSPACE}/helm || exit - sudo helm dependency build policy - sudo helm install csit-policy policy ${SET_VALUES} - sudo helm install prometheus prometheus + helm dependency build policy + helm install csit-policy policy ${SET_VALUES} + helm install prometheus prometheus wait_for_pods_running default 900 ${READINESS_CONTAINERS[@]} echo "Policy chart installation completed" echo "-------------------------------------------" diff --git a/csit/run-project-csit.sh b/csit/run-project-csit.sh index cbb62e6d..8183cdee 100755 --- a/csit/run-project-csit.sh +++ b/csit/run-project-csit.sh @@ -33,7 +33,7 @@ function docker_stats(){ fi # Memory details per Docker - docker ps --format "table {{ .Names }}\t{{ .Status }}" + docker ps --format "table {{ .Image }}\t{{ .Names }}\t{{ .Status }}" echo docker stats --no-stream @@ -42,66 +42,65 @@ function docker_stats(){ function setup_clamp() { export ROBOT_FILES="policy-clamp-test.robot clamp-slas.robot" - source "${WORKSPACE}"/compose/start-compose.sh policy-clamp-runtime-acm --grafana + source ${DOCKER_COMPOSE_DIR}/start-compose.sh policy-clamp-runtime-acm --grafana sleep 30 - bash "${SCRIPTS}"/wait_for_rest.sh localhost "${ACM_PORT}" + bash ${SCRIPTS}/wait_for_rest.sh localhost "${ACM_PORT}" } function setup_clamp_replica() { + export ACM_REPLICA_TEARDOWN=true export ROBOT_FILES="policy-clamp-test.robot" export TEST_ENV="docker" - source "${WORKSPACE}"/compose/start-acm-replica.sh 2 - sleep 30 - bash "${SCRIPTS}"/wait_for_rest.sh localhost "${ACM_PORT}" + export PROJECT=clamp + source ${DOCKER_COMPOSE_DIR}/start-acm-replica.sh --start --replicas=2 + echo "Waiting a minute for the replicas to be started..." + sleep 60 + # checking on apex-pdp status because acm-r replicas only start after apex-pdp is running + bash ${SCRIPTS}/wait_for_rest.sh localhost ${APEX_PORT} + apex_healthcheck + bash ${SCRIPTS}/wait_for_rest.sh localhost ${ACM_PORT} } function setup_api() { export ROBOT_FILES="api-test.robot api-slas.robot" - source "${WORKSPACE}"/compose/start-compose.sh api --grafana + source ${DOCKER_COMPOSE_DIR}/start-compose.sh api --grafana sleep 10 - bash "${SCRIPTS}"/wait_for_rest.sh localhost ${API_PORT} + bash ${SCRIPTS}/wait_for_rest.sh localhost ${API_PORT} } function setup_pap() { export ROBOT_FILES="pap-test.robot pap-slas.robot" - source "${WORKSPACE}"/compose/start-compose.sh apex-pdp --grafana + source ${DOCKER_COMPOSE_DIR}/start-compose.sh apex-pdp --grafana sleep 10 - bash "${SCRIPTS}"/wait_for_rest.sh localhost ${PAP_PORT} + bash ${SCRIPTS}/wait_for_rest.sh localhost ${PAP_PORT} } function setup_apex() { export ROBOT_FILES="apex-pdp-test.robot apex-slas.robot" - source "${WORKSPACE}"/compose/start-compose.sh apex-pdp --grafana - sleep 10 - bash "${SCRIPTS}"/wait_for_rest.sh localhost ${PAP_PORT} - bash "${SCRIPTS}"/wait_for_rest.sh localhost ${APEX_PORT} - apex_healthcheck -} - -function setup_apex_postgres() { - export ROBOT_FILES="apex-pdp-test.robot" - source "${WORKSPACE}"/compose/start-postgres-tests.sh apex-pdp 1 + source ${DOCKER_COMPOSE_DIR}/start-compose.sh apex-pdp --grafana sleep 10 - bash "${SCRIPTS}"/wait_for_rest.sh localhost ${PAP_PORT} - bash "${SCRIPTS}"/wait_for_rest.sh localhost ${APEX_PORT} + bash ${SCRIPTS}/wait_for_rest.sh localhost ${PAP_PORT} + bash ${SCRIPTS}/wait_for_rest.sh localhost ${APEX_PORT} apex_healthcheck } function setup_apex_medium() { export SUITES="apex-slas-3.robot" - source "${WORKSPACE}"/compose/start-multiple-pdp.sh 3 + export APEX_REPLICA_TEARDOWN=true + source ${DOCKER_COMPOSE_DIR}/start-multiple-pdp.sh --start --replicas=3 sleep 10 - bash "${SCRIPTS}"/wait_for_rest.sh localhost ${PAP_PORT} - bash "${SCRIPTS}"/wait_for_rest.sh localhost ${APEX_PORT} + bash ${SCRIPTS}/wait_for_rest.sh localhost ${PAP_PORT} + bash ${SCRIPTS}/wait_for_rest.sh localhost ${APEX_PORT} apex_healthcheck } function setup_apex_large() { export ROBOT_FILES="apex-slas-10.robot" - source "${WORKSPACE}"/compose/start-multiple-pdp.sh 10 + export APEX_REPLICA_TEARDOWN=true + source ${DOCKER_COMPOSE_DIR}/start-multiple-pdp.sh --start --replicas=10 sleep 10 - bash "${SCRIPTS}"/wait_for_rest.sh localhost ${PAP_PORT} - bash "${SCRIPTS}"/wait_for_rest.sh localhost ${APEX_PORT} + bash ${SCRIPTS}/wait_for_rest.sh localhost ${PAP_PORT} + bash ${SCRIPTS}/wait_for_rest.sh localhost ${APEX_PORT} apex_healthcheck } @@ -124,58 +123,50 @@ function apex_healthcheck() { } function setup_drools_apps() { - export ROBOT_FILES="drools-applications-test.robot" - source "${WORKSPACE}"/compose/start-compose.sh drools-applications + export ROBOT_FILES="drools-applications-test.robot drools-applications-slas.robot" + source ${DOCKER_COMPOSE_DIR}/start-compose.sh drools-applications --grafana sleep 10 - bash "${SCRIPTS}"/wait_for_rest.sh localhost ${PAP_PORT} + bash ${SCRIPTS}/wait_for_rest.sh localhost ${PAP_PORT} sleep 10 - bash "${SCRIPTS}"/wait_for_rest.sh localhost ${DROOLS_APPS_PORT} + bash ${SCRIPTS}/wait_for_rest.sh localhost ${DROOLS_APPS_PORT} sleep 10 - bash "${SCRIPTS}"/wait_for_rest.sh localhost ${DROOLS_APPS_TELEMETRY_PORT} + bash ${SCRIPTS}/wait_for_rest.sh localhost ${DROOLS_APPS_TELEMETRY_PORT} } function setup_xacml_pdp() { - export ROBOT_FILES="xacml-pdp-test.robot" - source "${WORKSPACE}"/compose/start-compose.sh xacml-pdp - sleep 10 - bash "${SCRIPTS}"/wait_for_rest.sh localhost "${XACML_PORT}" -} - -function setup_xacml_pdp_postgres() { - export ROBOT_FILES="xacml-pdp-test.robot" - source "${WORKSPACE}"/compose/start-postgres-tests.sh xacml-pdp 1 + export ROBOT_FILES="xacml-pdp-test.robot xacml-pdp-slas.robot" + source ${DOCKER_COMPOSE_DIR}/start-compose.sh xacml-pdp --grafana sleep 10 - bash "${SCRIPTS}"/wait_for_rest.sh localhost "${XACML_PORT}" + bash ${SCRIPTS}/wait_for_rest.sh localhost "${XACML_PORT}" } function setup_drools_pdp() { export ROBOT_FILES="drools-pdp-test.robot" - source "${WORKSPACE}"/compose/start-compose.sh drools-pdp + source ${DOCKER_COMPOSE_DIR}/start-compose.sh drools-pdp sleep 30 - bash "${SCRIPTS}"/wait_for_rest.sh localhost ${DROOLS_TELEMETRY_PORT} + bash ${SCRIPTS}/wait_for_rest.sh localhost ${DROOLS_TELEMETRY_PORT} } function setup_distribution() { - zip -F ${WORKSPACE}/csit/resources/tests/data/csar/sample_csar_with_apex_policy.csar \ - --out ${WORKSPACE}/csit/resources/tests/data/csar/csar_temp.csar -q + zip -F ${CSAR_DIR}/sample_csar_with_apex_policy.csar --out ${CSAR_DIR}/csar_temp.csar -q # Remake temp directory sudo rm -rf /tmp/distribution sudo mkdir /tmp/distribution export ROBOT_FILES="distribution-test.robot" - source "${WORKSPACE}"/compose/start-compose.sh distribution + source ${DOCKER_COMPOSE_DIR}/start-compose.sh distribution sleep 10 - bash "${SCRIPTS}"/wait_for_rest.sh localhost "${DIST_PORT}" + bash ${SCRIPTS}/wait_for_rest.sh localhost "${DIST_PORT}" } function build_robot_image() { - bash "${SCRIPTS}"/build-csit-docker-image.sh + bash ${SCRIPTS}/build-csit-docker-image.sh cd ${WORKSPACE} } function run_robot() { - docker compose -f "${WORKSPACE}"/compose/docker-compose.yml up csit-tests + docker compose -f ${DOCKER_COMPOSE_DIR}/compose.yaml up csit-tests export RC=$? } @@ -204,7 +195,7 @@ function set_project_config() { ;; apex-pdp-postgres | policy-apex-pdp-postgres) - setup_apex_postgres + setup_apex ;; apex-pdp-medium | policy-apex-pdp-medium) @@ -219,10 +210,6 @@ function set_project_config() { setup_xacml_pdp ;; - xacml-pdp-postgres | policy-xacml-pdp-postgres) - setup_xacml_pdp_postgres - ;; - drools-pdp | policy-drools-pdp) setup_drools_pdp ;; @@ -244,9 +231,18 @@ function set_project_config() { # even with forced finish, clean up docker containers function on_exit(){ - rm -rf ${WORKSPACE}/csit/resources/tests/data/csar/csar_temp.csar - source ${WORKSPACE}/compose/stop-compose.sh - cp ${WORKSPACE}/compose/*.log ${WORKSPACE}/csit/archives/${PROJECT} + rm -rf ${CSAR_DIR}/csar_temp.csar + + # teardown of compose containers for acm-replicas doesn't work with normal stop-compose script + if [ "${ACM_REPLICA_TEARDOWN}" = true ]; then + source ${DOCKER_COMPOSE_DIR}/start-acm-replica.sh --stop --replicas=2 + elif [ "${APEX_REPLICA_TEARDOWN}" = true ]; then + source ${DOCKER_COMPOSE_DIR}/start-multiple-pdp.sh --stop --replicas=2 + else + source ${DOCKER_COMPOSE_DIR}/stop-compose.sh ${PROJECT} + fi + + mv ${DOCKER_COMPOSE_DIR}/*.log ${ROBOT_LOG_DIR} exit $RC } @@ -261,11 +257,13 @@ fi export GERRIT_BRANCH=$(awk -F= '$1 == "defaultbranch" { print $2 }' "${WORKSPACE}"/.gitreview) export PROJECT="${1}" -export ROBOT_LOG_DIR=${WORKSPACE}/csit/archives/${PROJECT} +export ROBOT_LOG_DIR="${WORKSPACE}/csit/archives/${PROJECT}" export SCRIPTS="${WORKSPACE}/csit/resources/scripts" +export CSAR_DIR="${WORKSPACE}/csit/resources/tests/data/csar" +export DOCKER_COMPOSE_DIR="${WORKSPACE}/compose" export ROBOT_FILES="" -# always 'docker' if running docker compose -export TEST_ENV="docker" +export ACM_REPLICA_TEARDOWN=false +export APEX_REPLICA_TEARDOWN=false cd "${WORKSPACE}" @@ -284,7 +282,7 @@ if [[ $compose_version == *"Docker Compose version"* ]]; then else echo "Docker Compose Plugin not installed. Installing now..." sudo mkdir -p /usr/local/lib/docker/cli-plugins - sudo curl -SL https://github.com/docker/compose/releases/download/v2.27.0/docker-compose-linux-x86_64 -o /usr/local/lib/docker/cli-plugins/docker-compose + sudo curl -SL https://github.com/docker/compose/releases/download/v2.29.1/docker-compose-linux-x86_64 -o /usr/local/lib/docker/cli-plugins/docker-compose sudo chmod +x /usr/local/lib/docker/cli-plugins/docker-compose fi @@ -301,9 +299,9 @@ else build_robot_image fi -docker_stats | tee "${WORKSPACE}/csit/archives/${PROJECT}/_sysinfo-1-after-setup.txt" +docker_stats | tee "${ROBOT_LOG_DIR}/_sysinfo-1-after-setup.txt" # start the CSIT container and run the tests run_robot -docker ps --format "table {{ .Names }}\t{{ .Status }}" +docker ps --format "table {{ .Image }}\t{{ .Names }}\t{{ .Status }}" |