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/ClientIPTopN.robot

38 lines
2.1 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

*** Settings ***
Library Collections
Library RequestsLibrary
Library String
Resource ../../../02-Keyword/tsg_bfapi/Common.robot
Resource ../../../03-Variable/Bifangapivariable.txt
Resource ForTwoKeywords.robot
*** Variables ***
${bigDataIP} 192.168.40.186
${bigDataPort} 9999
*** Keywords ***
ClientIPTopN
#dashboard 源IP统计 bifang和bigData对比
[Documentation]
... 描述ProxyPinning
... 参数starttime(必传,开始时间)
... orderBy(必传,排序 sessions、bytes、packets 从这三个中选择)
... limit(必传,限制条数)
... endtime(必传,结束时间)
[Arguments] ${starttime} ${endtime} ${orderBy} ${limit}
${data} Set Variable startTime=${startTime}&endTime=${endTime}&orderBy=${orderBy}&limit=${limit}
${url1} Set Variable report/traffic/topn/clientip
${bfResponse} TrafficBFRequest ${url1} ${data}
@{List1} Set Variable ${bfResponse['data']['list']}
Create Session bdapi http://${bigDataIP}:${bigDataPort}
${sql} Set Variable select source as client_ip, 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_internal_host_log where \ __time >= '${startTime}' and __time < '${endTime}' and order_by='${orderBy}' group by source 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 clientIp
${type} Set Variable client_ip
Run Keyword If ${List1}!=[] and ${list}!=[] ForToTopN-One ${List1} ${type1} ${type} ${list}