blob: 76c1bdc6fd5096d2cb3d65300494dd5abd872c2b [file] [log] [blame]
Chenfei Gaod4c51852019-02-06 20:45:10 -05001*** Settings ***
2Library Collections
3Library RequestsLibrary
4Library OperatingSystem
5Library json
6
7*** Test Cases ***
8Healthcheck
9 [Documentation] Runs Policy Api Health check
Bilal A9f54c002020-01-16 16:12:19 +000010 ${auth}= Create List healthcheck zb!XztG34
Chenfei Gaofd967382019-02-12 15:52:37 -050011 Log Creating session https://${POLICY_API_IP}:6969
12 ${session}= Create Session policy https://${POLICY_API_IP}:6969 auth=${auth}
Chenfei Gaod4c51852019-02-06 20:45:10 -050013 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
Michael Mokry88f4d472019-03-04 12:00:05 -060014 ${resp}= Get Request policy /policy/api/v1/healthcheck headers=${headers}
Chenfei Gaod4c51852019-02-06 20:45:10 -050015 Log Received response from policy ${resp.text}
16 Should Be Equal As Strings ${resp.status_code} 200
17 Should Be Equal As Strings ${resp.json()['code']} 200
18
19Statistics
20 [Documentation] Runs Policy Api Statistics
Bilal A9f54c002020-01-16 16:12:19 +000021 ${auth}= Create List healthcheck zb!XztG34
Chenfei Gaofd967382019-02-12 15:52:37 -050022 Log Creating session https://${POLICY_API_IP}:6969
23 ${session}= Create Session policy https://${POLICY_API_IP}:6969 auth=${auth}
Chenfei Gaod4c51852019-02-06 20:45:10 -050024 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
Michael Mokry88f4d472019-03-04 12:00:05 -060025 ${resp}= Get Request policy /policy/api/v1/statistics headers=${headers}
Chenfei Gaod4c51852019-02-06 20:45:10 -050026 Log Received response from policy ${resp.text}
27 Should Be Equal As Strings ${resp.status_code} 200
Chenfei Gaofd967382019-02-12 15:52:37 -050028 Should Be Equal As Strings ${resp.json()['code']} 200
Bilal A95097c22019-04-12 22:38:32 +000029
30RetrievePolicyTypes
31 [Documentation] Gets Policy Types
Bilal A9f54c002020-01-16 16:12:19 +000032 ${auth}= Create List healthcheck zb!XztG34
Bilal A95097c22019-04-12 22:38:32 +000033 Log Creating session https://${POLICY_API_IP}:6969
34 ${session}= Create Session policy https://${POLICY_API_IP}:6969 auth=${auth}
35 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
36 ${resp}= Get Request policy /policy/api/v1/policytypes headers=${headers}
37 Log Received response from policy ${resp.text}
38 Should Be Equal As Strings ${resp.status_code} 200
39 Should Be Equal As Strings ${resp.json()['version']} 1.0.0
40
Bilal A9f54c002020-01-16 16:12:19 +000041CreateTCAPolicyTypeV1
a.sreekumar20705742020-02-14 12:03:33 +000042 [Documentation] Create TCA Policy Type Version 1. Trying to create an existing policy type with any change and same version should cause error.
Bilal A9f54c002020-01-16 16:12:19 +000043 ${auth}= Create List healthcheck zb!XztG34
44 ${postjson}= Get file ${CURDIR}/data/onap.policy.monitoring.cdap.tca.hi.lo.app.v1.json
45 Log Creating session https://${POLICY_API_IP}:6969
46 ${session}= Create Session policy https://${POLICY_API_IP}:6969 auth=${auth}
47 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
48 ${resp}= Post Request policy /policy/api/v1/policytypes data=${postjson} headers=${headers}
49 Log Received response from policy ${resp.text}
50 Should Be Equal As Strings ${resp.status_code} 406
51
52CreateTCAPolicyTypeV2
53 [Documentation] Create TCA Policy Type Version 2
54 ${auth}= Create List healthcheck zb!XztG34
55 ${postjson}= Get file ${CURDIR}/data/onap.policy.monitoring.cdap.tca.hi.lo.app.v2.json
Bilal A4174bbb2019-04-15 21:15:50 +000056 Log Creating session https://${POLICY_API_IP}:6969
57 ${session}= Create Session policy https://${POLICY_API_IP}:6969 auth=${auth}
58 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
59 ${resp}= Post Request policy /policy/api/v1/policytypes data=${postjson} headers=${headers}
60 Log Received response from policy ${resp.text}
61 Should Be Equal As Strings ${resp.status_code} 200
62 ${postjsonobject} To Json ${postjson}
Bilal A9f54c002020-01-16 16:12:19 +000063 Dictionary Should Contain Key ${resp.json()} tosca_definitions_version
64 Dictionary Should Contain Key ${postjsonobject} tosca_definitions_version
Bilal A4174bbb2019-04-15 21:15:50 +000065
66RetrieveMonitoringPolicyTypes
67 [Documentation] Retrieve Monitoring related Policy Types
Bilal A9f54c002020-01-16 16:12:19 +000068 ${auth}= Create List healthcheck zb!XztG34
Bilal A4174bbb2019-04-15 21:15:50 +000069 Log Creating session https://${POLICY_API_IP}:6969
70 ${session}= Create Session policy https://${POLICY_API_IP}:6969 auth=${auth}
71 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
72 ${resp}= Get Request policy /policy/api/v1/policytypes/onap.policies.Monitoring headers=${headers}
73 Log Received response from policy ${resp.text}
74 Should Be Equal As Strings ${resp.status_code} 200
jhh9d5fb222019-09-09 13:59:23 -050075 List Should Contain Value ${resp.json()['policy_types']} onap.policies.Monitoring
Bilal A4174bbb2019-04-15 21:15:50 +000076
77
Bilal A9f54c002020-01-16 16:12:19 +000078CreateNewMonitoringPolicyV1
79 [Documentation] Create a new Monitoring TCA policy version 1
80 ${auth}= Create List healthcheck zb!XztG34
81 ${postjson}= Get file ${CURDIR}/data/vCPE.policy.monitoring.input.tosca.v1.json
Bilal A4174bbb2019-04-15 21:15:50 +000082 Log Creating session https://${POLICY_API_IP}:6969
83 ${session}= Create Session policy https://${POLICY_API_IP}:6969 auth=${auth}
84 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
85 ${resp}= Post Request policy /policy/api/v1/policytypes/onap.policies.monitoring.cdap.tca.hi.lo.app/versions/1.0.0/policies data=${postjson} headers=${headers}
86 Log Received response from policy ${resp.text}
87 ${postjsonobject} To Json ${postjson}
88 Should Be Equal As Strings ${resp.status_code} 200
89 Dictionary Should Contain Key ${resp.json()['topology_template']['policies'][0]} onap.restart.tca
90 Dictionary Should Contain Key ${postjsonobject['topology_template']['policies'][0]} onap.restart.tca
91
Bilal A9f54c002020-01-16 16:12:19 +000092SimpleCreateNewMonitoringPolicyV1
a.sreekumar20705742020-02-14 12:03:33 +000093 [Documentation] Create a new Monitoring TCA policiy version 1 using simple endpoint. Trying to create an existing policy with any change and same version should cause error.
Bilal A9f54c002020-01-16 16:12:19 +000094 ${auth}= Create List healthcheck zb!XztG34
a.sreekumar20705742020-02-14 12:03:33 +000095 ${postjson}= Get file ${CURDIR}/data/vCPE.policy.monitoring.input.tosca.v1_2.json
Bilal A9f54c002020-01-16 16:12:19 +000096 Log Creating session https://${POLICY_API_IP}:6969
97 ${session}= Create Session policy https://${POLICY_API_IP}:6969 auth=${auth}
98 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
99 ${resp}= Post Request policy /policy/api/v1/policies data=${postjson} headers=${headers}
100 Log Received response from policy ${resp.text}
101 Should Be Equal As Strings ${resp.status_code} 406
102
103SimpleCreateNewMonitoringPolicyV2
104 [Documentation] Create a new Monitoring TCA policiy version 2 using simple endpoint
105 ${auth}= Create List healthcheck zb!XztG34
106 ${postjson}= Get file ${CURDIR}/data/vCPE.policy.monitoring.input.tosca.v2.json
Chenfei Gaod5ba0fd2019-10-21 16:13:27 -0400107 Log Creating session https://${POLICY_API_IP}:6969
108 ${session}= Create Session policy https://${POLICY_API_IP}:6969 auth=${auth}
109 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
110 ${resp}= Post Request policy /policy/api/v1/policies data=${postjson} headers=${headers}
111 Log Received response from policy ${resp.text}
112 ${postjsonobject} To Json ${postjson}
113 Should Be Equal As Strings ${resp.status_code} 200
114 Dictionary Should Contain Key ${resp.json()['topology_template']['policies'][0]} onap.restart.tca
115 Dictionary Should Contain Key ${postjsonobject['topology_template']['policies'][0]} onap.restart.tca
116
Bilal A4174bbb2019-04-15 21:15:50 +0000117RetrievePoliciesOfType
118 [Documentation] Retrieve all Policies Created for a specific Policy Type
119 ${auth}= Create List healthcheck zb!XztG34
Bilal A9f54c002020-01-16 16:12:19 +0000120 ${expjson}= Get file ${CURDIR}/data/vCPE.policy.monitoring.input.tosca.v1.json
Bilal A4174bbb2019-04-15 21:15:50 +0000121 Log Creating session https://${POLICY_API_IP}:6969
122 ${session}= Create Session policy https://${POLICY_API_IP}:6969 auth=${auth}
123 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
124 ${resp}= Get Request policy /policy/api/v1/policytypes/onap.policies.monitoring.cdap.tca.hi.lo.app/versions/1.0.0/policies headers=${headers}
125 Log Received response from policy ${resp.text}
126 ${expjsonobject} To Json ${expjson}
127 Should Be Equal As Strings ${resp.status_code} 200
128 Dictionary Should Contain Key ${resp.json()['topology_template']['policies'][0]} onap.restart.tca
129 Dictionary Should Contain Key ${expjsonobject['topology_template']['policies'][0]} onap.restart.tca
130
Bilal A9f54c002020-01-16 16:12:19 +0000131DeleteSpecificPolicyV1
132 [Documentation] Delete the Monitoring Policy Version 1 of the TCA Policy Type
Bilal A4174bbb2019-04-15 21:15:50 +0000133 ${auth}= Create List healthcheck zb!XztG34
134 Log Creating session https://${POLICY_API_IP}:6969
135 ${session}= Create Session policy https://${POLICY_API_IP}:6969 auth=${auth}
136 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
137 ${resp}= Delete Request policy /policy/api/v1/policytypes/onap.policies.monitoring.cdap.tca.hi.lo.app/versions/1.0.0/policies/onap.restart.tca/versions/1.0.0 headers=${headers}
138 Log Received response from policy ${resp.text}
139 Should Be Equal As Strings ${resp.status_code} 200
140 ${resp}= Delete Request policy /policy/api/v1/policytypes/onap.policies.monitoring.cdap.tca.hi.lo.app/versions/1.0.0/policies/onap.restart.tca/versions/1.0.0 headers=${headers}
141 Should Be Equal As Strings ${resp.status_code} 404
Bilal A9f54c002020-01-16 16:12:19 +0000142
143DeleteSpecificPolicyV2
144 [Documentation] Delete the Monitoring Policy Version 2 of the TCA Policy Type
145 ${auth}= Create List healthcheck zb!XztG34
146 Log Creating session https://${POLICY_API_IP}:6969
147 ${session}= Create Session policy https://${POLICY_API_IP}:6969 auth=${auth}
148 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
149 ${resp}= Delete Request policy /policy/api/v1/policytypes/onap.policies.monitoring.cdap.tca.hi.lo.app/versions/1.0.0/policies/onap.restart.tca/versions/2.0.0 headers=${headers}
150 Log Received response from policy ${resp.text}
151 Should Be Equal As Strings ${resp.status_code} 200
152 ${resp}= Delete Request policy /policy/api/v1/policytypes/onap.policies.monitoring.cdap.tca.hi.lo.app/versions/1.0.0/policies/onap.restart.tca/versions/2.0.0 headers=${headers}
153 Should Be Equal As Strings ${resp.status_code} 404
154
155DeleteSpecificPolicyTypeV1
156 [Documentation] Delete the TCA Policy Type Version 1
157 ${auth}= Create List healthcheck zb!XztG34
158 Log Creating session https://${POLICY_API_IP}:6969
159 ${session}= Create Session policy https://${POLICY_API_IP}:6969 auth=${auth}
160 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
161 ${resp}= Delete Request policy /policy/api/v1/policytypes/onap.policies.monitoring.cdap.tca.hi.lo.app/versions/1.0.0 headers=${headers}
162 Log Received response from policy ${resp.text}
163 Should Be Equal As Strings ${resp.status_code} 200
164 ${resp}= Delete Request policy /policy/api/v1/policytypes/onap.policies.monitoring.cdap.tca.hi.lo.app/versions/1.0.0 headers=${headers}
165 Should Be Equal As Strings ${resp.status_code} 404
166
167DeleteSpecificPolicyTypeV2
168 [Documentation] Delete the TCA Policy Type Version 2
169 ${auth}= Create List healthcheck zb!XztG34
170 Log Creating session https://${POLICY_API_IP}:6969
171 ${session}= Create Session policy https://${POLICY_API_IP}:6969 auth=${auth}
172 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
173 ${resp}= Delete Request policy /policy/api/v1/policytypes/onap.policies.monitoring.cdap.tca.hi.lo.app/versions/2.0.0 headers=${headers}
174 Log Received response from policy ${resp.text}
175 Should Be Equal As Strings ${resp.status_code} 200
176 ${resp}= Delete Request policy /policy/api/v1/policytypes/onap.policies.monitoring.cdap.tca.hi.lo.app/versions/2.0.0 headers=${headers}
177 Should Be Equal As Strings ${resp.status_code} 404