blob: 7f108d01663e124339a646f8f9eb6db07760ac81 [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
10 ${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
21 ${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
32 ${auth}= Create List healthcheck zb!XztG34
33 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 A4174bbb2019-04-15 21:15:50 +000041CreateTCAPolicyType
42 [Documentation] Create TCA Policy Type
43 ${auth}= Create List healthcheck zb!XztG34
44 ${postjson}= Get file ${CURDIR}/data/onap.policy.monitoring.cdap.tca.hi.lo.app.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} 200
51 ${postjsonobject} To Json ${postjson}
52 Dictionary Should Contain Key ${resp.json()} tosca_definitions_version
53 Dictionary Should Contain Key ${postjsonobject} tosca_definitions_version
54
55RetrieveMonitoringPolicyTypes
56 [Documentation] Retrieve Monitoring related Policy Types
57 ${auth}= Create List healthcheck zb!XztG34
58 Log Creating session https://${POLICY_API_IP}:6969
59 ${session}= Create Session policy https://${POLICY_API_IP}:6969 auth=${auth}
60 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
61 ${resp}= Get Request policy /policy/api/v1/policytypes/onap.policies.Monitoring headers=${headers}
62 Log Received response from policy ${resp.text}
63 Should Be Equal As Strings ${resp.status_code} 200
jhh9d5fb222019-09-09 13:59:23 -050064 List Should Contain Value ${resp.json()['policy_types']} onap.policies.Monitoring
Bilal A4174bbb2019-04-15 21:15:50 +000065
66
67CreateNewMonitoringPolicy
68 [Documentation] Create a new Monitoring TCA policy
69 ${auth}= Create List healthcheck zb!XztG34
70 ${postjson}= Get file ${CURDIR}/data/vCPE.policy.monitoring.input.tosca.json
71 Log Creating session https://${POLICY_API_IP}:6969
72 ${session}= Create Session policy https://${POLICY_API_IP}:6969 auth=${auth}
73 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
74 ${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}
75 Log Received response from policy ${resp.text}
76 ${postjsonobject} To Json ${postjson}
77 Should Be Equal As Strings ${resp.status_code} 200
78 Dictionary Should Contain Key ${resp.json()['topology_template']['policies'][0]} onap.restart.tca
79 Dictionary Should Contain Key ${postjsonobject['topology_template']['policies'][0]} onap.restart.tca
80
Chenfei Gaod5ba0fd2019-10-21 16:13:27 -040081SimpleCreateNewMonitoringPolicy
82 [Documentation] Create a new Monitoring TCA policiy using simple endpoint
83 ${auth}= Create List healthcheck zb!XztG34
84 ${postjson}= Get file ${CURDIR}/data/vCPE.policy.monitoring.input.tosca.json
85 Log Creating session https://${POLICY_API_IP}:6969
86 ${session}= Create Session policy https://${POLICY_API_IP}:6969 auth=${auth}
87 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
88 ${resp}= Post Request policy /policy/api/v1/policies data=${postjson} headers=${headers}
89 Log Received response from policy ${resp.text}
90 ${postjsonobject} To Json ${postjson}
91 Should Be Equal As Strings ${resp.status_code} 200
92 Dictionary Should Contain Key ${resp.json()['topology_template']['policies'][0]} onap.restart.tca
93 Dictionary Should Contain Key ${postjsonobject['topology_template']['policies'][0]} onap.restart.tca
94
Bilal A4174bbb2019-04-15 21:15:50 +000095RetrievePoliciesOfType
96 [Documentation] Retrieve all Policies Created for a specific Policy Type
97 ${auth}= Create List healthcheck zb!XztG34
98 ${expjson}= Get file ${CURDIR}/data/vCPE.policy.monitoring.input.tosca.json
99 Log Creating session https://${POLICY_API_IP}:6969
100 ${session}= Create Session policy https://${POLICY_API_IP}:6969 auth=${auth}
101 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
102 ${resp}= Get Request policy /policy/api/v1/policytypes/onap.policies.monitoring.cdap.tca.hi.lo.app/versions/1.0.0/policies headers=${headers}
103 Log Received response from policy ${resp.text}
104 ${expjsonobject} To Json ${expjson}
105 Should Be Equal As Strings ${resp.status_code} 200
106 Dictionary Should Contain Key ${resp.json()['topology_template']['policies'][0]} onap.restart.tca
107 Dictionary Should Contain Key ${expjsonobject['topology_template']['policies'][0]} onap.restart.tca
108
109DeleteSpecificPolicy
110 [Documentation] Delete Policy of a Type
111 ${auth}= Create List healthcheck zb!XztG34
112 Log Creating session https://${POLICY_API_IP}:6969
113 ${session}= Create Session policy https://${POLICY_API_IP}:6969 auth=${auth}
114 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
115 ${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}
116 Log Received response from policy ${resp.text}
117 Should Be Equal As Strings ${resp.status_code} 200
118 ${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}
119 Should Be Equal As Strings ${resp.status_code} 404