blob: 959df40e4f68fa26b8a40fcb41ddceccd0148bfa [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
64 Dictionary Should Contain Key ${resp.json()['policy_types'][0]} onap.policies.Monitoring
65
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
81RetrievePoliciesOfType
82 [Documentation] Retrieve all Policies Created for a specific Policy Type
83 ${auth}= Create List healthcheck zb!XztG34
84 ${expjson}= 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}= Get Request policy /policy/api/v1/policytypes/onap.policies.monitoring.cdap.tca.hi.lo.app/versions/1.0.0/policies headers=${headers}
89 Log Received response from policy ${resp.text}
90 ${expjsonobject} To Json ${expjson}
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 ${expjsonobject['topology_template']['policies'][0]} onap.restart.tca
94
95DeleteSpecificPolicy
96 [Documentation] Delete Policy of a Type
97 ${auth}= Create List healthcheck zb!XztG34
98 Log Creating session https://${POLICY_API_IP}:6969
99 ${session}= Create Session policy https://${POLICY_API_IP}:6969 auth=${auth}
100 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
101 ${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}
102 Log Received response from policy ${resp.text}
103 Should Be Equal As Strings ${resp.status_code} 200
104 ${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}
105 Should Be Equal As Strings ${resp.status_code} 404