a.sreekumar | 60d6a08 | 2021-08-20 17:39:53 +0100 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Library Collections |
| 3 | Library RequestsLibrary |
| 4 | Library OperatingSystem |
| 5 | Library json |
| 6 | |
a.sreekumar | 60d6a08 | 2021-08-20 17:39:53 +0100 | [diff] [blame] | 7 | *** Keywords *** |
| 8 | |
adheli.tavares | 496b301 | 2021-11-01 10:40:32 +0000 | [diff] [blame] | 9 | PolicyAdminAuth |
| 10 | ${policyadmin}= Create list policyadmin zb!XztG34 |
adheli.tavares | 8361cb0 | 2024-02-21 15:29:36 +0000 | [diff] [blame] | 11 | RETURN ${policyadmin} |
adheli.tavares | 496b301 | 2021-11-01 10:40:32 +0000 | [diff] [blame] | 12 | |
adheli.tavares | 496b301 | 2021-11-01 10:40:32 +0000 | [diff] [blame] | 13 | PerformPostRequest |
adheli.tavares | 1f339f8 | 2023-02-17 15:14:07 +0000 | [diff] [blame] | 14 | [Arguments] ${domain} ${url} ${expectedstatus} ${postjson} ${params} ${auth} |
| 15 | Log Creating session http://${domain} |
| 16 | ${session}= Create Session policy http://${domain} auth=${auth} |
adheli.tavares | 496b301 | 2021-11-01 10:40:32 +0000 | [diff] [blame] | 17 | ${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.tavares | 8361cb0 | 2024-02-21 15:29:36 +0000 | [diff] [blame] | 20 | RETURN ${resp} |
adheli.tavares | 496b301 | 2021-11-01 10:40:32 +0000 | [diff] [blame] | 21 | |
| 22 | PerformPutRequest |
adheli.tavares | 1f339f8 | 2023-02-17 15:14:07 +0000 | [diff] [blame] | 23 | [Arguments] ${domain} ${url} ${expectedstatus} ${params} ${auth} |
| 24 | Log Creating session http://${domain} |
| 25 | ${session}= Create Session policy http://${domain} auth=${auth} |
adheli.tavares | 496b301 | 2021-11-01 10:40:32 +0000 | [diff] [blame] | 26 | ${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.tavares | 8361cb0 | 2024-02-21 15:29:36 +0000 | [diff] [blame] | 29 | RETURN ${resp} |
adheli.tavares | 496b301 | 2021-11-01 10:40:32 +0000 | [diff] [blame] | 30 | |
| 31 | PerformGetRequest |
adheli.tavares | 1f339f8 | 2023-02-17 15:14:07 +0000 | [diff] [blame] | 32 | [Arguments] ${domain} ${url} ${expectedstatus} ${params} ${auth} |
| 33 | Log Creating session http://${domain} |
| 34 | ${session}= Create Session policy http://${domain} auth=${auth} |
adheli.tavares | 496b301 | 2021-11-01 10:40:32 +0000 | [diff] [blame] | 35 | ${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.tavares | 8361cb0 | 2024-02-21 15:29:36 +0000 | [diff] [blame] | 38 | RETURN ${resp} |
adheli.tavares | 496b301 | 2021-11-01 10:40:32 +0000 | [diff] [blame] | 39 | |
| 40 | PerformDeleteRequest |
adheli.tavares | 1f339f8 | 2023-02-17 15:14:07 +0000 | [diff] [blame] | 41 | [Arguments] ${domain} ${url} ${expectedstatus} ${auth} |
| 42 | Log Creating session http://${domain} |
| 43 | ${session}= Create Session policy http://${domain} auth=${auth} |
adheli.tavares | 496b301 | 2021-11-01 10:40:32 +0000 | [diff] [blame] | 44 | ${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.sreekumar | 60d6a08 | 2021-08-20 17:39:53 +0100 | [diff] [blame] | 48 | CreatePolicy |
| 49 | [Arguments] ${url} ${expectedstatus} ${postjson} ${policyname} ${policyversion} |
| 50 | [Documentation] Create the specific policy |
adheli.tavares | 496b301 | 2021-11-01 10:40:32 +0000 | [diff] [blame] | 51 | ${policyadmin}= PolicyAdminAuth |
adheli.tavares | 1f339f8 | 2023-02-17 15:14:07 +0000 | [diff] [blame] | 52 | ${resp}= PerformPostRequest ${POLICY_API_IP} ${url} ${expectedstatus} ${postjson} null ${policyadmin} |
a.sreekumar | 60d6a08 | 2021-08-20 17:39:53 +0100 | [diff] [blame] | 53 | 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 | |
rameshiyer27 | a8be1f7 | 2022-03-16 10:36:33 +0000 | [diff] [blame] | 56 | CreateNodeTemplate |
| 57 | [Arguments] ${url} ${expectedstatus} ${postjson} ${nodeTemplateListLength} |
| 58 | [Documentation] Create the node templates |
| 59 | ${policyadmin}= PolicyAdminAuth |
adheli.tavares | 1f339f8 | 2023-02-17 15:14:07 +0000 | [diff] [blame] | 60 | ${resp}= PerformPostRequest ${POLICY_API_IP} ${url} ${expectedstatus} ${postjson} \ ${policyadmin} |
rameshiyer27 | a8be1f7 | 2022-03-16 10:36:33 +0000 | [diff] [blame] | 61 | Run Keyword If ${expectedstatus}==200 Length Should Be ${resp.json()['topology_template']['node_templates']} ${nodeTemplateListLength} |
| 62 | |
| 63 | |
a.sreekumar | 60d6a08 | 2021-08-20 17:39:53 +0100 | [diff] [blame] | 64 | QueryPdpGroups |
adheli.tavares | 1f339f8 | 2023-02-17 15:14:07 +0000 | [diff] [blame] | 65 | [Documentation] Verify pdp group query - suphosts upto 2 groups |
a.sreekumar | 60d6a08 | 2021-08-20 17:39:53 +0100 | [diff] [blame] | 66 | [Arguments] ${groupsLength} ${group1Name} ${group1State} ${policiesLengthInGroup1} ${group2Name} ${group2State} ${policiesLengthInGroup2} |
adheli.tavares | 496b301 | 2021-11-01 10:40:32 +0000 | [diff] [blame] | 67 | ${policyadmin}= PolicyAdminAuth |
adheli.tavares | 1f339f8 | 2023-02-17 15:14:07 +0000 | [diff] [blame] | 68 | ${resp}= PerformGetRequest ${POLICY_PAP_IP} /policy/pap/v1/pdps 200 null ${policyadmin} |
a.sreekumar | 60d6a08 | 2021-08-20 17:39:53 +0100 | [diff] [blame] | 69 | 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 | |
| 77 | QueryPolicyAudit |
| 78 | [Arguments] ${url} ${expectedstatus} ${pdpGroup} ${pdpType} ${policyName} ${expectedAction} |
adheli.tavares | 496b301 | 2021-11-01 10:40:32 +0000 | [diff] [blame] | 79 | ${policyadmin}= PolicyAdminAuth |
adheli.tavares | 2ac4b6c | 2024-05-30 10:17:05 +0100 | [diff] [blame] | 80 | ${resp}= PerformGetRequest ${POLICY_PAP_IP} ${url} ${expectedstatus} recordCount=4 ${policyadmin} |
rameshiyer27 | a8be1f7 | 2022-03-16 10:36:33 +0000 | [diff] [blame] | 81 | Log Received response from queryPolicyAudit ${resp.text} |
| 82 | FOR ${responseEntry} IN @{resp.json()} |
adheli.tavares | 2ac4b6c | 2024-05-30 10:17:05 +0100 | [diff] [blame] | 83 | Exit For Loop IF '${responseEntry['policy']['name']}'=='${policyName}' and '${responseEntry['action']}'=='${expectedAction}' |
rameshiyer27 | a8be1f7 | 2022-03-16 10:36:33 +0000 | [diff] [blame] | 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.sreekumar | 60d6a08 | 2021-08-20 17:39:53 +0100 | [diff] [blame] | 91 | |
| 92 | QueryPolicyStatus |
adheli.tavares | 496b301 | 2021-11-01 10:40:32 +0000 | [diff] [blame] | 93 | [Documentation] Verify policy deployment status |
| 94 | [Arguments] ${policyName} ${pdpGroup} ${pdpType} ${pdpName} ${policyTypeName} |
| 95 | ${policyadmin}= PolicyAdminAuth |
adheli.tavares | 1f339f8 | 2023-02-17 15:14:07 +0000 | [diff] [blame] | 96 | ${resp}= PerformGetRequest ${POLICY_PAP_IP} /policy/pap/v1/policies/status 200 null ${policyadmin} |
adheli.tavares | 496b301 | 2021-11-01 10:40:32 +0000 | [diff] [blame] | 97 | 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.tavares | 496b301 | 2021-11-01 10:40:32 +0000 | [diff] [blame] | 103 | 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.sreekumar | 60d6a08 | 2021-08-20 17:39:53 +0100 | [diff] [blame] | 109 | |
a.sreekumar | 67f7bd9 | 2022-02-14 13:51:34 +0000 | [diff] [blame] | 110 | GetMetrics |
adheli.tavares | 1f339f8 | 2023-02-17 15:14:07 +0000 | [diff] [blame] | 111 | [Arguments] ${domain} ${auth} ${context_path} |
| 112 | Log Creating session http://${domain} |
| 113 | ${session}= Create Session policy http://${domain} auth=${auth} |
liamfallon | c49f64d | 2023-01-19 15:30:30 +0000 | [diff] [blame] | 114 | ${resp}= GET On Session policy ${context_path}metrics expected_status=200 |
a.sreekumar | 67f7bd9 | 2022-02-14 13:51:34 +0000 | [diff] [blame] | 115 | Log Received response from policy ${resp.text} |
adheli.tavares | 8361cb0 | 2024-02-21 15:29:36 +0000 | [diff] [blame] | 116 | RETURN ${resp} |
adheli.tavares | c6eb02a | 2023-02-02 08:44:51 +0000 | [diff] [blame] | 117 | |
saul.gill | bbf5f96 | 2024-06-25 17:42:22 +0100 | [diff] [blame] | 118 | VerifyTracingWorks |
| 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 | |
| 126 | VerifyKafkaInTraces |
| 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 | |
| 137 | VerifyHttpInTraces |
| 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.tavares | 9fc9fa4 | 2023-02-09 11:56:27 +0000 | [diff] [blame] | 148 | QueryPrometheus |
| 149 | [Arguments] ${query} |
| 150 | ${params}= Create Dictionary query=${query} |
adheli.tavares | 1f339f8 | 2023-02-17 15:14:07 +0000 | [diff] [blame] | 151 | ${resp}= GET http://${PROMETHEUS_IP}/api/v1/query ${params} |
adheli.tavares | 9fc9fa4 | 2023-02-09 11:56:27 +0000 | [diff] [blame] | 152 | Status Should Be OK |
| 153 | Log Received response from Prometheus ${resp.text} |
adheli.tavares | 8361cb0 | 2024-02-21 15:29:36 +0000 | [diff] [blame] | 154 | RETURN ${resp.json()} |
adheli.tavares | 9fc9fa4 | 2023-02-09 11:56:27 +0000 | [diff] [blame] | 155 | |
| 156 | ValidateResponseTime |
| 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.tavares | 1153b6d | 2023-02-28 12:59:37 +0000 | [diff] [blame] | 163 | |
rameshiyer27 | f2609a3 | 2023-12-14 14:17:35 +0000 | [diff] [blame] | 164 | CheckKafkaTopic |
| 165 | [Arguments] ${topic} ${expected_status} |
rameshiyer27 | 31c61d4 | 2024-01-21 14:24:03 +0000 | [diff] [blame] | 166 | ${resp}= Run Process ${CURDIR}/kafka_consumer.py ${topic} 60 ${expected_status} ${KAFKA_IP} |
rameshiyer27 | f2e4da7 | 2024-01-13 21:26:09 +0000 | [diff] [blame] | 167 | Should Contain ${resp.stdout} ${expected_status} |
adheli.tavares | 8361cb0 | 2024-02-21 15:29:36 +0000 | [diff] [blame] | 168 | RETURN ${resp.stdout} |
rameshiyer27 | f2609a3 | 2023-12-14 14:17:35 +0000 | [diff] [blame] | 169 | |
| 170 | GetKafkaTopic |
| 171 | [Arguments] ${topic} |
rameshiyer27 | 31c61d4 | 2024-01-21 14:24:03 +0000 | [diff] [blame] | 172 | ${resp}= Run Process ${CURDIR}/make_topics.py ${topic} ${KAFKA_IP} |