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

35 lines
2.0 KiB
Plaintext
Raw Normal View History

*** Settings ***
Library Collections
Library RequestsLibrary
Library String
Resource ../../../03-Variable/Bifangapivariable.txt
Resource ForTwoKeywords.robot
*** Keywords ***
UrlTopN
#dashboard Url统计 bifang和bigData对比
[Documentation]
... 描述ProxyPinning
... 参数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]}
#${limit} Set Variable 10
${data} Set Variable startTime=${startTime}&endTime=${endTime}&limit=${limit}
${url1} Set Variable report/traffic/topn/url
${bfResponse} trafficBFRequest ${url1} ${data}
@{List1} Set Variable ${bfResponse['data']['list']}
Create Session bdapi http://${bigDataIP}:${bigDataPort}
${sql} Set Variable select url,sum(session_num) as hits \ from top_urls_log where __time >= '${startTime}' and __time < '${endTime}' \ group by url 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']}
Run Keyword If ${List1}!=[] and ${list}!=[] ForToUrlTopN-One ${List1} ${list}