0426 日志查询封装公共部分
This commit is contained in:
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,7 +1,7 @@
|
||||
*** Settings ***
|
||||
Library Collections
|
||||
Library RequestsLibrary
|
||||
Resource ../../03-Variable/BifangApiVariable.txt
|
||||
Library Collections
|
||||
Library RequestsLibrary
|
||||
Resource ../../03-Variable/BifangApiVariable.txt
|
||||
|
||||
*** Keywords ***
|
||||
Post-Request
|
||||
@@ -21,30 +21,30 @@ Get-Request
|
||||
${response} to json ${remoteResponse.content}
|
||||
Should Be Equal As Strings ${remoteResponse.status_code} 200
|
||||
[Return] ${response}
|
||||
|
||||
|
||||
Delete-Request
|
||||
[Arguments] ${url} ${data}
|
||||
${header} Create Dictionary Content-Type=application/json Authorization=${token}
|
||||
Create Session api http://${host}:${port}/${version} headers=${header}
|
||||
${remoteResponse} Delete Request api ${url} data=${data} headers=${header}
|
||||
${remoteResponse} Delete Request api ${url} data=${data} headers=${header}
|
||||
${response} to json ${remoteResponse.content}
|
||||
Should Be Equal As Strings ${remoteResponse.status_code} 200
|
||||
[Return] ${response}
|
||||
|
||||
|
||||
UpFilePostRequest
|
||||
[Arguments] ${url} ${data} ${files} ${fileDesc}
|
||||
${header} Set To Dictionary ${fileDesc} Authorization=${token}
|
||||
Create Session api http://${host}:${port}/${version} headers=${header}
|
||||
${remoteResponse} Post Request api ${url} data=${data} files=${files} headers=${header}
|
||||
${remoteResponse} Post Request api ${url} data=${data} files=${files} headers=${header}
|
||||
${response} to json ${remoteResponse.content}
|
||||
Should Be Equal As Strings ${remoteResponse.status_code} 200
|
||||
[Return] ${response}
|
||||
|
||||
|
||||
UpFilePutRequest
|
||||
[Arguments] ${url} ${data} ${files} ${fileDesc}
|
||||
${header} Set To Dictionary ${fileDesc} Authorization=${token}
|
||||
${header} Set To Dictionary ${fileDesc} Authorization=${token}
|
||||
Create Session api http://${host}:${port}/${version} headers=${header}
|
||||
${remoteResponse} Put Request api ${url} params=${data} files=${files} headers=${header}
|
||||
${remoteResponse} Put Request api ${url} params=${data} files=${files} headers=${header}
|
||||
${response} to json ${remoteResponse.content}
|
||||
Should Be Equal As Strings ${remoteResponse.status_code} 200
|
||||
[Return] ${response}
|
||||
[Return] ${response}
|
||||
|
||||
46
02-Keyword/tsg_bfapi/LogStatistics.robot
Normal file
46
02-Keyword/tsg_bfapi/LogStatistics.robot
Normal file
@@ -0,0 +1,46 @@
|
||||
*** Settings ***
|
||||
Library RequestsLibrary
|
||||
Resource ../../03-Variable/BifangApiVariable.txt
|
||||
Library string
|
||||
|
||||
*** Keywords ***
|
||||
GetApi
|
||||
[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}
|
||||
${strendTime}= run keyword if '${endTime}'!='${None}' Set Variable endTime=${endTime}&
|
||||
... ELSE Set Variable ${EMPTY}
|
||||
${strstatisticTime}= run keyword if '${statisticTime}'!='${None}' Set Variable statisticTime=${statisticTime}&
|
||||
... ELSE Set Variable ${EMPTY}
|
||||
${strlimit}= run keyword if '${limit}'!='${None}' Set Variable limit=${limit}&
|
||||
... ELSE Set Variable ${EMPTY}
|
||||
${strstatisticsUnit}= run keyword if '${statisticsUnit}'!='${None}' Set Variable statisticsUnit=${statisticsUnit}&
|
||||
... ELSE Set Variable ${EMPTY}
|
||||
${strtimeGranularity}= run keyword if '${timeGranularity}'!='${None}' Set Variable timeGranularity=${timeGranularity}&
|
||||
... ELSE Set Variable ${EMPTY}
|
||||
${strpolicy_id} run keyword if '${policy_id}'!='${None}' Set Variable policy_id=${policy_id}&
|
||||
... 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} ${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}
|
||||
log ${remoteResponse}
|
||||
${response} to json ${remoteResponse.content}
|
||||
#验证请求是否成功
|
||||
Should Be Equal As Strings ${remoteResponse.status_code} 200
|
||||
Should Be Equal As Strings ${response}[code] 200
|
||||
#请求大数据
|
||||
#sql拼接
|
||||
#BigData ${sql}
|
||||
|
||||
BigData
|
||||
[Arguments] ${sql}
|
||||
#创建请求信息
|
||||
Create Session api http://192.168.40.224:9999
|
||||
#发送请求
|
||||
${remoteResponse} Get Request api ?query= ${sql}
|
||||
Reference in New Issue
Block a user