dashboard页面 毕方和大数据 对比用例,需要安装DateTime库,
命令为pip install DateTime
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
*** Settings ***
|
||||
Force Tags tsg-bfapi dashboard clientIP topn
|
||||
Library Collections
|
||||
Library REST
|
||||
Resource ../../../03-Variable/Bifangapivariable.txt
|
||||
Resource ../../../02-Keyword/tsg_bfapi/dashboard_data_compare/ClientIPTopN.robot
|
||||
|
||||
*** Test Cases ***
|
||||
ClientIPTopN-0001
|
||||
#dashboard 源IP统计 bifang和bigData对比
|
||||
ClientIPTopN 1 bytes 5
|
||||
|
||||
ClientIPTopN-0002
|
||||
#dashboard 源IP统计 bifang和bigData对比
|
||||
ClientIPTopN 2 packets 5
|
||||
|
||||
ClientIPTopN-0003
|
||||
#dashboard 源IP统计 bifang和bigData对比
|
||||
ClientIPTopN 3 sessions 10
|
||||
@@ -0,0 +1,19 @@
|
||||
*** Settings ***
|
||||
Force Tags tsg-bfapi dashboard Domain topn
|
||||
Library Collections
|
||||
Library REST
|
||||
Resource ../../../03-Variable/Bifangapivariable.txt
|
||||
Resource ../../../02-Keyword/tsg_bfapi/dashboard_data_compare/DomainTopN.robot
|
||||
|
||||
*** Test Cases ***
|
||||
DomainTopN-0001
|
||||
#dashboard 域名统计 bifang和bigData对比
|
||||
DomainTopN 1 bytes 10
|
||||
|
||||
DomainTopN-0002
|
||||
#dashboard 域名统计 bifang和bigData对比
|
||||
DomainTopN 2 packets 10
|
||||
|
||||
DomainTopN-0003
|
||||
#dashboard 域名统计 bifang和bigData对比
|
||||
DomainTopN 3 sessions 10
|
||||
@@ -0,0 +1,103 @@
|
||||
*** Settings ***
|
||||
Force Tags tsg-bfapi dashboard policy action
|
||||
Library Collections
|
||||
Library REST
|
||||
Resource ../../../03-Variable/Bifangapivariable.txt
|
||||
Resource ../../../02-Keyword/tsg_bfapi/dashboard_data_compare/PolicyActionHitStatistics.robot
|
||||
|
||||
*** Test Cases ***
|
||||
SecurityEventActionHit-bytes-0001
|
||||
# dashboard界面 安全策略各动作命中计数 bytes bifang和bigData对比
|
||||
SecurityEventActionHit-bytes 1 300 5
|
||||
|
||||
SecurityEventActionHit-bytes-0002
|
||||
# dashboard界面 安全策略各动作命中计数 bytes bifang和bigData对比
|
||||
SecurityEventActionHit-bytes 2 600 5
|
||||
|
||||
SecurityEventActionHit-bytes-0003
|
||||
# dashboard界面 安全策略各动作命中计数 bytes bifang和bigData对比
|
||||
SecurityEventActionHit-bytes 3 600 10
|
||||
|
||||
SecurityEventActionHit-packets-0001
|
||||
# dashboard界面 安全策略各动作命中计数 packets bifang和bigData对比
|
||||
SecurityEventActionHit-packets 1 300 5
|
||||
|
||||
SecurityEventActionHit-packets-0002
|
||||
# dashboard界面 安全策略各动作命中计数 packets bifang和bigData对比
|
||||
SecurityEventActionHit-packets 2 600 5
|
||||
|
||||
SecurityEventActionHit-packets-0003
|
||||
# dashboard界面 安全策略各动作命中计数 packets bifang和bigData对比
|
||||
SecurityEventActionHit-packets 3 600 10 2020-03-31 16:00:00 2020-04-07 16:00:00
|
||||
|
||||
SecurityEventActionHit-sessions-0001
|
||||
# dashboard界面 安全策略各动作命中计数 sessions bifang和bigData对比
|
||||
SecurityEventActionHit-sessions 1 300 5
|
||||
|
||||
SecurityEventActionHit-sessions-0002
|
||||
# dashboard界面 安全策略各动作命中计数 sessions bifang和bigData对比
|
||||
SecurityEventActionHit-sessions 2 300 5
|
||||
|
||||
SecurityEventActionHit-sessions-0003
|
||||
# dashboard界面 安全策略各动作命中计数 sessions bifang和bigData对比
|
||||
SecurityEventActionHit-sessions 3 300 10
|
||||
|
||||
SecurityEventActionHit-thrend-bytes-0001
|
||||
# dashboard界面 安全策略各动作命中计数趋势 bytes bifang和bigData对比
|
||||
SecurityEventActionHit-thrend-bytes 1 300 5
|
||||
|
||||
SecurityEventActionHit-thrend-bytes-0002
|
||||
# dashboard界面 安全策略各动作命中计数趋势 bytes bifang和bigData对比
|
||||
SecurityEventActionHit-thrend-bytes 2 300 5
|
||||
|
||||
SecurityEventActionHit-thrend-bytes-0003
|
||||
# dashboard界面 安全策略各动作命中计数趋势 bytes bifang和bigData对比
|
||||
SecurityEventActionHit-thrend-bytes 3 600 10
|
||||
|
||||
SecurityEventActionHit-thrend-packets-0001
|
||||
# dashboard界面 安全策略各动作命中计数趋势 packets bifang和bigData对比
|
||||
SecurityEventActionHit-thrend-packets 1 300 5
|
||||
|
||||
SecurityEventActionHit-thrend-packets-0002
|
||||
# dashboard界面 安全策略各动作命中计数趋势 packets bifang和bigData对比
|
||||
SecurityEventActionHit-thrend-packets 2 300 5
|
||||
|
||||
SecurityEventActionHit-thrend-packets-0003
|
||||
# dashboard界面 安全策略各动作命中计数趋势 packets bifang和bigData对比
|
||||
SecurityEventActionHit-thrend-packets 3 600 10
|
||||
|
||||
SecurityEventActionHit-thrend-sessions-0001
|
||||
# dashboard界面 安全策略各动作命中计数趋势 sessions bifang和bigData对比
|
||||
SecurityEventActionHit-thrend-sessions 1 300 5
|
||||
|
||||
SecurityEventActionHit-thrend-sessions-0002
|
||||
# dashboard界面 安全策略各动作命中计数趋势 sessions bifang和bigData对比
|
||||
SecurityEventActionHit-thrend-sessions 2 300 5
|
||||
|
||||
SecurityEventActionHit-thrend-sessions-0003
|
||||
# dashboard界面 安全策略各动作命中计数趋势 sessions bifang和bigData对比
|
||||
SecurityEventActionHit-thrend-sessions 3 600 10
|
||||
|
||||
ProxyEventActionHit-sessions-0001
|
||||
# dashboard界面 代理策略各动作命中计数 sessions bifang和bigData对比
|
||||
ProxyEventActionHit-sessions 1 300 5
|
||||
|
||||
ProxyEventActionHit-sessions-0002
|
||||
# dashboard界面 代理策略各动作命中计数 sessions bifang和bigData对比
|
||||
ProxyEventActionHit-sessions 2 300 5
|
||||
|
||||
ProxyEventActionHit-sessions-0003
|
||||
# dashboard界面 代理策略各动作命中计数 sessions bifang和bigData对比
|
||||
ProxyEventActionHit-sessions 3 600 10
|
||||
|
||||
ProxyEventActionHit-trend-sessions-0001
|
||||
# dashboard界面 代理策略各动作命中计数趋势 sessions bifang和bigData对比
|
||||
ProxyEventActionHit-trend-sessions 1 300 5
|
||||
|
||||
ProxyEventActionHit-trend-sessions-0002
|
||||
# dashboard界面 代理策略各动作命中计数趋势 sessions bifang和bigData对比
|
||||
ProxyEventActionHit-trend-sessions 2 300 5
|
||||
|
||||
ProxyEventActionHit-trend-sessions-0003
|
||||
# dashboard界面 代理策略各动作命中计数趋势 sessions bifang和bigData对比
|
||||
ProxyEventActionHit-trend-sessions 3 600 10
|
||||
@@ -0,0 +1,30 @@
|
||||
*** Settings ***
|
||||
Force Tags tsg-bfapi dashboard policy topn
|
||||
Library Collections
|
||||
Resource ../../../03-Variable/Bifangapivariable.txt
|
||||
Resource ../../../02-Keyword/tsg_bfapi/dashboard_data_compare/PolicyEventHitTopN.robot
|
||||
|
||||
*** Test Cases ***
|
||||
SecurityEventHitTopN-0001
|
||||
# dashboard界面 安全策略命中TopN bifang和bigData对比
|
||||
SecurityEventHit 1 10
|
||||
|
||||
SecurityEventHitTopN-0002
|
||||
# dashboard界面 安全策略命中TopN bifang和bigData对比
|
||||
SecurityEventHit 2 10
|
||||
|
||||
SecurityEventHitTopN-0003
|
||||
# dashboard界面 安全策略命中TopN bifang和bigData对比
|
||||
SecurityEventHit 3 10
|
||||
|
||||
ProxyEventHitTopN-0001
|
||||
# dashboard界面 代理策略命中TopN bifang和bigData对比
|
||||
ProxyEventHit 1 10
|
||||
|
||||
ProxyEventHitTopN-0002
|
||||
# dashboard界面 代理策略命中TopN bifang和bigData对比
|
||||
ProxyEventHit 2 10
|
||||
|
||||
ProxyEventHitTopN-0003
|
||||
# dashboard界面 代理策略命中TopN bifang和bigData对比
|
||||
ProxyEventHit 3 10
|
||||
@@ -0,0 +1,32 @@
|
||||
*** Settings ***
|
||||
Force Tags tsg-bfapi dashboard proxy pinning
|
||||
Library Collections
|
||||
Library REST
|
||||
Resource ../../../03-Variable/Bifangapivariable.txt
|
||||
Resource ../../../02-Keyword/tsg_bfapi/dashboard_data_compare/ProxyPinningStatistics.robot
|
||||
|
||||
*** Test Cases ***
|
||||
ProxyPinning-0001
|
||||
# dashboard界面 Proxy Pinning计数 bifang和bigData对比
|
||||
ProxyPinning 1 300 5
|
||||
|
||||
ProxyPinning-0002
|
||||
# dashboard界面 Proxy Pinning计数 bifang和bigData对比
|
||||
ProxyPinning 2 300 5
|
||||
|
||||
ProxyPinning-0003
|
||||
# dashboard界面 Proxy Pinning计数 bifang和bigData对比
|
||||
ProxyPinning 3 600 10
|
||||
|
||||
|
||||
ProxyPinning-trend-0001
|
||||
# dashboard界面 Proxy Pinning计数 bifang和bigData对比
|
||||
ProxyPinningTrend 1 300 5
|
||||
|
||||
ProxyPinning-trend-0002
|
||||
# dashboard界面 Proxy Pinning计数 bifang和bigData对比
|
||||
ProxyPinningTrend 2 300 5
|
||||
|
||||
ProxyPinning-trend-0003
|
||||
# dashboard界面 Proxy Pinning计数 bifang和bigData对比
|
||||
ProxyPinningTrend 3 600 10
|
||||
@@ -0,0 +1,19 @@
|
||||
*** Settings ***
|
||||
Force Tags tsg-bfapi dashboard serviceIP topn
|
||||
Library Collections
|
||||
Library REST
|
||||
Resource ../../../03-Variable/Bifangapivariable.txt
|
||||
Resource ../../../02-Keyword/tsg_bfapi/dashboard_data_compare/ServiceIPTopN.robot
|
||||
|
||||
*** Test Cases ***
|
||||
ServiceIPTopN-0001
|
||||
#dashboard 目的IP统计 bifang和bigData对比
|
||||
ServiceIPTopN 1 bytes 10
|
||||
|
||||
ServiceIPTopN-0002
|
||||
#dashboard 目的IP统计 bifang和bigData对比
|
||||
ServiceIPTopN 2 packets 10
|
||||
|
||||
ServiceIPTopN-0003
|
||||
#dashboard 目的IP统计 bifang和bigData对比
|
||||
ServiceIPTopN 3 sessions 10
|
||||
@@ -0,0 +1,19 @@
|
||||
*** Settings ***
|
||||
Force Tags tsg-bfapi dashboard subscriberid topn
|
||||
Library Collections
|
||||
Library REST
|
||||
Resource ../../../03-Variable/Bifangapivariable.txt
|
||||
Resource ../../../02-Keyword/tsg_bfapi/dashboard_data_compare/SubscriberidTopN.robot
|
||||
|
||||
*** Test Cases ***
|
||||
SubscriberidTopN-0001
|
||||
#dashboard 用户TopN统计 bifang和bigData对比
|
||||
SubscriberidTopN 1 bytes 10
|
||||
|
||||
SubscriberidTopN-0002
|
||||
#dashboard 用户TopN统计 bifang和bigData对比
|
||||
SubscriberidTopN 2 packets 10
|
||||
|
||||
SubscriberidTopN-0003
|
||||
#dashboard 用户TopN统计 bifang和bigData对比
|
||||
SubscriberidTopN 3 sessions 10
|
||||
@@ -0,0 +1,31 @@
|
||||
*** Settings ***
|
||||
Force Tags tsg-bfapi dashboard traffic newCount liveCount
|
||||
Library Collections
|
||||
Resource ../../../03-Variable/Bifangapivariable.txt
|
||||
Resource ../../../02-Keyword/tsg_bfapi/dashboard_data_compare/TrafficSessionNewLiveStatistic.robot
|
||||
|
||||
*** Test Cases ***
|
||||
SessionStatistics-NewLive-0001
|
||||
# dashboard界面新建和活跃连接数统计 bifang和bigData对比
|
||||
SessionStatistics-NewLive 1
|
||||
|
||||
SessionStatistics-NewLive-0002
|
||||
# dashboard界面新建和活跃连接数统计 bifang和bigData对比
|
||||
SessionStatistics-NewLive 2
|
||||
|
||||
SessionStatistics-NewLive-0003
|
||||
# dashboard界面新建和活跃连接数统计 bifang和bigData对比
|
||||
SessionStatistics-NewLive 3
|
||||
|
||||
SessionStatistics-NewLiveTrend-0001
|
||||
# dashboard界面新建和活跃连接数趋势 bifang和bigData对比
|
||||
SessionStatistics-NewLive-Trend 1 60 5
|
||||
|
||||
SessionStatistics-NewLiveTrend-0002
|
||||
# dashboard界面新建和活跃连接数趋势 bifang和bigData对比
|
||||
SessionStatistics-NewLive-Trend 2 300 5
|
||||
|
||||
SessionStatistics-NewLiveTrend-0003
|
||||
# dashboard界面新建和活跃连接数趋势 bifang和bigData对比
|
||||
SessionStatistics-NewLive-Trend 3 600 10
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
*** Settings ***
|
||||
Force Tags tsg-bfapi dashboard traffic
|
||||
Library Collections
|
||||
Resource ../../../03-Variable/Bifangapivariable.txt
|
||||
Resource ../../../02-Keyword/tsg_bfapi/dashboard_data_compare/TrafficStatistics.robot
|
||||
|
||||
*** Test Cases ***
|
||||
TrafficStatistics-bytes-0001
|
||||
# Traffics-带宽统计 统计类型:bytes bifang和bigData对比 Traffic IN/OUT
|
||||
Dashboard-Traffic-bytes 1
|
||||
|
||||
TrafficStatistics-bytes-0002
|
||||
# Traffics-带宽统计 统计类型:bytes bifang和bigData对比 Traffic IN/OUT
|
||||
Dashboard-Traffic-bytes 2
|
||||
|
||||
TrafficStatistics-bytes-0003
|
||||
# Traffics-带宽统计 统计类型:bytes bifang和bigData对比 Traffic IN/OUT
|
||||
Dashboard-Traffic-bytes 3
|
||||
|
||||
TrafficStatistics-packets-0001
|
||||
# Traffics-带宽统计 统计类型:packets bifang和bigData对比 Traffic IN/OUT
|
||||
Dashboard-Traffic-packets 1 2020-04-06 10:00:00 2020-04-06 12:00:00
|
||||
|
||||
TrafficStatistics-packets-0002
|
||||
# Traffics-带宽统计 统计类型:packets bifang和bigData对比 Traffic IN/OUT
|
||||
Dashboard-Traffic-packets 2
|
||||
|
||||
TrafficStatistics-packets-0003
|
||||
# Traffics-带宽统计 统计类型:packets bifang和bigData对比 Traffic IN/OUT
|
||||
Dashboard-Traffic-packets 3
|
||||
|
||||
TrafficStatistics-sessions-0001
|
||||
# Traffics-带宽统计 统计类型:sessions bifang和bigData对比 Traffic IN/OUT
|
||||
Dashboard-Traffic-sessions 1
|
||||
|
||||
TrafficStatistics-sessions-0002
|
||||
# Traffics-带宽统计 统计类型:sessions bifang和bigData对比 Traffic IN/OUT
|
||||
Dashboard-Traffic-sessions 2
|
||||
|
||||
TrafficStatistics-sessions-0003
|
||||
# Traffics-带宽统计 统计类型:sessions bifang和bigData对比 Traffic IN/OUT
|
||||
Dashboard-Traffic-sessions 3
|
||||
|
||||
TrafficStatistics-trend-bytes-0001
|
||||
# Traffics-带宽趋势 统计类型:bytes bifang和bigData对比 Traffic IN/OUT
|
||||
Dashboard-Traffic-trend-bytes 1 60 5
|
||||
|
||||
TrafficStatistics-trend-bytes-0002
|
||||
# Traffics-带宽趋势 统计类型:bytes bifang和bigData对比 Traffic IN/OUT
|
||||
Dashboard-Traffic-trend-bytes 2 300 5
|
||||
|
||||
TrafficStatistics-trend-bytes-0003
|
||||
# Traffics-带宽趋势 统计类型:bytes bifang和bigData对比 Traffic IN/OUT
|
||||
Dashboard-Traffic-trend-bytes 3 300 10
|
||||
|
||||
TrafficStatistics-trend-packets-0001
|
||||
# Traffics-带宽趋势 统计类型:packets bifang和bigData对比 Traffic IN/OUT
|
||||
Dashboard-Traffic-trend-packets 1 60 5
|
||||
|
||||
TrafficStatistics-trend-packets-0002
|
||||
# Traffics-带宽趋势 统计类型:packets bifang和bigData对比 Traffic IN/OUT
|
||||
Dashboard-Traffic-trend-packets 2 60 10
|
||||
|
||||
TrafficStatistics-trend-packets-0003
|
||||
# Traffics-带宽趋势 统计类型:packets bifang和bigData对比 Traffic IN/OUT
|
||||
Dashboard-Traffic-trend-packets 3 300 10
|
||||
|
||||
TrafficStatistics-trend-sessions-0001
|
||||
# Traffics-带宽趋势 统计类型:sessions bifang和bigData对比 Traffic IN/OUT
|
||||
Dashboard-Traffic-trend-sessions 1 60 5
|
||||
|
||||
TrafficStatistics-trend-sessions-0002
|
||||
# Traffics-带宽趋势 统计类型:sessions bifang和bigData对比 Traffic IN/OUT
|
||||
Dashboard-Traffic-trend-sessions 2 60 10
|
||||
|
||||
TrafficStatistics-trend-sessions-0003
|
||||
# Traffics-带宽趋势 统计类型:sessions bifang和bigData对比 Traffic IN/OUT
|
||||
Dashboard-Traffic-trend-sessions 3 300 10
|
||||
|
||||
19
01-TestCase/tsg_bfapi/dashboard_data_compare/UrlTopN.robot
Normal file
19
01-TestCase/tsg_bfapi/dashboard_data_compare/UrlTopN.robot
Normal file
@@ -0,0 +1,19 @@
|
||||
*** Settings ***
|
||||
Force Tags tsg-bfapi dashboard url topn
|
||||
Library Collections
|
||||
Library REST
|
||||
Resource ../../../03-Variable/Bifangapivariable.txt
|
||||
Resource ../../../02-Keyword/tsg_bfapi/dashboard_data_compare/UrlTopN.robot
|
||||
|
||||
*** Test Cases ***
|
||||
UrlTopN-0001
|
||||
#dashboard Url统计 bifang和bigData对比
|
||||
UrlTopN 1 10
|
||||
|
||||
UrlTopN-0002
|
||||
#dashboard Url统计 bifang和bigData对比
|
||||
UrlTopN 2 10
|
||||
|
||||
UrlTopN-0003
|
||||
#dashboard Url统计 bifang和bigData对比
|
||||
UrlTopN 3 10
|
||||
@@ -0,0 +1,39 @@
|
||||
*** Settings ***
|
||||
Library Collections
|
||||
Library RequestsLibrary
|
||||
Library String
|
||||
Resource ../../../03-Variable/Bifangapivariable.txt
|
||||
Resource ForTwoKeywords.robot
|
||||
|
||||
*** Keywords ***
|
||||
ClientIPTopN
|
||||
#dashboard 源IP统计 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/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}
|
||||
|
||||
|
||||
38
02-Keyword/tsg_bfapi/dashboard_data_compare/DomainTopN.robot
Normal file
38
02-Keyword/tsg_bfapi/dashboard_data_compare/DomainTopN.robot
Normal file
@@ -0,0 +1,38 @@
|
||||
*** 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}
|
||||
|
||||
199
02-Keyword/tsg_bfapi/dashboard_data_compare/ForTwoKeywords.robot
Normal file
199
02-Keyword/tsg_bfapi/dashboard_data_compare/ForTwoKeywords.robot
Normal file
@@ -0,0 +1,199 @@
|
||||
*** Settings ***
|
||||
Library Collections
|
||||
Library RequestsLibrary
|
||||
Library DateTime
|
||||
Library String
|
||||
Resource ../../../03-Variable/Bifangapivariable.txt
|
||||
|
||||
*** Variables ***
|
||||
${bigDataIP} 192.168.40.186
|
||||
${bigDataPort} 9999
|
||||
|
||||
*** Keywords ***
|
||||
GetFormateTime
|
||||
[Arguments] ${timeNum}
|
||||
@{time}= Get Time year month day hour min sec
|
||||
${date}= Catenate SEPARATOR=- @{time}[0] @{time}[1] @{time}[2]
|
||||
${datetime}= Catenate SEPARATOR=: @{time}[3] 00 00
|
||||
${endTime} Catenate ${date} ${datetime}
|
||||
${startTime} Run Keyword If '${timeNum}'=='1' Add Time To Date ${endTime} -1:00:00
|
||||
... ELSE IF '${timeNum}'=='2' Add Time To Date ${endTime} -1days
|
||||
... ELSE IF '${timeNum}'=='3' Add Time To Date ${endTime} -7days
|
||||
${startTime} Get Substring ${startTime} 0 19
|
||||
[Return] ${startTime} ${endTime}
|
||||
|
||||
TrafficBFRequest
|
||||
[Arguments] ${url} ${data}
|
||||
${header} Create Dictionary Content-Type=application/x-www-form-urlencoded Authorization=${token}
|
||||
Create Session api http://${host}:${port}/${version} headers=${header}
|
||||
${bfRemoteResponse} Get Request api ${url}?${data} headers=${header}
|
||||
${bfResponse} to json ${bfRemoteResponse.content}
|
||||
Should Be Equal As Strings ${bfRemoteResponse.status_code} 200
|
||||
Should Be Equal As Strings ${bfResponse['code']} 200
|
||||
[Return] ${bfResponse}
|
||||
|
||||
ForToTraffic
|
||||
[Arguments] ${element1} ${type} ${types} @{list}
|
||||
FOR ${element} IN @{list}
|
||||
log ${element}
|
||||
Run Keyword If '${element1['statisticsTime']}'=='${element['stat_time']}' and '${element['type']}'=='${type}' Should Be Equal ${element1['statisticsNum']} ${element['${types}']}
|
||||
END
|
||||
|
||||
ForToTrafficTrend
|
||||
[Arguments] ${bytesList1} ${type} ${types} ${bytesList2}
|
||||
FOR ${element1} IN @{bytesList1}
|
||||
log ${element1}
|
||||
ForToTraffic ${element1} ${type} ${types} @{bytesList2}
|
||||
END
|
||||
|
||||
ForToEventHitTop
|
||||
[Arguments] ${element1} ${types} @{list}
|
||||
FOR ${element} IN @{list}
|
||||
log ${element}
|
||||
Run Keyword If '${element1['policyId']}'=='${element['policy_id']}' Should Be Equal ${element1['sessions']} ${element['${types}']}
|
||||
END
|
||||
|
||||
ForToEventHitTopTrend
|
||||
[Arguments] ${bfList} ${types} ${list}
|
||||
FOR ${element1} IN @{bfList}
|
||||
log ${element1}
|
||||
ForToEventHitTop ${element1} ${types} @{list}
|
||||
END
|
||||
|
||||
ForToSecurityActionBytes
|
||||
[Arguments] ${actionCountList} ${list}
|
||||
FOR ${element} IN @{actionCountList}
|
||||
log ${element}
|
||||
Run Keyword If '${element['action']}'=='Default' Should Be Equal ${element['bytes']} ${list['default_bytes']}
|
||||
... ELSE IF '${element['action']}'=='Allow' Should Be Equal ${element['bytes']} ${list['allow_bytes']}
|
||||
... ELSE IF '${element['action']}'=='Deny' Should Be Equal ${element['bytes']} ${list['deny_bytes']}
|
||||
... ELSE IF '${element['action']}'=='Monitor' Should Be Equal ${element['bytes']} ${list['monitor_bytes']}
|
||||
... ELSE IF '${element['action']}'=='Intercept' Should Be Equal ${element['bytes']} ${list['intercept_bytes']}
|
||||
END
|
||||
|
||||
ForToSecurityActionPackets
|
||||
[Arguments] ${actionCountList} ${list}
|
||||
FOR ${element} IN @{actionCountList}
|
||||
log ${element}
|
||||
Run Keyword If '${element['action']}'=='Default' Should Be Equal ${element['packets']} ${list['default_packets']}
|
||||
... ELSE IF '${element['action']}'=='Allow' Should Be Equal ${element['packets']} ${list['allow_packets']}
|
||||
... ELSE IF '${element['action']}'=='Deny' Should Be Equal ${element['packets']} ${list['deny_packets']}
|
||||
... ELSE IF '${element['action']}'=='Monitor' Should Be Equal ${element['packets']} ${list['monitor_packets']}
|
||||
... ELSE IF '${element['action']}'=='Intercept' Should Be Equal ${element['packets']} ${list['intercept_packets']}
|
||||
END
|
||||
|
||||
ForToSecurityActionSessions
|
||||
[Arguments] ${actionCountList} ${list}
|
||||
FOR ${element} IN @{actionCountList}
|
||||
log ${element}
|
||||
Run Keyword If '${element['action']}'=='Default' Should Be Equal ${element['sessions']} ${list['default_sessions']}
|
||||
... ELSE IF '${element['action']}'=='Allow' Should Be Equal ${element['sessions']} ${list['allow_sessions']}
|
||||
... ELSE IF '${element['action']}'=='Deny' Should Be Equal ${element['sessions']} ${list['deny_sessions']}
|
||||
... ELSE IF '${element['action']}'=='Monitor' Should Be Equal ${element['sessions']} ${list['monitor_sessions']}
|
||||
... ELSE IF '${element['action']}'=='Intercept' Should Be Equal ${element['sessions']} ${list['intercept_sessions']}
|
||||
END
|
||||
|
||||
ForToSecurityAtionTrend
|
||||
[Arguments] ${element1} ${type} @{list}
|
||||
FOR ${element} IN @{list}
|
||||
log ${element}
|
||||
Run Keyword If '${element1['statisticTime']}'=='${element['stat_time']}' and '${element1['action']}'=='Default' and '${element['type']}'=='default_bytes' Should Be Equal ${element1['${type}']} ${element['${type}']}
|
||||
... ELSE IF '${element1['statisticTime']}'=='${element['stat_time']}' and '${element1['action']}'=='Allow' and '${element['type']}'=='allow_bytes' Should Be Equal ${element1['${type}']} ${element['${type}']}
|
||||
... ELSE IF '${element1['statisticTime']}'=='${element['stat_time']}' and '${element1['action']}'=='Deny' and '${element['type']}'=='deny_bytes' Should Be Equal ${element1['${type}']} ${element['${type}']}
|
||||
... ELSE IF '${element1['statisticTime']}'=='${element['stat_time']}' and '${element1['action']}'=='Monitor' and '${element['type']}'=='monitor_bytes' Should Be Equal ${element1['${type}']} ${element['${type}']}
|
||||
... ELSE IF '${element1['statisticTime']}'=='${element['stat_time']}' and '${element1['action']}'=='Intercept' and '${element['type']}'=='intercept_bytes' Should Be Equal ${element1['${type}']} ${element['${type}']}
|
||||
END
|
||||
|
||||
|
||||
ForToSecurityAtionTrendOne
|
||||
[Arguments] ${actionTrendList} ${type} @{list}
|
||||
FOR ${element1} IN @{actionTrendList}
|
||||
log ${element1}
|
||||
ForToSecurityAtionTrend ${element1} ${type} @{list}
|
||||
END
|
||||
|
||||
ForToProxyAtion
|
||||
[Arguments] ${element1} @{list}
|
||||
FOR ${element} IN @{list}
|
||||
log ${element}
|
||||
Run Keyword If '${element1['action']}'=='Allow' and '${element['action']}'=='allow' Should Be Equal ${element1['sessions']} ${element['hits']}
|
||||
... ELSE IF '${element1['action']}'=='Deny' and '${element['action']}'=='deny' Should Be Equal ${element1['sessions']} ${element['hits']}
|
||||
... ELSE IF '${element1['action']}'=='Monitor' and '${element['action']}'=='monitor' Should Be Equal ${element1['sessions']} ${element['hits']}
|
||||
... ELSE IF '${element1['action']}'=='Redirect' and '${element['action']}'=='redirect' Should Be Equal ${element1['sessions']} ${element['hits']}
|
||||
... ELSE IF '${element1['action']}'=='Replace' and '${element['action']}'=='replace' Should Be Equal ${element1['sessions']} ${element['hits']}
|
||||
... ELSE IF '${element1['action']}'=='Hijack' and '${element['action']}'=='hijack' Should Be Equal ${element1['sessions']} ${element['hits']}
|
||||
... ELSE IF '${element1['action']}'=='Insert' and '${element['action']}'=='insert' Should Be Equal ${element1['sessions']} ${element['hits']}
|
||||
END
|
||||
|
||||
ForToProxyAtionSession
|
||||
[Arguments] ${actionCountList} ${list}
|
||||
FOR ${element1} IN @{actionCountList}
|
||||
log ${element1}
|
||||
ForToProxyAtion ${element1} @{list}
|
||||
END
|
||||
|
||||
ForToProxyAtionTrend
|
||||
[Arguments] ${element1} @{list}
|
||||
FOR ${element} IN @{list}
|
||||
log ${element}
|
||||
Run Keyword If '${element1['statisticTime']}'=='${element['stat_time']}' and '${element1['action']}'=='Allow' and '${element['action']}'=='allow' Should Be Equal ${element1['sessions']} ${element['hits']}
|
||||
... ELSE IF '${element1['statisticTime']}'=='${element['stat_time']}' and '${element1['action']}'=='Deny' and '${element['action']}'=='deny' Should Be Equal ${element1['sessions']} ${element['hits']}
|
||||
... ELSE IF '${element1['statisticTime']}'=='${element['stat_time']}' and '${element1['action']}'=='Monitor' and '${element['action']}'=='monitor' Should Be Equal ${element1['sessions']} ${element['hits']}
|
||||
... ELSE IF '${element1['statisticTime']}'=='${element['stat_time']}' and '${element1['action']}'=='Redirect' and '${element['action']}'=='redirect' Should Be Equal ${element1['sessions']} ${element['hits']}
|
||||
... ELSE IF '${element1['statisticTime']}'=='${element['stat_time']}' and '${element1['action']}'=='Replace' and '${element['action']}'=='replace' Should Be Equal ${element1['sessions']} ${element['hits']}
|
||||
... ELSE IF '${element1['statisticTime']}'=='${element['stat_time']}' and '${element1['action']}'=='Hijack' and '${element['action']}'=='hijack' Should Be Equal ${element1['sessions']} ${element['hits']}
|
||||
... ELSE IF '${element1['statisticTime']}'=='${element['stat_time']}' and '${element1['action']}'=='Insert' and '${element['action']}'=='insert' Should Be Equal ${element1['sessions']} ${element['hits']}
|
||||
END
|
||||
|
||||
|
||||
ForToProxyAtionTrendSession
|
||||
[Arguments] ${trendList} ${list}
|
||||
FOR ${element1} IN @{trendList}
|
||||
log ${element1}
|
||||
ForToProxyAtionTrend ${element1} @{list}
|
||||
END
|
||||
|
||||
|
||||
ForToProxyPinning
|
||||
[Arguments] ${element1} ${type} @{list}
|
||||
FOR ${element} IN @{list}
|
||||
log ${element}
|
||||
Run Keyword If '${element1['statisticTime']}'=='${element['stat_time']}' and '${element['type']}'=='${type}' Should Be Equal ${element1['sessions']} ${element['hits']}
|
||||
END
|
||||
|
||||
|
||||
ForToProxyPinningTrend
|
||||
[Arguments] ${trendList} ${type} ${list}
|
||||
FOR ${element1} IN @{trendList}
|
||||
log ${element1}
|
||||
ForToProxyPinning ${element1} ${type} @{list}
|
||||
END
|
||||
|
||||
|
||||
ForToTopN
|
||||
[Arguments] ${element1} ${type1} ${type} @{list}
|
||||
FOR ${element} IN @{list}
|
||||
log ${element}
|
||||
Run Keyword If '${element1['${type1}']}'=='${element['${type}']}' Run Keywords Should Be Equal ${element1['sentBytes']} ${element['sent_bytes']} AND Should Be Equal ${element1['receivedBytes']} ${element['received_bytes']} AND Should Be Equal ${element1['totalBytes']} ${element['bytes']} AND Should Be Equal ${element1['sentPackets']} ${element['sent_packets']} AND Should Be Equal ${element1['receivedPackets']} ${element['received_packets']} AND Should Be Equal ${element1['totalPackets']} ${element['packets']} AND Should Be Equal ${element1['sessions']} ${element['sessions']}
|
||||
END
|
||||
|
||||
ForToTopN-One
|
||||
[Arguments] ${List1} ${type1} ${type} ${List}
|
||||
FOR ${element1} IN @{List1}
|
||||
log ${element1}
|
||||
ForToTopN ${element1} ${type1} ${type} @{list}
|
||||
END
|
||||
|
||||
ForToUrlTopN
|
||||
[Arguments] ${element1} @{list}
|
||||
FOR ${element} IN @{list}
|
||||
log ${element}
|
||||
Run Keyword If '${element1['url']}'=='${element['url']}' Should Be Equal ${element1['sessions']} ${element['hits']}
|
||||
END
|
||||
|
||||
ForToUrlTopN-One
|
||||
[Arguments] ${List1} ${List}
|
||||
FOR ${element1} IN @{List1}
|
||||
log ${element1}
|
||||
ForToUrlTopN ${element1} @{list}
|
||||
END
|
||||
@@ -0,0 +1,246 @@
|
||||
*** Settings ***
|
||||
Library Collections
|
||||
Library RequestsLibrary
|
||||
Library String
|
||||
Resource ../../../03-Variable/Bifangapivariable.txt
|
||||
Resource ForTwoKeywords.robot
|
||||
|
||||
*** Keywords ***
|
||||
SecurityEventActionHit-bytes
|
||||
# dashboard界面 安全策略各动作命中计数 bytes bifang和bigData对比
|
||||
[Documentation]
|
||||
... 描述:Security-Action-bytes
|
||||
... 参数: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]}
|
||||
${logType} Set Variable security_event_hits_log
|
||||
#${timeGranularity} Set Variable 300
|
||||
#${limit} Set Variable 5
|
||||
${data} Set Variable startTime=${startTime}&endTime=${endTime}&logType=${logType}&timeGranularity=${timeGranularity}&limit=${limit}
|
||||
${url1} Set Variable report/policyevent/hit/action
|
||||
${bfResponse} trafficBFRequest ${url1} ${data}
|
||||
@{actionCountList} Set Variable ${bfResponse['data']['actionCount']}
|
||||
Create Session bdapi http://${bigDataIP}:${bigDataPort}
|
||||
${sql} Set Variable select sum(default_in_bytes+default_out_bytes) as default_bytes, sum(allow_in_bytes+allow_out_bytes) as allow_bytes, sum(deny_in_bytes+deny_out_bytes) as deny_bytes, sum(monitor_in_bytes+monitor_out_bytes) as monitor_bytes, sum(intercept_in_bytes+intercept_out_bytes) as intercept_bytes 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
|
||||
@{list} Set Variable ${response['data']}
|
||||
Run Keyword If ${actionCountList}!=[] and ${list}!=[] ForToSecurityActionBytes ${actionCountList} ${list[0]}
|
||||
|
||||
SecurityEventActionHit-packets
|
||||
# dashboard界面 安全策略各动作命中计数 packets bifang和bigData对比
|
||||
[Documentation]
|
||||
... 描述:Security-Action-packets
|
||||
... 参数: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]}
|
||||
${logType} Set Variable security_event_hits_log
|
||||
#${timeGranularity} Set Variable 300
|
||||
#${limit} Set Variable 5
|
||||
${data} Set Variable startTime=${startTime}&endTime=${endTime}&logType=${logType}&timeGranularity=${timeGranularity}&limit=${limit}
|
||||
${url1} Set Variable report/policyevent/hit/action
|
||||
${bfResponse} trafficBFRequest ${url1} ${data}
|
||||
@{actionCountList} Set Variable ${bfResponse['data']['actionCount']}
|
||||
Create Session bdapi http://${bigDataIP}:${bigDataPort}
|
||||
${sql} Set Variable select \ sum(default_in_packets+default_out_packets) as default_packets, sum(allow_in_packets+allow_out_packets) as allow_packets, sum(deny_in_packets+deny_out_packets) as deny_packets, sum(monitor_in_packets+monitor_out_packets) as monitor_packets, sum(intercept_in_packets+intercept_out_packets) as intercept_packets from traffic_metrics_log \ where \ \ __time >= '${startTime}' and __time < '${endTime}' 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 ${actionCountList}!=[] and ${list}!=[] ForToSecurityActionPackets ${actionCountList} ${list[0]}
|
||||
|
||||
SecurityEventActionHit-sessions
|
||||
# dashboard界面 安全策略各动作命中计数 sessions bifang和bigData对比
|
||||
[Documentation]
|
||||
... 描述:Security-Action-sessions
|
||||
... 参数: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]}
|
||||
${logType} Set Variable security_event_hits_log
|
||||
#${timeGranularity} Set Variable 300
|
||||
#${limit} Set Variable 5
|
||||
${data} Set Variable startTime=${startTime}&endTime=${endTime}&logType=${logType}&timeGranularity=${timeGranularity}&limit=${limit}
|
||||
${url1} Set Variable report/policyevent/hit/action
|
||||
${bfResponse} trafficBFRequest ${url1} ${data}
|
||||
@{actionCountList} Set Variable ${bfResponse['data']['actionCount']}
|
||||
Create Session bdapi http://${bigDataIP}:${bigDataPort}
|
||||
${sql} Set Variable select sum(default_conn_num) as default_sessions, sum(allow_conn_num) as allow_sessions, sum(deny_conn_num) as deny_sessions, sum(monitor_conn_num) as monitor_sessions, sum(intercept_conn_num) as intercept_sessions 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
|
||||
@{list} Set Variable ${response['data']}
|
||||
Run Keyword If ${actionCountList}!=[] and ${list}!=[] ForToSecurityActionSessions ${actionCountList} ${list[0]}
|
||||
|
||||
SecurityEventActionHit-thrend-bytes
|
||||
# dashboard界面 安全策略各动作命中计数趋势 bytes bifang和bigData对比
|
||||
[Documentation]
|
||||
... 描述:Security-Action-thrend-bytes
|
||||
... 参数: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]}
|
||||
${logType} Set Variable security_event_hits_log
|
||||
#${timeGranularity} Set Variable 300
|
||||
#${limit} Set Variable 5
|
||||
${data} Set Variable startTime=${startTime}&endTime=${endTime}&logType=${logType}&timeGranularity=${timeGranularity}&limit=${limit}
|
||||
${url1} Set Variable report/policyevent/hit/action
|
||||
${bfResponse} trafficBFRequest ${url1} ${data}
|
||||
@{actionTrendList} Set Variable ${bfResponse['data']['trendList']}
|
||||
${type} Set Variable bytes
|
||||
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, 'default_bytes' as type, \ sum(default_in_bytes+default_out_bytes) as bytes 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, 'allow_bytes' as type, \ sum(allow_in_bytes+allow_out_bytes) as bytes 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, 'deny_bytes' as type, \ sum(deny_in_bytes+deny_out_bytes) as bytes 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, 'monitor_bytes' as type, \ sum(monitor_in_bytes+monitor_out_bytes) as bytes 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, 'intercept_bytes' as type, \ sum(intercept_in_bytes+intercept_out_bytes) as bytes 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
|
||||
@{list} Set Variable ${response['data']}
|
||||
#${types} Set Variable bytes
|
||||
Run Keyword If ${actionTrendList}!=[] and ${list}!=[] ForToSecurityAtionTrendOne ${actionTrendList} ${type} @{list}
|
||||
|
||||
|
||||
SecurityEventActionHit-thrend-packets
|
||||
# dashboard界面 安全策略各动作命中计数趋势 packets bifang和bigData对比
|
||||
[Documentation]
|
||||
... 描述:Security-Action-thrend-packets
|
||||
... 参数:timeNum(必传,查询的时间范围类型 1 当前时间前一小时 2 当前时间前一天 3 当前时间前一周)
|
||||
... timeGranularity(必传,时间粒度300s )
|
||||
... 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]}
|
||||
${logType} Set Variable security_event_hits_log
|
||||
#${timeGranularity} Set Variable 300
|
||||
#${limit} Set Variable 5
|
||||
${data} Set Variable startTime=${startTime}&endTime=${endTime}&logType=${logType}&timeGranularity=${timeGranularity}&limit=${limit}
|
||||
${url1} Set Variable report/policyevent/hit/action
|
||||
${bfResponse} trafficBFRequest ${url1} ${data}
|
||||
@{actionTrendList} Set Variable ${bfResponse['data']['trendList']}
|
||||
${type} Set Variable packets
|
||||
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, 'default_packets' as type, \ sum(default_in_packets+default_out_packets) as packets 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, 'allow_packets' as type, sum(allow_in_packets+allow_out_packets) as packets 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, 'deny_packets' as type, sum(deny_in_packets+deny_out_packets) as packets 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, 'monitor_packets' as type, sum(monitor_in_packets+monitor_out_packets) as packets 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, 'intercept_packets' as type, sum(intercept_in_packets+intercept_out_packets) as packets 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
|
||||
@{list} Set Variable ${response['data']}
|
||||
#${types} Set Variable packets
|
||||
Run Keyword If ${actionTrendList}!=[] and ${list}!=[] ForToSecurityAtionTrendOne ${actionTrendList} ${type} @{list}
|
||||
|
||||
SecurityEventActionHit-thrend-sessions
|
||||
# dashboard界面 安全策略各动作命中计数趋势 sessions bifang和bigData对比
|
||||
[Documentation]
|
||||
... 描述:Security-Action-thrend-packets
|
||||
... 参数:timeNum(必传,查询的时间范围类型 1 当前时间前一小时 2 当前时间前一天 3 当前时间前一周)
|
||||
... timeGranularity(必传,时间粒度300s )
|
||||
... 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]}
|
||||
${logType} Set Variable security_event_hits_log
|
||||
#${timeGranularity} Set Variable 300
|
||||
#${limit} Set Variable 5
|
||||
${data} Set Variable startTime=${startTime}&endTime=${endTime}&logType=${logType}&timeGranularity=${timeGranularity}&limit=${limit}
|
||||
${url1} Set Variable report/policyevent/hit/action
|
||||
${bfResponse} trafficBFRequest ${url1} ${data}
|
||||
@{actionTrendList} Set Variable ${bfResponse['data']['trendList']}
|
||||
${type} Set Variable sessions
|
||||
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, 'default_conn_num' as type, sum(default_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, 'allow_conn_num' as type, sum(allow_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, 'deny_conn_num' as type, sum(deny_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, 'monitor_conn_num' as type, sum(monitor_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, 'intercept_conn_num' as type, sum(intercept_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
|
||||
@{list} Set Variable ${response['data']}
|
||||
#${types} Set Variable sessions
|
||||
Run Keyword If ${actionTrendList}!=[] and ${list}!=[] ForToSecurityAtionTrendOne ${actionTrendList} ${type} @{list}
|
||||
|
||||
ProxyEventActionHit-sessions
|
||||
# dashboard界面 代理策略各动作命中计数 sessions bifang和bigData对比
|
||||
[Documentation]
|
||||
... 描述:Proxy-Action-sessions
|
||||
... 参数:timeNum(必传,查询的时间范围类型 1 当前时间前一小时 2 当前时间前一天 3 当前时间前一周)
|
||||
... timeGranularity(必传,时间粒度300s )
|
||||
... 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]}
|
||||
${logType} Set Variable proxy_event_hits_log
|
||||
#${timeGranularity} Set Variable 300
|
||||
#${limit} Set Variable 5
|
||||
${data} Set Variable startTime=${startTime}&endTime=${endTime}&logType=${logType}&timeGranularity=${timeGranularity}&limit=${limit}
|
||||
${url1} Set Variable report/policyevent/hit/action
|
||||
${bfResponse} trafficBFRequest ${url1} ${data}
|
||||
@{actionCountList} Set Variable ${bfResponse['data']['actionCount']}
|
||||
Create Session bdapi http://${bigDataIP}:${bigDataPort}
|
||||
${sql} Set Variable select sub_action as action, sum(hits) as hits from proxy_event_hits_log where \ __time >= '${startTime}' and __time < '${endTime}' \ group by \ sub_action
|
||||
${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 ${actionCountList}!=[] and ${list}!=[] ForToProxyAtionSession ${actionCountList} ${list}
|
||||
|
||||
ProxyEventActionHit-trend-sessions
|
||||
# dashboard界面 代理策略各动作命中计数趋势 sessions bifang和bigData对比
|
||||
[Documentation]
|
||||
... 描述:Proxy-Action-trend-sessions
|
||||
... 参数:timeNum(必传,查询的时间范围类型 1 当前时间前一小时 2 当前时间前一天 3 当前时间前一周)
|
||||
... timeGranularity(必传,时间粒度300s )
|
||||
... 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]}
|
||||
${logType} Set Variable proxy_event_hits_log
|
||||
#${timeGranularity} Set Variable 300
|
||||
#${limit} Set Variable 5
|
||||
${data} Set Variable startTime=${startTime}&endTime=${endTime}&logType=${logType}&timeGranularity=${timeGranularity}&limit=${limit}
|
||||
${url1} Set Variable report/policyevent/hit/action
|
||||
${bfResponse} trafficBFRequest ${url1} ${data}
|
||||
@{trendList} Set Variable ${bfResponse['data']['trendList']}
|
||||
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, sub_action \ as action, sum(hits) as hits from proxy_event_hits_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'), sub_action \ 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 ${trendList}!=[] and ${list}!=[] ForToProxyAtionTrendSession ${trendList} ${list}
|
||||
@@ -0,0 +1,73 @@
|
||||
*** Settings ***
|
||||
Library Collections
|
||||
Library RequestsLibrary
|
||||
Library String
|
||||
Resource ../../../03-Variable/Bifangapivariable.txt
|
||||
Resource ForTwoKeywords.robot
|
||||
|
||||
*** Keywords ***
|
||||
SecurityEventHit
|
||||
# dashboard界面 安全策略命中TopN bifang和bigData对比
|
||||
[Documentation]
|
||||
... 描述:SecurityEventHit 安全策略命中TopN
|
||||
... 参数: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]}
|
||||
${logType} Set Variable security_event_hits_log
|
||||
#${limit} Set Variable 5
|
||||
${data} Set Variable startTime=${startTime}&endTime=${endTime}&logType=${logType}&limit=${limit}
|
||||
${url1} Set Variable report/policyevent/hit/topn
|
||||
${bfResponse} trafficBFRequest ${url1} ${data}
|
||||
@{bfList} Set Variable ${bfResponse['data']['list']}
|
||||
${bfListLength} Get Length ${bfList}
|
||||
Create Session bdapi http://${bigDataIP}:${bigDataPort}
|
||||
${sql} Set Variable select policy_id, action, sum(hits) as hits from security_event_hits_log \ where \ __time >='${startTime}' and __time < '${endTime}' \ group by policy_id, action \ 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']}
|
||||
${listLength} Get Length ${list}
|
||||
Should Be Equal As Integers ${bfListLength} ${listLength}
|
||||
${types} Set Variable hits
|
||||
Run Keyword If ${bfList}!=[] and ${list}!=[] ForToEventHitTopTrend ${bfList} ${types} ${list}
|
||||
|
||||
|
||||
ProxyEventHit
|
||||
# dashboard界面 代理策略命中TopN bifang和bigData对比
|
||||
[Documentation]
|
||||
... 描述:ProxyEventHit 代理策略命中TopN
|
||||
... 参数: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]}
|
||||
${logType} Set Variable proxy_event_hits_log
|
||||
#${limit} Set Variable 5
|
||||
${data} Set Variable startTime=${startTime}&endTime=${endTime}&logType=${logType}&limit=${limit}
|
||||
${url1} Set Variable report/policyevent/hit/topn
|
||||
${bfResponse} trafficBFRequest ${url1} ${data}
|
||||
@{bfList} Set Variable ${bfResponse['data']['list']}
|
||||
${bfListLength} Get Length ${bfList}
|
||||
Create Session bdapi http://${bigDataIP}:${bigDataPort}
|
||||
${sql} Set Variable select \ policy_id, sub_action as \ action, sum(hits) as \ hits from \ proxy_event_hits_log \ where __time >= '${startTime}' and __time < '${endTime}' \ \ group by policy_id, sub_action 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']}
|
||||
${listLength} Get Length ${list}
|
||||
Should Be Equal As Integers ${bfListLength} ${listLength}
|
||||
${types} Set Variable hits
|
||||
Run Keyword If ${bfList}!=[] and ${list}!=[] ForToEventHitTopTrend ${bfList} ${types} ${list}
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
*** Settings ***
|
||||
Library Collections
|
||||
Library RequestsLibrary
|
||||
Library String
|
||||
Resource ../../../03-Variable/Bifangapivariable.txt
|
||||
Resource ForTwoKeywords.robot
|
||||
|
||||
*** Keywords ***
|
||||
ProxyPinning
|
||||
# dashboard界面 Proxy Pinning计数 bifang和bigData对比
|
||||
[Documentation]
|
||||
... 描述:ProxyPinning
|
||||
... 参数:timeNum(必传,查询的时间范围类型 1 当前时间前一小时 2 当前时间前一天 3 当前时间前一周)
|
||||
... timeGranularity(必传,时间粒度 300s)
|
||||
... 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 300
|
||||
#${limit} Set Variable 5
|
||||
${data} Set Variable startTime=${startTime}&endTime=${endTime}&timeGranularity=${timeGranularity}&limit=${limit}
|
||||
${url1} Set Variable report/policyevent/hit/pinning
|
||||
${bfResponse} TrafficBFRequest ${url1} ${data}
|
||||
${notPinningNum} Set Variable ${bfResponse['data']['notPinningNum']}
|
||||
${maybePinningNum} Set Variable ${bfResponse['data']['maybePinningNum']}
|
||||
${pinningNum} Set Variable ${bfResponse['data']['pinningNum']}
|
||||
Create Session bdapi http://${bigDataIP}:${bigDataPort}
|
||||
${sql} Set Variable (select \ sum(hits) as hits, 'not_pinning_num' as type from security_event_hits_log \ where __time >= '${startTime}' and __time < '${endTime}' and pinningst=0) \ union all \ (select \ sum(hits) as hits, 'pinning_num' as type from security_event_hits_log \ where __time >= '${startTime}' and __time < '${endTime}' and pinningst=1) \ union all \ (select \ sum(hits) as hits, 'maybe_pinning_num' as type from security_event_hits_log \ where __time >= '${startTime}' and __time < '${endTime}' and pinningst=2)
|
||||
${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']}
|
||||
FOR ${element} IN @{list}
|
||||
log ${element}
|
||||
Run Keyword If '${element['type']}'=='not_pinning_num' Should Be Equal ${element['hits']} ${notPinningNum}
|
||||
... ELSE IF '${element['type']}'=='pinning_num' Should Be Equal ${element['hits']} ${pinningNum}
|
||||
... ELSE IF '${element['type']}'=='maybe_pinning_num' Should Be Equal ${element['hits']} ${maybePinningNum}
|
||||
END
|
||||
|
||||
ProxyPinningTrend
|
||||
# dashboard界面 Proxy Pinning计数趋势 bifang和bigData对比
|
||||
[Documentation]
|
||||
... 描述:ProxyPinning-trend
|
||||
... 参数:timeNum(必传,查询的时间范围类型 1 当前时间前一小时 2 当前时间前一天 3 当前时间前一周)
|
||||
... timeGranularity(必传,时间粒度 300s)
|
||||
... 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 300
|
||||
#${limit} Set Variable 5
|
||||
${data} Set Variable startTime=${startTime}&endTime=${endTime}&timeGranularity=${timeGranularity}&limit=${limit}
|
||||
${url1} Set Variable report/policyevent/hit/pinning
|
||||
${bfResponse} trafficBFRequest ${url1} ${data}
|
||||
@{notPinningTrendList} Set Variable ${bfResponse['data']['notPinningTrendList']}
|
||||
@{maybePinningTrendList} Set Variable ${bfResponse['data']['maybePinningTrendList']}
|
||||
@{pinningTrendList} Set Variable ${bfResponse['data']['pinningTrendList']}
|
||||
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, 'not_pinning_num' as type, sum(hits) as hits from security_event_hits_log where __time >= '${startTime}' and __time < '${endTime}' and pinningst=0 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, 'pinning_num' as type, sum(hits) as hits from security_event_hits_log where \ __time >= '${startTime}' and __time < '${endTime}' and pinningst=1 \ 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, 'maybe_pinning_num' as type, sum(hits) as hits from security_event_hits_log where \ __time >= '${startTime}' and __time < '${endTime}' and pinningst=2 \ \ 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
|
||||
@{list} Set Variable ${response['data']}
|
||||
${type1} Set Variable not_pinning_num
|
||||
Run Keyword If ${notPinningTrendList}!=[] and ${list}!=[] ForToProxyPinningTrend ${notPinningTrendList} ${type1} ${list}
|
||||
${type2} Set Variable maybe_pinning_num
|
||||
Run Keyword If ${maybePinningTrendList}!=[] and ${list}!=[] ForToProxyPinningTrend ${maybePinningTrendList} ${type2} ${list}
|
||||
${type3} Set Variable pinning_num
|
||||
Run Keyword If ${pinningTrendList}!=[] and ${list}!=[] ForToProxyPinningTrend ${pinningTrendList} ${type3} ${list}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
*** Settings ***
|
||||
Library Collections
|
||||
Library RequestsLibrary
|
||||
Library String
|
||||
Resource ../../../03-Variable/Bifangapivariable.txt
|
||||
Resource ForTwoKeywords.robot
|
||||
|
||||
*** Keywords ***
|
||||
ServiceIPTopN
|
||||
#dashboard 目的IP统计 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/serverip
|
||||
${bfResponse} trafficBFRequest ${url1} ${data}
|
||||
@{List1} Set Variable ${bfResponse['data']['list']}
|
||||
Create Session bdapi http://${bigDataIP}:${bigDataPort}
|
||||
${sql} Set Variable select destination as server_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_external_host_log \ where \ __time >= '${startTime}' and __time < '${endTime}' and order_by='${orderBy}' group by destination 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 serverIp
|
||||
${type} Set Variable server_ip
|
||||
Run Keyword If ${List1}!=[] and ${list}!=[] ForToTopN-One ${List1} ${type1} ${type} ${list}
|
||||
@@ -0,0 +1,38 @@
|
||||
*** Settings ***
|
||||
Library Collections
|
||||
Library RequestsLibrary
|
||||
Library String
|
||||
Resource ../../../03-Variable/Bifangapivariable.txt
|
||||
Resource ForTwoKeywords.robot
|
||||
|
||||
*** Keywords ***
|
||||
SubscriberidTopN
|
||||
#dashboard 用户TopN统计 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/subscriberid
|
||||
${bfResponse} trafficBFRequest ${url1} ${data}
|
||||
@{List1} Set Variable ${bfResponse['data']['list']}
|
||||
Create Session bdapi http://${bigDataIP}:${bigDataPort}
|
||||
${sql} Set Variable select subscriber_id, 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_user_log where \ __time >= '${startTime}' and __time < '${endTime}' \ and order_by='${orderBy}' group by subscriber_id 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 subscriberid
|
||||
${type} Set Variable subscriber_id
|
||||
Run Keyword If ${List1}!=[] and ${list}!=[] ForToTopN-One ${List1} ${type1} ${type} ${list}
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
*** 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}
|
||||
|
||||
|
||||
@@ -0,0 +1,193 @@
|
||||
*** Settings ***
|
||||
Library Collections
|
||||
Library RequestsLibrary
|
||||
Library String
|
||||
Resource ../../../03-Variable/Bifangapivariable.txt
|
||||
Resource ForTwoKeywords.robot
|
||||
|
||||
*** Keywords ***
|
||||
Dashboard-Traffic-bytes
|
||||
# Traffics-带宽统计 统计类型:bytes bifang和bigData对比 Traffic IN/OUT
|
||||
[Documentation]
|
||||
... 描述:Traffic-Bytes统计
|
||||
... 参数: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}&statisticsUnit=bytes
|
||||
${url1} Set Variable report/traffic/statisticsbyunit
|
||||
${bfResponse} TrafficBFRequest ${url1} ${data}
|
||||
${trafficInBytes} Set Variable ${bfResponse['data']['trafficInBytes']}
|
||||
${trafficOutBytes} Set Variable ${bfResponse['data']['trafficOutBytes']}
|
||||
Create Session bdapi http://${bigDataIP}:${bigDataPort}
|
||||
${sql} Set Variable select sum(total_in_bytes) as traffic_in_bytes, sum(total_out_bytes) as traffic_out_bytes from traffic_metrics_log where __time >= '${startTime}' and __time < '${endTime}'
|
||||
${remoteResponse} Get Request bdapi ?query=${sql}
|
||||
${response} to json ${remoteResponse.content}
|
||||
${trafficInBytes1} Set Variable ${response['data'][0]['traffic_in_bytes']}
|
||||
${trafficOutBytes1} Set Variable ${response['data'][0]['traffic_out_bytes']}
|
||||
Should Be True ${trafficInBytes}==${trafficInBytes1}
|
||||
Should Be True ${trafficOutBytes}==${trafficOutBytes1}
|
||||
[Return] OK
|
||||
|
||||
Dashboard-Traffic-packets
|
||||
# Traffics-带宽统计 统计类型:packets bifang和bigData对比 Traffic IN/OUT
|
||||
[Documentation]
|
||||
... 描述:Traffic-packets统计
|
||||
... 参数: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}&statisticsUnit=packets
|
||||
${url1} Set Variable report/traffic/statisticsbyunit
|
||||
${bfResponse} TrafficBFRequest ${url1} ${data}
|
||||
${trafficInPackets} Set Variable ${bfResponse['data']['trafficInPackets']}
|
||||
${trafficOutPackets} Set Variable ${bfResponse['data']['trafficOutPackets']}
|
||||
Create Session bdapi http://${bigDataIP}:${bigDataPort}
|
||||
${sql} Set Variable select sum(total_in_packets) as traffic_in_packets, sum(total_out_packets) as traffic_out_packets 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
|
||||
${traffic_in_packets1} Set Variable ${response['data'][0]['traffic_in_packets']}
|
||||
${traffic_out_packets1} Set Variable ${response['data'][0]['traffic_out_packets']}
|
||||
Should Be True ${trafficInPackets}==${traffic_in_packets1}
|
||||
Should Be True ${trafficOutPackets}==${traffic_out_packets1}
|
||||
[Return] OK
|
||||
|
||||
Dashboard-Traffic-sessions
|
||||
# Traffics-带宽统计 统计类型:sessions bifang和bigData对比 Traffic IN/OUT
|
||||
[Documentation]
|
||||
... 描述:Traffic-sessions统计
|
||||
... 参数: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}&statisticsUnit=sessions
|
||||
${url1} Set Variable report/traffic/statisticsbyunit
|
||||
${bfResponse} trafficBFRequest ${url1} ${data}
|
||||
${sessions} Set Variable ${bfResponse['data']['sessions']}
|
||||
Create Session bdapi http://${bigDataIP}:${bigDataPort}
|
||||
${sql} Set Variable select sum(new_conn_num) as sessions 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
|
||||
${sessions1} Set Variable ${response['data'][0]['sessions']}
|
||||
Should Be True ${sessions}==${sessions1}
|
||||
[Return] OK
|
||||
|
||||
Dashboard-Traffic-trend-bytes
|
||||
# Traffics-带宽趋势 统计类型:bytes bifang和bigData对比 Traffic IN/OUT
|
||||
[Documentation]
|
||||
... 描述:Traffic-trend-bytes
|
||||
... 参数: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}&statisticsUnit=bytes&timeGranularity=${timeGranularity}&limit=${limit}
|
||||
${url1} Set Variable report/traffic/statisticsbyunit
|
||||
${bfResponse} trafficBFRequest ${url1} ${data}
|
||||
@{bytesOutList1} Set Variable ${bfResponse['data']['trafficOutBytesList']}
|
||||
@{bytesInList1} Set Variable ${bfResponse['data']['trafficInBytesList']}
|
||||
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, 'traffic_in_bytes' as type, sum(total_in_bytes) as bytes 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, 'traffic_out_bytes' as type, sum(total_out_bytes) as bytes 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
|
||||
@{bytesList2} Set Variable ${response['data']}
|
||||
${typeIn} Set Variable traffic_in_bytes
|
||||
${typeOut} Set Variable traffic_out_bytes
|
||||
${types} Set Variable bytes
|
||||
Run Keyword If ${bytesOutList1}!=[] and ${bytesList2}!=[] ForToTrafficTrend ${bytesOutList1} ${typeOut} ${types} ${bytesList2}
|
||||
Run Keyword If ${bytesInList1}!=[] and ${bytesList2}!=[] ForToTrafficTrend ${bytesInList1} ${typeIn} ${types} ${bytesList2}
|
||||
|
||||
Dashboard-Traffic-trend-packets
|
||||
# Traffics-带宽趋势 统计类型:packets bifang和bigData对比 Traffic IN/OUT
|
||||
[Documentation]
|
||||
... 描述:Traffic-trend-packets
|
||||
... 参数: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
|
||||
${data} Set Variable startTime=${startTime}&endTime=${endTime}&statisticsUnit=packets&timeGranularity=${timeGranularity}&limit=${limit}
|
||||
${url1} Set Variable report/traffic/statisticsbyunit
|
||||
${bfResponse} trafficBFRequest ${url1} ${data}
|
||||
@{packetsOutList1} Set Variable ${bfResponse['data']['trafficOutPacketsList']}
|
||||
@{packetsInList1} Set Variable ${bfResponse['data']['trafficInPacketsList']}
|
||||
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, 'traffic_in_packets' as type, sum(total_in_packets) as packets 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') union all select DATE_FORMAT(FROM_UNIXTIME(FLOOR(UNIX_TIMESTAMP(__time)/${timeGranularity})*${timeGranularity}),'%Y-%m-%d %H:%i:%s') as stat_time, 'traffic_out_packets' as type, sum(total_out_packets) as packets 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'))
|
||||
#${remoteResponse} Get Request bdapi ?query=${sql}
|
||||
${sql} Set Variable (select DATE_FORMAT(FROM_UNIXTIME(FLOOR(UNIX_TIMESTAMP(__time)/${timeGranularity})*${timeGranularity}),'%Y-%m-%d %H:%i:%s') as stat_time, 'traffic_in_packets' as type, sum(total_in_packets) as packets 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, 'traffic_out_packets' as type, sum(total_out_packets) as packets 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
|
||||
@{packetsList2} Set Variable ${response['data']}
|
||||
${typeIn} Set Variable traffic_in_packets
|
||||
${typeOut} Set Variable traffic_out_packets
|
||||
${types} Set Variable packets
|
||||
Run Keyword If ${packetsOutList1}!=[] and ${packetsList2}!=[] ForToTrafficTrend ${packetsOutList1} ${typeOut} ${types} ${packetsList2}
|
||||
Run Keyword If ${packetsInList1}!=[] and ${packetsList2}!=[] ForToTrafficTrend ${packetsInList1} ${typeIn} ${types} ${packetsList2}
|
||||
|
||||
Dashboard-Traffic-trend-sessions
|
||||
# Traffics-带宽趋势 统计类型:sessions bifang和bigData对比 Traffic IN/OUT
|
||||
[Documentation]
|
||||
... 描述:Traffic-trend-sessions
|
||||
... 参数: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
|
||||
${data} Set Variable startTime=${startTime}&endTime=${endTime}&statisticsUnit=sessions&timeGranularity=${timeGranularity}&limit=${limit}
|
||||
${url1} Set Variable report/traffic/statisticsbyunit
|
||||
${bfResponse} trafficBFRequest ${url1} ${data}
|
||||
@{sessionsList1} Set Variable ${bfResponse['data']['sessionsList']}
|
||||
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, 'total_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')
|
||||
#${remoteResponse} Get Request bdapi ?query=${sql}
|
||||
${sql} Set Variable select DATE_FORMAT(FROM_UNIXTIME(FLOOR(UNIX_TIMESTAMP(__time)/${timeGranularity}) *${timeGranularity}),'%Y-%m-%d %H:%i:%s') as stat_time, 'total_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}
|
||||
${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
|
||||
@{sessionsList2} Set Variable ${response['data']}
|
||||
${type} Set Variable total_conn_num
|
||||
${types} Set Variable sessions
|
||||
Run Keyword If ${sessionsList1}!=[] and ${sessionsList2}!=[] ForToTrafficTrend ${sessionsList1} ${type} ${types} ${sessionsList2}
|
||||
|
||||
|
||||
|
||||
|
||||
34
02-Keyword/tsg_bfapi/dashboard_data_compare/UrlTopN.robot
Normal file
34
02-Keyword/tsg_bfapi/dashboard_data_compare/UrlTopN.robot
Normal file
@@ -0,0 +1,34 @@
|
||||
*** 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}
|
||||
|
||||
Reference in New Issue
Block a user