This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
dongxiaoyan-tsg-autotest/02-Keyword/tsg_bfapi/dashboard_data_compare/PolicyEventHitTopN.robot

65 lines
3.6 KiB
Plaintext
Raw Normal View History

*** Settings ***
Library Collections
Library RequestsLibrary
Library String
Resource ../../../03-Variable/Bifangapivariable.txt
Resource ForTwoKeywords.robot
*** Keywords ***
SecurityEventHit
# dashboard界面 安全策略命中TopN bifang和bigData对比
[Documentation]
... 描述SecurityEventHit 安全策略命中TopN
... 参数starttime(必传,开始时间紧)
... limit(必传,限制条数)
... endtime(必传,结束时间)
... logType(必填,日志类型。)
... 返回:对比结果
[Arguments] ${starttime} ${endtime} ${limit}
${logType} Set Variable security_event_hits_log
${data} Set Variable startTime=${startTime}&endTime=${endTime}&logType=${logType}&limit=${limit}
${url1} Set Variable report/policyevent/hit/topn
${bfResponse} trafficBFRequest ${url1} ${data}
@{bfList} Set Variable ${bfResponse['data']['list']}
${bfListLength} Get Length ${bfList}
Create Session bdapi http://${bigDataIP}:${bigDataPort}
${sql} Set Variable select policy_id, action, sum(hits) as hits from security_event_hits_log \ where \ __time >='${startTime}' and __time < '${endTime}' \ group by policy_id, action \ order by hits desc limit ${limit}
${remoteResponse} Get Request bdapi ?query=${sql}
${response} to json ${remoteResponse.content}
Should Be Equal As Strings ${remoteResponse.status_code} 200
Should Be Equal As Strings ${response['status']} 200
@{list} Set Variable ${response['data']}
${listLength} Get Length ${list}
Should Be Equal As Integers ${bfListLength} ${listLength}
${types} Set Variable hits
Run Keyword If ${bfList}!=[] and ${list}!=[] ForToEventHitTopTrend ${bfList} ${types} ${list}
ProxyEventHit
# dashboard界面 代理策略命中TopN bifang和bigData对比
[Documentation]
... 描述ProxyEventHit 代理策略命中TopN
... 参数starttime(必传,开始时间紧)
... limit(必传,限制条数)
... endtime(必传,结束时间)
... logType(必填,日志类型。)
... 返回:对比结果
[Arguments] ${starttime} ${endtime} ${limit}
${logType} Set Variable proxy_event_hits_log
${data} Set Variable startTime=${startTime}&endTime=${endTime}&logType=${logType}&limit=${limit}
${url1} Set Variable report/policyevent/hit/topn
${bfResponse} trafficBFRequest ${url1} ${data}
@{bfList} Set Variable ${bfResponse['data']['list']}
${bfListLength} Get Length ${bfList}
Create Session bdapi http://${bigDataIP}:${bigDataPort}
${sql} Set Variable select \ policy_id, sub_action as \ action, sum(hits) as \ hits from \ proxy_event_hits_log \ where __time >= '${startTime}' and __time < '${endTime}' \ \ group by policy_id, sub_action order by hits desc limit ${limit}
${remoteResponse} Get Request bdapi ?query=${sql}
${response} to json ${remoteResponse.content}
Should Be Equal As Strings ${remoteResponse.status_code} 200
Should Be Equal As Strings ${response['status']} 200
@{list} Set Variable ${response['data']}
${listLength} Get Length ${list}
Should Be Equal As Integers ${bfListLength} ${listLength}
${types} Set Variable hits
Run Keyword If ${bfList}!=[] and ${list}!=[] ForToEventHitTopTrend ${bfList} ${types} ${list}