diff options
author | adheli.tavares <adheli.tavares@est.tech> | 2023-02-17 15:14:07 +0000 |
---|---|---|
committer | Adheli Tavares <adheli.tavares@est.tech> | 2023-02-22 13:22:48 +0000 |
commit | 1f339f886d01c6d6ac5cfd6467850c61fee4f675 (patch) | |
tree | 9c59715170d07c951421f5cf8f4d7d939e289c8b /csit/common-library.robot | |
parent | a6664dc5c767210a78f140b9fa149c2a8261b428 (diff) |
Restructure of csit files to be used both by docker and k8s config
Issue-ID: POLICY-4125
Change-Id: Id63b3badb1b451b36e3226970dcafaa5a62d860f
Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
Diffstat (limited to 'csit/common-library.robot')
-rw-r--r-- | csit/common-library.robot | 137 |
1 files changed, 0 insertions, 137 deletions
diff --git a/csit/common-library.robot b/csit/common-library.robot deleted file mode 100644 index 871e7efe..00000000 --- a/csit/common-library.robot +++ /dev/null @@ -1,137 +0,0 @@ -*** Settings *** -Library Collections -Library RequestsLibrary -Library OperatingSystem -Library json - -*** Keywords *** - -PolicyAdminAuth - ${policyadmin}= Create list policyadmin zb!XztG34 - [return] ${policyadmin} - -HealthCheckAuth - ${healthcheck}= Create list policyadmin zb!XztG34 - [return] ${healthcheck} - -PerformPostRequest - [Arguments] ${port} ${url} ${expectedstatus} ${postjson} ${params} ${auth} - Log Creating session http://localhost:${port} - ${session}= Create Session policy http://localhost:${port} auth=${auth} - ${headers}= Create Dictionary Accept=application/json Content-Type=application/json - ${resp}= POST On Session policy ${url} data=${postjson} params=${params} headers=${headers} expected_status=${expectedstatus} - Log Received response from policy ${resp.text} - [return] ${resp} - -PerformPutRequest - [Arguments] ${port} ${url} ${expectedstatus} ${params} ${auth} - Log Creating session http://localhost:${port} - ${session}= Create Session policy http://localhost:${port} auth=${auth} - ${headers}= Create Dictionary Accept=application/json Content-Type=application/json - ${resp}= PUT On Session policy ${url} params=${params} headers=${headers} expected_status=${expectedstatus} - Log Received response from policy ${resp.text} - [return] ${resp} - -PerformGetRequest - [Arguments] ${port} ${url} ${expectedstatus} ${params} ${auth} - Log Creating session http://localhost:${port} - ${session}= Create Session policy http://localhost:${port} auth=${auth} - ${headers}= Create Dictionary Accept=application/json Content-Type=application/json - ${resp}= GET On Session policy ${url} params=${params} headers=${headers} expected_status=${expectedstatus} - Log Received response from policy ${resp.text} - [return] ${resp} - -PerformDeleteRequest - [Arguments] ${port} ${url} ${expectedstatus} ${auth} - Log Creating session http://localhost:${port} - ${session}= Create Session policy http://localhost:${port} auth=${auth} - ${headers}= Create Dictionary Accept=application/json Content-Type=application/json - ${resp}= DELETE On Session policy ${url} headers=${headers} expected_status=${expectedstatus} - Log Received response from policy ${resp.text} - -CreatePolicy - [Arguments] ${url} ${expectedstatus} ${postjson} ${policyname} ${policyversion} - [Documentation] Create the specific policy - ${policyadmin}= PolicyAdminAuth - ${resp}= PerformPostRequest ${POLICY_API_PORT} ${url} ${expectedstatus} ${postjson} null ${policyadmin} - Run Keyword If ${expectedstatus}==200 Dictionary Should Contain Key ${resp.json()['topology_template']['policies'][0]} ${policyname} - Run Keyword If ${expectedstatus}==200 Should Be Equal As Strings ${resp.json()['topology_template']['policies'][0]['${policyname}']['version']} ${policyversion} - -CreateNodeTemplate - [Arguments] ${url} ${expectedstatus} ${postjson} ${nodeTemplateListLength} - [Documentation] Create the node templates - ${policyadmin}= PolicyAdminAuth - ${resp}= PerformPostRequest ${POLICY_API_PORT} ${url} ${expectedstatus} ${postjson} \ ${policyadmin} - Run Keyword If ${expectedstatus}==200 Length Should Be ${resp.json()['topology_template']['node_templates']} ${nodeTemplateListLength} - - -QueryPdpGroups - [Documentation] Verify pdp group query - supports upto 2 groups - [Arguments] ${groupsLength} ${group1Name} ${group1State} ${policiesLengthInGroup1} ${group2Name} ${group2State} ${policiesLengthInGroup2} - ${policyadmin}= PolicyAdminAuth - ${resp}= PerformGetRequest ${POLICY_PAP_PORT} /policy/pap/v1/pdps 200 null ${policyadmin} - Length Should Be ${resp.json()['groups']} ${groupsLength} - Should Be Equal As Strings ${resp.json()['groups'][0]['name']} ${group1Name} - Should Be Equal As Strings ${resp.json()['groups'][0]['pdpGroupState']} ${group1State} - Length Should Be ${resp.json()['groups'][0]['pdpSubgroups'][0]['policies']} ${policiesLengthInGroup1} - Run Keyword If ${groupsLength}>1 Should Be Equal As Strings ${resp.json()['groups'][1]['name']} ${group2Name} - Run Keyword If ${groupsLength}>1 Should Be Equal As Strings ${resp.json()['groups'][1]['pdpGroupState']} ${group2State} - Run Keyword If ${groupsLength}>1 Length Should Be ${resp.json()['groups'][1]['pdpSubgroups'][0]['policies']} ${policiesLengthInGroup2} - -QueryPolicyAudit - [Arguments] ${url} ${expectedstatus} ${pdpGroup} ${pdpType} ${policyName} ${expectedAction} - ${policyadmin}= PolicyAdminAuth - ${resp}= PerformGetRequest ${POLICY_PAP_PORT} ${url} ${expectedstatus} recordCount=2 ${policyadmin} - Log Received response from queryPolicyAudit ${resp.text} - FOR ${responseEntry} IN @{resp.json()} - Exit For Loop IF '${responseEntry['policy']['name']}'=='${policyName}' - END - Should Be Equal As Strings ${responseEntry['pdpGroup']} ${pdpGroup} - Should Be Equal As Strings ${responseEntry['pdpType']} ${pdpType} - Should Be Equal As Strings ${responseEntry['policy']['name']} ${policyName} - Should Be Equal As Strings ${responseEntry['policy']['version']} 1.0.0 - Should Be Equal As Strings ${responseEntry['action']} ${expectedAction} - Should Be Equal As Strings ${responseEntry['user']} policyadmin - -QueryPolicyStatus - [Documentation] Verify policy deployment status - [Arguments] ${policyName} ${pdpGroup} ${pdpType} ${pdpName} ${policyTypeName} - ${policyadmin}= PolicyAdminAuth - ${resp}= PerformGetRequest ${POLICY_PAP_PORT} /policy/pap/v1/policies/status 200 null ${policyadmin} - FOR ${responseEntry} IN @{resp.json()} - Exit For Loop IF '${responseEntry['policy']['name']}'=='${policyName}' - END - Should Be Equal As Strings ${resp.status_code} 200 - Should Be Equal As Strings ${responseEntry['pdpGroup']} ${pdpGroup} - Should Be Equal As Strings ${responseEntry['pdpType']} ${pdpType} - Should Be Equal As Strings ${responseEntry['pdpId']} ${pdpName} - Should Be Equal As Strings ${responseEntry['policy']['name']} ${policyName} - Should Be Equal As Strings ${responseEntry['policy']['version']} 1.0.0 - Should Be Equal As Strings ${responseEntry['policyType']['name']} ${policyTypeName} - Should Be Equal As Strings ${responseEntry['policyType']['version']} 1.0.0 - Should Be Equal As Strings ${responseEntry['deploy']} True - Should Be Equal As Strings ${responseEntry['state']} SUCCESS - -GetMetrics - [Arguments] ${port} ${auth} ${context_path} - Log Creating session http://localhost:${port} - ${session}= Create Session policy http://localhost:${port} auth=${auth} - ${resp}= GET On Session policy ${context_path}metrics expected_status=200 - Log Received response from policy ${resp.text} - [return] ${resp} - -QueryPrometheus - [Arguments] ${query} - ${params}= Create Dictionary query=${query} - ${resp}= GET http://localhost:30259/api/v1/query ${params} - Status Should Be OK - Log Received response from Prometheus ${resp.text} - [return] ${resp.json()} - -ValidateResponseTime - [Arguments] ${job} ${uri} ${method} ${timeLimit} - [Documentation] Check if uri response is under the required time - ${resp}= QueryPrometheus http_server_requests_seconds_sum{uri="${uri}",method="${method}",job="${job}"}/http_server_requests_seconds_count{uri="${uri}",method="${method}",job="${job}"} - ${rawNumber}= Evaluate ${resp['data']['result'][0]['value'][1]} - ${actualTime}= Set Variable ${rawNumber * ${1000}} - Should Be True ${actualTime} <= ${timeLimit} |