feat:(日志服务)支持日志总数查询

This commit is contained in:
wangxin
2020-06-24 18:07:07 +08:00
parent b1809c8083
commit 554c8564ae
2 changed files with 29 additions and 23 deletions

View File

@@ -521,21 +521,25 @@ Policy-log-v1-00026
${objectIds} Set Variable ${EMPTY}
Comment 查询schema
${schema_query} ${schema_type} ${default_columns} ${fields} GetLogSchema security_event_log
Comment 处理schema,构造查询条件
${queryFieldList} Create List
FOR ${field} IN @{fields}
log ${field}
${return} ${doc} Run Keyword And Ignore Error Get From Dictionary ${field} doc
Continue For Loop If "${return}"=="FAIL"
${return} ${allow_query} Run Keyword And Ignore Error Get From Dictionary ${doc} allow_query
Continue For Loop If "${allow_query}"=="false" or "${return}"=="FAIL"
${fieldDict} Create Dictionary name=${field['name']} type=${field['type']}
Append To List ${queryFieldList} ${fieldDict}
END
Comment 处理schema,构造查询条件
${params} Create Dictionary pageSize=${10} logType=security_event_log
... start_common_recv_time=2020-06-01 00:00:00
... end_common_recv_time=2020-06-24 00:00:00
... fields=common_log_id|long,http_url|string,common_client_ip|string,common_client_port|int,common_server_ip|string,common_server_port|int
... conditions=common_server_port|int|in|${80}^${8080}
... orderBy=common_server_ip|true
${resData} QueryLogList ${params}
... common_log_ids=162273027957354498
${resData} QueryLogs ${params} list
Policy-log-v1-00027
${objectIds} Set Variable ${EMPTY}
Comment 查询schema
${schema_query} ${schema_type} ${default_columns} ${fields} GetLogSchema security_event_log
Comment 处理schema,构造查询条件
${params} Create Dictionary pageSize=${10} logType=security_event_log
... start_common_recv_time=2020-06-01 00:00:00
... end_common_recv_time=2020-06-24 00:00:00
... fields=common_log_id|long,http_url|string,common_client_ip|string,common_client_port|int,common_server_ip|string,common_server_port|int
... conditions=common_server_port|int|in|${80}^${8080}
... orderBy=common_server_ip|true
... common_log_ids=162273027957354498
${resData} QueryLogs ${params} count

View File

@@ -22,7 +22,7 @@ GetLogSchema
${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
QueryLogs
[Documentation]
... 日志列表查询
... params字典列表
@@ -31,7 +31,7 @@ QueryLogList
... fields=name1|type,name2|type
... conditions=field1|type|symbol|value1^value2,field2|type|symbol|value3^value4
... value1^value2是使用^分隔的字符串解析后为[value1,value2]格式的数组
[Arguments] ${params}
[Arguments] ${params} ${path}
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
@@ -42,14 +42,16 @@ QueryLogList
#处理排序
${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}
... ELSE IF "${path}"=="list" ManageOrderBy ${orderBy} ELSE IF "${path}"=="count"
... Set Variable ${orderBy}
Run Keyword If "${path}"=="list" Set To Dictionary ${params} orderBy=${orderBy}
Run Keyword If "${path}"=="count" Remove From Dictionary ${params} orderBy
${return} ${fields} Run Keyword And Ignore Error Get From Dictionary ${params} fields
Run Keyword If "${path}"=="list" Should Not Be Empty ${fields}
${fields} Run Keyword If "${path}"=="list" ManageFields ${fields}
... ELSE Create List
Run Keyword If "${path}"=="list" Set To Dictionary ${params} fields=${fields}
Run Keyword If "${path}"=="count" Remove From Dictionary ${params} 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
@@ -62,7 +64,7 @@ QueryLogList
... ELSE Create List
Set To Dictionary ${params} conditions=${conditions}
${bodyJson} json.Dumps ${params} ensure_ascii=False
${response} BasePostRequestForV2 ${logUrl}/list ${bodyJson} ${version}
${response} BasePostRequestForV2 ${logUrl}/${path} ${bodyJson} ${version}
${rescode} Set Variable ${response['code']}
Should Be Equal As Integers ${rescode} 200
${resData} Set Variable ${response['data']}