rameshiyer27 | 0700486 | 2023-01-23 11:50:01 +0000 | [diff] [blame^] | 1 | *** Settings *** |
| 2 | Library Collections |
| 3 | Library RequestsLibrary |
| 4 | Library OperatingSystem |
| 5 | Library Process |
| 6 | Library json |
| 7 | Resource common-library.robot |
| 8 | |
| 9 | *** Test Cases *** |
| 10 | Healthcheck |
| 11 | [Documentation] Verify policy xacml-pdp health check |
| 12 | ${resp}= PdpxGetReq /policy/pdpx/v1/healthcheck |
| 13 | Should Be Equal As Strings ${resp.json()['code']} 200 |
| 14 | |
| 15 | Statistics |
| 16 | [Documentation] Verify policy xacml-pdp statistics |
| 17 | ${resp}= PdpxGetReq /policy/pdpx/v1/statistics |
| 18 | Should Be Equal As Strings ${resp.json()['code']} 200 |
| 19 | |
| 20 | Metrics |
| 21 | [Documentation] Verify policy-xacml-pdp is exporting prometheus metrics |
| 22 | ${resp}= PdpxGetReq /metrics |
| 23 | Should Contain ${resp.text} jvm_threads_current |
| 24 | |
| 25 | MakeTopics |
| 26 | [Documentation] Creates the Policy topics |
| 27 | ${result}= Run Process ${SCR_DMAAP}/make_topic.sh POLICY-PDP-PAP |
| 28 | Should Be Equal As Integers ${result.rc} 0 |
| 29 | |
| 30 | ExecuteXacmlPolicy |
| 31 | CreateMonitorPolicy |
| 32 | CreateOptimizationPolicy |
| 33 | Wait Until Keyword Succeeds 1 min 15 sec GetDefaultDecision |
| 34 | DeployPolicies |
| 35 | Wait Until Keyword Succeeds 1 min 15 sec GetStatisticsAfterDeployed |
| 36 | Wait Until Keyword Succeeds 1 min 15 sec GetAbbreviatedDecisionResult |
| 37 | Wait Until Keyword Succeeds 1 min 15 sec GetMonitoringDecision |
| 38 | Wait Until Keyword Succeeds 1 min 15 sec GetNamingDecision |
| 39 | Wait Until Keyword Succeeds 1 min 15 sec GetOptimizationDecision |
| 40 | Wait Until Keyword Succeeds 1 min 15 sec GetStatisticsAfterDecision |
| 41 | UndeployMonitorPolicy |
| 42 | Wait Until Keyword Succeeds 1 min 15 sec GetStatisticsAfterUndeploy |
| 43 | |
| 44 | *** Keywords *** |
| 45 | |
| 46 | CreateMonitorPolicy |
| 47 | [Documentation] Create a Monitoring policy |
| 48 | ${postjson}= Get file ${DATA2}/vCPE.policy.monitoring.input.tosca.json |
| 49 | CreatePolicy /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/1.0.0/policies 200 ${postjson} onap.restart.tca 1.0.0 |
| 50 | |
| 51 | CreateOptimizationPolicy |
| 52 | [Documentation] Create an Optimization policy |
| 53 | ${postjson}= Get file ${DATA2}/vCPE.policies.optimization.input.tosca.json |
| 54 | CreatePolicy /policy/api/v1/policytypes/onap.policies.optimization.resource.AffinityPolicy/versions/1.0.0/policies 200 ${postjson} OSDF_CASABLANCA.Affinity_Default 1.0.0 |
| 55 | |
| 56 | GetDefaultDecision |
| 57 | [Documentation] Get Default Decision with no policies in Xacml PDP |
| 58 | ${postjson}= Get file ${CURDIR}/data/onap.policy.guard.decision.request.json |
| 59 | ${resp}= DecisionPostReq ${postjson} abbrev=true |
| 60 | ${status}= Get From Dictionary ${resp.json()} status |
| 61 | Should Be Equal As Strings ${status} Permit |
| 62 | |
| 63 | DeployPolicies |
| 64 | [Documentation] Runs Policy PAP to deploy a policy |
| 65 | ${postjson}= Get file ${CURDIR}/data/vCPE.policy.input.tosca.deploy.json |
| 66 | ${policyadmin}= PolicyAdminAuth |
| 67 | PerformPostRequest ${POLICY_PAP_IP} /policy/pap/v1/pdps/policies 202 ${postjson} null ${policyadmin} |
| 68 | ${result}= Run Process ${SCR_DMAAP}/wait_topic.sh POLICY-PDP-PAP |
| 69 | ... responseTo xacml ACTIVE onap.restart.tca |
| 70 | Should Be Equal As Integers ${result.rc} 0 |
| 71 | |
| 72 | GetStatisticsAfterDeployed |
| 73 | [Documentation] Verify policy xacml-pdp statistics after policy is deployed |
| 74 | ${resp}= PdpxGetReq /policy/pdpx/v1/statistics |
| 75 | Should Be Equal As Strings ${resp.json()['code']} 200 |
| 76 | Should Be Equal As Strings ${resp.json()['totalPoliciesCount']} 3 |
| 77 | |
| 78 | GetAbbreviatedDecisionResult |
| 79 | [Documentation] Get Decision with abbreviated results from Policy Xacml PDP |
| 80 | ${postjson}= Get file ${CURDIR}/data/onap.policy.monitoring.decision.request.json |
| 81 | ${resp}= DecisionPostReq ${postjson} abbrev=true |
| 82 | ${policy}= Get From Dictionary ${resp.json()['policies']} onap.restart.tca |
| 83 | Dictionary Should Contain Key ${policy} type |
| 84 | Dictionary Should Contain Key ${policy} metadata |
| 85 | Dictionary Should Not Contain Key ${policy} type_version |
| 86 | Dictionary Should Not Contain Key ${policy} properties |
| 87 | Dictionary Should Not Contain Key ${policy} name |
| 88 | Dictionary Should Not Contain Key ${policy} version |
| 89 | |
| 90 | GetMonitoringDecision |
| 91 | [Documentation] Get Decision from Monitoring Policy Xacml PDP |
| 92 | ${postjson}= Get file ${CURDIR}/data/onap.policy.monitoring.decision.request.json |
| 93 | ${resp}= DecisionPostReq ${postjson} null |
| 94 | ${policy}= Get From Dictionary ${resp.json()['policies']} onap.restart.tca |
| 95 | Dictionary Should Contain Key ${policy} type |
| 96 | Dictionary Should Contain Key ${policy} metadata |
| 97 | Dictionary Should Contain Key ${policy} type_version |
| 98 | Dictionary Should Contain Key ${policy} properties |
| 99 | Dictionary Should Contain Key ${policy} name |
| 100 | Dictionary Should Contain Key ${policy} version |
| 101 | |
| 102 | GetNamingDecision |
| 103 | [Documentation] Get Decision from Naming Policy Xacml PDP |
| 104 | ${postjson}= Get file ${CURDIR}/data/onap.policy.naming.decision.request.json |
| 105 | ${resp}= DecisionPostReq ${postjson} null |
| 106 | ${policy}= Get From Dictionary ${resp.json()['policies']} SDNC_Policy.ONAP_NF_NAMING_TIMESTAMP |
| 107 | Dictionary Should Contain Key ${policy} type |
| 108 | Dictionary Should Contain Key ${policy} type_version |
| 109 | Dictionary Should Contain Key ${policy} properties |
| 110 | Dictionary Should Contain Key ${policy} name |
| 111 | |
| 112 | GetOptimizationDecision |
| 113 | [Documentation] Get Decision from Optimization Policy Xacml PDP |
| 114 | ${postjson}= Get file ${CURDIR}/data/onap.policy.optimization.decision.request.json |
| 115 | ${resp}= DecisionPostReq ${postjson} null |
| 116 | ${policy}= Get From Dictionary ${resp.json()['policies']} OSDF_CASABLANCA.Affinity_Default |
| 117 | Dictionary Should Contain Key ${policy} type |
| 118 | Dictionary Should Contain Key ${policy} type_version |
| 119 | Dictionary Should Contain Key ${policy} properties |
| 120 | Dictionary Should Contain Key ${policy} name |
| 121 | |
| 122 | GetStatisticsAfterDecision |
| 123 | [Documentation] Runs Policy Xacml PDP Statistics after Decision request |
| 124 | ${resp}= PdpxGetReq /policy/pdpx/v1/statistics |
| 125 | Should Be Equal As Strings ${resp.json()['code']} 200 |
| 126 | Should Be Equal As Strings ${resp.json()['permitDecisionsCount']} 4 |
| 127 | Should Be Equal As Strings ${resp.json()['notApplicableDecisionsCount']} 1 |
| 128 | |
| 129 | UndeployMonitorPolicy |
| 130 | [Documentation] Runs Policy PAP to undeploy a policy |
| 131 | ${policyadmin}= PolicyAdminAuth |
| 132 | PerformDeleteRequest ${POLICY_PAP_IP} /policy/pap/v1/pdps/policies/onap.restart.tca 202 ${policyadmin} |
| 133 | |
| 134 | GetStatisticsAfterUndeploy |
| 135 | [Documentation] Runs Policy Xacml PDP Statistics after policy is undeployed |
| 136 | ${resp}= PdpxGetReq /policy/pdpx/v1/statistics |
| 137 | Should Be Equal As Strings ${resp.json()['code']} 200 |
| 138 | Should Be Equal As Strings ${resp.json()['totalPoliciesCount']} 2 |
| 139 | |
| 140 | PdpxGetReq |
| 141 | [Arguments] ${url} |
| 142 | ${hcauth}= HealthCheckAuth |
| 143 | ${resp}= PerformGetRequest ${POLICY_PDPX_IP} ${url} 200 null ${hcauth} |
| 144 | [return] ${resp} |
| 145 | |
| 146 | DecisionPostReq |
| 147 | [Arguments] ${postjson} ${abbr} |
| 148 | ${hcauth}= HealthCheckAuth |
| 149 | ${resp}= PerformPostRequest ${POLICY_PDPX_IP} /policy/pdpx/v1/decision 200 ${postjson} ${abbr} ${hcauth} |
| 150 | [return] ${resp} |