Add SLA validations to API 05/133405/2
authorwaynedunican <wayne.dunican@est.tech>
Fri, 24 Feb 2023 08:44:58 +0000 (08:44 +0000)
committerWayne Dunican <wayne.dunican@est.tech>
Mon, 27 Feb 2023 08:49:19 +0000 (08:49 +0000)
Issue-ID: POLICY-4528
Change-Id: I517cb477bbccb36d5e2000b60450a2c015d4940b
Signed-off-by: Wayne Dunican <wayne.dunican@est.tech>
csit/resources/scripts/setup-api.sh
csit/resources/tests/api-slas.robot [new file with mode: 0644]
csit/resources/tests/api-test.robot

index 2a98464..5a5cad2 100755 (executable)
@@ -28,7 +28,8 @@ unset http_proxy https_proxy
 # wait for the app to start up
 bash "${SCRIPTS}"/wait_for_rest.sh localhost ${API_PORT}
 
-export SUITES="api-test.robot"
+export SUITES="api-test.robot
+api-slas.robot"
 
 ROBOT_VARIABLES="-v POLICY_API_IP:localhost:${API_PORT} -v PROMETHEUS_IP:localhost:${PROMETHEUS_PORT}
 -v DATA:${DATA} -v NODETEMPLATES:${NODETEMPLATES}"
diff --git a/csit/resources/tests/api-slas.robot b/csit/resources/tests/api-slas.robot
new file mode 100644 (file)
index 0000000..c5feb72
--- /dev/null
@@ -0,0 +1,45 @@
+*** Settings ***
+Library    Collections
+Library    RequestsLibrary
+Library    OperatingSystem
+Library    json
+Resource    ${CURDIR}/common-library.robot
+
+*** Keywords ***
+ValidateResponseTimeForApi
+    [Arguments]  ${uri}  ${method}
+    [Documentation]  Check if uri response is under the 500ms required time for api metrics
+    ValidateResponseTime  api-metrics  ${uri}  ${method}  500
+
+*** Test Cases ***
+WaitForPrometheusServer
+    [Documentation]  Sleep time to wait for Prometheus server to gather all metrics
+    Sleep    1 minute
+
+ValidateResponseTimeForHealthcheck
+    [Documentation]  Validate component healthcheck response time
+    ValidateResponseTimeForApi  /healthcheck  GET
+
+ValidateResponseTimeForStatistics
+    [Documentation]  Validate statistics response time
+    ValidateResponseTimeForApi  /statistics  GET
+
+ValidateResponseTimeQueryPolicies
+    [Documentation]  Validate query policies response time
+    ValidateResponseTimeForApi  /policies  GET
+
+ValidateResponseTimeQueryPolicyVersion
+    [Documentation]  Validate query policy by version response time
+    ValidateResponseTimeForApi  /policies/{policyId}/versions/{policyVersion}  GET
+
+ValidateResponseTimeCreatePolicy
+    [Documentation]  Validate response time for creating a policy
+    ValidateResponseTimeForApi  /policytypes/{policyTypeId}/versions/{policyTypeVersion}/policies  POST
+
+ValidateResponseTimeCreatePolicyType
+    [Documentation]  Validate response time for creating a policyType
+    ValidateResponseTimeForApi  /policytypes  POST
+
+ValidateResponseTimeDeletePolicy
+    [Documentation]  Validate response time for deletion of policies
+    ValidateResponseTimeForApi  /policies/{policyId}/versions/{policyVersion}  DELETE
\ No newline at end of file
index e8679a7..f3c87de 100644 (file)
@@ -140,6 +140,11 @@ GetReq
      ${resp}=  PerformGetRequest  ${POLICY_API_IP}  ${url}  200  null  ${auth}
      [return]  ${resp}
 
+ValidateResponseTimeForApi
+    [Arguments]  ${url}  ${method}
+    [Documentation]  Check if url response is under required time for api metrics
+    ValidateResponseTime  api-metrics  ${url}  ${method}  500
+
 DeleteReq
      [Arguments]  ${url}  ${expectedstatus}
      ${auth}=  PolicyAdminAuth