72 lines
5.5 KiB
Plaintext
72 lines
5.5 KiB
Plaintext
*** Settings ***
|
||
Library Collections
|
||
Library RequestsLibrary
|
||
Library String
|
||
Resource ../../../03-Variable/Bifangapivariable.txt
|
||
Resource ForTwoKeywords.robot
|
||
|
||
*** Keywords ***
|
||
SessionStatistics-NewLive
|
||
# dashboard界面新建和活跃连接数统计 bifang和bigData对比
|
||
[Documentation]
|
||
... 描述:Session-NewLive统计(新建和存活的链接数)
|
||
... 参数:timeNum(必传,查询的时间范围类型 1 当前时间前一小时 2 当前时间前一天 3 当前时间前一周)
|
||
... param(非必传,参数数量为2位,依次顺序为'startTime'、'endTime',自定义时两个参数必须都有,如果没有就使用timeNum查询)
|
||
... 返回:对比结果
|
||
[Arguments] ${timeNum} @{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]}
|
||
${data} Set Variable startTime=${startTime}&endTime=${endTime}
|
||
${url1} Set Variable report/traffic/sessions/statisticsbytype
|
||
${bfResponse} trafficBFRequest ${url1} ${data}
|
||
${newCount} Set Variable ${bfResponse['data']['newCount']}
|
||
${liveCount} Set Variable ${bfResponse['data']['liveCount']}
|
||
Create Session bdapi http://${bigDataIP}:${bigDataPort}
|
||
${sql} Set Variable select sum(new_conn_num) as new_conn_num, sum(established_conn_num) as live_conn_num from traffic_metrics_log where __time >= '${startTime}' and __time < '${endTime}'
|
||
${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
|
||
${newConnNum1} Set Variable ${response['data'][0]['new_conn_num']}
|
||
${liveConnNum1} Set Variable ${response['data'][0]['live_conn_num']}
|
||
Should Be True ${newCount}==${newConnNum1}
|
||
Should Be True ${liveCount}==${liveConnNum1}
|
||
|
||
SessionStatistics-NewLive-Trend
|
||
# dashboard界面新建和活跃连接数趋势 bifang和bigData对比
|
||
[Documentation]
|
||
... 描述:Session-NewLive-Trend统计(新建和存活的链接数趋势)
|
||
... 参数:timeNum(必传,查询的时间范围类型 1 当前时间前一小时 2 当前时间前一天 3 当前时间前一周)
|
||
... timeGranularity(必传,时间粒度 )
|
||
... limit(必传,限制条数)
|
||
... param(非必传,参数数量为2位,依次顺序为'startTime'、'endTime',自定义时两个参数必须都有,如果没有就使用timeNum查询)
|
||
... 返回:对比结果
|
||
[Arguments] ${timeNum} ${timeGranularity} ${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]}
|
||
#${timeGranularity} Set Variable 60
|
||
#${limit} Set Variable 5
|
||
${data} Set Variable startTime=${startTime}&endTime=${endTime}&timeGranularity=${timeGranularity}&limit=${limit}
|
||
${url1} Set Variable report/traffic/sessions/statisticsbytype
|
||
${bfResponse} trafficBFRequest ${url1} ${data}
|
||
@{newTrendList1} Set Variable ${bfResponse['data']['newTrendList']}
|
||
@{liveTrendList1} Set Variable ${bfResponse['data']['liveTrendList']}
|
||
Create Session bdapi http://${bigDataIP}:${bigDataPort}
|
||
${sql} Set Variable (select DATE_FORMAT(FROM_UNIXTIME(FLOOR(UNIX_TIMESTAMP(__time)/${timeGranularity})*${timeGranularity}),'%Y-%m-%d %H:%i:%s') as stat_time, 'new_conn_num' as type, sum(new_conn_num) as sessions from traffic_metrics_log where \ __time >= '${startTime}' and __time < '${endTime}' group by DATE_FORMAT(FROM_UNIXTIME(FLOOR(UNIX_TIMESTAMP(__time)/${timeGranularity})*${timeGranularity}),'%Y-%m-%d %H:%i:%s') limit ${limit}) union all (select DATE_FORMAT(FROM_UNIXTIME(FLOOR(UNIX_TIMESTAMP(__time)/${timeGranularity})*${timeGranularity}),'%Y-%m-%d %H:%i:%s') as stat_time, 'live_conn_num' as type, sum(established_conn_num) as sessions from traffic_metrics_log where \ \ __time >= '${startTime}' and __time < '${endTime}' \ group by DATE_FORMAT(FROM_UNIXTIME(FLOOR(UNIX_TIMESTAMP(__time)/${timeGranularity})*${timeGranularity}),'%Y-%m-%d %H:%i:%s') 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
|
||
@{list2} Set Variable ${response['data']}
|
||
${typeNew} Set Variable new_conn_num
|
||
${typeLive} Set Variable live_conn_num
|
||
${types} Set Variable sessions
|
||
Run Keyword If ${newTrendList1}!=[] and ${list2}!=[] ForToTrafficTrend ${newTrendList1} ${typeNew} ${types} ${list2}
|
||
Run Keyword If ${liveTrendList1}!=[] and ${list2}!=[] ForToTrafficTrend ${liveTrendList1} ${typeLive} ${types} ${list2}
|
||
|
||
|