dashboard页面 毕方和大数据 对比用例,需要安装DateTime库,
命令为pip install DateTime
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
*** Settings ***
|
||||
Library Collections
|
||||
Library RequestsLibrary
|
||||
Library String
|
||||
Resource ../../../03-Variable/Bifangapivariable.txt
|
||||
Resource ForTwoKeywords.robot
|
||||
|
||||
*** Keywords ***
|
||||
SecurityEventHit
|
||||
# dashboard界面 安全策略命中TopN bifang和bigData对比
|
||||
[Documentation]
|
||||
... 描述:SecurityEventHit 安全策略命中TopN
|
||||
... 参数:timeNum(必传,查询的时间范围类型 1 当前时间前一小时 2 当前时间前一天 3 当前时间前一周)
|
||||
... limit(必传,限制条数)
|
||||
... param(非必传,参数数量为2位,依次顺序为'startTime'、'endTime',自定义时两个参数必须都有,如果没有就使用timeNum查询)
|
||||
... 返回:对比结果
|
||||
[Arguments] ${timeNum} ${limit} @{param}
|
||||
${length} Run Keyword If ${param}!=[] Get Length ${param}
|
||||
... ELSE Set Variable ${0}
|
||||
${startTime} ${endTime} Run Keyword If ${length}==${0} GetFormateTime ${timeNum}
|
||||
... ELSE IF ${length}>${0} Set Variable ${param[0]} ${param[1]}
|
||||
${logType} Set Variable security_event_hits_log
|
||||
#${limit} Set Variable 5
|
||||
${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
|
||||
... 参数:timeNum(必传,查询的时间范围类型 1 当前时间前一小时 2 当前时间前一天 3 当前时间前一周)
|
||||
... limit(必传,限制条数)
|
||||
... param(非必传,参数数量为2位,依次顺序为'startTime'、'endTime',自定义时两个参数必须都有,如果没有就使用timeNum查询)
|
||||
... 返回:对比结果
|
||||
[Arguments] ${timeNum} ${limit} @{param}
|
||||
${length} Run Keyword If ${param}!=[] Get Length ${param}
|
||||
... ELSE Set Variable ${0}
|
||||
${startTime} ${endTime} Run Keyword If ${length}==${0} GetFormateTime ${timeNum}
|
||||
... ELSE IF ${length}>${0} Set Variable ${param[0]} ${param[1]}
|
||||
${logType} Set Variable proxy_event_hits_log
|
||||
#${limit} Set Variable 5
|
||||
${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}
|
||||
|
||||
Reference in New Issue
Block a user