39 lines
2.6 KiB
Plaintext
39 lines
2.6 KiB
Plaintext
*** Settings ***
|
||
Library Collections
|
||
Library RequestsLibrary
|
||
Library String
|
||
Resource ../../../03-Variable/Bifangapivariable.txt
|
||
Resource ForTwoKeywords.robot
|
||
|
||
*** Keywords ***
|
||
DomainTopN
|
||
#dashboard 域名统计 bifang和bigData对比
|
||
[Documentation]
|
||
... 描述:ProxyPinning
|
||
... 参数:timeNum(必传,查询的时间范围类型 1 当前时间前一小时 2 当前时间前一天 3 当前时间前一周)
|
||
... orderBy(必传,排序 sessions、bytes、packets 从这三个中选择)
|
||
... limit(必传,限制条数)
|
||
... param(非必传,参数数量为2位,依次顺序为'startTime'、'endTime',自定义时两个参数必须都有,如果没有就使用timeNum查询)
|
||
[Arguments] ${timeNum} ${orderBy} ${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]}
|
||
#${orderBy} Set Variable bytes
|
||
#${limit} Set Variable 10
|
||
${data} Set Variable startTime=${startTime}&endTime=${endTime}&orderBy=${orderBy}&limit=${limit}
|
||
${url1} Set Variable report/traffic/topn/domain
|
||
${bfResponse} trafficBFRequest ${url1} ${data}
|
||
@{List1} Set Variable ${bfResponse['data']['list']}
|
||
Create Session bdapi http://${bigDataIP}:${bigDataPort}
|
||
${sql} Set Variable select domain, sum(session_num) as sessions, sum(c2s_byte_num) as sent_bytes, sum(s2c_byte_num) as received_bytes, sum(c2s_byte_num + s2c_byte_num) as bytes, \ sum(c2s_pkt_num) as sent_packets ,sum(s2c_pkt_num) as received_packets, sum(c2s_pkt_num+s2c_pkt_num) as packets from top_website_domain_log where \ __time >= '${startTime}' and __time < '${endTime}' \ and order_by='${orderBy}' group by domain order by ${orderBy} 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']}
|
||
${type1} Set Variable domain
|
||
#${type} Set Variable domain
|
||
Run Keyword If ${List1}!=[] and ${list}!=[] ForToTopN-One ${List1} ${type1} ${type1} ${list}
|
||
|