This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
dongxiaoyan-tsg-autotest/02-Keyword/tsg_bfapi/LogStatistics.robot

47 lines
2.6 KiB
Plaintext
Raw Normal View History

2020-04-26 18:53:34 +08:00
*** Settings ***
Library RequestsLibrary
Resource ../../03-Variable/BifangApiVariable.txt
Library string
2020-04-26 18:53:34 +08:00
*** Keywords ***
GetApi
[Arguments] ${url} ${startTime}=${None} ${endTime}=${None} ${limit}=${None} ${statisticTime}=${None} ${statisticsUnit}=${None} ${timeGranularity}=${None} ${policy_id}=${None} ${ip}=${None}
2020-04-26 18:53:34 +08:00
#拼接查询条件
${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}
2020-04-26 18:53:34 +08:00
#创建请求信息
${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}
2020-04-26 18:53:34 +08:00
#验证请求是否成功
Should Be Equal As Strings ${remoteResponse.status_code} 200
Should Be Equal As Strings ${response}[code] 200
2020-04-26 18:53:34 +08:00
#请求大数据
#sql拼接
#BigData ${sql}
2020-04-26 18:53:34 +08:00
BigData
[Arguments] ${sql}
#创建请求信息
Create Session api http://192.168.40.224:9999
#发送请求
${remoteResponse} Get Request api ?query= ${sql}