Jim Hahn | b3a962f | 2021-05-12 11:33:43 -0400 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Library Collections |
| 3 | Library RequestsLibrary |
| 4 | Library OperatingSystem |
| 5 | Library json |
adheli.tavares | 1f339f8 | 2023-02-17 15:14:07 +0000 | [diff] [blame] | 6 | Resource ${CURDIR}/common-library.robot |
Jim Hahn | b3a962f | 2021-05-12 11:33:43 -0400 | [diff] [blame] | 7 | |
| 8 | *** Test Cases *** |
| 9 | |
| 10 | Healthcheck |
| 11 | [Documentation] Verify policy api health check |
adheli.tavares | 496b301 | 2021-11-01 10:40:32 +0000 | [diff] [blame] | 12 | ${resp}= GetReq /policy/api/v1/healthcheck |
Jim Hahn | b3a962f | 2021-05-12 11:33:43 -0400 | [diff] [blame] | 13 | Should Be Equal As Strings ${resp.json()['code']} 200 |
Prakhar Pandey | 3a34857 | 2022-03-25 15:46:19 -0400 | [diff] [blame] | 14 | Should Be Equal As Strings ${resp.json()['healthy']} True |
| 15 | Should Be Equal As Strings ${resp.json()['message']} alive |
a.sreekumar | 60d6a08 | 2021-08-20 17:39:53 +0100 | [diff] [blame] | 16 | |
Jim Hahn | b3a962f | 2021-05-12 11:33:43 -0400 | [diff] [blame] | 17 | RetrievePolicyTypes |
| 18 | [Documentation] Retrieve all policy types |
| 19 | FetchPolicyTypes /policy/api/v1/policytypes 37 |
| 20 | |
| 21 | CreateTCAPolicyTypeV1 |
| 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 | |
| 25 | CreateTCAPolicyTypeV2 |
jhh | 9f9719e | 2022-08-17 19:20:27 -0500 | [diff] [blame] | 26 | [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 | |
| 29 | CreateTCAPolicyTypeV3 |
| 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 Hahn | b3a962f | 2021-05-12 11:33:43 -0400 | [diff] [blame] | 32 | |
| 33 | RetrieveMonitoringPolicyTypes |
| 34 | [Documentation] Retrieve all monitoring related policy types |
| 35 | FetchPolicyTypes /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2 2 |
| 36 | |
| 37 | CreateNewMonitoringPolicyV1 |
| 38 | [Documentation] Create a policy named 'onap.restart.tca' and version '1.0.0' using specific api |
a.sreekumar | 60d6a08 | 2021-08-20 17:39:53 +0100 | [diff] [blame] | 39 | ${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 Hahn | b3a962f | 2021-05-12 11:33:43 -0400 | [diff] [blame] | 41 | |
| 42 | CreateNewMonitoringPolicyV1Again |
| 43 | [Documentation] Create an existing policy with modification and keeping the same version should result in error. |
a.sreekumar | 60d6a08 | 2021-08-20 17:39:53 +0100 | [diff] [blame] | 44 | ${postjson}= Get file ${DATA}/vCPE.policy.monitoring.input.tosca.v1_2.json |
| 45 | CreatePolicy /policy/api/v1/policies 406 ${postjson} null null |
Jim Hahn | b3a962f | 2021-05-12 11:33:43 -0400 | [diff] [blame] | 46 | |
| 47 | CreateNewMonitoringPolicyV2 |
| 48 | [Documentation] Create a policy named 'onap.restart.tca' and version '2.0.0' using generic api |
a.sreekumar | 60d6a08 | 2021-08-20 17:39:53 +0100 | [diff] [blame] | 49 | ${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 Hahn | b3a962f | 2021-05-12 11:33:43 -0400 | [diff] [blame] | 51 | |
rameshiyer27 | a8be1f7 | 2022-03-16 10:36:33 +0000 | [diff] [blame] | 52 | CreateNodeTemplates |
| 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 Hahn | b3a962f | 2021-05-12 11:33:43 -0400 | [diff] [blame] | 57 | RetrievePoliciesOfType |
| 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 | |
| 61 | RetrieveAllPolicies |
| 62 | [Documentation] Retrieve all policies |
| 63 | FetchPolicies /policy/api/v1/policies 3 |
| 64 | |
| 65 | RetrieveSpecificPolicy |
| 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 | |
rameshiyer27 | a8be1f7 | 2022-03-16 10:36:33 +0000 | [diff] [blame] | 69 | RetrieveAllNodeTemplates |
| 70 | [Documentation] Retrieve all node templates |
| 71 | FetchNodeTemplates /policy/api/v1/nodetemplates 3 |
| 72 | |
| 73 | RetrieveSpecificNodeTemplate |
| 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 | |
| 77 | DeleteSpecificNodeTemplate |
| 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 Hahn | b3a962f | 2021-05-12 11:33:43 -0400 | [diff] [blame] | 82 | DeleteSpecificPolicy |
| 83 | [Documentation] Delete a policy named 'onap.restart.tca' and version '1.0.0' using generic api |
adheli.tavares | 496b301 | 2021-11-01 10:40:32 +0000 | [diff] [blame] | 84 | 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 Hahn | b3a962f | 2021-05-12 11:33:43 -0400 | [diff] [blame] | 86 | |
| 87 | DeleteSpecificPolicyV2 |
| 88 | [Documentation] Delete a policy named 'onap.restart.tca' and version '2.0.0' using specific api |
adheli.tavares | 496b301 | 2021-11-01 10:40:32 +0000 | [diff] [blame] | 89 | 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 Hahn | b3a962f | 2021-05-12 11:33:43 -0400 | [diff] [blame] | 91 | |
| 92 | DeleteSpecificPolicyTypeV1 |
| 93 | [Documentation] Delete a policy type named 'onap.policies.monitoring.tcagen2' and version '1.0.0' |
adheli.tavares | 496b301 | 2021-11-01 10:40:32 +0000 | [diff] [blame] | 94 | 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 Hahn | b3a962f | 2021-05-12 11:33:43 -0400 | [diff] [blame] | 96 | |
| 97 | DeleteSpecificPolicyTypeV2 |
| 98 | [Documentation] Delete a policy type named 'onap.policies.monitoring.tcagen2' and version '2.0.0' |
adheli.tavares | 496b301 | 2021-11-01 10:40:32 +0000 | [diff] [blame] | 99 | 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 Hahn | b3a962f | 2021-05-12 11:33:43 -0400 | [diff] [blame] | 101 | |
jhh | 9f9719e | 2022-08-17 19:20:27 -0500 | [diff] [blame] | 102 | DeleteSpecificPolicyTypeV3 |
| 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 Pandey | 3a34857 | 2022-03-25 15:46:19 -0400 | [diff] [blame] | 107 | Metrics |
| 108 | [Documentation] Verify policy-api is exporting prometheus metrics |
| 109 | ${auth}= PolicyAdminAuth |
adheli.tavares | 1f339f8 | 2023-02-17 15:14:07 +0000 | [diff] [blame] | 110 | ${resp}= GetMetrics ${POLICY_API_IP} ${auth} /policy/api/v1/ |
adheli.tavares | 43a40e1 | 2023-07-18 12:04:20 +0100 | [diff] [blame] | 111 | 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 Pandey | 3a34857 | 2022-03-25 15:46:19 -0400 | [diff] [blame] | 121 | 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 Hahn | b3a962f | 2021-05-12 11:33:43 -0400 | [diff] [blame] | 128 | *** Keywords *** |
| 129 | |
adheli.tavares | 496b301 | 2021-11-01 10:40:32 +0000 | [diff] [blame] | 130 | GetReq |
| 131 | [Arguments] ${url} |
| 132 | ${auth}= PolicyAdminAuth |
adheli.tavares | 1f339f8 | 2023-02-17 15:14:07 +0000 | [diff] [blame] | 133 | ${resp}= PerformGetRequest ${POLICY_API_IP} ${url} 200 null ${auth} |
adheli.tavares | 8361cb0 | 2024-02-21 15:29:36 +0000 | [diff] [blame] | 134 | RETURN ${resp} |
adheli.tavares | 496b301 | 2021-11-01 10:40:32 +0000 | [diff] [blame] | 135 | |
| 136 | DeleteReq |
| 137 | [Arguments] ${url} ${expectedstatus} |
| 138 | ${auth}= PolicyAdminAuth |
adheli.tavares | 1f339f8 | 2023-02-17 15:14:07 +0000 | [diff] [blame] | 139 | ${resp}= PerformDeleteRequest ${POLICY_API_IP} ${url} ${expectedstatus} ${auth} |
adheli.tavares | 8361cb0 | 2024-02-21 15:29:36 +0000 | [diff] [blame] | 140 | RETURN ${resp} |
adheli.tavares | 496b301 | 2021-11-01 10:40:32 +0000 | [diff] [blame] | 141 | |
Jim Hahn | b3a962f | 2021-05-12 11:33:43 -0400 | [diff] [blame] | 142 | CreatePolicyType |
| 143 | [Arguments] ${url} ${expectedstatus} ${jsonfile} ${policytypename} ${policytypeversion} |
| 144 | [Documentation] Create the specific policy type |
a.sreekumar | 60d6a08 | 2021-08-20 17:39:53 +0100 | [diff] [blame] | 145 | ${postjson}= Get file ${CURDIR}/data/${jsonfile} |
adheli.tavares | 496b301 | 2021-11-01 10:40:32 +0000 | [diff] [blame] | 146 | ${auth}= PolicyAdminAuth |
adheli.tavares | 1f339f8 | 2023-02-17 15:14:07 +0000 | [diff] [blame] | 147 | ${resp}= PerformPostRequest ${POLICY_API_IP} ${url} ${expectedstatus} ${postjson} null ${auth} |
Jim Hahn | b3a962f | 2021-05-12 11:33:43 -0400 | [diff] [blame] | 148 | 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 | |
| 151 | FetchPolicyTypes |
| 152 | [Arguments] ${url} ${expectedLength} |
| 153 | [Documentation] Fetch all policy types |
adheli.tavares | 496b301 | 2021-11-01 10:40:32 +0000 | [diff] [blame] | 154 | ${resp}= GetReq ${url} |
Jim Hahn | b3a962f | 2021-05-12 11:33:43 -0400 | [diff] [blame] | 155 | Length Should Be ${resp.json()['policy_types']} ${expectedLength} |
| 156 | |
Jim Hahn | b3a962f | 2021-05-12 11:33:43 -0400 | [diff] [blame] | 157 | FetchPolicy |
| 158 | [Arguments] ${url} ${keyword} |
| 159 | [Documentation] Fetch the specific policy |
adheli.tavares | 496b301 | 2021-11-01 10:40:32 +0000 | [diff] [blame] | 160 | ${resp}= GetReq ${url} |
Jim Hahn | b3a962f | 2021-05-12 11:33:43 -0400 | [diff] [blame] | 161 | Dictionary Should Contain Key ${resp.json()['topology_template']['policies'][0]} ${keyword} |
| 162 | |
| 163 | FetchPolicies |
| 164 | [Arguments] ${url} ${expectedLength} |
| 165 | [Documentation] Fetch all policies |
adheli.tavares | 496b301 | 2021-11-01 10:40:32 +0000 | [diff] [blame] | 166 | ${resp}= GetReq ${url} |
Jim Hahn | b3a962f | 2021-05-12 11:33:43 -0400 | [diff] [blame] | 167 | Length Should Be ${resp.json()['topology_template']['policies']} ${expectedLength} |
rameshiyer27 | a8be1f7 | 2022-03-16 10:36:33 +0000 | [diff] [blame] | 168 | |
| 169 | |
| 170 | FetchNodeTemplates |
| 171 | [Arguments] ${url} ${expectedLength} |
| 172 | [Documentation] Fetch all node templates |
| 173 | ${resp}= GetReq ${url} |
| 174 | Length Should Be ${resp.json()} ${expectedLength} |
| 175 | |
| 176 | FetchNodeTemplate |
| 177 | [Arguments] ${url} ${keyword} |
| 178 | [Documentation] Fetch the specific node template |
| 179 | ${resp}= GetReq ${url} |
jhh | 9f9719e | 2022-08-17 19:20:27 -0500 | [diff] [blame] | 180 | Dictionary Should Contain Value ${resp.json()[0]} ${keyword} |