2020-06-28 14:10:24 +08:00
|
|
|
|
*** Settings ***
|
2020-06-24 17:37:09 +08:00
|
|
|
|
Library json
|
|
|
|
|
|
Library Collections
|
|
|
|
|
|
Library RequestsLibrary
|
2020-06-28 14:10:24 +08:00
|
|
|
|
Library DateTime
|
2020-06-24 17:37:09 +08:00
|
|
|
|
Resource ../../../03-Variable/BifangApiVariable.txt
|
|
|
|
|
|
Resource ../../../02-Keyword/tsg_bfapi/policy_file_interface/FunctionalKeywords.robot
|
|
|
|
|
|
Resource ../Common.robot
|
|
|
|
|
|
*** Variables ***
|
|
|
|
|
|
${logUrl} /log
|
2020-07-20 11:41:44 +08:00
|
|
|
|
${arraySplitor} ,
|
|
|
|
|
|
${itemSplitor} |
|
|
|
|
|
|
${valueSplitor} ^
|
2020-06-24 17:37:09 +08:00
|
|
|
|
*** Keywords ***
|
|
|
|
|
|
GetLogSchema
|
|
|
|
|
|
[Documentation]
|
|
|
|
|
|
... 日志schema查询
|
|
|
|
|
|
... logType 日志类型
|
|
|
|
|
|
... resData schema数据
|
|
|
|
|
|
[Arguments] ${logType}
|
|
|
|
|
|
${response} BaseFormRequest ${logUrl}/schema logType=${logType} ${version}
|
|
|
|
|
|
${rescode} Set Variable ${response['code']}
|
2020-06-28 14:10:24 +08:00
|
|
|
|
Should Be Equal As Strings ${rescode} 200
|
2020-06-24 17:37:09 +08:00
|
|
|
|
${resData} Set Variable ${response['data']}
|
|
|
|
|
|
${schema_query} Get From Dictionary ${resData['doc']} schema_query
|
|
|
|
|
|
${schema_type} Get From Dictionary ${resData['doc']} schema_type
|
|
|
|
|
|
${default_columns} Get From Dictionary ${resData['doc']} default_columns
|
|
|
|
|
|
[Return] ${schema_query} ${schema_type} ${default_columns} ${resData['fields']}
|
2020-06-24 18:07:07 +08:00
|
|
|
|
QueryLogs
|
2020-06-24 17:37:09 +08:00
|
|
|
|
[Documentation]
|
|
|
|
|
|
... 日志列表查询
|
|
|
|
|
|
... params字典列表
|
|
|
|
|
|
... 注意如下字典字段格式
|
|
|
|
|
|
... orderBy=field名字1|true,field名字2|false
|
|
|
|
|
|
... fields=name1|type,name2|type
|
2020-06-28 14:10:24 +08:00
|
|
|
|
... 当path为batch时,fields=name1|type|lang1,name2|type|lang2
|
2020-06-24 17:37:09 +08:00
|
|
|
|
... conditions=field1|type|symbol|value1^value2,field2|type|symbol|value3^value4
|
|
|
|
|
|
... value1^value2是使用^分隔的字符串解析后为[value1,value2]格式的数组
|
2020-06-24 18:07:07 +08:00
|
|
|
|
[Arguments] ${params} ${path}
|
2020-06-24 17:37:09 +08:00
|
|
|
|
Should Not Be Empty ${params}
|
|
|
|
|
|
${return} ${pageSize} Run Keyword And Ignore Error Get From Dictionary ${params} pageSize
|
|
|
|
|
|
Run Keyword If "${return}"=="PASS" and "${pageSize}"=="${EMPTY}" Remove From Dictionary ${params} pageSize
|
2020-06-28 14:10:24 +08:00
|
|
|
|
Run Keyword If "${path}"=="batch" Remove From Dictionary ${params} pageSize
|
2020-06-24 17:37:09 +08:00
|
|
|
|
${return} ${pageNo} Run Keyword And Ignore Error Get From Dictionary ${params} pageNo
|
|
|
|
|
|
Run Keyword If "${return}"=="PASS" and "${pageNo}"=="${EMPTY}" Remove From Dictionary ${params} pageNo
|
2020-06-28 14:10:24 +08:00
|
|
|
|
Run Keyword If "${path}"=="batch" Remove From Dictionary ${params} pageNo
|
2020-06-24 17:37:09 +08:00
|
|
|
|
Dictionary Should Contain Key ${params} logType
|
|
|
|
|
|
${logType} Get From Dictionary ${params} logType
|
|
|
|
|
|
#处理排序
|
|
|
|
|
|
${return} ${orderBy} Run Keyword And Ignore Error Get From Dictionary ${params} orderBy
|
|
|
|
|
|
${orderBy} Run Keyword If "${return}"=="FAIL" or "${orderBy}"=="${EMPTY}" Create List
|
2020-07-17 18:33:32 +08:00
|
|
|
|
... ELSE IF "${path}"=="list" or "${path}"=="batch" ManageOrderBy ${orderBy}
|
|
|
|
|
|
... ELSE IF "${path}"=="count" Set Variable ${orderBy}
|
|
|
|
|
|
|
2020-06-28 14:10:24 +08:00
|
|
|
|
Run Keyword If "${path}"=="list" or "${path}"=="batch" Set To Dictionary ${params} orderBy=${orderBy}
|
2020-06-24 18:07:07 +08:00
|
|
|
|
Run Keyword If "${path}"=="count" Remove From Dictionary ${params} orderBy
|
2020-07-17 18:33:32 +08:00
|
|
|
|
|
2020-06-24 18:07:07 +08:00
|
|
|
|
${return} ${fields} Run Keyword And Ignore Error Get From Dictionary ${params} fields
|
2020-07-17 18:33:32 +08:00
|
|
|
|
${fields} Run Keyword If "${return}"=="FAIL" Set Variable ${EMPTY}
|
|
|
|
|
|
... ELSE Set Variable ${fields}
|
2020-06-24 18:07:07 +08:00
|
|
|
|
Run Keyword If "${path}"=="list" Should Not Be Empty ${fields}
|
2020-06-28 14:10:24 +08:00
|
|
|
|
${fields} Run Keyword If "${path}"=="list" or "${path}"=="batch" ManageFields ${fields}
|
2020-06-24 18:07:07 +08:00
|
|
|
|
... ELSE Create List
|
2020-06-28 14:10:24 +08:00
|
|
|
|
Run Keyword If "${path}"=="list" or "${path}"=="batch" Set To Dictionary ${params} fields=${fields}
|
2020-06-24 18:07:07 +08:00
|
|
|
|
Run Keyword If "${path}"=="count" Remove From Dictionary ${params} fields
|
2020-07-17 18:33:32 +08:00
|
|
|
|
|
2020-06-24 17:37:09 +08:00
|
|
|
|
${start_common_recv_time} Get From Dictionary ${params} start_common_recv_time
|
|
|
|
|
|
Should Not Be Empty ${start_common_recv_time}
|
|
|
|
|
|
${end_common_recv_time} Get From Dictionary ${params} end_common_recv_time
|
|
|
|
|
|
Should Not Be Empty ${end_common_recv_time}
|
|
|
|
|
|
|
|
|
|
|
|
${return} ${userTags} Run Keyword And Ignore Error Get From Dictionary ${params} userTags
|
|
|
|
|
|
Run Keyword If "${return}"=="PASS" and "${userTags}"=="${EMPTY}" Remove From Dictionary ${params} userTags
|
|
|
|
|
|
${return} ${conditions} Run Keyword And Ignore Error Get From Dictionary ${params} conditions
|
|
|
|
|
|
${conditions} Run Keyword If "${return}"=="PASS" and "${conditions}"!="${EMPTY}" ManageConditions ${conditions}
|
|
|
|
|
|
... ELSE Create List
|
|
|
|
|
|
Set To Dictionary ${params} conditions=${conditions}
|
|
|
|
|
|
${bodyJson} json.Dumps ${params} ensure_ascii=False
|
2020-06-28 14:10:24 +08:00
|
|
|
|
${response} Run Keyword If "${path}"!="batch" BasePostRequestForV2 ${logUrl}/${path} ${bodyJson} ${version}
|
|
|
|
|
|
... ELSE BasePostRequestReturnBinary ${logUrl}/${path} ${bodyJson} ${version}
|
|
|
|
|
|
|
|
|
|
|
|
Run Keyword If "${path}"!="batch" Should Be Equal As Integers ${response['code']} 200
|
|
|
|
|
|
${time} Get Current Date result_format=datetime exclude_millis=True
|
|
|
|
|
|
${resData} Run Keyword If "${path}"!="batch" Set Variable ${response['data']}
|
|
|
|
|
|
... ELSE WriteExcel downloads ${logType}${time.year}${time.month}${time.day}${time.hour}${time.minute}${time.second}.xlsx ${response}
|
2020-06-24 17:37:09 +08:00
|
|
|
|
[Return] ${resData}
|
|
|
|
|
|
ManageOrderBy
|
|
|
|
|
|
[Documentation]
|
2020-07-17 18:33:32 +08:00
|
|
|
|
... 处理 order by
|
2020-06-24 17:37:09 +08:00
|
|
|
|
[Arguments] ${orderBy}
|
|
|
|
|
|
${orderByList} Create List
|
2020-07-20 11:41:44 +08:00
|
|
|
|
@{orderByArr} Split String ${orderBy} ${arraySplitor}
|
2020-06-24 17:37:09 +08:00
|
|
|
|
FOR ${order} IN @{orderByArr}
|
2020-07-20 11:41:44 +08:00
|
|
|
|
@{orderByArr} Split String ${order} ${itemSplitor}
|
2020-06-24 17:37:09 +08:00
|
|
|
|
${dict} Create Dictionary field=${orderByArr}[0] asc=${orderByArr}[1]
|
|
|
|
|
|
Append To List ${orderByList} ${dict}
|
|
|
|
|
|
END
|
|
|
|
|
|
[Return] ${orderByList}
|
|
|
|
|
|
ManageFields
|
2020-06-28 14:10:24 +08:00
|
|
|
|
[Documentation]
|
|
|
|
|
|
... 处理fields
|
2020-06-24 17:37:09 +08:00
|
|
|
|
[Arguments] ${fields}
|
|
|
|
|
|
${fieldsList} Create List
|
2020-07-20 11:41:44 +08:00
|
|
|
|
@{fieldsArr} Split String ${fields} ${arraySplitor}
|
2020-06-24 17:37:09 +08:00
|
|
|
|
FOR ${field} IN @{fieldsArr}
|
2020-07-20 11:41:44 +08:00
|
|
|
|
@{fieldArr} Split String ${field} ${itemSplitor}
|
2020-07-17 18:33:32 +08:00
|
|
|
|
${dict} Create Dictionary name=${fieldArr}[0] type=${fieldArr}[1]
|
|
|
|
|
|
${len} Get Length ${fieldArr}
|
2020-06-28 14:10:24 +08:00
|
|
|
|
# batch时有lang字段
|
2020-07-17 18:33:32 +08:00
|
|
|
|
Run Keyword If ${len}==3 Set To Dictionary ${dict} lang=${fieldArr}[2]
|
2020-06-24 17:37:09 +08:00
|
|
|
|
Append To List ${fieldsList} ${dict}
|
|
|
|
|
|
END
|
|
|
|
|
|
[Return] ${fieldsList}
|
|
|
|
|
|
ManageConditions
|
2020-06-28 14:10:24 +08:00
|
|
|
|
[Documentation]
|
|
|
|
|
|
... 处理conditions
|
2020-06-24 17:37:09 +08:00
|
|
|
|
[Arguments] ${conditions}
|
|
|
|
|
|
${conditionsList} Create List
|
2020-07-20 11:41:44 +08:00
|
|
|
|
@{conditionsArr} Split String ${conditions} ${arraySplitor}
|
2020-06-24 17:37:09 +08:00
|
|
|
|
FOR ${condition} IN @{conditionsArr}
|
2020-07-20 11:41:44 +08:00
|
|
|
|
@{conditionArr} Split String ${condition} ${itemSplitor}
|
|
|
|
|
|
@{value} Split String ${conditionArr}[3] ${valueSplitor}
|
2020-06-24 17:37:09 +08:00
|
|
|
|
${type} Set Variable ${conditionArr}[1]
|
|
|
|
|
|
${value} Run Keyword If "${type}"=="int" or "${type}"=="long" toDigitList ${value} ${type}
|
|
|
|
|
|
... ELSE Set Variable ${value}
|
|
|
|
|
|
${dict} Create Dictionary field=${conditionArr}[0] type=${type} symbol=${conditionArr}[2] value=${value}
|
|
|
|
|
|
Append To List ${conditionsList} ${dict}
|
|
|
|
|
|
END
|
|
|
|
|
|
[Return] ${conditionsList}
|
|
|
|
|
|
toDigitList
|
2020-06-28 14:10:24 +08:00
|
|
|
|
[Documentation]
|
|
|
|
|
|
... 转换为int 或者long型的list
|
2020-06-24 17:37:09 +08:00
|
|
|
|
[Arguments] ${values} ${type}
|
|
|
|
|
|
${list} Create List
|
|
|
|
|
|
FOR ${var} IN @{values}
|
2020-07-20 11:22:48 +08:00
|
|
|
|
#wx-fix python3中没有long类型,整形只有int类型,可以当做long类型使用
|
|
|
|
|
|
${var} Evaluate int('${var}')
|
2020-06-24 17:37:09 +08:00
|
|
|
|
Append To List ${list} ${var}
|
|
|
|
|
|
END
|
2020-06-28 14:10:24 +08:00
|
|
|
|
[Return] ${list}
|
|
|
|
|
|
WriteExcel
|
|
|
|
|
|
[Documentation]
|
|
|
|
|
|
... 二进制文件导出为Excel
|
|
|
|
|
|
[Arguments] ${filePath} ${fileName} ${content}
|
|
|
|
|
|
Create Binary File ${path}/${filePath}/${fileName} ${content}
|
|
|
|
|
|
[Return] ${path}/${filePath}/${fileName}
|