blob: cddecab969d6f9552ee3516fd0db2739c3f435c9 [file] [log] [blame]
Jim Hahn3486a922021-05-10 15:36:30 -04001*** Settings ***
2Library Collections
3Library RequestsLibrary
4Library OperatingSystem
5Library Process
6Library json
adheli.tavares1f339f82023-02-17 15:14:07 +00007Resource ${CURDIR}/common-library.robot
Jim Hahn3486a922021-05-10 15:36:30 -04008
9*** Test Cases ***
10Healthcheck
adheli.tavares496b3012021-11-01 10:40:32 +000011 [Documentation] Verify policy xacml-pdp health check
12 ${resp}= PdpxGetReq /policy/pdpx/v1/healthcheck
13 Should Be Equal As Strings ${resp.json()['code']} 200
Jim Hahn3486a922021-05-10 15:36:30 -040014
a.sreekumar60d6a082021-08-20 17:39:53 +010015Metrics
16 [Documentation] Verify policy-xacml-pdp is exporting prometheus metrics
adheli.tavares496b3012021-11-01 10:40:32 +000017 ${resp}= PdpxGetReq /metrics
a.sreekumar60d6a082021-08-20 17:39:53 +010018 Should Contain ${resp.text} jvm_threads_current
19
Jim Hahn3486a922021-05-10 15:36:30 -040020MakeTopics
adheli.tavares496b3012021-11-01 10:40:32 +000021 [Documentation] Creates the Policy topics
rameshiyer27f2e4da72024-01-13 21:26:09 +000022 GetKafkaTopic policy-pdp-pap
Jim Hahn3486a922021-05-10 15:36:30 -040023
24ExecuteXacmlPolicy
adheli.tavares496b3012021-11-01 10:40:32 +000025 CreateMonitorPolicy
26 CreateOptimizationPolicy
27 Wait Until Keyword Succeeds 1 min 15 sec GetDefaultDecision
28 DeployPolicies
adheli.tavares496b3012021-11-01 10:40:32 +000029 Wait Until Keyword Succeeds 1 min 15 sec GetAbbreviatedDecisionResult
30 Wait Until Keyword Succeeds 1 min 15 sec GetMonitoringDecision
31 Wait Until Keyword Succeeds 1 min 15 sec GetNamingDecision
32 Wait Until Keyword Succeeds 1 min 15 sec GetOptimizationDecision
adheli.tavares496b3012021-11-01 10:40:32 +000033 UndeployMonitorPolicy
Jim Hahn3486a922021-05-10 15:36:30 -040034
35*** Keywords ***
36
37CreateMonitorPolicy
adheli.tavares496b3012021-11-01 10:40:32 +000038 [Documentation] Create a Monitoring policy
adheli.tavares1f339f82023-02-17 15:14:07 +000039 ${postjson}= Get file ${DATA}/vCPE.policy.monitoring.input.tosca.json
adheli.tavares496b3012021-11-01 10:40:32 +000040 CreatePolicy /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/1.0.0/policies 200 ${postjson} onap.restart.tca 1.0.0
Jim Hahn3486a922021-05-10 15:36:30 -040041
42CreateOptimizationPolicy
adheli.tavares496b3012021-11-01 10:40:32 +000043 [Documentation] Create an Optimization policy
adheli.tavares1f339f82023-02-17 15:14:07 +000044 ${postjson}= Get file ${DATA}/vCPE.policies.optimization.input.tosca.json
adheli.tavares496b3012021-11-01 10:40:32 +000045 CreatePolicy /policy/api/v1/policytypes/onap.policies.optimization.resource.AffinityPolicy/versions/1.0.0/policies 200 ${postjson} OSDF_CASABLANCA.Affinity_Default 1.0.0
Jim Hahn3486a922021-05-10 15:36:30 -040046
47GetDefaultDecision
adheli.tavares496b3012021-11-01 10:40:32 +000048 [Documentation] Get Default Decision with no policies in Xacml PDP
49 ${postjson}= Get file ${CURDIR}/data/onap.policy.guard.decision.request.json
50 ${resp}= DecisionPostReq ${postjson} abbrev=true
51 ${status}= Get From Dictionary ${resp.json()} status
52 Should Be Equal As Strings ${status} Permit
Jim Hahn3486a922021-05-10 15:36:30 -040053
54DeployPolicies
adheli.tavares496b3012021-11-01 10:40:32 +000055 [Documentation] Runs Policy PAP to deploy a policy
56 ${postjson}= Get file ${CURDIR}/data/vCPE.policy.input.tosca.deploy.json
57 ${policyadmin}= PolicyAdminAuth
adheli.tavares1f339f82023-02-17 15:14:07 +000058 PerformPostRequest ${POLICY_PAP_IP} /policy/pap/v1/pdps/policies 202 ${postjson} null ${policyadmin}
rameshiyer27f2e4da72024-01-13 21:26:09 +000059 sleep 20s
60 ${result}= CheckKafkaTopic policy-notification onap.restart.tca
61 Should Contain ${result} deployed-policies
Jim Hahn3486a922021-05-10 15:36:30 -040062
Jim Hahn3486a922021-05-10 15:36:30 -040063GetAbbreviatedDecisionResult
adheli.tavares496b3012021-11-01 10:40:32 +000064 [Documentation] Get Decision with abbreviated results from Policy Xacml PDP
65 ${postjson}= Get file ${CURDIR}/data/onap.policy.monitoring.decision.request.json
66 ${resp}= DecisionPostReq ${postjson} abbrev=true
67 ${policy}= Get From Dictionary ${resp.json()['policies']} onap.restart.tca
68 Dictionary Should Contain Key ${policy} type
69 Dictionary Should Contain Key ${policy} metadata
70 Dictionary Should Not Contain Key ${policy} type_version
71 Dictionary Should Not Contain Key ${policy} properties
72 Dictionary Should Not Contain Key ${policy} name
73 Dictionary Should Not Contain Key ${policy} version
Jim Hahn3486a922021-05-10 15:36:30 -040074
75GetMonitoringDecision
adheli.tavares496b3012021-11-01 10:40:32 +000076 [Documentation] Get Decision from Monitoring Policy Xacml PDP
77 ${postjson}= Get file ${CURDIR}/data/onap.policy.monitoring.decision.request.json
78 ${resp}= DecisionPostReq ${postjson} null
79 ${policy}= Get From Dictionary ${resp.json()['policies']} onap.restart.tca
80 Dictionary Should Contain Key ${policy} type
81 Dictionary Should Contain Key ${policy} metadata
82 Dictionary Should Contain Key ${policy} type_version
83 Dictionary Should Contain Key ${policy} properties
84 Dictionary Should Contain Key ${policy} name
85 Dictionary Should Contain Key ${policy} version
Jim Hahn3486a922021-05-10 15:36:30 -040086
87GetNamingDecision
adheli.tavares496b3012021-11-01 10:40:32 +000088 [Documentation] Get Decision from Naming Policy Xacml PDP
89 ${postjson}= Get file ${CURDIR}/data/onap.policy.naming.decision.request.json
90 ${resp}= DecisionPostReq ${postjson} null
91 ${policy}= Get From Dictionary ${resp.json()['policies']} SDNC_Policy.ONAP_NF_NAMING_TIMESTAMP
92 Dictionary Should Contain Key ${policy} type
93 Dictionary Should Contain Key ${policy} type_version
94 Dictionary Should Contain Key ${policy} properties
95 Dictionary Should Contain Key ${policy} name
Jim Hahn3486a922021-05-10 15:36:30 -040096
97GetOptimizationDecision
adheli.tavares496b3012021-11-01 10:40:32 +000098 [Documentation] Get Decision from Optimization Policy Xacml PDP
99 ${postjson}= Get file ${CURDIR}/data/onap.policy.optimization.decision.request.json
100 ${resp}= DecisionPostReq ${postjson} null
101 ${policy}= Get From Dictionary ${resp.json()['policies']} OSDF_CASABLANCA.Affinity_Default
102 Dictionary Should Contain Key ${policy} type
103 Dictionary Should Contain Key ${policy} type_version
104 Dictionary Should Contain Key ${policy} properties
105 Dictionary Should Contain Key ${policy} name
Jim Hahn3486a922021-05-10 15:36:30 -0400106
Jim Hahn3486a922021-05-10 15:36:30 -0400107UndeployMonitorPolicy
adheli.tavares496b3012021-11-01 10:40:32 +0000108 [Documentation] Runs Policy PAP to undeploy a policy
109 ${policyadmin}= PolicyAdminAuth
adheli.tavares1f339f82023-02-17 15:14:07 +0000110 PerformDeleteRequest ${POLICY_PAP_IP} /policy/pap/v1/pdps/policies/onap.restart.tca 202 ${policyadmin}
Jim Hahn3486a922021-05-10 15:36:30 -0400111
adheli.tavares496b3012021-11-01 10:40:32 +0000112PdpxGetReq
113 [Arguments] ${url}
adheli.tavares1153b6d2023-02-28 12:59:37 +0000114 ${hcauth}= PolicyAdminAuth
adheli.tavares1f339f82023-02-17 15:14:07 +0000115 ${resp}= PerformGetRequest ${POLICY_PDPX_IP} ${url} 200 null ${hcauth}
adheli.tavares8361cb02024-02-21 15:29:36 +0000116 RETURN ${resp}
adheli.tavares496b3012021-11-01 10:40:32 +0000117
118DecisionPostReq
119 [Arguments] ${postjson} ${abbr}
adheli.tavares1153b6d2023-02-28 12:59:37 +0000120 ${hcauth}= PolicyAdminAuth
adheli.tavares1f339f82023-02-17 15:14:07 +0000121 ${resp}= PerformPostRequest ${POLICY_PDPX_IP} /policy/pdpx/v1/decision 200 ${postjson} ${abbr} ${hcauth}
adheli.tavares8361cb02024-02-21 15:29:36 +0000122 RETURN ${resp}