blob: bce58231a80438a4d7f0ed8fa190c655db8622b4 [file] [log] [blame]
Jim Hahnb3a962f2021-05-12 11:33:43 -04001*** Settings ***
2Library Collections
3Library RequestsLibrary
4Library OperatingSystem
5Library json
adheli.tavares1f339f82023-02-17 15:14:07 +00006Resource ${CURDIR}/common-library.robot
Jim Hahnb3a962f2021-05-12 11:33:43 -04007
8*** Test Cases ***
9
10Healthcheck
11 [Documentation] Verify policy api health check
adheli.tavares496b3012021-11-01 10:40:32 +000012 ${resp}= GetReq /policy/api/v1/healthcheck
Jim Hahnb3a962f2021-05-12 11:33:43 -040013 Should Be Equal As Strings ${resp.json()['code']} 200
Prakhar Pandey3a348572022-03-25 15:46:19 -040014 Should Be Equal As Strings ${resp.json()['healthy']} True
15 Should Be Equal As Strings ${resp.json()['message']} alive
a.sreekumar60d6a082021-08-20 17:39:53 +010016
Jim Hahnb3a962f2021-05-12 11:33:43 -040017RetrievePolicyTypes
18 [Documentation] Retrieve all policy types
19 FetchPolicyTypes /policy/api/v1/policytypes 37
20
21CreateTCAPolicyTypeV1
22 [Documentation] Create an existing policy type with modification and keeping the same version should result in error.
23 CreatePolicyType /policy/api/v1/policytypes 406 onap.policy.monitoring.tcagen2.v1.json null null
24
25CreateTCAPolicyTypeV2
jhh9f9719e2022-08-17 19:20:27 -050026 [Documentation] Create an existing policy type with modification and keeping the same version should result in error.
27 CreatePolicyType /policy/api/v1/policytypes 406 onap.policy.monitoring.tcagen2.v2.json null null
28
29CreateTCAPolicyTypeV3
30 [Documentation] Create a policy type named 'onap.policies.monitoring.tcagen2' and version '3.0.0'
31 CreatePolicyType /policy/api/v1/policytypes 200 onap.policy.monitoring.tcagen2.v3.json onap.policies.monitoring.tcagen2 3.0.0
Jim Hahnb3a962f2021-05-12 11:33:43 -040032
33RetrieveMonitoringPolicyTypes
34 [Documentation] Retrieve all monitoring related policy types
35 FetchPolicyTypes /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2 2
36
37CreateNewMonitoringPolicyV1
38 [Documentation] Create a policy named 'onap.restart.tca' and version '1.0.0' using specific api
a.sreekumar60d6a082021-08-20 17:39:53 +010039 ${postjson}= Get file ${DATA}/vCPE.policy.monitoring.input.tosca.json
40 CreatePolicy /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/1.0.0/policies 200 ${postjson} onap.restart.tca 1.0.0
Jim Hahnb3a962f2021-05-12 11:33:43 -040041
42CreateNewMonitoringPolicyV1Again
43 [Documentation] Create an existing policy with modification and keeping the same version should result in error.
a.sreekumar60d6a082021-08-20 17:39:53 +010044 ${postjson}= Get file ${DATA}/vCPE.policy.monitoring.input.tosca.v1_2.json
45 CreatePolicy /policy/api/v1/policies 406 ${postjson} null null
Jim Hahnb3a962f2021-05-12 11:33:43 -040046
47CreateNewMonitoringPolicyV2
48 [Documentation] Create a policy named 'onap.restart.tca' and version '2.0.0' using generic api
a.sreekumar60d6a082021-08-20 17:39:53 +010049 ${postjson}= Get file ${DATA}/vCPE.policy.monitoring.input.tosca.v2.json
50 CreatePolicy /policy/api/v1/policies 200 ${postjson} onap.restart.tca 2.0.0
Jim Hahnb3a962f2021-05-12 11:33:43 -040051
rameshiyer27a8be1f72022-03-16 10:36:33 +000052CreateNodeTemplates
53 [Documentation] Create node templates in database using specific api
54 ${postjson}= Get file ${NODETEMPLATES}/nodetemplates.metadatasets.input.tosca.json
55 CreateNodeTemplate /policy/api/v1/nodetemplates 200 ${postjson} 3
56
Jim Hahnb3a962f2021-05-12 11:33:43 -040057RetrievePoliciesOfType
58 [Documentation] Retrieve all policies belonging to a specific Policy Type
59 FetchPolicies /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/1.0.0/policies 2
60
61RetrieveAllPolicies
62 [Documentation] Retrieve all policies
63 FetchPolicies /policy/api/v1/policies 3
64
65RetrieveSpecificPolicy
66 [Documentation] Retrieve a policy named 'onap.restart.tca' and version '1.0.0' using generic api
67 FetchPolicy /policy/api/v1/policies/onap.restart.tca/versions/1.0.0 onap.restart.tca
68
rameshiyer27a8be1f72022-03-16 10:36:33 +000069RetrieveAllNodeTemplates
70 [Documentation] Retrieve all node templates
71 FetchNodeTemplates /policy/api/v1/nodetemplates 3
72
73RetrieveSpecificNodeTemplate
74 [Documentation] Retrieve a node template named 'apexMetadata_grpc' and version '1.2.1' using generic api
75 FetchNodeTemplate /policy/api/v1/nodetemplates/apexMetadata_grpc/versions/1.2.1 apexMetadata_grpc
76
77DeleteSpecificNodeTemplate
78 [Documentation] Delete a node template named 'apexMetadata_adaptive' and version '2.3.1' using generic api
79 DeleteReq /policy/api/v1/nodetemplates/apexMetadata_adaptive/versions/2.3.1 200
80 DeleteReq /policy/api/v1/nodetemplates/apexMetadata_adaptive/versions/2.3.1 404
81
Jim Hahnb3a962f2021-05-12 11:33:43 -040082DeleteSpecificPolicy
83 [Documentation] Delete a policy named 'onap.restart.tca' and version '1.0.0' using generic api
adheli.tavares496b3012021-11-01 10:40:32 +000084 DeleteReq /policy/api/v1/policies/onap.restart.tca/versions/1.0.0 200
85 DeleteReq /policy/api/v1/policies/onap.restart.tca/versions/1.0.0 404
Jim Hahnb3a962f2021-05-12 11:33:43 -040086
87DeleteSpecificPolicyV2
88 [Documentation] Delete a policy named 'onap.restart.tca' and version '2.0.0' using specific api
adheli.tavares496b3012021-11-01 10:40:32 +000089 DeleteReq /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/1.0.0/policies/onap.restart.tca/versions/2.0.0 200
90 DeleteReq /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/1.0.0/policies/onap.restart.tca/versions/2.0.0 404
Jim Hahnb3a962f2021-05-12 11:33:43 -040091
92DeleteSpecificPolicyTypeV1
93 [Documentation] Delete a policy type named 'onap.policies.monitoring.tcagen2' and version '1.0.0'
adheli.tavares496b3012021-11-01 10:40:32 +000094 DeleteReq /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/1.0.0 200
95 DeleteReq /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/1.0.0 404
Jim Hahnb3a962f2021-05-12 11:33:43 -040096
97DeleteSpecificPolicyTypeV2
98 [Documentation] Delete a policy type named 'onap.policies.monitoring.tcagen2' and version '2.0.0'
adheli.tavares496b3012021-11-01 10:40:32 +000099 DeleteReq /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/2.0.0 200
100 DeleteReq /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/2.0.0 404
Jim Hahnb3a962f2021-05-12 11:33:43 -0400101
jhh9f9719e2022-08-17 19:20:27 -0500102DeleteSpecificPolicyTypeV3
103 [Documentation] Delete a policy type named 'onap.policies.monitoring.tcagen2' and version '3.0.0'
104 DeleteReq /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/3.0.0 200
105 DeleteReq /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/3.0.0 404
106
Prakhar Pandey3a348572022-03-25 15:46:19 -0400107Metrics
108 [Documentation] Verify policy-api is exporting prometheus metrics
109 ${auth}= PolicyAdminAuth
adheli.tavares1f339f82023-02-17 15:14:07 +0000110 ${resp}= GetMetrics ${POLICY_API_IP} ${auth} /policy/api/v1/
adheli.tavares43a40e12023-07-18 12:04:20 +0100111 Should Contain ${resp.text} http_server_requests_seconds_count{error="none",exception="none",method="GET",outcome="SUCCESS",status="200",uri="/healthcheck",} 1.0
112 Should Contain ${resp.text} http_server_requests_seconds_count{error="none",exception="none",method="GET",outcome="SUCCESS",status="200",uri="/policytypes",} 1.0
113 Should Contain ${resp.text} http_server_requests_seconds_count{error="none",exception="none",method="GET",outcome="SUCCESS",status="200",uri="/policies",} 1.0
114 Should Contain ${resp.text} http_server_requests_seconds_count{error="none",exception="none",method="GET",outcome="SUCCESS",status="200",uri="/policies/{policyId}/versions/{policyVersion}",} 1.0
115 Should Contain ${resp.text} http_server_requests_seconds_count{error="none",exception="none",method="GET",outcome="SUCCESS",status="200",uri="/policytypes/{policyTypeId}/versions/{policyTypeVersion}/policies",} 1.0
116 Should Contain ${resp.text} http_server_requests_seconds_count{error="none",exception="none",method="POST",outcome="SUCCESS",status="200",uri="/policytypes/{policyTypeId}/versions/{policyTypeVersion}/policies",} 1.0
117 Should Contain ${resp.text} http_server_requests_seconds_count{error="none",exception="none",method="POST",outcome="SUCCESS",status="200",uri="/policytypes",} 1.0
118 Should Contain ${resp.text} http_server_requests_seconds_count{error="none",exception="none",method="DELETE",outcome="SUCCESS",status="200",uri="/policies/{policyId}/versions/{policyVersion}",} 1.0
119 Should Contain ${resp.text} http_server_requests_seconds_count{error="none",exception="none",method="DELETE",outcome="SUCCESS",status="200",uri="/policytypes/{policyTypeId}/versions/{versionId}",} 3.0
120 Should Contain ${resp.text} http_server_requests_seconds_count{error="none",exception="none",method="DELETE",outcome="SUCCESS",status="200",uri="/policytypes/{policyTypeId}/versions/{policyTypeVersion}/policies/{policyId}/versions/{policyVersion}",} 1.0
Prakhar Pandey3a348572022-03-25 15:46:19 -0400121 Should Contain ${resp.text} http_server_requests_seconds_sum
122 Should Contain ${resp.text} http_server_requests_seconds_max
123 Should Contain ${resp.text} spring_data_repository_invocations_seconds_count
124 Should Contain ${resp.text} spring_data_repository_invocations_seconds_sum
125 Should Contain ${resp.text} spring_data_repository_invocations_seconds_max
126 Should Contain ${resp.text} jvm_threads_live_threads
127
Jim Hahnb3a962f2021-05-12 11:33:43 -0400128*** Keywords ***
129
adheli.tavares496b3012021-11-01 10:40:32 +0000130GetReq
131 [Arguments] ${url}
132 ${auth}= PolicyAdminAuth
adheli.tavares1f339f82023-02-17 15:14:07 +0000133 ${resp}= PerformGetRequest ${POLICY_API_IP} ${url} 200 null ${auth}
adheli.tavares8361cb02024-02-21 15:29:36 +0000134 RETURN ${resp}
adheli.tavares496b3012021-11-01 10:40:32 +0000135
136DeleteReq
137 [Arguments] ${url} ${expectedstatus}
138 ${auth}= PolicyAdminAuth
adheli.tavares1f339f82023-02-17 15:14:07 +0000139 ${resp}= PerformDeleteRequest ${POLICY_API_IP} ${url} ${expectedstatus} ${auth}
adheli.tavares8361cb02024-02-21 15:29:36 +0000140 RETURN ${resp}
adheli.tavares496b3012021-11-01 10:40:32 +0000141
Jim Hahnb3a962f2021-05-12 11:33:43 -0400142CreatePolicyType
143 [Arguments] ${url} ${expectedstatus} ${jsonfile} ${policytypename} ${policytypeversion}
144 [Documentation] Create the specific policy type
a.sreekumar60d6a082021-08-20 17:39:53 +0100145 ${postjson}= Get file ${CURDIR}/data/${jsonfile}
adheli.tavares496b3012021-11-01 10:40:32 +0000146 ${auth}= PolicyAdminAuth
adheli.tavares1f339f82023-02-17 15:14:07 +0000147 ${resp}= PerformPostRequest ${POLICY_API_IP} ${url} ${expectedstatus} ${postjson} null ${auth}
Jim Hahnb3a962f2021-05-12 11:33:43 -0400148 Run Keyword If ${expectedstatus}==200 List Should Contain Value ${resp.json()['policy_types']} ${policytypename}
149 Run Keyword If ${expectedstatus}==200 Should Be Equal As Strings ${resp.json()['policy_types']['${policytypename}']['version']} ${policytypeversion}
150
151FetchPolicyTypes
152 [Arguments] ${url} ${expectedLength}
153 [Documentation] Fetch all policy types
adheli.tavares496b3012021-11-01 10:40:32 +0000154 ${resp}= GetReq ${url}
Jim Hahnb3a962f2021-05-12 11:33:43 -0400155 Length Should Be ${resp.json()['policy_types']} ${expectedLength}
156
Jim Hahnb3a962f2021-05-12 11:33:43 -0400157FetchPolicy
158 [Arguments] ${url} ${keyword}
159 [Documentation] Fetch the specific policy
adheli.tavares496b3012021-11-01 10:40:32 +0000160 ${resp}= GetReq ${url}
Jim Hahnb3a962f2021-05-12 11:33:43 -0400161 Dictionary Should Contain Key ${resp.json()['topology_template']['policies'][0]} ${keyword}
162
163FetchPolicies
164 [Arguments] ${url} ${expectedLength}
165 [Documentation] Fetch all policies
adheli.tavares496b3012021-11-01 10:40:32 +0000166 ${resp}= GetReq ${url}
Jim Hahnb3a962f2021-05-12 11:33:43 -0400167 Length Should Be ${resp.json()['topology_template']['policies']} ${expectedLength}
rameshiyer27a8be1f72022-03-16 10:36:33 +0000168
169
170FetchNodeTemplates
171 [Arguments] ${url} ${expectedLength}
172 [Documentation] Fetch all node templates
173 ${resp}= GetReq ${url}
174 Length Should Be ${resp.json()} ${expectedLength}
175
176FetchNodeTemplate
177 [Arguments] ${url} ${keyword}
178 [Documentation] Fetch the specific node template
179 ${resp}= GetReq ${url}
jhh9f9719e2022-08-17 19:20:27 -0500180 Dictionary Should Contain Value ${resp.json()[0]} ${keyword}