blob: a585bc9763f938509fd4611d9df5cd73c10b7ca6 [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
adheli.tavares8361cb02024-02-21 15:29:36 +000011 RETURN ${policyadmin}
adheli.tavares496b3012021-11-01 10:40:32 +000012
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}
adheli.tavares8361cb02024-02-21 15:29:36 +000020 RETURN ${resp}
adheli.tavares496b3012021-11-01 10:40:32 +000021
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}
adheli.tavares8361cb02024-02-21 15:29:36 +000029 RETURN ${resp}
adheli.tavares496b3012021-11-01 10:40:32 +000030
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}
adheli.tavares8361cb02024-02-21 15:29:36 +000038 RETURN ${resp}
adheli.tavares496b3012021-11-01 10:40:32 +000039
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.tavares2ac4b6c2024-05-30 10:17:05 +010080 ${resp}= PerformGetRequest ${POLICY_PAP_IP} ${url} ${expectedstatus} recordCount=4 ${policyadmin}
rameshiyer27a8be1f72022-03-16 10:36:33 +000081 Log Received response from queryPolicyAudit ${resp.text}
82 FOR ${responseEntry} IN @{resp.json()}
adheli.tavares2ac4b6c2024-05-30 10:17:05 +010083 Exit For Loop IF '${responseEntry['policy']['name']}'=='${policyName}' and '${responseEntry['action']}'=='${expectedAction}'
rameshiyer27a8be1f72022-03-16 10:36:33 +000084 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}
adheli.tavares496b3012021-11-01 10:40:32 +0000103 Should Be Equal As Strings ${responseEntry['policy']['name']} ${policyName}
104 Should Be Equal As Strings ${responseEntry['policy']['version']} 1.0.0
105 Should Be Equal As Strings ${responseEntry['policyType']['name']} ${policyTypeName}
106 Should Be Equal As Strings ${responseEntry['policyType']['version']} 1.0.0
107 Should Be Equal As Strings ${responseEntry['deploy']} True
108 Should Be Equal As Strings ${responseEntry['state']} SUCCESS
a.sreekumar60d6a082021-08-20 17:39:53 +0100109
a.sreekumar67f7bd92022-02-14 13:51:34 +0000110GetMetrics
adheli.tavares1f339f82023-02-17 15:14:07 +0000111 [Arguments] ${domain} ${auth} ${context_path}
112 Log Creating session http://${domain}
113 ${session}= Create Session policy http://${domain} auth=${auth}
liamfallonc49f64d2023-01-19 15:30:30 +0000114 ${resp}= GET On Session policy ${context_path}metrics expected_status=200
a.sreekumar67f7bd92022-02-14 13:51:34 +0000115 Log Received response from policy ${resp.text}
adheli.tavares8361cb02024-02-21 15:29:36 +0000116 RETURN ${resp}
adheli.tavaresc6eb02a2023-02-02 08:44:51 +0000117
saul.gillbbf5f962024-06-25 17:42:22 +0100118VerifyTracingWorks
119 [Arguments] ${domain} ${service}
120 Log Creating session http://${domain}
121 ${session}= Create Session jaeger http://${domain}
122 ${resp}= GET On Session jaeger /api/traces params=service=${service} expected_status=200
123 Log Received response from jaeger ${resp.text}
124 RETURN ${resp}
125
126VerifyKafkaInTraces
127 [Arguments] ${domain} ${service}
128 Log Creating session http://${domain}
129 ${session}= Create Session jaeger http://${domain}
130 ${tags}= Create Dictionary otel.library.name=io.opentelemetry.kafka-clients-2.6 messaging.system=kafka
131 ${tags_json}= evaluate json.dumps(${tags}) json
132 ${params}= Create Dictionary service=${service} tags=${tags_json} operation=policy-acruntime-participant send lookback=1h limit=10
133 ${resp}= GET On Session jaeger /api/traces params=${params} expected_status=200
134 Log Received response from jaeger ${resp.text}
135 RETURN ${resp}
136
137VerifyHttpInTraces
138 [Arguments] ${domain} ${service}
139 Log Creating session http://${domain}
140 ${session}= Create Session jaeger http://${domain}
141 ${tags}= Create Dictionary uri=/v2/compositions/{compositionId}
142 ${tags_json}= evaluate json.dumps(${tags}) json
143 ${params}= Create Dictionary service=${service} tags=${tags_json} operation=http put /v2/compositions/{compositionId} lookback=1h limit=10
144 ${resp}= GET On Session jaeger /api/traces params=${params} expected_status=200
145 Log Received response from jaeger ${resp.text}
146 RETURN ${resp}
147
adheli.tavares9fc9fa42023-02-09 11:56:27 +0000148QueryPrometheus
149 [Arguments] ${query}
150 ${params}= Create Dictionary query=${query}
adheli.tavares1f339f82023-02-17 15:14:07 +0000151 ${resp}= GET http://${PROMETHEUS_IP}/api/v1/query ${params}
adheli.tavares9fc9fa42023-02-09 11:56:27 +0000152 Status Should Be OK
153 Log Received response from Prometheus ${resp.text}
adheli.tavares8361cb02024-02-21 15:29:36 +0000154 RETURN ${resp.json()}
adheli.tavares9fc9fa42023-02-09 11:56:27 +0000155
156ValidateResponseTime
157 [Arguments] ${job} ${uri} ${method} ${timeLimit}
158 [Documentation] Check if uri response is under the required time
159 ${resp}= QueryPrometheus http_server_requests_seconds_sum{uri="${uri}",method="${method}",job="${job}"}/http_server_requests_seconds_count{uri="${uri}",method="${method}",job="${job}"}
160 ${rawNumber}= Evaluate ${resp['data']['result'][0]['value'][1]}
161 ${actualTime}= Set Variable ${rawNumber * ${1000}}
162 Should Be True ${actualTime} <= ${timeLimit}
adheli.tavares1153b6d2023-02-28 12:59:37 +0000163
rameshiyer27f2609a32023-12-14 14:17:35 +0000164CheckKafkaTopic
165 [Arguments] ${topic} ${expected_status}
rameshiyer2731c61d42024-01-21 14:24:03 +0000166 ${resp}= Run Process ${CURDIR}/kafka_consumer.py ${topic} 60 ${expected_status} ${KAFKA_IP}
rameshiyer27f2e4da72024-01-13 21:26:09 +0000167 Should Contain ${resp.stdout} ${expected_status}
adheli.tavares8361cb02024-02-21 15:29:36 +0000168 RETURN ${resp.stdout}
rameshiyer27f2609a32023-12-14 14:17:35 +0000169
170GetKafkaTopic
171 [Arguments] ${topic}
rameshiyer2731c61d42024-01-21 14:24:03 +0000172 ${resp}= Run Process ${CURDIR}/make_topics.py ${topic} ${KAFKA_IP}