blob: c43b5dca805d05c334088e8bffd06e4e1c14080c [file] [log] [blame]
a.sreekumar60d6a082021-08-20 17:39:53 +01001*** Settings ***
2Library Collections
3Library RequestsLibrary
4Library OperatingSystem
5Library json
6
a.sreekumar60d6a082021-08-20 17:39:53 +01007*** Keywords ***
8
adheli.tavares496b3012021-11-01 10:40:32 +00009PolicyAdminAuth
10 ${policyadmin}= Create list policyadmin zb!XztG34
11 [return] ${policyadmin}
12
adheli.tavares496b3012021-11-01 10:40:32 +000013PerformPostRequest
adheli.tavares1f339f82023-02-17 15:14:07 +000014 [Arguments] ${domain} ${url} ${expectedstatus} ${postjson} ${params} ${auth}
15 Log Creating session http://${domain}
16 ${session}= Create Session policy http://${domain} auth=${auth}
adheli.tavares496b3012021-11-01 10:40:32 +000017 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
18 ${resp}= POST On Session policy ${url} data=${postjson} params=${params} headers=${headers} expected_status=${expectedstatus}
19 Log Received response from policy ${resp.text}
20 [return] ${resp}
21
22PerformPutRequest
adheli.tavares1f339f82023-02-17 15:14:07 +000023 [Arguments] ${domain} ${url} ${expectedstatus} ${params} ${auth}
24 Log Creating session http://${domain}
25 ${session}= Create Session policy http://${domain} auth=${auth}
adheli.tavares496b3012021-11-01 10:40:32 +000026 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
27 ${resp}= PUT On Session policy ${url} params=${params} headers=${headers} expected_status=${expectedstatus}
28 Log Received response from policy ${resp.text}
29 [return] ${resp}
30
31PerformGetRequest
adheli.tavares1f339f82023-02-17 15:14:07 +000032 [Arguments] ${domain} ${url} ${expectedstatus} ${params} ${auth}
33 Log Creating session http://${domain}
34 ${session}= Create Session policy http://${domain} auth=${auth}
adheli.tavares496b3012021-11-01 10:40:32 +000035 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
36 ${resp}= GET On Session policy ${url} params=${params} headers=${headers} expected_status=${expectedstatus}
37 Log Received response from policy ${resp.text}
38 [return] ${resp}
39
40PerformDeleteRequest
adheli.tavares1f339f82023-02-17 15:14:07 +000041 [Arguments] ${domain} ${url} ${expectedstatus} ${auth}
42 Log Creating session http://${domain}
43 ${session}= Create Session policy http://${domain} auth=${auth}
adheli.tavares496b3012021-11-01 10:40:32 +000044 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
45 ${resp}= DELETE On Session policy ${url} headers=${headers} expected_status=${expectedstatus}
46 Log Received response from policy ${resp.text}
47
a.sreekumar60d6a082021-08-20 17:39:53 +010048CreatePolicy
49 [Arguments] ${url} ${expectedstatus} ${postjson} ${policyname} ${policyversion}
50 [Documentation] Create the specific policy
adheli.tavares496b3012021-11-01 10:40:32 +000051 ${policyadmin}= PolicyAdminAuth
adheli.tavares1f339f82023-02-17 15:14:07 +000052 ${resp}= PerformPostRequest ${POLICY_API_IP} ${url} ${expectedstatus} ${postjson} null ${policyadmin}
a.sreekumar60d6a082021-08-20 17:39:53 +010053 Run Keyword If ${expectedstatus}==200 Dictionary Should Contain Key ${resp.json()['topology_template']['policies'][0]} ${policyname}
54 Run Keyword If ${expectedstatus}==200 Should Be Equal As Strings ${resp.json()['topology_template']['policies'][0]['${policyname}']['version']} ${policyversion}
55
rameshiyer27a8be1f72022-03-16 10:36:33 +000056CreateNodeTemplate
57 [Arguments] ${url} ${expectedstatus} ${postjson} ${nodeTemplateListLength}
58 [Documentation] Create the node templates
59 ${policyadmin}= PolicyAdminAuth
adheli.tavares1f339f82023-02-17 15:14:07 +000060 ${resp}= PerformPostRequest ${POLICY_API_IP} ${url} ${expectedstatus} ${postjson} \ ${policyadmin}
rameshiyer27a8be1f72022-03-16 10:36:33 +000061 Run Keyword If ${expectedstatus}==200 Length Should Be ${resp.json()['topology_template']['node_templates']} ${nodeTemplateListLength}
62
63
a.sreekumar60d6a082021-08-20 17:39:53 +010064QueryPdpGroups
adheli.tavares1f339f82023-02-17 15:14:07 +000065 [Documentation] Verify pdp group query - suphosts upto 2 groups
a.sreekumar60d6a082021-08-20 17:39:53 +010066 [Arguments] ${groupsLength} ${group1Name} ${group1State} ${policiesLengthInGroup1} ${group2Name} ${group2State} ${policiesLengthInGroup2}
adheli.tavares496b3012021-11-01 10:40:32 +000067 ${policyadmin}= PolicyAdminAuth
adheli.tavares1f339f82023-02-17 15:14:07 +000068 ${resp}= PerformGetRequest ${POLICY_PAP_IP} /policy/pap/v1/pdps 200 null ${policyadmin}
a.sreekumar60d6a082021-08-20 17:39:53 +010069 Length Should Be ${resp.json()['groups']} ${groupsLength}
70 Should Be Equal As Strings ${resp.json()['groups'][0]['name']} ${group1Name}
71 Should Be Equal As Strings ${resp.json()['groups'][0]['pdpGroupState']} ${group1State}
72 Length Should Be ${resp.json()['groups'][0]['pdpSubgroups'][0]['policies']} ${policiesLengthInGroup1}
73 Run Keyword If ${groupsLength}>1 Should Be Equal As Strings ${resp.json()['groups'][1]['name']} ${group2Name}
74 Run Keyword If ${groupsLength}>1 Should Be Equal As Strings ${resp.json()['groups'][1]['pdpGroupState']} ${group2State}
75 Run Keyword If ${groupsLength}>1 Length Should Be ${resp.json()['groups'][1]['pdpSubgroups'][0]['policies']} ${policiesLengthInGroup2}
76
77QueryPolicyAudit
78 [Arguments] ${url} ${expectedstatus} ${pdpGroup} ${pdpType} ${policyName} ${expectedAction}
adheli.tavares496b3012021-11-01 10:40:32 +000079 ${policyadmin}= PolicyAdminAuth
adheli.tavares1f339f82023-02-17 15:14:07 +000080 ${resp}= PerformGetRequest ${POLICY_PAP_IP} ${url} ${expectedstatus} recordCount=2 ${policyadmin}
rameshiyer27a8be1f72022-03-16 10:36:33 +000081 Log Received response from queryPolicyAudit ${resp.text}
82 FOR ${responseEntry} IN @{resp.json()}
83 Exit For Loop IF '${responseEntry['policy']['name']}'=='${policyName}'
84 END
85 Should Be Equal As Strings ${responseEntry['pdpGroup']} ${pdpGroup}
86 Should Be Equal As Strings ${responseEntry['pdpType']} ${pdpType}
87 Should Be Equal As Strings ${responseEntry['policy']['name']} ${policyName}
88 Should Be Equal As Strings ${responseEntry['policy']['version']} 1.0.0
89 Should Be Equal As Strings ${responseEntry['action']} ${expectedAction}
90 Should Be Equal As Strings ${responseEntry['user']} policyadmin
a.sreekumar60d6a082021-08-20 17:39:53 +010091
92QueryPolicyStatus
adheli.tavares496b3012021-11-01 10:40:32 +000093 [Documentation] Verify policy deployment status
94 [Arguments] ${policyName} ${pdpGroup} ${pdpType} ${pdpName} ${policyTypeName}
95 ${policyadmin}= PolicyAdminAuth
adheli.tavares1f339f82023-02-17 15:14:07 +000096 ${resp}= PerformGetRequest ${POLICY_PAP_IP} /policy/pap/v1/policies/status 200 null ${policyadmin}
adheli.tavares496b3012021-11-01 10:40:32 +000097 FOR ${responseEntry} IN @{resp.json()}
98 Exit For Loop IF '${responseEntry['policy']['name']}'=='${policyName}'
99 END
100 Should Be Equal As Strings ${resp.status_code} 200
101 Should Be Equal As Strings ${responseEntry['pdpGroup']} ${pdpGroup}
102 Should Be Equal As Strings ${responseEntry['pdpType']} ${pdpType}
103 Should Be Equal As Strings ${responseEntry['pdpId']} ${pdpName}
104 Should Be Equal As Strings ${responseEntry['policy']['name']} ${policyName}
105 Should Be Equal As Strings ${responseEntry['policy']['version']} 1.0.0
106 Should Be Equal As Strings ${responseEntry['policyType']['name']} ${policyTypeName}
107 Should Be Equal As Strings ${responseEntry['policyType']['version']} 1.0.0
108 Should Be Equal As Strings ${responseEntry['deploy']} True
109 Should Be Equal As Strings ${responseEntry['state']} SUCCESS
a.sreekumar60d6a082021-08-20 17:39:53 +0100110
a.sreekumar67f7bd92022-02-14 13:51:34 +0000111GetMetrics
adheli.tavares1f339f82023-02-17 15:14:07 +0000112 [Arguments] ${domain} ${auth} ${context_path}
113 Log Creating session http://${domain}
114 ${session}= Create Session policy http://${domain} auth=${auth}
liamfallonc49f64d2023-01-19 15:30:30 +0000115 ${resp}= GET On Session policy ${context_path}metrics expected_status=200
a.sreekumar67f7bd92022-02-14 13:51:34 +0000116 Log Received response from policy ${resp.text}
117 [return] ${resp}
adheli.tavaresc6eb02a2023-02-02 08:44:51 +0000118
adheli.tavares9fc9fa42023-02-09 11:56:27 +0000119QueryPrometheus
120 [Arguments] ${query}
121 ${params}= Create Dictionary query=${query}
adheli.tavares1f339f82023-02-17 15:14:07 +0000122 ${resp}= GET http://${PROMETHEUS_IP}/api/v1/query ${params}
adheli.tavares9fc9fa42023-02-09 11:56:27 +0000123 Status Should Be OK
124 Log Received response from Prometheus ${resp.text}
125 [return] ${resp.json()}
126
127ValidateResponseTime
128 [Arguments] ${job} ${uri} ${method} ${timeLimit}
129 [Documentation] Check if uri response is under the required time
130 ${resp}= QueryPrometheus http_server_requests_seconds_sum{uri="${uri}",method="${method}",job="${job}"}/http_server_requests_seconds_count{uri="${uri}",method="${method}",job="${job}"}
131 ${rawNumber}= Evaluate ${resp['data']['result'][0]['value'][1]}
132 ${actualTime}= Set Variable ${rawNumber * ${1000}}
133 Should Be True ${actualTime} <= ${timeLimit}
adheli.tavares1153b6d2023-02-28 12:59:37 +0000134
135GetTopic
136 [Arguments] ${topic}
137 Create Session session http://${DMAAP_IP} max_retries=1
138 ${params}= Create Dictionary limit 1 timeout 0
139 ${resp}= GET On Session session /events/${topic}/script/1 ${params}
140 Status Should Be OK ${resp}
141
142CheckTopic
143 [Arguments] ${topic} ${expected_status}
144 Create Session session http://${DMAAP_IP} max_retries=1
145 ${params}= Create Dictionary limit 1
146 ${resp}= GET On Session session /events/${topic}/script/1 ${params}
147 Log Received response from dmaap ${resp.text}
148 Status Should Be OK ${resp}
149 Should Contain ${resp.text} ${expected_status}
150 [Return] ${resp.text}