blob: 2ae52a7e36988ce5d1277dfef8be388f5c60ad49 [file] [log] [blame]
rameshiyer2707004862023-01-23 11:50:01 +00001*** Settings ***
2Library Collections
3Library RequestsLibrary
4Library OperatingSystem
5Library Process
6Library json
7Resource common-library.robot
8
9*** Test Cases ***
10Healthcheck
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
15Statistics
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
20Metrics
21 [Documentation] Verify policy-xacml-pdp is exporting prometheus metrics
22 ${resp}= PdpxGetReq /metrics
23 Should Contain ${resp.text} jvm_threads_current
24
25MakeTopics
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
30ExecuteXacmlPolicy
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
46CreateMonitorPolicy
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
51CreateOptimizationPolicy
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
56GetDefaultDecision
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
63DeployPolicies
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
72GetStatisticsAfterDeployed
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
78GetAbbreviatedDecisionResult
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
90GetMonitoringDecision
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
102GetNamingDecision
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
112GetOptimizationDecision
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
122GetStatisticsAfterDecision
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
129UndeployMonitorPolicy
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
134GetStatisticsAfterUndeploy
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
140PdpxGetReq
141 [Arguments] ${url}
142 ${hcauth}= HealthCheckAuth
143 ${resp}= PerformGetRequest ${POLICY_PDPX_IP} ${url} 200 null ${hcauth}
144 [return] ${resp}
145
146DecisionPostReq
147 [Arguments] ${postjson} ${abbr}
148 ${hcauth}= HealthCheckAuth
149 ${resp}= PerformPostRequest ${POLICY_PDPX_IP} /policy/pdpx/v1/decision 200 ${postjson} ${abbr} ${hcauth}
150 [return] ${resp}