@@ -1,105 +0,0 @@
|
||||
*** Settings ***
|
||||
Resource ../../../02-Keyword/tsg_bfapi/LogStatistics.robot
|
||||
Library DateTime
|
||||
|
||||
*** Test Cases ***
|
||||
Statistics-Country-00001
|
||||
#apiName,请求大数据时,用于区分每个接口的sql
|
||||
${apiName} set variable country
|
||||
#请求地址 例如:/report/domain/recommend
|
||||
${url} set variable /report/country/sourceipnum
|
||||
#开始时间格式Y-M-D h:i:s
|
||||
${startTime} set variable 2020-4-11 13:36:35.000
|
||||
#结束时间格式Y-M-D h:i:s
|
||||
${endTime} set variable 2020-4-30 13:36:35.000
|
||||
#limit int型
|
||||
${limit} set variable 50
|
||||
GetApi ${apiName} ${url} startTime=${startTime} endTime=${endTime} limit=${limit}
|
||||
|
||||
Statistics-Country-00002
|
||||
#最近一小时
|
||||
#apiName,请求大数据时,用于区分每个接口的sql
|
||||
${apiName} set variable country
|
||||
#请求地址 例如:/report/domain/recommend
|
||||
${url} set variable /report/country/sourceipnum
|
||||
#开始时间
|
||||
#结束时间格式Y-M-D h:i:s
|
||||
${Time} get current date
|
||||
${endTime}= add time to date ${Time} -00:05:00
|
||||
#开始时间格式Y-M-D h:i:s
|
||||
${startTime}= add time to date ${endTime}= -01:00:00
|
||||
#limit int型
|
||||
${limit} set variable 50
|
||||
GetApi ${apiName} ${url} startTime=${startTime} endTime=${endTime} limit=${limit}
|
||||
|
||||
Statistics-Country-00003
|
||||
#最近一天
|
||||
#apiName,请求大数据时,用于区分每个接口的sql
|
||||
${apiName} set variable country
|
||||
#请求地址 例如:/report/domain/recommend
|
||||
${url} set variable /report/country/sourceipnum
|
||||
#开始时间
|
||||
#结束时间格式Y-M-D h:i:s
|
||||
${Time} get current date
|
||||
${endTime}= add time to date ${Time} -00:05:00
|
||||
#结束时间格式Y-M-D h:i:s
|
||||
${startTime}= add time to date ${endTime}= -1 days
|
||||
log ${endTime}
|
||||
log ${startTime}
|
||||
#limit int型
|
||||
${limit} set variable 50
|
||||
GetApi ${apiName} ${url} startTime=${startTime} endTime=${endTime} limit=${limit}
|
||||
|
||||
Statistics-Country-00004
|
||||
#最近一周
|
||||
#apiName,请求大数据时,用于区分每个接口的sql
|
||||
${apiName} set variable country
|
||||
#请求地址 例如:/report/domain/recommend
|
||||
${url} set variable /report/country/sourceipnum
|
||||
#开始时间
|
||||
#结束时间格式Y-M-D h:i:s
|
||||
${Time} get current date
|
||||
${endTime}= add time to date ${Time} -00:05:00
|
||||
#结束时间格式Y-M-D h:i:s
|
||||
${startTime}= add time to date ${endTime}= -7 days
|
||||
log ${endTime}
|
||||
log ${startTime}
|
||||
#limit int型
|
||||
${limit} set variable 50
|
||||
GetApi ${apiName} ${url} startTime=${startTime} endTime=${endTime} limit=${limit}
|
||||
|
||||
Statistics-Country-00005
|
||||
#最近一个月(30天)
|
||||
#apiName,请求大数据时,用于区分每个接口的sql
|
||||
${apiName} set variable country
|
||||
#请求地址 例如:/report/domain/recommend
|
||||
${url} set variable /report/country/sourceipnum
|
||||
#开始时间
|
||||
#结束时间格式Y-M-D h:i:s
|
||||
${Time} get current date
|
||||
${endTime}= add time to date ${Time} -00:05:00
|
||||
#结束时间格式Y-M-D h:i:s
|
||||
${startTime}= add time to date ${endTime}= -30 days
|
||||
log ${endTime}
|
||||
log ${startTime}
|
||||
#limit int型
|
||||
${limit} set variable 50
|
||||
GetApi ${apiName} ${url} startTime=${startTime} endTime=${endTime} limit=${limit}
|
||||
|
||||
Statistics-Country-00006
|
||||
#最近一年(365天)
|
||||
#apiName,请求大数据时,用于区分每个接口的sql
|
||||
${apiName} set variable country
|
||||
#请求地址 例如:/report/domain/recommend
|
||||
${url} set variable /report/country/sourceipnum
|
||||
#开始时间
|
||||
#结束时间格式Y-M-D h:i:s
|
||||
${Time} get current date
|
||||
${endTime}= add time to date ${Time} -00:05:00
|
||||
#结束时间格式Y-M-D h:i:s
|
||||
${startTime}= add time to date ${endTime}= -365 days
|
||||
log ${endTime}
|
||||
log ${startTime}
|
||||
#limit int型
|
||||
${limit} set variable 50
|
||||
GetApi ${apiName} ${url} startTime=${startTime} endTime=${endTime} limit=${limit}
|
||||
@@ -1,12 +0,0 @@
|
||||
*** Settings ***
|
||||
Resource ../../../02-Keyword/tsg_bfapi/LogStatistics.robot
|
||||
|
||||
*** Test Cases ***
|
||||
Statistics-domain-00001
|
||||
#apiName,请求大数据时,用于区分每个接口的sql
|
||||
${apiName} set variable domain
|
||||
#请求地址 例如:/report/domain/recommend
|
||||
${url} set variable /report/domain/recommend
|
||||
# \ 统计时间, \ 查询最近24小时数据;例如当前时间为2020-03-26 15:14:00, 查询时间应设为推前1小时的整点,实际传入参数为 "2020-03-26 14:00:00"
|
||||
${statisticTime} set variable 2020-04-26 23:00:00
|
||||
GetApi ${apiName} ${url} statisticTime=${statisticTime}
|
||||
@@ -1,102 +0,0 @@
|
||||
*** Settings ***
|
||||
Resource ../../../02-Keyword/tsg_bfapi/LogStatistics.robot
|
||||
Library DateTime
|
||||
|
||||
*** Test Cases ***
|
||||
Statistics-hijack_srcip_location-00001
|
||||
#apiName,请求大数据时,用于区分每个接口的sql
|
||||
${apiName} set variable hijack_srcip_location
|
||||
#请求地址 例如:/report/domain/recommend
|
||||
${url} set variable /report/hijack_srcip_location
|
||||
#开始时间格式Y-M-D h:i:s
|
||||
${startTime} set variable 2020-04-01 16:43:48
|
||||
#结束时间格式Y-M-D h:i:s
|
||||
${endTime} set variable 2020-04-26 16:40:01
|
||||
#策略ID
|
||||
${policy_id} set variable 0
|
||||
GetApi ${apiName} ${url} startTime=${startTime} endTime=${endTime} policy_id=${policy_id}
|
||||
|
||||
Statistics-hijack_srcip_location-00002
|
||||
#最近一小时
|
||||
#apiName,请求大数据时,用于区分每个接口的sql
|
||||
${apiName} set variable hijack_srcip_location
|
||||
#请求地址 例如:/report/domain/recommend
|
||||
${url} set variable /report/hijack_srcip_location
|
||||
#结束时间格式Y-M-D h:i:s
|
||||
${Time} get current date
|
||||
${endTime}= add time to date ${Time} -00:05:00
|
||||
${endTime} Get Substring ${endTime} \ -4
|
||||
#开始时间格式Y-M-D h:i:s
|
||||
${startTime}= add time to date ${endTime}= -01:00:00
|
||||
${startTime} Get Substring ${startTime} \ -4
|
||||
#策略ID
|
||||
${policy_id} set variable 0
|
||||
GetApi ${apiName} ${url} startTime=${startTime} endTime=${endTime} policy_id=${policy_id}
|
||||
|
||||
Statistics-hijack_srcip_location-00003
|
||||
#最近一天
|
||||
#apiName,请求大数据时,用于区分每个接口的sql
|
||||
${apiName} set variable hijack_srcip_location
|
||||
#请求地址 例如:/report/domain/recommend
|
||||
${url} set variable /report/hijack_srcip_location
|
||||
#结束时间格式Y-M-D h:i:s
|
||||
${Time} get current date
|
||||
${endTime}= add time to date ${Time} -00:05:00
|
||||
${endTime} Get Substring ${endTime} \ -4
|
||||
#结束时间格式Y-M-D h:i:s
|
||||
${startTime}= add time to date ${endTime}= -1 days
|
||||
${startTime} Get Substring ${startTime} \ -4
|
||||
#策略ID
|
||||
${policy_id} set variable 0
|
||||
GetApi ${apiName} ${url} startTime=${startTime} endTime=${endTime} policy_id=${policy_id}
|
||||
|
||||
Statistics-hijack_srcip_location-00004
|
||||
#最近一周
|
||||
#apiName,请求大数据时,用于区分每个接口的sql
|
||||
${apiName} set variable hijack_srcip_location
|
||||
#请求地址 例如:/report/domain/recommend
|
||||
${url} set variable /report/hijack_srcip_location
|
||||
#结束时间格式Y-M-D h:i:s
|
||||
${Time} get current date
|
||||
${endTime}= add time to date ${Time} -00:05:00
|
||||
${endTime} Get Substring ${endTime} \ -4
|
||||
#开始时间格式Y-M-D h:i:s
|
||||
${startTime}= add time to date ${endTime}= -7 days
|
||||
${startTime} Get Substring ${startTime} \ -4
|
||||
#策略ID
|
||||
${policy_id} set variable 0
|
||||
GetApi ${apiName} ${url} startTime=${startTime} endTime=${endTime} policy_id=${policy_id}
|
||||
|
||||
Statistics-hijack_srcip_location-00005
|
||||
#最近一个月(30天)
|
||||
#apiName,请求大数据时,用于区分每个接口的sql
|
||||
${apiName} set variable hijack_srcip_location
|
||||
#请求地址 例如:/report/domain/recommend
|
||||
${url} set variable /report/hijack_srcip_location
|
||||
#结束时间格式Y-M-D h:i:s
|
||||
${Time} get current date
|
||||
${endTime}= add time to date ${Time} -00:05:00
|
||||
${endTime} Get Substring ${endTime} \ -4
|
||||
#开始时间格式Y-M-D h:i:s
|
||||
${startTime}= add time to date ${endTime}= -30 days
|
||||
${startTime} Get Substring ${startTime} \ -4
|
||||
#策略ID
|
||||
${policy_id} set variable 0
|
||||
GetApi ${apiName} ${url} startTime=${startTime} endTime=${endTime} policy_id=${policy_id}
|
||||
|
||||
Statistics-hijack_srcip_location-00006
|
||||
#最近一年(365天)
|
||||
#apiName,请求大数据时,用于区分每个接口的sql
|
||||
${apiName} set variable hijack_srcip_location
|
||||
#请求地址 例如:/report/domain/recommend
|
||||
${url} set variable /report/hijack_srcip_location
|
||||
#结束时间格式Y-M-D h:i:s
|
||||
${Time} get current date
|
||||
${endTime}= add time to date ${Time} -00:05:00
|
||||
${endTime} Get Substring ${endTime} \ -4
|
||||
#开始时间格式Y-M-D h:i:s
|
||||
${startTime}= add time to date ${endTime}= -365 days
|
||||
${startTime} Get Substring ${startTime} \ -4
|
||||
#策略ID
|
||||
${policy_id} set variable 0
|
||||
GetApi ${apiName} ${url} startTime=${startTime} endTime=${endTime} policy_id=${policy_id}
|
||||
@@ -1,113 +0,0 @@
|
||||
*** Settings ***
|
||||
Resource ../../../02-Keyword/tsg_bfapi/LogStatistics.robot
|
||||
Library DateTime
|
||||
|
||||
*** Test Cases ***
|
||||
Statistics-ip_correlation_domain-00001
|
||||
#apiName,请求大数据时,用于区分每个接口的sql
|
||||
${apiName} set variable ip_correlation_domain
|
||||
#请求地址 例如:/report/domain/recommend
|
||||
${url} set variable /report/ip_correlation_domain
|
||||
#开始时间格式Y-M-D h:i:s
|
||||
${startTime} set variable 2020-04-01 16:05:04
|
||||
#结束时间格式Y-M-D h:i:s
|
||||
${endTime} set variable 2020-04-28 16:05:11
|
||||
#IP
|
||||
${ip} set variable 04.194.66.194
|
||||
GetApi ${apiName} ${url} startTime=${startTime} endTime=${endTime} ip=${ip}
|
||||
|
||||
Statistics-ip_correlation_domain-00002
|
||||
#apiName,请求大数据时,用于区分每个接口的sql
|
||||
${apiName} set variable ip_correlation_domain
|
||||
#请求地址 例如:/report/domain/recommend
|
||||
${url} set variable /report/ip_correlation_domain
|
||||
#开始时间格式Y-M-D h:i:s
|
||||
${startTime} set variable 2020-04-01 16:05:04
|
||||
#结束时间格式Y-M-D h:i:s
|
||||
${endTime} set variable 2020-04-28 16:05:11
|
||||
GetApi ${apiName} ${url} startTime=${startTime} endTime=${endTime}
|
||||
|
||||
Statistics-ip_correlation_domain-00003
|
||||
#最近一小时
|
||||
#apiName,请求大数据时,用于区分每个接口的sql
|
||||
${apiName} set variable ip_correlation_domain
|
||||
#请求地址 例如:/report/domain/recommend
|
||||
${url} set variable /report/ip_correlation_domain
|
||||
#结束时间格式Y-M-D h:i:s
|
||||
${Time} get current date
|
||||
${endTime}= add time to date ${Time} -00:05:00
|
||||
${endTime} Get Substring ${endTime} \ -4
|
||||
#开始时间格式Y-M-D h:i:s
|
||||
${startTime}= add time to date ${endTime}= -01:00:00
|
||||
${startTime} Get Substring ${startTime} \ -4
|
||||
#IP
|
||||
${ip} set variable 04.194.66.194
|
||||
GetApi ${apiName} ${url} startTime=${startTime} endTime=${endTime} ip=${ip}
|
||||
|
||||
Statistics-ip_correlation_domain-00004
|
||||
#最近一天
|
||||
#apiName,请求大数据时,用于区分每个接口的sql
|
||||
${apiName} set variable ip_correlation_domain
|
||||
#请求地址 例如:/report/domain/recommend
|
||||
${url} set variable /report/ip_correlation_domain
|
||||
#结束时间格式Y-M-D h:i:s
|
||||
${Time} get current date
|
||||
${endTime}= add time to date ${Time} -00:05:00
|
||||
${endTime} Get Substring ${endTime} \ -4
|
||||
#开始时间格式Y-M-D h:i:s
|
||||
${startTime}= add time to date ${endTime}= -1 days
|
||||
${startTime} Get Substring ${startTime} \ -4
|
||||
#IP
|
||||
${ip} set variable 04.194.66.194
|
||||
GetApi ${apiName} ${url} startTime=${startTime} endTime=${endTime} ip=${ip}
|
||||
|
||||
Statistics-ip_correlation_domain-00005
|
||||
#最近一周(7天)
|
||||
#apiName,请求大数据时,用于区分每个接口的sql
|
||||
${apiName} set variable ip_correlation_domain
|
||||
#请求地址 例如:/report/domain/recommend
|
||||
${url} set variable /report/ip_correlation_domain
|
||||
#结束时间格式Y-M-D h:i:s
|
||||
${Time} get current date
|
||||
${endTime}= add time to date ${Time} -00:05:00
|
||||
${endTime} Get Substring ${endTime} \ -4
|
||||
#开始时间格式Y-M-D h:i:s
|
||||
${startTime}= add time to date ${endTime}= -7 days
|
||||
${startTime} Get Substring ${startTime} \ -4
|
||||
#IP
|
||||
${ip} set variable 04.194.66.194
|
||||
GetApi ${apiName} ${url} startTime=${startTime} endTime=${endTime} ip=${ip}
|
||||
|
||||
Statistics-ip_correlation_domain-00006
|
||||
#最近一个月(30天)
|
||||
#apiName,请求大数据时,用于区分每个接口的sql
|
||||
${apiName} set variable ip_correlation_domain
|
||||
#请求地址 例如:/report/domain/recommend
|
||||
${url} set variable /report/ip_correlation_domain
|
||||
#结束时间格式Y-M-D h:i:s
|
||||
${Time} get current date
|
||||
${endTime}= add time to date ${Time} -00:05:00
|
||||
${endTime} Get Substring ${endTime} \ -4
|
||||
#开始时间格式Y-M-D h:i:s
|
||||
${startTime}= add time to date ${endTime}= -30 days
|
||||
${startTime} Get Substring ${startTime} \ -4
|
||||
#IP
|
||||
${ip} set variable 04.194.66.194
|
||||
GetApi ${apiName} ${url} startTime=${startTime} endTime=${endTime} ip=${ip}
|
||||
|
||||
Statistics-ip_correlation_domain-00007
|
||||
#最近一年
|
||||
#apiName,请求大数据时,用于区分每个接口的sql
|
||||
${apiName} set variable ip_correlation_domain
|
||||
#请求地址 例如:/report/domain/recommend
|
||||
${url} set variable /report/ip_correlation_domain
|
||||
#结束时间格式Y-M-D h:i:s
|
||||
${Time} get current date
|
||||
${endTime}= add time to date ${Time} -00:05:00
|
||||
${endTime} Get Substring ${endTime} \ -4
|
||||
#开始时间格式Y-M-D h:i:s
|
||||
${startTime}= add time to date ${endTime}= -365 days
|
||||
${startTime} Get Substring ${startTime} \ -4
|
||||
#IP
|
||||
${ip} set variable 04.194.66.194
|
||||
GetApi ${apiName} ${url} startTime=${startTime} endTime=${endTime} ip=${ip}
|
||||
@@ -1,130 +0,0 @@
|
||||
*** Settings ***
|
||||
Resource ../../../02-Keyword/tsg_bfapi/LogStatistics.robot
|
||||
Library DateTime
|
||||
|
||||
*** Test Cases ***
|
||||
Statistics-traffic-00001
|
||||
#apiName,请求大数据时,用于区分每个接口的sql
|
||||
${apiName} set variable traffic
|
||||
#请求地址 例如:/report/domain/recommend
|
||||
${url} set variable /report/traffic/statisticsbyunit
|
||||
#统计类型: bytes:字节数 packets:包数 sessions:连接数 如不指定,则统计全部 statisticsUnit=${statisticUnit}
|
||||
${statisticUnit} set variable bytes
|
||||
#开始时间格式Y-M-D h:i:s
|
||||
${startTime} set variable 2020-04-01 13:36:35
|
||||
#结束时间格式Y-M-D h:i:s
|
||||
${endTime} set variable 2020-04-28 16:04:56
|
||||
#统计粒度,单位秒,仅用于趋势查询sql 缺省为30秒
|
||||
${timeGranularity} set variable 70
|
||||
${limit} set variable 1
|
||||
GetApi ${apiName} ${url} startTime=${startTime} endTime=${endTime} timeGranularity=${timeGranularity} limit=${limit} statisticsUnit=${statisticUnit}
|
||||
|
||||
Statistics-traffic-00002
|
||||
#apiName,请求大数据时,用于区分每个接口的sql
|
||||
${apiName} set variable traffic
|
||||
#请求地址 例如:/report/domain/recommend
|
||||
${url} set variable /report/traffic/statisticsbyunit
|
||||
#开始时间格式Y-M-D h:i:s
|
||||
${startTime} set variable 2020-04-01 13:36:35
|
||||
${endTime} set variable 2020-04-28 16:04:56
|
||||
GetApi ${apiName} ${url} startTime=${startTime} endTime=${endTime}
|
||||
|
||||
Statistics-traffic-00003
|
||||
#最近一小时
|
||||
#apiName,请求大数据时,用于区分每个接口的sql
|
||||
${apiName} set variable traffic
|
||||
#请求地址 例如:/report/domain/recommend
|
||||
${url} set variable /report/traffic/statisticsbyunit
|
||||
#统计类型: bytes:字节数 packets:包数 sessions:连接数 如不指定,则统计全部 statisticsUnit=${statisticUnit}
|
||||
${statisticUnit} set variable bytes
|
||||
#结束时间格式Y-M-D h:i:s
|
||||
${Time} get current date
|
||||
${endTime}= add time to date ${Time} -00:05:00
|
||||
${endTime} Get Substring ${endTime} \ -4
|
||||
#开始时间格式Y-M-D h:i:s
|
||||
${startTime}= add time to date ${endTime}= -01:00:00
|
||||
${startTime} Get Substring ${startTime} \ -4
|
||||
#统计粒度,单位秒,仅用于趋势查询sql 缺省为30秒
|
||||
${timeGranularity} set variable 70
|
||||
${limit} set variable 1
|
||||
GetApi ${apiName} ${url} startTime=${startTime} endTime=${endTime} timeGranularity=${timeGranularity} limit=${limit} statisticsUnit=${statisticUnit}
|
||||
|
||||
Statistics-traffic-00004
|
||||
#最近一天
|
||||
#apiName,请求大数据时,用于区分每个接口的sql
|
||||
${apiName} set variable traffic
|
||||
#请求地址 例如:/report/domain/recommend
|
||||
${url} set variable /report/traffic/statisticsbyunit
|
||||
#统计类型: bytes:字节数 packets:包数 sessions:连接数 如不指定,则统计全部 statisticsUnit=${statisticUnit}
|
||||
${statisticUnit} set variable bytes
|
||||
#结束时间格式Y-M-D h:i:s
|
||||
${Time} get current date
|
||||
${endTime}= add time to date ${Time} -00:05:00
|
||||
${endTime} Get Substring ${endTime} \ -4
|
||||
#开始时间格式Y-M-D h:i:s
|
||||
${startTime}= add time to date ${endTime}= -1 days
|
||||
${startTime} Get Substring ${startTime} \ -4
|
||||
#统计粒度,单位秒,仅用于趋势查询sql 缺省为30秒
|
||||
${timeGranularity} set variable 70
|
||||
${limit} set variable 1
|
||||
GetApi ${apiName} ${url} startTime=${startTime} endTime=${endTime} timeGranularity=${timeGranularity} limit=${limit} statisticsUnit=${statisticUnit}
|
||||
|
||||
Statistics-traffic-00005
|
||||
#最近一周(7天)
|
||||
#apiName,请求大数据时,用于区分每个接口的sql
|
||||
${apiName} set variable traffic
|
||||
#请求地址 例如:/report/domain/recommend
|
||||
${url} set variable /report/traffic/statisticsbyunit
|
||||
#统计类型: bytes:字节数 packets:包数 sessions:连接数 如不指定,则统计全部 statisticsUnit=${statisticUnit}
|
||||
${statisticUnit} set variable bytes
|
||||
#结束时间格式Y-M-D h:i:s
|
||||
${Time} get current date
|
||||
${endTime}= add time to date ${Time} -00:05:00
|
||||
${endTime} Get Substring ${endTime} \ -4
|
||||
#开始时间格式Y-M-D h:i:s
|
||||
${startTime}= add time to date ${endTime}= -7 days
|
||||
${startTime} Get Substring ${startTime} \ -4
|
||||
#统计粒度,单位秒,仅用于趋势查询sql 缺省为30秒
|
||||
${timeGranularity} set variable 70
|
||||
${limit} set variable 1
|
||||
GetApi ${apiName} ${url} startTime=${startTime} endTime=${endTime} timeGranularity=${timeGranularity} limit=${limit} statisticsUnit=${statisticUnit}
|
||||
|
||||
Statistics-traffic-00006
|
||||
#最近一个月(30天)
|
||||
#apiName,请求大数据时,用于区分每个接口的sql
|
||||
${apiName} set variable traffic
|
||||
#请求地址 例如:/report/domain/recommend
|
||||
${url} set variable /report/traffic/statisticsbyunit
|
||||
#统计类型: bytes:字节数 packets:包数 sessions:连接数 如不指定,则统计全部 statisticsUnit=${statisticUnit}
|
||||
${statisticUnit} set variable bytes
|
||||
#结束时间格式Y-M-D h:i:s
|
||||
${Time} get current date
|
||||
${endTime}= add time to date ${Time} -00:05:00
|
||||
${endTime} Get Substring ${endTime} \ -4
|
||||
#开始时间格式Y-M-D h:i:s
|
||||
${startTime}= add time to date ${endTime}= -30 days
|
||||
${startTime} Get Substring ${startTime} \ -4
|
||||
#统计粒度,单位秒,仅用于趋势查询sql 缺省为30秒
|
||||
${timeGranularity} set variable 70
|
||||
${limit} set variable 1
|
||||
GetApi ${apiName} ${url} startTime=${startTime} endTime=${endTime} timeGranularity=${timeGranularity} limit=${limit} statisticsUnit=${statisticUnit}
|
||||
|
||||
Statistics-traffic-00007
|
||||
#最近一年(365天)
|
||||
#apiName,请求大数据时,用于区分每个接口的sql
|
||||
${apiName} set variable traffic
|
||||
#请求地址 例如:/report/domain/recommend
|
||||
${url} set variable /report/traffic/statisticsbyunit
|
||||
#统计类型: bytes:字节数 packets:包数 sessions:连接数 如不指定,则统计全部 statisticsUnit=${statisticUnit}
|
||||
${statisticUnit} set variable bytes
|
||||
#结束时间格式Y-M-D h:i:s
|
||||
${Time} get current date
|
||||
${endTime}= add time to date ${Time} -00:05:00
|
||||
${endTime} Get Substring ${endTime} \ -4
|
||||
#开始时间格式Y-M-D h:i:s
|
||||
${startTime}= add time to date ${endTime}= -365 days
|
||||
${startTime} Get Substring ${startTime} \ -4
|
||||
#统计粒度,单位秒,仅用于趋势查询sql 缺省为30秒
|
||||
${timeGranularity} set variable 70
|
||||
${limit} set variable 1
|
||||
GetApi ${apiName} ${url} startTime=${startTime} endTime=${endTime} timeGranularity=${timeGranularity} limit=${limit} statisticsUnit=${statisticUnit}
|
||||
@@ -1,12 +0,0 @@
|
||||
*** Settings ***
|
||||
Resource ../../../02-Keyword/tsg_bfapi/LogStatistics.robot
|
||||
|
||||
*** Test Cases ***
|
||||
Statistics-url-00001
|
||||
#apiName,请求大数据时,用于区分每个接口的sql
|
||||
${apiName} set variable url
|
||||
#请求地址 例如:/report/domain/recommend
|
||||
${url} set variable /report/url/recommend
|
||||
#统计时间, \ 查询最近24小时数据;例如当前时间为2020-03-26 15:14:00, 查询时间应设为推前1小时的整点,实际传入参数为 "2020-03-26 14:00:00" \ 响应参数说明
|
||||
${statisticTime} set variable 2020-04-27 14:00:00
|
||||
GetApi ${apiName} ${url} statisticTime=${statisticTime}
|
||||
82
01-TestCase/tsg_bfapi/api_log/LogStatistics.robot
Normal file
82
01-TestCase/tsg_bfapi/api_log/LogStatistics.robot
Normal file
@@ -0,0 +1,82 @@
|
||||
*** Settings ***
|
||||
Resource ../../../02-Keyword/tsg_bfapi/LogStatistics.robot
|
||||
|
||||
*** Test Cases ***
|
||||
Statistics-Country-00001
|
||||
#apiName,请求大数据时,用于区分每个接口的sql
|
||||
${apiName} set variable Country
|
||||
#请求地址 例如:/report/domain/recommend
|
||||
${url} set variable /report/country/sourceipnum
|
||||
#开始时间格式Y-M-D h:i:s
|
||||
${startTime} set variable 2020-4-20 13:36:35
|
||||
#结束时间格式Y-M-D h:i:s
|
||||
${endTime} set variable 2020-4-23 13:36:35
|
||||
#limit int型
|
||||
${limit} set variable 50
|
||||
GetApi ${url} startTime=${startTime} endTime=${endTime} limit=${limit}
|
||||
|
||||
Statistics-domain-00001
|
||||
#apiName,请求大数据时,用于区分每个接口的sql
|
||||
${apiName} set variable domain
|
||||
#请求地址 例如:/report/domain/recommend
|
||||
${url} set variable /report/domain/recommend
|
||||
#查询时间时间格式Y-M-D h:i:s
|
||||
${statisticTime} set variable 2020-04-22 14:00:00
|
||||
GetApi ${url} statisticTime=${statisticTime}
|
||||
|
||||
Statistics-url-00001
|
||||
#apiName,请求大数据时,用于区分每个接口的sql
|
||||
${apiName} set variable url
|
||||
#请求地址 例如:/report/domain/recommend
|
||||
${url} set variable /report/url/recommend
|
||||
#查询时间时间格式Y-M-D h:i:s
|
||||
${statisticTime} set variable 2020-04-22 14:00:00
|
||||
GetApi ${url} statisticTime=${statisticTime}
|
||||
|
||||
Statistics-traffic-00001
|
||||
#apiName,请求大数据时,用于区分每个接口的sql
|
||||
${apiName} set variable traffic
|
||||
#请求地址 例如:/report/domain/recommend
|
||||
${url} set variable /report/traffic/statisticsbyunit
|
||||
#统计类型: bytes:字节数 packets:包数 sessions:连接数 如不指定,则统计全部
|
||||
${statisticUnit} set variable bytes
|
||||
#开始时间格式Y-M-D h:i:s
|
||||
${startTime} set variable 2020-4-20 13:36:35
|
||||
#结束时间格式Y-M-D h:i:s
|
||||
${endTime} set variable 2020-4-26 16:04:56
|
||||
#统计粒度,单位秒,仅用于趋势查询sql 缺省为30秒
|
||||
${timeGranularity} set variable 50
|
||||
${limit} set variable 50
|
||||
GetApi ${url} statisticsUnit=${statisticUnit} startTime=${startTime} endTime=${endTime} timeGranularity=${timeGranularity} limit=${limit}
|
||||
|
||||
Statistics-traffic-00002
|
||||
#apiName,请求大数据时,用于区分每个接口的sql
|
||||
${apiName} set variable traffic
|
||||
#请求地址 例如:/report/domain/recommend
|
||||
${url} set variable /report/traffic/statisticsbyunit
|
||||
#开始时间格式Y-M-D h:i:s
|
||||
${startTime} set variable 2020-4-20 13:36:35
|
||||
${endTime} set variable 2020-4-26 16:04:56
|
||||
GetApi ${url} startTime=${startTime} endTime=${endTime}
|
||||
|
||||
Statistics-ip_correlation_domain-00001
|
||||
#请求地址 例如:/report/domain/recommend
|
||||
${url} set variable /report/ip_correlation_domain
|
||||
#开始时间格式Y-M-D h:i:s
|
||||
${startTime} set variable 2020-4-20 13:36:35
|
||||
#结束时间格式Y-M-D h:i:s
|
||||
${endTime} set variable 2020-4-26 16:04:56
|
||||
#IP
|
||||
${ip} set variable 157.225.77.82
|
||||
GetApi ${url} startTime=${startTime} endTime=${endTime} ip=${ip}
|
||||
|
||||
Statistics-hijack_srcip_location-00001
|
||||
#请求地址 例如:/report/domain/recommend
|
||||
${url} set variable /report/ip_correlation_domain
|
||||
#开始时间格式Y-M-D h:i:s
|
||||
${startTime} set variable 2020-4-20 13:36:35
|
||||
#结束时间格式Y-M-D h:i:s
|
||||
${endTime} set variable 2020-4-26 16:04:56
|
||||
#策略ID
|
||||
${policy_id} set variable 0
|
||||
GetApi ${url} startTime=${startTime} endTime=${endTime} policy_id=${policy_id}
|
||||
@@ -1,12 +1,11 @@
|
||||
*** Settings ***
|
||||
Resource ../../03-Variable/BifangApiVariable.txt
|
||||
Library RequestsLibrary
|
||||
Library String
|
||||
Library Collections
|
||||
Resource ../../03-Variable/BifangApiVariable.txt
|
||||
Library string
|
||||
|
||||
*** Keywords ***
|
||||
GetApi
|
||||
[Arguments] ${apiName} ${url} ${startTime}=${None} ${endTime}=${None} ${limit}=50000 ${statisticTime}=${None} ${statisticsUnit}=${None} ${timeGranularity}=${None} ${policy_id}=${None} ${ip}=${None}
|
||||
[Arguments] ${url} ${startTime}=${None} ${endTime}=${None} ${limit}=${None} ${statisticTime}=${None} ${statisticsUnit}=${None} ${timeGranularity}=${None} ${policy_id}=${None} ${ip}=${None}
|
||||
#拼接查询条件
|
||||
${strstrartTime}= run keyword if '${startTime}'!='${None}' Set Variable startTime=${startTime}&
|
||||
... ELSE Set Variable ${EMPTY}
|
||||
@@ -24,185 +23,24 @@ GetApi
|
||||
... ELSE Set Variable ${EMPTY}
|
||||
${strip} run keyword if '${ip}'!='${None}' Set Variable ip=${ip}&
|
||||
... ELSE Set Variable ${EMPTY}
|
||||
${condition} catenate SEPARATOR= ${strstrartTime} ${strendTime} ${strstatisticTime} ${strlimit} ${strstatisticsUnit} ${strtimeGranularity} ${strpolicy_id} ${strip}
|
||||
${condition} catenate SEPARATOR= ${strstrartTime} ${strendTime} ${strstatisticTime} ${strlimit} ${strstatisticsUnit} ${strtimeGranularity} ${strpolicy_id} ${ip}
|
||||
#创建请求信息
|
||||
${header} Create Dictionary Content-Type=application/x-www-form-urlencoded Authorization=${token}
|
||||
Create Session api http://${host}:${port}/${version}
|
||||
#发送请求
|
||||
${remoteResponse} Get Request api ${url}?${condition} headers=${header}
|
||||
${bifang} to json ${remoteResponse.content}
|
||||
log ${remoteResponse}
|
||||
${response} to json ${remoteResponse.content}
|
||||
#验证请求是否成功
|
||||
Should Be Equal As Strings ${remoteResponse.status_code} 200
|
||||
Should Be Equal As Strings ${bifang}[code] 200
|
||||
Should Be Equal As Strings ${response}[code] 200
|
||||
#请求大数据
|
||||
${strstrartTime}= run keyword if '${startTime}'!='${None}' Set Variable __time > '${startTime}' and
|
||||
... ELSE Set Variable ${EMPTY}
|
||||
${strendTime}= run keyword if '${endTime}'!='${None}' Set Variable __time < '${endTime}' and
|
||||
... ELSE Set Variable ${EMPTY}
|
||||
${strstatisticTime}= run keyword if '${statisticTime}'!='${None}' Set Variable statisticTime=${statisticTime} and
|
||||
... ELSE Set Variable ${EMPTY}
|
||||
${strstatisticsUnit}= run keyword if '${statisticsUnit}'!='${None}' Set Variable statisticsUnit=${statisticsUnit} and
|
||||
... ELSE Set Variable ${EMPTY}
|
||||
${strtimeGranularity}= run keyword if '${timeGranularity}'!='${None}' Set Variable timeGranularity=${timeGranularity} and
|
||||
... ELSE Set Variable ${EMPTY}
|
||||
${strpolicy_id} run keyword if '${policy_id}'!='${None}' Set Variable policy_id=${policy_id} and
|
||||
... ELSE Set Variable ${EMPTY}
|
||||
${strip} run keyword if '${ip}'!='${None}' Set Variable ip=${ip} and
|
||||
... ELSE Set Variable ${EMPTY}
|
||||
#sql拼接 ${where}
|
||||
${sqlwhere} catenate ${strstrartTime} ${strendTime} ${strstatisticTime} ${strstatisticsUnit} ${strtimeGranularity} ${strpolicy_id} ${strip}
|
||||
${strippedwhere}= Strip String ${sqlwhere} mode=right
|
||||
#截取最后一个and
|
||||
${where}= Get Substring ${strippedwhere} \ -4
|
||||
#BigData
|
||||
${sql}= run keyword if '${apiName}'=="country" Set Variable SELECT country, APPROX_COUNT_DISTINCT_DS_HLL(ip_object) as num FROM source_country_ip_num_log where ${where} group by country order by num desc limit ${limit}
|
||||
... ELSE IF '${apiName}'=="domain" Set Variable SELECT domain, protocol_type, ip_num, session_num \ FROM top_domain_recommend_daily_log where __time = '${statisticTime}'
|
||||
... ELSE IF '${apiName}'=="url" Set Variable SELECT url, content_length, ip_num, session_num \ FROM top_website_urls_daily_log where __time = '${statisticTime}'
|
||||
... ELSE IF '${apiName}'=="traffic" and '${statisticsUnit}'=='bytes' Set Variable select sum(total_in_bytes) as trafficInBytes, sum(total_out_bytes) as trafficOutBytes, \ sum(total_in_bytes+total_out_bytes) as trafficTotalBytes \ \ from traffic_metrics_log where __time >= '${startTime}' and __time < '${endTime}'
|
||||
... ELSE IF '${apiName}'=="traffic" and '${statisticsUnit}'=='packets' Set Variable select sum(total_in_packets) as trafficInPackets,sum(total_out_packets) as trafficOutPackets,sum(total_in_packets+total_out_packets) as trafficTotalPackets from traffic_metrics_log where __time >= '${startTime}' and __time < '${endTime}'
|
||||
... ELSE IF '${apiName}'=="traffic" and '${statisticsUnit}'=='sessions' Set Variable select sum(new_conn_num) as sessions \ from traffic_metrics_log where __time >= '${startTime}' and __time < '${endTime}'
|
||||
... ELSE IF '${apiName}'=="traffic" and '${statisticsUnit}'=='${None}' Set Variable select sum(total_in_bytes) as trafficInBytes, sum(total_out_bytes) as trafficOutBytes, \ sum(total_in_bytes+total_out_bytes) as trafficTotalBytes, sum(total_in_packets) as trafficInPackets,sum(total_out_packets) as trafficOutPackets,sum(total_in_packets+total_out_packets) as trafficTotalPackets, sum(new_conn_num) as sessions from traffic_metrics_log where __time >= '${startTime}' and __time < '${endTime}'
|
||||
... ELSE IF '${apiName}'=="ip_correlation_domain" and '${ip}'!='${None}' Set Variable SELECT \ ip, FROM_UNIXTIME(max(stat_time)) as last_time, FROM_UNIXTIME(min(stat_time)) as first_time, groupUniqArrayMerge(domain_list) as domain_list, groupUniqArrayMerge(port_list) as port_list \ FROM security_ip_info where \ stat_time >= '${startTime}' and stat_time < '${endTime}' and ip='${ip}' group by ip
|
||||
... ELSE IF '${apiName}'=="ip_correlation_domain" and ${ip}==${None} Set Variable SELECT ip,FROM_UNIXTIME(max(stat_time)) as last_time, FROM_UNIXTIME(min(stat_time)) as first_time, groupUniqArrayMerge(domain_list) as domain_list, groupUniqArrayMerge(port_list) as port_list \ FROM security_ip_info where \ stat_time >= '${startTime}' and stat_time < '${endTime}' \ group by ip
|
||||
... ELSE IF '${apiName}'=="hijack_srcip_location" Set Variable select ip, IP_TO_CITY(ip) as location, IP_TO_GEO(ip) as geo from (SELECT policy_id, arrayJoin(groupUniqArrayMerge(ip_list)) as ip FROM proxy_ip_info where \ stat_time >= '${startTime}' and stat_time < '${endTime}' and policy_id = ${policy_id} group by policy_id )
|
||||
log sql------------${sql}
|
||||
#traffic二次请求sql
|
||||
${sql2}= run keyword if '${apiName}'=='traffic' SplicingTrafficSql ${apiName} ${startTime} ${endTime} statisticsUnit=${statisticsUnit} timeGranularity=${timeGranularity} limit=${limit}
|
||||
#请求大数据接口
|
||||
${response}= BigData ${sql}
|
||||
${bigdata} to json ${response.content}
|
||||
#traffic二次请求大数据
|
||||
${response2}= run keyword if '${apiName}'=="traffic" BigData ${sql2}
|
||||
${bigdata2} run keyword if '${apiName}'=="traffic" to json ${response2.content}
|
||||
#响应码断言
|
||||
Should Be Equal As Strings ${response.status_code} 200
|
||||
Should Be Equal As Strings ${bigdata}[status] 200
|
||||
#traffic二次请求响应码断言
|
||||
run keyword if '${apiName}'=="traffic" run keywords Should Be Equal As Strings ${response2.status_code} 200
|
||||
... AND Should Be Equal As Strings ${bigdata2}[status] 200
|
||||
#traffic二次请求json拼接与毕方一致
|
||||
${bigdataTraffic}= run keyword if '${apiName}'=="traffic" SplicingTrafficJson ${bigdata} ${bigdata2}
|
||||
${bifanglist} run keyword if '${apiName}'=="ip_correlation_domain" set variable ${bifang['data']['list']['list']}
|
||||
... ELSE IF '${apiName}'=="traffic" set variable ${bifang['data']}
|
||||
... ELSE set variable ${bifang['data']['list']}
|
||||
${bigdatalist} run keyword if '${apiName}'=="traffic" set variable ${bigdataTraffic}
|
||||
... ELSE set variable ${bigdata['data']}
|
||||
FOR ${k} ${v} IN ENUMERATE @{bifanglist}
|
||||
run keyword if '${apiName}'=="hijack_srcip_location" List Should Contain Value ${bigdatalist} ${v}
|
||||
... ELSE IF '${apiName}'=="traffic" ForSecondary ${bigdatalist} ${bifanglist} ${apiName}
|
||||
... ELSE ForSecondary @{bigdatalist}[${k}] ${v} ${apiName}
|
||||
END
|
||||
#sql拼接
|
||||
#BigData ${sql}
|
||||
|
||||
BigData
|
||||
[Arguments] ${sql}
|
||||
#创建请求信息
|
||||
Create Session api http://192.168.40.224:9999
|
||||
#发送请求
|
||||
${remoteResponse}= Get Request api ?query=${sql}
|
||||
[Return] ${remoteResponse}
|
||||
|
||||
ForSecondary
|
||||
[Arguments] ${bigdata} ${v} ${apiName}
|
||||
${bigdata} run keyword if '${apiName}'=='traffic' Convert To Dictionary ${bigdata}
|
||||
... ELSE Set Variable ${bigdata}
|
||||
${strbig} Get Dictionary Values ${bigdata}
|
||||
${strfang} Get Dictionary Values ${v}
|
||||
FOR ${key} ${var} IN ENUMERATE @{bigdata}
|
||||
${string} Convert To String ${v}[${var}]
|
||||
${stt} Get Substring ${string} 0 1
|
||||
run keyword if '${stt}'=='[' ForTertiary ${bigdata}[${var}] ${v}[${var}]
|
||||
... ELSE List Should Contain Value ${strbig} ${v}[${var}]
|
||||
END
|
||||
|
||||
ForTertiary
|
||||
[Arguments] ${str1} ${str2}
|
||||
${str1} Convert To List ${str1}
|
||||
${str2} Convert To List ${str2}
|
||||
FOR ${kk} ${vv} IN ENUMERATE @{str1}
|
||||
List Should Contain Value ${str1} ${vv}
|
||||
END
|
||||
|
||||
SplicingTrafficJson
|
||||
[Arguments] ${bigdata} ${bigdata2}
|
||||
${bigdata} set variable ${bigdata['data']}[0]
|
||||
@{trafficOutPacketsList} Create list
|
||||
@{trafficOutBytesList} Create list
|
||||
@{trafficTotalPacketsList} Create list
|
||||
@{trafficInPacketsList} Create list
|
||||
@{trafficInBytesList} Create list
|
||||
@{sessionsList} Create list
|
||||
@{trafficTotalBytesList} Create list
|
||||
FOR ${k} ${v} IN ENUMERATE @{bigdata2['data']}
|
||||
${total_out_packets}= Run keyword and ignore error log ${v['total_out_packets']}
|
||||
${trafficOutPacketsListData}= run keyword if '${total_out_packets}[0]'!='FAIL' Create Dictionary statisticsTime=${v['statisticsTime']} statisticsNum=${v['total_out_packets']}
|
||||
${total_out_bytes}= Run keyword and ignore error log ${v['total_out_bytes']}
|
||||
${trafficOutBytesListData}= run keyword if '${total_out_bytes}[0]'!='FAIL' Create Dictionary statisticsTime=${v['statisticsTime']} statisticsNum=${v['total_out_bytes']}
|
||||
${total_all_packets}= Run keyword and ignore error log ${v['total_all_packets']}
|
||||
${trafficTotalPacketsListData}= run keyword if '${total_all_packets}[0]'!='FAIL' Create Dictionary statisticsTime=${v['statisticsTime']} statisticsNum=${v['total_all_packets']}
|
||||
${total_in_packets}= Run keyword and ignore error log ${v['total_in_packets']}
|
||||
${trafficInPacketsListData}= run keyword if '${total_in_packets}[0]'!='FAIL' Create Dictionary statisticsTime=${v['statisticsTime']} statisticsNum=${v['total_in_packets']}
|
||||
${total_in_bytes}= Run keyword and ignore error log ${v['total_in_bytes']}
|
||||
${trafficInBytesListData}= run keyword if '${total_in_bytes}[0]'!='FAIL' Create Dictionary statisticsTime=${v['statisticsTime']} statisticsNum=${v['total_in_bytes']}
|
||||
${sessions}= Run keyword and ignore error log ${v['sessions']}
|
||||
${sessionsListData}= run keyword if '${sessions}[0]'!='FAIL' Create Dictionary statisticsTime=${v['statisticsTime']} statisticsNum=${v['sessions']}
|
||||
${total_all_bytes}= Run keyword and ignore error log ${v['total_all_bytes']}
|
||||
${trafficTotalBytesListData}= run keyword if '${total_all_bytes}[0]'!='FAIL' Create Dictionary statisticsTime=${v['statisticsTime']} statisticsNum=${v['total_all_bytes']}
|
||||
Append To List ${trafficTotalPacketsList} ${trafficTotalPacketsListData}
|
||||
Append To List ${trafficInPacketsList} ${trafficInPacketsListData}
|
||||
Append To List ${trafficInBytesList} ${trafficInBytesListData}
|
||||
Append To List ${sessionsList} ${sessionsListData}
|
||||
Append To List ${trafficTotalBytesList} ${trafficTotalBytesListData}
|
||||
Append To List ${trafficOutPacketsList} ${trafficOutPacketsListData}
|
||||
Append To List ${trafficOutBytesList} ${trafficOutBytesListData}
|
||||
END
|
||||
${bigdataTraffic} Create Dictionary
|
||||
${1}= Run keyword and ignore error log ${bigdata['sessions']}
|
||||
run keyword if '${1}[0]'!='FAIL' Set To Dictionary ${bigdataTraffic} sessions=${bigdata['sessions']}
|
||||
${2}= Run keyword and ignore error log ${bigdata['trafficInPackets']}
|
||||
run keyword if '${2}[0]'!='FAIL' Set To Dictionary ${bigdataTraffic} trafficInPackets=${bigdata['trafficInPackets']}
|
||||
${3}= Run keyword and ignore error log ${bigdata['trafficTotalBytes']}
|
||||
run keyword if '${3}[0]'!='FAIL' Set To Dictionary ${bigdataTraffic} trafficTotalBytes=${bigdata['trafficTotalBytes']}
|
||||
${4}= Run keyword and ignore error log ${v['total_out_packets']}
|
||||
run keyword if '${4}[0]'!='FAIL' Set To Dictionary ${bigdataTraffic} trafficOutPacketsList=${trafficOutPacketsList}
|
||||
${5}= Run keyword and ignore error log ${bigdata['trafficInBytes']}
|
||||
run keyword if '${5}[0]'!='FAIL' Set To Dictionary ${bigdataTraffic} trafficInBytes=${bigdata['trafficInBytes']}
|
||||
${6}= Run keyword and ignore error log ${bigdata['trafficOutBytes']}
|
||||
run keyword if '${6}[0]'!='FAIL' Set To Dictionary ${bigdataTraffic} trafficOutBytes=${bigdata['trafficOutBytes']}
|
||||
${7}= Run keyword and ignore error log ${bigdata['trafficOutPackets']}
|
||||
run keyword if '${7}[0]'!='FAIL' Set To Dictionary ${bigdataTraffic} trafficOutPackets=${bigdata['trafficOutPackets']}
|
||||
${8}= Run keyword and ignore error log ${bigdata2['data'][0]['total_out_bytes']}
|
||||
run keyword if '${8}[0]'!='FAIL' Set To Dictionary ${bigdataTraffic} trafficOutBytesList=${trafficOutBytesList}
|
||||
${9}= Run keyword and ignore error log ${bigdata2['data'][0]['total_all_packets']}
|
||||
run keyword if '${9}[0]'!='FAIL' Set To Dictionary ${bigdataTraffic} trafficTotalPacketsList=${trafficTotalPacketsList}
|
||||
${10}= Run keyword and ignore error log ${bigdata2['data'][0]['total_in_packets']}
|
||||
run keyword if '${10}[0]'!='FAIL' Set To Dictionary ${bigdataTraffic} trafficInPacketsList=${trafficInPacketsList}
|
||||
${11}= Run keyword and ignore error log ${bigdata2['data'][0]['total_in_bytes']}
|
||||
run keyword if '${11}[0]'!='FAIL' Set To Dictionary ${bigdataTraffic} trafficInBytesList=${trafficInBytesList}
|
||||
${12}= Run keyword and ignore error log ${bigdata2['data'][0]['sessions']}
|
||||
run keyword if '${12}[0]'!='FAIL' Set To Dictionary ${bigdataTraffic} sessionsList=${sessionsList}
|
||||
${13}= Run keyword and ignore error log ${bigdata2['data'][0]['total_all_bytes']}
|
||||
run keyword if '${13}[0]'!='FAIL' Set To Dictionary ${bigdataTraffic} trafficTotalBytesList=${trafficTotalBytesList}
|
||||
${14}= Run keyword and ignore error log ${bigdata['trafficTotalPackets']}
|
||||
run keyword if '${14}[0]'!='FAIL' Set To Dictionary ${bigdataTraffic} trafficTotalPackets=${bigdata['trafficTotalPackets']}
|
||||
[Return] ${bigdataTraffic}
|
||||
|
||||
SplicingTrafficSql
|
||||
[Arguments] ${apiName} ${startTime} ${endTime} ${statisticsUnit} ${limit} ${timeGranularity}
|
||||
${bytes}= run keyword if '${apiName}'=="traffic" and '${statisticsUnit}'=='bytes' Set Variable sum(total_in_bytes) as total_in_bytes, sum(total_out_bytes) as total_out_bytes, sum(total_in_bytes+total_out_bytes) as total_all_bytes,
|
||||
... ELSE Set Variable ${EMPTY}
|
||||
${packets}= run keyword if '${apiName}'=="traffic" and '${statisticsUnit}'=='packets' Set Variable sum(total_in_packets) as total_in_packets, sum(total_out_packets) as total_out_packets, sum(total_in_packets+total_out_packets) as total_all_packets,
|
||||
... ELSE Set Variable ${EMPTY}
|
||||
${sessions}= run keyword if '${apiName}'=="traffic" and '${statisticsUnit}'=='sessions' Set Variable sum(new_conn_num) as sessions
|
||||
... ELSE Set Variable ${EMPTY}
|
||||
${where} catenate ${bytes} ${packets} ${sessions}
|
||||
${where} run keyword if '${apiName}'=="traffic" and '${statisticsUnit}'=='${None}' Set Variable sum(total_in_bytes) as total_in_bytes, sum(total_out_bytes) as total_out_bytes, sum(total_in_bytes+total_out_bytes) as total_all_bytes, sum(total_in_packets) as total_in_packets, sum(total_out_packets) as total_out_packets, sum(total_in_packets+total_out_packets) as total_all_packets, sum(new_conn_num) as sessions,
|
||||
... ELSE Set Variable ${where}
|
||||
#清空尾随空格
|
||||
${strippedwhere}= Strip String ${where} mode=right
|
||||
#时间粒度默认值
|
||||
${timeGranularity}= run keyword if '${timeGranularity}'=="${None}" set variable 30
|
||||
... ELSE set variable ${timeGranularity}
|
||||
#截取最后一个and
|
||||
${where}= Get Substring ${strippedwhere} \ -1
|
||||
${sql2} catenate select DATE_FORMAT(FROM_UNIXTIME(FLOOR(UNIX_TIMESTAMP(__time)/${timeGranularity})*${timeGranularity}),'%Y-%m-%d %H:%i:%s') as statisticsTime, ${where} 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}
|
||||
[Return] ${sql2}
|
||||
${remoteResponse} Get Request api ?query= ${sql}
|
||||
|
||||
Reference in New Issue
Block a user