blob: aac05ec80c89c600b1370c5f3e4e03261a4df234 [file] [log] [blame]
rameshiyer2707004862023-01-23 11:50:01 +00001*** Settings ***
2Library Collections
3Library RequestsLibrary
4Library OperatingSystem
5Library json
6Resource common-library.robot
7
8*** Test Cases ***
9
10Healthcheck
11 [Documentation] Verify policy api health check
12 ${resp}= GetReq /policy/api/v1/healthcheck
13 Should Be Equal As Strings ${resp.json()['code']} 200
14 Should Be Equal As Strings ${resp.json()['healthy']} True
15 Should Be Equal As Strings ${resp.json()['message']} alive
16
17Statistics
18 [Documentation] Verify policy api statistics
19 ${resp}= GetReq /policy/api/v1/statistics
20 Should Be Equal As Strings ${resp.json()['code']} 200
21
22RetrievePolicyTypes
23 [Documentation] Retrieve all policy types
24 FetchPolicyTypes /policy/api/v1/policytypes 37
25
26CreateTCAPolicyTypeV1
27 [Documentation] Create an existing policy type with modification and keeping the same version should result in error.
28 CreatePolicyType /policy/api/v1/policytypes 406 onap.policy.monitoring.tcagen2.v1.json null null
29
30CreateTCAPolicyTypeV2
31 [Documentation] Create an existing policy type with modification and keeping the same version should result in error.
32 CreatePolicyType /policy/api/v1/policytypes 406 onap.policy.monitoring.tcagen2.v2.json null null
33
34CreateTCAPolicyTypeV3
35 [Documentation] Create a policy type named 'onap.policies.monitoring.tcagen2' and version '3.0.0'
36 CreatePolicyType /policy/api/v1/policytypes 200 onap.policy.monitoring.tcagen2.v3.json onap.policies.monitoring.tcagen2 3.0.0
37
38RetrieveMonitoringPolicyTypes
39 [Documentation] Retrieve all monitoring related policy types
40 FetchPolicyTypes /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2 2
41
42CreateNewMonitoringPolicyV1
43 [Documentation] Create a policy named 'onap.restart.tca' and version '1.0.0' using specific api
44 ${postjson}= Get file ${DATA}/vCPE.policy.monitoring.input.tosca.json
45 CreatePolicy /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/1.0.0/policies 200 ${postjson} onap.restart.tca 1.0.0
46
47CreateNewMonitoringPolicyV1Again
48 [Documentation] Create an existing policy with modification and keeping the same version should result in error.
49 ${postjson}= Get file ${DATA}/vCPE.policy.monitoring.input.tosca.v1_2.json
50 CreatePolicy /policy/api/v1/policies 406 ${postjson} null null
51
52CreateNewMonitoringPolicyV2
53 [Documentation] Create a policy named 'onap.restart.tca' and version '2.0.0' using generic api
54 ${postjson}= Get file ${DATA}/vCPE.policy.monitoring.input.tosca.v2.json
55 CreatePolicy /policy/api/v1/policies 200 ${postjson} onap.restart.tca 2.0.0
56
57
58CreateNodeTemplates
59 [Documentation] Create node templates in database using specific api
60 ${postjson}= Get file ${NODETEMPLATES}/nodetemplates.metadatasets.input.tosca.json
61 CreateNodeTemplate /policy/api/v1/nodetemplates 200 ${postjson} 3
62
63RetrievePoliciesOfType
64 [Documentation] Retrieve all policies belonging to a specific Policy Type
65 FetchPolicies /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/1.0.0/policies 2
66
67RetrieveAllPolicies
68 [Documentation] Retrieve all policies
69 FetchPolicies /policy/api/v1/policies 3
70
71RetrieveSpecificPolicy
72 [Documentation] Retrieve a policy named 'onap.restart.tca' and version '1.0.0' using generic api
73 FetchPolicy /policy/api/v1/policies/onap.restart.tca/versions/1.0.0 onap.restart.tca
74
75RetrieveAllNodeTemplates
76 [Documentation] Retrieve all node templates
77 FetchNodeTemplates /policy/api/v1/nodetemplates 3
78
79RetrieveSpecificNodeTemplate
80 [Documentation] Retrieve a node template named 'apexMetadata_grpc' and version '1.2.1' using generic api
81 FetchNodeTemplate /policy/api/v1/nodetemplates/apexMetadata_grpc/versions/1.2.1 apexMetadata_grpc
82
83DeleteSpecificNodeTemplate
84 [Documentation] Delete a node template named 'apexMetadata_adaptive' and version '2.3.1' using generic api
85 DeleteReq /policy/api/v1/nodetemplates/apexMetadata_adaptive/versions/2.3.1 200
86 DeleteReq /policy/api/v1/nodetemplates/apexMetadata_adaptive/versions/2.3.1 404
87
88
89DeleteSpecificPolicy
90 [Documentation] Delete a policy named 'onap.restart.tca' and version '1.0.0' using generic api
91 DeleteReq /policy/api/v1/policies/onap.restart.tca/versions/1.0.0 200
92 DeleteReq /policy/api/v1/policies/onap.restart.tca/versions/1.0.0 404
93
94DeleteSpecificPolicyV2
95 [Documentation] Delete a policy named 'onap.restart.tca' and version '2.0.0' using specific api
96 DeleteReq /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/1.0.0/policies/onap.restart.tca/versions/2.0.0 200
97 DeleteReq /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/1.0.0/policies/onap.restart.tca/versions/2.0.0 404
98
99DeleteSpecificPolicyTypeV1
100 [Documentation] Delete a policy type named 'onap.policies.monitoring.tcagen2' and version '1.0.0'
101 DeleteReq /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/1.0.0 200
102 DeleteReq /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/1.0.0 404
103
104DeleteSpecificPolicyTypeV2
105 [Documentation] Delete a policy type named 'onap.policies.monitoring.tcagen2' and version '2.0.0'
106 DeleteReq /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/2.0.0 200
107 DeleteReq /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/2.0.0 404
108
109DeleteSpecificPolicyTypeV3
110 [Documentation] Delete a policy type named 'onap.policies.monitoring.tcagen2' and version '3.0.0'
111 DeleteReq /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/3.0.0 200
112 DeleteReq /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/3.0.0 404
113
114Metrics
115 [Documentation] Verify policy-api is exporting prometheus metrics
116 ${auth}= PolicyAdminAuth
117 ${resp}= GetMetrics ${POLICY_API_IP} ${auth} /policy/api/v1/
rameshiyer27be226252023-02-09 14:46:18 +0000118 Should Contain ${resp.text} http_server_requests_seconds_count{exception="None",method="GET",outcome="SUCCESS",status="200",uri="/healthcheck",}
119 Should Contain ${resp.text} http_server_requests_seconds_count{exception="None",method="GET",outcome="SUCCESS",status="200",uri="/statistics",} 1.0
120 Should Contain ${resp.text} http_server_requests_seconds_count{exception="None",method="GET",outcome="SUCCESS",status="200",uri="/policytypes",} 1.0
121 Should Contain ${resp.text} http_server_requests_seconds_count{exception="None",method="GET",outcome="SUCCESS",status="200",uri="/policies",} 1.0
122 Should Contain ${resp.text} http_server_requests_seconds_count{exception="None",method="GET",outcome="SUCCESS",status="200",uri="/policies/{policyId}/versions/{policyVersion}",} 1.0
123 Should Contain ${resp.text} http_server_requests_seconds_count{exception="None",method="GET",outcome="SUCCESS",status="200",uri="/policytypes/{policyTypeId}/versions/{policyTypeVersion}/policies",} 1.0
124 Should Contain ${resp.text} http_server_requests_seconds_count{exception="None",method="POST",outcome="SUCCESS",status="200",uri="/policytypes/{policyTypeId}/versions/{policyTypeVersion}/policies",} 1.0
125 Should Contain ${resp.text} http_server_requests_seconds_count{exception="None",method="POST",outcome="SUCCESS",status="200",uri="/policytypes",} 1.0
126 Should Contain ${resp.text} http_server_requests_seconds_count{exception="None",method="DELETE",outcome="SUCCESS",status="200",uri="/policies/{policyId}/versions/{policyVersion}",} 1.0
127 Should Contain ${resp.text} http_server_requests_seconds_count{exception="None",method="DELETE",outcome="SUCCESS",status="200",uri="/policytypes/{policyTypeId}/versions/{versionId}",} 3.0
128 Should Contain ${resp.text} http_server_requests_seconds_count{exception="None",method="DELETE",outcome="SUCCESS",status="200",uri="/policytypes/{policyTypeId}/versions/{policyTypeVersion}/policies/{policyId}/versions/{policyVersion}",} 1.0
rameshiyer2707004862023-01-23 11:50:01 +0000129 Should Contain ${resp.text} http_server_requests_seconds_sum
130 Should Contain ${resp.text} http_server_requests_seconds_max
131 Should Contain ${resp.text} spring_data_repository_invocations_seconds_count
132 Should Contain ${resp.text} spring_data_repository_invocations_seconds_sum
133 Should Contain ${resp.text} spring_data_repository_invocations_seconds_max
134 Should Contain ${resp.text} jvm_threads_live_threads
135
136*** Keywords ***
137
138GetReq
139 [Arguments] ${url}
140 ${auth}= PolicyAdminAuth
141 ${resp}= PerformGetRequest ${POLICY_API_IP} ${url} 200 null ${auth}
142 [return] ${resp}
143
144DeleteReq
145 [Arguments] ${url} ${expectedstatus}
146 ${auth}= PolicyAdminAuth
147 ${resp}= PerformDeleteRequest ${POLICY_API_IP} ${url} ${expectedstatus} ${auth}
148 [return] ${resp}
149
150CreatePolicyType
151 [Arguments] ${url} ${expectedstatus} ${jsonfile} ${policytypename} ${policytypeversion}
152 [Documentation] Create the specific policy type
153 ${postjson}= Get file ${CURDIR}/data/${jsonfile}
154 ${auth}= PolicyAdminAuth
155 ${resp}= PerformPostRequest ${POLICY_API_IP} ${url} ${expectedstatus} ${postjson} null ${auth}
156 Run Keyword If ${expectedstatus}==200 List Should Contain Value ${resp.json()['policy_types']} ${policytypename}
157 Run Keyword If ${expectedstatus}==200 Should Be Equal As Strings ${resp.json()['policy_types']['${policytypename}']['version']} ${policytypeversion}
158
159FetchPolicyTypes
160 [Arguments] ${url} ${expectedLength}
161 [Documentation] Fetch all policy types
162 ${resp}= GetReq ${url}
163 Length Should Be ${resp.json()['policy_types']} ${expectedLength}
164
165FetchPolicy
166 [Arguments] ${url} ${keyword}
167 [Documentation] Fetch the specific policy
168 ${resp}= GetReq ${url}
169 Dictionary Should Contain Key ${resp.json()['topology_template']['policies'][0]} ${keyword}
170
171FetchPolicies
172 [Arguments] ${url} ${expectedLength}
173 [Documentation] Fetch all policies
174 ${resp}= GetReq ${url}
175 Length Should Be ${resp.json()['topology_template']['policies']} ${expectedLength}
176
177
178FetchNodeTemplates
179 [Arguments] ${url} ${expectedLength}
180 [Documentation] Fetch all node templates
181 ${resp}= GetReq ${url}
182 Length Should Be ${resp.json()} ${expectedLength}
183
184FetchNodeTemplate
185 [Arguments] ${url} ${keyword}
186 [Documentation] Fetch the specific node template
187 ${resp}= GetReq ${url}
188 Dictionary Should Contain Value ${resp.json()[0]} ${keyword}