*** Settings *** Library Collections Library RequestsLibrary Library String Resource ../../../03-Variable/Bifangapivariable.txt Resource ForTwoKeywords.robot *** Keywords *** SessionStatistics-NewLive # dashboard界面新建和活跃连接数统计 bifang和bigData对比 [Documentation] ... 描述:Session-NewLive统计(新建和存活的链接数) ... 参数:starttime(必传,开始时间紧) ... endtime(必传,结束时间 ... 返回:对比结果 [Arguments] ${starttime} ${endtime} ${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统计(新建和存活的链接数趋势) ... 参数:starttime(必传,开始时间紧) ... timeGranularity(非必传,时间粒度 ) ... limit(非必传,限制条数) ... endtime(必传,结束时间 ... 返回:对比结果 [Arguments] ${starttime} ${endtime} ${timeGranularity} ${limit} ${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}