blob: a585bc9763f938509fd4611d9df5cd73c10b7ca6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
*** Settings ***
Library Collections
Library RequestsLibrary
Library OperatingSystem
Library json
*** Keywords ***
PolicyAdminAuth
${policyadmin}= Create list policyadmin zb!XztG34
RETURN ${policyadmin}
PerformPostRequest
[Arguments] ${domain} ${url} ${expectedstatus} ${postjson} ${params} ${auth}
Log Creating session http://${domain}
${session}= Create Session policy http://${domain} 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] ${domain} ${url} ${expectedstatus} ${params} ${auth}
Log Creating session http://${domain}
${session}= Create Session policy http://${domain} 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] ${domain} ${url} ${expectedstatus} ${params} ${auth}
Log Creating session http://${domain}
${session}= Create Session policy http://${domain} 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] ${domain} ${url} ${expectedstatus} ${auth}
Log Creating session http://${domain}
${session}= Create Session policy http://${domain} 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_IP} ${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_IP} ${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 - suphosts upto 2 groups
[Arguments] ${groupsLength} ${group1Name} ${group1State} ${policiesLengthInGroup1} ${group2Name} ${group2State} ${policiesLengthInGroup2}
${policyadmin}= PolicyAdminAuth
${resp}= PerformGetRequest ${POLICY_PAP_IP} /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_IP} ${url} ${expectedstatus} recordCount=4 ${policyadmin}
Log Received response from queryPolicyAudit ${resp.text}
FOR ${responseEntry} IN @{resp.json()}
Exit For Loop IF '${responseEntry['policy']['name']}'=='${policyName}' and '${responseEntry['action']}'=='${expectedAction}'
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_IP} /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['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] ${domain} ${auth} ${context_path}
Log Creating session http://${domain}
${session}= Create Session policy http://${domain} auth=${auth}
${resp}= GET On Session policy ${context_path}metrics expected_status=200
Log Received response from policy ${resp.text}
RETURN ${resp}
VerifyTracingWorks
[Arguments] ${domain} ${service}
Log Creating session http://${domain}
${session}= Create Session jaeger http://${domain}
${resp}= GET On Session jaeger /api/traces params=service=${service} expected_status=200
Log Received response from jaeger ${resp.text}
RETURN ${resp}
VerifyKafkaInTraces
[Arguments] ${domain} ${service}
Log Creating session http://${domain}
${session}= Create Session jaeger http://${domain}
${tags}= Create Dictionary otel.library.name=io.opentelemetry.kafka-clients-2.6 messaging.system=kafka
${tags_json}= evaluate json.dumps(${tags}) json
${params}= Create Dictionary service=${service} tags=${tags_json} operation=policy-acruntime-participant send lookback=1h limit=10
${resp}= GET On Session jaeger /api/traces params=${params} expected_status=200
Log Received response from jaeger ${resp.text}
RETURN ${resp}
VerifyHttpInTraces
[Arguments] ${domain} ${service}
Log Creating session http://${domain}
${session}= Create Session jaeger http://${domain}
${tags}= Create Dictionary uri=/v2/compositions/{compositionId}
${tags_json}= evaluate json.dumps(${tags}) json
${params}= Create Dictionary service=${service} tags=${tags_json} operation=http put /v2/compositions/{compositionId} lookback=1h limit=10
${resp}= GET On Session jaeger /api/traces params=${params} expected_status=200
Log Received response from jaeger ${resp.text}
RETURN ${resp}
QueryPrometheus
[Arguments] ${query}
${params}= Create Dictionary query=${query}
${resp}= GET http://${PROMETHEUS_IP}/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}
CheckKafkaTopic
[Arguments] ${topic} ${expected_status}
${resp}= Run Process ${CURDIR}/kafka_consumer.py ${topic} 60 ${expected_status} ${KAFKA_IP}
Should Contain ${resp.stdout} ${expected_status}
RETURN ${resp.stdout}
GetKafkaTopic
[Arguments] ${topic}
${resp}= Run Process ${CURDIR}/make_topics.py ${topic} ${KAFKA_IP}
|