114 lines
5.8 KiB
Plaintext
114 lines
5.8 KiB
Plaintext
*** Settings ***
|
|
Library json
|
|
Library Collections
|
|
Library RequestsLibrary
|
|
Resource ../../../03-Variable/BifangApiVariable.txt
|
|
Resource ../../../02-Keyword/tsg_bfapi/policy_file_interface/FunctionalKeywords.robot
|
|
Resource ../Common.robot
|
|
*** Variables ***
|
|
${logUrl} /log
|
|
*** Keywords ***
|
|
GetLogSchema
|
|
[Documentation]
|
|
... 日志schema查询
|
|
... logType 日志类型
|
|
... resData schema数据
|
|
[Arguments] ${logType}
|
|
${response} BaseFormRequest ${logUrl}/schema logType=${logType} ${version}
|
|
${rescode} Set Variable ${response['code']}
|
|
Should Be Equal As Integers ${rescode} 200
|
|
${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']}
|
|
QueryLogList
|
|
[Documentation]
|
|
... 日志列表查询
|
|
... params字典列表
|
|
... 注意如下字典字段格式
|
|
... orderBy=field名字1|true,field名字2|false
|
|
... fields=name1|type,name2|type
|
|
... conditions=field1|type|symbol|value1^value2,field2|type|symbol|value3^value4
|
|
... value1^value2是使用^分隔的字符串解析后为[value1,value2]格式的数组
|
|
[Arguments] ${params}
|
|
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
|
|
${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
|
|
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
|
|
... ELSE ManageOrderBy ${orderBy}
|
|
Set To Dictionary ${params} orderBy=${orderBy}
|
|
|
|
${fields} Get From Dictionary ${params} fields
|
|
Should Not Be Empty ${fields}
|
|
${fields} ManageFields ${fields}
|
|
Set To Dictionary ${params} fields=${fields}
|
|
|
|
${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
|
|
${response} BasePostRequestForV2 ${logUrl}/list ${bodyJson} ${version}
|
|
${rescode} Set Variable ${response['code']}
|
|
Should Be Equal As Integers ${rescode} 200
|
|
${resData} Set Variable ${response['data']}
|
|
[Return] ${resData}
|
|
ManageOrderBy
|
|
[Documentation]
|
|
...
|
|
[Arguments] ${orderBy}
|
|
${orderByList} Create List
|
|
@{orderByArr} Split String ${orderBy} ,
|
|
FOR ${order} IN @{orderByArr}
|
|
@{orderByArr} Split String ${order} |
|
|
${dict} Create Dictionary field=${orderByArr}[0] asc=${orderByArr}[1]
|
|
Append To List ${orderByList} ${dict}
|
|
END
|
|
[Return] ${orderByList}
|
|
ManageFields
|
|
[Arguments] ${fields}
|
|
${fieldsList} Create List
|
|
@{fieldsArr} Split String ${fields} ,
|
|
FOR ${field} IN @{fieldsArr}
|
|
@{fieldsArr} Split String ${field} |
|
|
${dict} Create Dictionary name=${fieldsArr}[0] type=${fieldsArr}[1]
|
|
Append To List ${fieldsList} ${dict}
|
|
END
|
|
[Return] ${fieldsList}
|
|
ManageConditions
|
|
[Arguments] ${conditions}
|
|
${conditionsList} Create List
|
|
@{conditionsArr} Split String ${conditions} ,
|
|
FOR ${condition} IN @{conditionsArr}
|
|
@{conditionArr} Split String ${condition} |
|
|
@{value} Split String ${conditionArr}[3] ^
|
|
${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
|
|
[Arguments] ${values} ${type}
|
|
${list} Create List
|
|
FOR ${var} IN @{values}
|
|
${var} Run Keyword If "${type}"=="int" Evaluate int('${var}')
|
|
... ELSE Evaluate long('${var}')
|
|
Append To List ${list} ${var}
|
|
END
|
|
[Return] ${list} |