1.新增上传Log日志纯接口及针对全流程log日志字段的目的性验证关键字及测试用例
This commit is contained in:
@@ -1,9 +1,7 @@
|
|||||||
*** Settings ***
|
*** Settings ***
|
||||||
Force Tags tsg_adc_wp
|
|
||||||
Resource ../../../03-Variable/BifangApiVariable.txt
|
Resource ../../../03-Variable/BifangApiVariable.txt
|
||||||
Library ../../../04-CustomLibrary/Custometest/LogSchema.py
|
Library ../../../04-CustomLibrary/Custometest/LogSchema.py
|
||||||
Library ../../../04-CustomLibrary/Custometest/LogResponseVAL.py
|
Library ../../../04-CustomLibrary/Custometest/LogResponseVAL.py
|
||||||
Resource ../../../05-Other/AllFlowCaseVariable1.txt
|
|
||||||
Library DateTime
|
Library DateTime
|
||||||
Library json
|
Library json
|
||||||
Library OperatingSystem
|
Library OperatingSystem
|
||||||
@@ -59,6 +57,18 @@ LogExportVerifyCase
|
|||||||
${Schemaurl} Set Variable http://${host}:${port}/v1/log/schema?logType=${logType}
|
${Schemaurl} Set Variable http://${host}:${port}/v1/log/schema?logType=${logType}
|
||||||
exportlog ${Logurl} ${Schemaurl} ${token} ${StartTime1} ${EndTime1} ${logType} ${filter}
|
exportlog ${Logurl} ${Schemaurl} ${token} ${StartTime1} ${EndTime1} ${logType} ${filter}
|
||||||
END
|
END
|
||||||
|
|
||||||
|
LogExportCeilingVerifyCase
|
||||||
|
[Documentation] 验证日志导出接口上限测试,当前导出上限为十万
|
||||||
|
${Logurl} Set Variable http://${host}:${port}/v1/log/batch
|
||||||
|
${logTypelist} create list security_event_log proxy_event_log connection_record_log radius_record_log voip_record_log live_session_record_log transaction_record_log gtpc_record_log
|
||||||
|
${StartTime1} Set Variable 2020-05-01 00:00:00
|
||||||
|
${EndTime1} Set Variable 2021-05-01 00:00:00
|
||||||
|
${filter} Set Variable
|
||||||
|
FOR ${logType} in @{logTypelist}
|
||||||
|
${Schemaurl} Set Variable http://${host}:${port}/v1/log/schema?logType=${logType}
|
||||||
|
exportlog ${Logurl} ${Schemaurl} ${token} ${StartTime1} ${EndTime1} ${logType} ${filter}
|
||||||
|
END
|
||||||
|
|
||||||
LogRetrieveVerifyCase
|
LogRetrieveVerifyCase
|
||||||
[Documentation] 验证日志检索条件接口
|
[Documentation] 验证日志检索条件接口
|
||||||
@@ -74,6 +84,22 @@ LogRetrieveVerifyCase
|
|||||||
${responsebody} loglistverify ${Logurl} ${Schemaurl} ${token} ${StartTime1} ${EndTime1} ${logType} ${filter}
|
${responsebody} loglistverify ${Logurl} ${Schemaurl} ${token} ${StartTime1} ${EndTime1} ${logType} ${filter}
|
||||||
LogRetrieve ${Schemaurl} ${host} ${port} ${token} ${logType} ${responsebody}
|
LogRetrieve ${Schemaurl} ${host} ${port} ${token} ${logType} ${responsebody}
|
||||||
END
|
END
|
||||||
|
|
||||||
|
LogRetrieveComplexSqlVerifyCase
|
||||||
|
[Documentation] 日志检索条件接口复杂SQL验证
|
||||||
|
${Logurl} Set Variable http://${host}:${port}/v1/log/list
|
||||||
|
${logTypelist} create list security_event_log connection_record_log security_event_log proxy_event_log connection_record_log radius_record_log voip_record_log live_session_record_log transaction_record_log gtpc_record_log
|
||||||
|
${EndTime} get current date
|
||||||
|
${EndTime1} Get Substring ${EndTime} \ -4
|
||||||
|
${StartTime} add time to date ${EndTime} -03:00:00
|
||||||
|
${StartTime1} Get Substring ${StartTime} \ -4
|
||||||
|
${filter} Set Variable
|
||||||
|
FOR ${logType} in @{logTypelist}
|
||||||
|
${Schemaurl} Set Variable http://${host}:${port}/v1/log/schema?logType=${logType}
|
||||||
|
${responsebody} loglistverify ${Logurl} ${Schemaurl} ${token} ${StartTime1} ${EndTime1} ${logType} ${filter}
|
||||||
|
LogRetrieveSql ${Schemaurl} ${host} ${port} ${token} ${logType} ${responsebody}
|
||||||
|
END
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
54
01-TestCase/tsg_bfapi/api_log/LogPurposeInterfaceCase.robot
Normal file
54
01-TestCase/tsg_bfapi/api_log/LogPurposeInterfaceCase.robot
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
*** Settings ***
|
||||||
|
Force Tags tsg_adc_wp
|
||||||
|
Resource ../../../03-Variable/BifangApiVariable.txt
|
||||||
|
Library ../../../04-CustomLibrary/Custometest/LogSchema.py
|
||||||
|
Resource ../../../05-Other/AllFlowCaseVariable1.txt
|
||||||
|
Library OperatingSystem
|
||||||
|
Library Selenium2Library
|
||||||
|
Library RequestsLibrary
|
||||||
|
Library Collections
|
||||||
|
Library String
|
||||||
|
|
||||||
|
*** Variables ***
|
||||||
|
|
||||||
|
*** Test Cases ***
|
||||||
|
|
||||||
|
LogAllConditionsVerifyCase
|
||||||
|
[Documentation] 全流程日志各字段查询
|
||||||
|
${Logurl} Set Variable http://${host}:${port}/v1/log/list
|
||||||
|
${logTypelist} create list security_event_log proxy_event_log connection_record_log radius_record_log voip_record_log live_session_record_log transaction_record_log gtpc_record_log
|
||||||
|
${EndTime1} Set Variable ${endtime}
|
||||||
|
${StartTime1} Set Variable ${starttime}
|
||||||
|
${filter} Set Variable
|
||||||
|
FOR ${logType} in @{logTypelist}
|
||||||
|
${Schemaurl} Set Variable http://${host}:${port}/v1/log/schema?logType=${logType}
|
||||||
|
${responsebody} loglistverify ${Logurl} ${Schemaurl} ${token} ${StartTime1} ${EndTime1} ${logType} ${filter}
|
||||||
|
log ${responsebody}
|
||||||
|
logAllFieldsListInterface ${Logurl} ${Schemaurl} ${token} ${StartTime1} ${EndTime1} ${logType} ${responsebody} ${lognumber} ${logcycles}
|
||||||
|
END
|
||||||
|
|
||||||
|
LogFieldVerifyCase
|
||||||
|
[Documentation] 全流程日志详情字段
|
||||||
|
${Logurl} Set Variable http://${host}:${port}/v1/log/list
|
||||||
|
${logTypelist} create list security_event_log proxy_event_log connection_record_log radius_record_log voip_record_log live_session_record_log transaction_record_log gtpc_record_log
|
||||||
|
${EndTime1} Set Variable ${endtime}
|
||||||
|
${StartTime1} Set Variable ${starttime}
|
||||||
|
${filter} Set Variable
|
||||||
|
FOR ${logType} in @{logTypelist}
|
||||||
|
${Schemaurl} Set Variable http://${host}:${port}/v1/log/schema?logType=${logType}
|
||||||
|
${responsebody} loglistverify ${Logurl} ${Schemaurl} ${token} ${StartTime1} ${EndTime1} ${logType} ${filter}
|
||||||
|
log ${responsebody}
|
||||||
|
LogFieldValidation ${Schemaurl} ${token} ${responsebody}
|
||||||
|
END
|
||||||
|
|
||||||
|
LogExportVerifyCase
|
||||||
|
[Documentation] 全流程日志导出
|
||||||
|
${Logurl} Set Variable http://${host}:${port}/v1/log/batch
|
||||||
|
${logTypelist} create list security_event_log proxy_event_log connection_record_log radius_record_log voip_record_log live_session_record_log transaction_record_log gtpc_record_log
|
||||||
|
${EndTime1} Set Variable ${endtime}
|
||||||
|
${StartTime1} Set Variable ${starttime}
|
||||||
|
${filter} Set Variable
|
||||||
|
FOR ${logType} in @{logTypelist}
|
||||||
|
${Schemaurl} Set Variable http://${host}:${port}/v1/log/schema?logType=${logType}
|
||||||
|
exportlog ${Logurl} ${Schemaurl} ${token} ${StartTime1} ${EndTime1} ${logType} ${filter}
|
||||||
|
END
|
||||||
@@ -145,136 +145,6 @@ LogApiVerifyCase-007
|
|||||||
|
|
||||||
log ${responsebody}
|
log ${responsebody}
|
||||||
|
|
||||||
|
|
||||||
###################################################白云波 20.15版本接口测试####################################################################
|
|
||||||
|
|
||||||
LogGTPFieldVerifyCase
|
|
||||||
[Documentation] 验证api接口:验证Session Records 日志GTP字段丰富验证
|
|
||||||
${Logurl} Set Variable http://${host}:${port}/v1/log/list
|
|
||||||
${logType} Set Variable connection_record_log
|
|
||||||
${Schemaurl} Set Variable http://${host}:${port}/v1/log/schema?logType=${logType}
|
|
||||||
${EndTime} get current date
|
|
||||||
${EndTime1} Get Substring ${EndTime} \ -4
|
|
||||||
${StartTime} add time to date ${EndTime} -01:00:00
|
|
||||||
${StartTime1} Get Substring ${StartTime} \ -4
|
|
||||||
${filter} Set Variable ${条件待定}
|
|
||||||
${responsebody} loglistverify ${Logurl} ${Schemaurl} ${token} ${StartTime1} ${EndTime1} ${logType} ${filter}
|
|
||||||
${targetdict} create list tunnel_schema_type gtp_SGW_ip gtp_PGW_ip gtp_SGW_port gtp_PGW_port gtp_uplink_TEID gtp_downlink_TEID mpls_c2s_direction_label mpls_s2c_direction_label
|
|
||||||
... vlan_c2s_direction_id vlan_s2c_direction_id source_mac destination_mac c2s_source_mac c2s_destination_mac s2c_source_mac s2c_destination_mac
|
|
||||||
log ${responsebody}
|
|
||||||
${strlist} FieldValidation ${responsebody} ${targetdict}
|
|
||||||
log ${strlist}
|
|
||||||
|
|
||||||
|
|
||||||
LiveSessionRecordLogApiVerifyCase
|
|
||||||
[Documentation] live_session_record_log纯接口测试用例
|
|
||||||
${Logurl} Set Variable http://${host}:${port}/v1/log/list
|
|
||||||
${logType} Set Variable live_session_record_log
|
|
||||||
${Schemaurl} Set Variable http://${host}:${port}/v1/log/schema?logType=${logType}
|
|
||||||
${EndTime} get current date
|
|
||||||
${EndTime1} Get Substring ${EndTime} \ -4
|
|
||||||
${StartTime} add time to date ${EndTime} -01:00:00
|
|
||||||
${StartTime1} Get Substring ${StartTime} \ -4
|
|
||||||
logapiverify ${Logurl} ${Schemaurl} ${token} ${StartTime1} ${EndTime1} ${logType}
|
|
||||||
|
|
||||||
LiveSessionRecordLogCount
|
|
||||||
[Documentation] live_session_record_log统计日志总数
|
|
||||||
${Logurl} Set Variable http://${host}:${port}/v1/log/count
|
|
||||||
${logType} Set Variable live_session_record_log
|
|
||||||
${EndTime} get current date
|
|
||||||
${EndTime1} Get Substring ${EndTime} \ -4
|
|
||||||
${StartTime} add time to date ${EndTime} -01:00:00
|
|
||||||
${StartTime1} Get Substring ${StartTime} \ -4
|
|
||||||
${count} countlog_query ${Logurl} ${token} ${StartTime1} ${EndTime1} ${logType}
|
|
||||||
log ${count}
|
|
||||||
|
|
||||||
LiveSessionRecordLogExportLog
|
|
||||||
[Documentation] live_session_record_log导出日志
|
|
||||||
${Logurl} Set Variable http://${host}:${port}/v1/log/batch
|
|
||||||
${logType} Set Variable live_session_record_log
|
|
||||||
${Schemaurl} Set Variable http://${host}:${port}/v1/log/schema?logType=${logType}
|
|
||||||
${EndTime} get current date
|
|
||||||
${EndTime1} Get Substring ${EndTime} \ -4
|
|
||||||
${StartTime} add time to date ${EndTime} -01:00:00
|
|
||||||
${StartTime1} Get Substring ${StartTime} \ -4
|
|
||||||
${filter} Set Variable
|
|
||||||
exportlog ${Logurl} ${Schemaurl} ${token} ${StartTime1} ${EndTime1} ${logType} ${filter}
|
|
||||||
|
|
||||||
|
|
||||||
LiveSessionRecordLogRetrievalConditionApiVerify
|
|
||||||
[Documentation] 验证api接口:日志检索条件校验(filter内容验证)
|
|
||||||
${logType} Set Variable live_session_record_log
|
|
||||||
${filter} Set Variable common_recv_time = 45535
|
|
||||||
${urlpath} Set Variable ?logType=${logType}&filter=${filter}
|
|
||||||
${Logurl} Set Variable http://${host}:${port}/v1/interface/gateway/sql/galaxy/log/filter/validation${urlpath}
|
|
||||||
${responsebody} distributed_query ${Logurl} ${token}
|
|
||||||
log ${responsebody}
|
|
||||||
|
|
||||||
|
|
||||||
TransactionRecordLogApiVerifyCase
|
|
||||||
[Documentation] transaction_record_log纯接口测试用例
|
|
||||||
${Logurl} Set Variable http://${host}:${port}/v1/log/list
|
|
||||||
${logType} Set Variable transaction_record_log
|
|
||||||
${Schemaurl} Set Variable http://${host}:${port}/v1/log/schema?logType=${logType}
|
|
||||||
${EndTime} get current date
|
|
||||||
${EndTime1} Get Substring ${EndTime} \ -4
|
|
||||||
${StartTime} add time to date ${EndTime} -01:00:00
|
|
||||||
${StartTime1} Get Substring ${StartTime} \ -4
|
|
||||||
logapiverify ${Logurl} ${Schemaurl} ${token} ${StartTime1} ${EndTime1} ${logType}
|
|
||||||
|
|
||||||
TransactionRecordLogCount
|
|
||||||
[Documentation] transaction_record_log统计日志总数
|
|
||||||
${Logurl} Set Variable http://${host}:${port}/v1/log/count
|
|
||||||
${logType} Set Variable transaction_record_log
|
|
||||||
${EndTime} get current date
|
|
||||||
${EndTime1} Get Substring ${EndTime} \ -4
|
|
||||||
${StartTime} add time to date ${EndTime} -01:00:00
|
|
||||||
${StartTime1} Get Substring ${StartTime} \ -4
|
|
||||||
${count} countlog_query ${Logurl} ${token} ${StartTime1} ${EndTime1} ${logType}
|
|
||||||
log ${count}
|
|
||||||
|
|
||||||
TransactionRecordLogExportLog
|
|
||||||
[Documentation] transaction_record_log导出日志
|
|
||||||
${Logurl} Set Variable http://${host}:${port}/v1/log/batch
|
|
||||||
${logType} Set Variable transaction_record_log
|
|
||||||
${Schemaurl} Set Variable http://${host}:${port}/v1/log/schema?logType=${logType}
|
|
||||||
${EndTime} get current date
|
|
||||||
${EndTime1} Get Substring ${EndTime} \ -4
|
|
||||||
${StartTime} add time to date ${EndTime} -01:00:00
|
|
||||||
${StartTime1} Get Substring ${StartTime} \ -4
|
|
||||||
${filter} Set Variable
|
|
||||||
exportlog ${Logurl} ${Schemaurl} ${token} ${StartTime1} ${EndTime1} ${logType} ${filter}
|
|
||||||
|
|
||||||
|
|
||||||
TransactionRecordLogRetrievalConditionApiVerify
|
|
||||||
[Documentation] transaction_record_log:日志检索条件校验(filter内容验证)
|
|
||||||
${logType} Set Variable transaction_record_log
|
|
||||||
${filter} Set Variable common_recv_time = 45535
|
|
||||||
${urlpath} Set Variable ?logType=${logType}&filter=${filter}
|
|
||||||
${Logurl} Set Variable http://${host}:${port}/v1/interface/gateway/sql/galaxy/log/filter/validation${urlpath}
|
|
||||||
${responsebody} distributed_query ${Logurl} ${token}
|
|
||||||
log ${responsebody}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
import re
|
||||||
|
import time
|
||||||
|
|
||||||
import jsonpath
|
import jsonpath
|
||||||
# 1.说明:本方法用于对日志接口返回数据中的字段和数据进行判断
|
# 1.说明:本方法用于对日志接口返回数据中的字段和数据进行判断
|
||||||
# 2.传入数据说明:responsedict - 接口返回数据的json数据
|
# 2.传入数据说明:responsedict - 接口返回数据的json数据
|
||||||
@@ -35,11 +38,21 @@ def FieldValidation(responsedict, targetlist):
|
|||||||
responsevalue=str(responsevalue)
|
responsevalue=str(responsevalue)
|
||||||
if len(target) == 3:
|
if len(target) == 3:
|
||||||
targetvalue = target[2]
|
targetvalue = target[2]
|
||||||
p = conditional(conditions, responsevalue, targetkey, sum, targetvalue)
|
torf=is_valid_date(responsevalue)
|
||||||
strlist.append(p)
|
if torf == True:
|
||||||
|
timeArray = time.strptime(responsevalue, "%Y-%m-%d %H:%M:%S")
|
||||||
|
timeStamp = str(int(time.mktime(timeArray)))
|
||||||
|
p = conditional(conditions, timeStamp, targetkey, sum, targetvalue)
|
||||||
|
if p != "":
|
||||||
|
strlist.append(p)
|
||||||
|
else:
|
||||||
|
p = conditional(conditions, responsevalue, targetkey, sum, targetvalue)
|
||||||
|
if p != "":
|
||||||
|
strlist.append(p)
|
||||||
elif len(target) == 2:
|
elif len(target) == 2:
|
||||||
p = conditional(conditions, responsevalue, targetkey, sum)
|
p = conditional(conditions, responsevalue, targetkey, sum)
|
||||||
strlist.append(p)
|
if p != "":
|
||||||
|
strlist.append(p)
|
||||||
else:
|
else:
|
||||||
str2 = "返回数据第" + str(sum) + "组数据中不存在该字段:" + target[0]
|
str2 = "返回数据第" + str(sum) + "组数据中不存在该字段:" + target[0]
|
||||||
print(str2)
|
print(str2)
|
||||||
@@ -177,3 +190,14 @@ def Assertresults(resultslist):
|
|||||||
for i in resultslist:
|
for i in resultslist:
|
||||||
if i != "":
|
if i != "":
|
||||||
assert 1 == 2
|
assert 1 == 2
|
||||||
|
|
||||||
|
|
||||||
|
def is_valid_date(strdate):
|
||||||
|
'''判断是否是一个有效的日期字符串'''
|
||||||
|
a = re.findall(":", strdate)
|
||||||
|
b = re.findall("-", strdate)
|
||||||
|
if len(a) ==2 and len(b) == 2:
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|||||||
@@ -247,7 +247,6 @@ def logapiverify(schemauerl,logurl, token, starttime, endtime,logtype):
|
|||||||
def loglistverify(logurl, schemauerl, token, starttime, endtime, logtype, filtervalue):
|
def loglistverify(logurl, schemauerl, token, starttime, endtime, logtype, filtervalue):
|
||||||
a = schema(schemauerl, token)
|
a = schema(schemauerl, token)
|
||||||
fields = a["data"]["fields"]
|
fields = a["data"]["fields"]
|
||||||
print(fields)
|
|
||||||
url = logurl # "http://192.168.44.72:8080/v1/log/list"
|
url = logurl # "http://192.168.44.72:8080/v1/log/list"
|
||||||
headers = {"Content-Type": "application/json",
|
headers = {"Content-Type": "application/json",
|
||||||
"Authorization": token}
|
"Authorization": token}
|
||||||
@@ -258,12 +257,85 @@ def loglistverify(logurl, schemauerl, token, starttime, endtime, logtype, filter
|
|||||||
"fields": fields,
|
"fields": fields,
|
||||||
"filter": filtervalue
|
"filter": filtervalue
|
||||||
}
|
}
|
||||||
|
# print(json.dumps(data))
|
||||||
response1 = requests.post(url=url, data=json.dumps(data), headers=headers)
|
response1 = requests.post(url=url, data=json.dumps(data), headers=headers)
|
||||||
code = response1.json()["code"]
|
code = response1.json()["code"]
|
||||||
assert code == 200
|
assert code == 200
|
||||||
print(response1.json()["code"])
|
print(response1.json()["code"])
|
||||||
return response1.json()
|
return response1.json()
|
||||||
|
|
||||||
|
#目的性验证,循坏返回列表中所有字段进行查询
|
||||||
|
def loglistverifys(logurl, schemaurl, token, starttime, endtime, logtype, datajson):
|
||||||
|
nullkey = []
|
||||||
|
data = datajson
|
||||||
|
keylist = LogResponseVAL.getKeys(data)
|
||||||
|
a = schema(schemaurl, token)
|
||||||
|
fields = a["data"]["fields"]
|
||||||
|
for i in keylist:
|
||||||
|
conditions = data[i]
|
||||||
|
for field in fields:
|
||||||
|
name = field["name"]
|
||||||
|
if field["doc"] == None or field["doc"]["visibility"] == None:
|
||||||
|
if i == name:
|
||||||
|
if conditions != None and conditions != "":
|
||||||
|
if field["type"] == "string":
|
||||||
|
if conditions[0] == "'" and conditions[-1] == "'":
|
||||||
|
filtervalue = i + " = " + conditions
|
||||||
|
VasserValue=i + " = " + conditions[1:-1]
|
||||||
|
|
||||||
|
else:
|
||||||
|
filtervalue = i + " = " + "'" + conditions + "'"
|
||||||
|
VasserValue= i + " = " + conditions
|
||||||
|
else:
|
||||||
|
if i == "common_recv_time" or i == "common_start_time" or i == "common_end_time" or i == "common_processing_time":
|
||||||
|
timeArray = time.strptime(conditions, "%Y-%m-%d %H:%M:%S")
|
||||||
|
timeStamp = str(int(time.mktime(timeArray)))
|
||||||
|
filtervalue = i + " = " + timeStamp
|
||||||
|
VasserValue = filtervalue
|
||||||
|
|
||||||
|
else:
|
||||||
|
filtervalue = i + " = " + str(conditions)
|
||||||
|
VasserValue = filtervalue
|
||||||
|
print("filtervalue",filtervalue)
|
||||||
|
#根据提取条件进行查询日志列表
|
||||||
|
responsebody = loglistverify(logurl, schemaurl, token, starttime, endtime, logtype,
|
||||||
|
filtervalue)
|
||||||
|
filterlist=[VasserValue]
|
||||||
|
print(VasserValue)
|
||||||
|
LogResponseVAL.FieldValidation(responsebody,filterlist)
|
||||||
|
|
||||||
|
else:
|
||||||
|
nullkey.append(i) #所有为None或者“”的字段
|
||||||
|
return nullkey
|
||||||
|
|
||||||
|
# 多条循环 变量设置为公共参数 若循环内一个字段没有值 进行下次循坏
|
||||||
|
def logAllFieldsListInterface(logurl, schemaurl, token, starttime, endtime, logtype, datajson,lognumber,logcycles):
|
||||||
|
datalist = datajson["data"]["list"]
|
||||||
|
keylist=[]
|
||||||
|
number=0
|
||||||
|
print(lognumber)
|
||||||
|
print(type(lognumber))
|
||||||
|
print(logcycles)
|
||||||
|
print(type(logcycles))
|
||||||
|
for i in range(0, len(datalist), int(lognumber)):# 循环取出count个列表元素
|
||||||
|
number+=1
|
||||||
|
nullkeylist=[]
|
||||||
|
ret=datalist[i:i + int(lognumber)]
|
||||||
|
for data in ret:
|
||||||
|
nullkey=loglistverifys(logurl, schemaurl, token, starttime, endtime, logtype, data)
|
||||||
|
nullkeylist.append(nullkey)
|
||||||
|
print(nullkeylist)
|
||||||
|
for j in nullkeylist:
|
||||||
|
#对返回的为空的key进行取交集
|
||||||
|
if len(keylist) == 0:
|
||||||
|
keylist=j
|
||||||
|
else:
|
||||||
|
#取两个列表的交集
|
||||||
|
keylist=list(set(keylist).intersection(set(j)))
|
||||||
|
if len(keylist) == 0 or number >= int(logcycles):
|
||||||
|
break
|
||||||
|
print("最终数据中没有值的字段为:",keylist)
|
||||||
|
|
||||||
|
|
||||||
# 事件日志和通联日志时间分布查询 ,日志检索条件校验(filter内容验证)
|
# 事件日志和通联日志时间分布查询 ,日志检索条件校验(filter内容验证)
|
||||||
def distributed_query(logurl, token):
|
def distributed_query(logurl, token):
|
||||||
@@ -291,23 +363,54 @@ def LogRetrieve(schemaurl,host,port,token,logType,datajson):
|
|||||||
if i == name:
|
if i == name:
|
||||||
if field["type"] == "string":
|
if field["type"] == "string":
|
||||||
filter = "logType=" + logType + "&" + "filter=" + i + "=" + "'" + str1 + "'"
|
filter = "logType=" + logType + "&" + "filter=" + i + "=" + "'" + str1 + "'"
|
||||||
Logurl = "http://" + host + ":" + port + "/v1/interface/gateway/sql/galaxy/log/filter/validation?" + filter
|
|
||||||
print(Logurl)
|
|
||||||
responsebody = distributed_query(Logurl, token)
|
|
||||||
else:
|
else:
|
||||||
if i == "common_recv_time" or i == "common_start_time" or i == "common_end_time" or i == "common_processing_time":
|
if i == "common_recv_time" or i == "common_start_time" or i == "common_end_time" or i == "common_processing_time":
|
||||||
timeArray = time.strptime(conditions, "%Y-%m-%d %H:%M:%S")
|
timeArray = time.strptime(conditions, "%Y-%m-%d %H:%M:%S")
|
||||||
timeStamp = str(int(time.mktime(timeArray)))
|
timeStamp = str(int(time.mktime(timeArray)))
|
||||||
filter = "logType=" + logType + "&" + "filter=" + i + "=" + timeStamp
|
filter = "logType=" + logType + "&" + "filter=" + i + "=" + timeStamp
|
||||||
Logurl = "http://" + host + ":" + port + "/v1/interface/gateway/sql/galaxy/log/filter/validation?" + filter
|
|
||||||
print(Logurl)
|
|
||||||
responsebody = distributed_query(Logurl, token)
|
|
||||||
else:
|
else:
|
||||||
filter = "logType=" + logType + "&" + "filter=" + i + "=" + str(number)
|
filter = "logType=" + logType + "&" + "filter=" + i + "=" + str(number)
|
||||||
Logurl = "http://" + host + ":" + port + "/v1/interface/gateway/sql/galaxy/log/filter/validation?" + filter
|
Logurl = "http://" + host + ":" + port + "/v1/interface/gateway/sql/galaxy/log/filter/validation?" + filter
|
||||||
print(Logurl)
|
print(Logurl)
|
||||||
responsebody = distributed_query(Logurl, token)
|
responsebody = distributed_query(Logurl, token)
|
||||||
|
|
||||||
|
# 日志检索条件校验 复杂sql
|
||||||
|
def LogRetrieveSql(schemaurl,host,port,token,logType,datajson):
|
||||||
|
data = datajson["data"]["list"][0]
|
||||||
|
keylist = LogResponseVAL.getKeys(data)
|
||||||
|
sqllist=random.sample(keylist, 4)
|
||||||
|
number = 45585
|
||||||
|
str1 = random.choice('abcdefghijklmnopqrstuvwxyz')
|
||||||
|
print(sqllist)
|
||||||
|
a = schema(schemaurl, token)
|
||||||
|
filterlist=[]
|
||||||
|
fields=a["data"]["fields"]
|
||||||
|
for i in sqllist:
|
||||||
|
conditions = data[i]
|
||||||
|
for field in fields:
|
||||||
|
name = field["name"]
|
||||||
|
if i == name:
|
||||||
|
if field["type"] == "string":
|
||||||
|
if conditions == "" or conditions == None:
|
||||||
|
conditions=str1
|
||||||
|
filter = i + "=" + "'" + conditions + "'"
|
||||||
|
else:
|
||||||
|
if i == "common_recv_time" or i == "common_start_time" or i == "common_end_time" or i == "common_processing_time":
|
||||||
|
timeArray = time.strptime(conditions, "%Y-%m-%d %H:%M:%S")
|
||||||
|
timeStamp = str(int(time.mktime(timeArray)))
|
||||||
|
filter =i + "=" + timeStamp
|
||||||
|
else:
|
||||||
|
if conditions == "" or conditions == None:
|
||||||
|
conditions = number
|
||||||
|
filter = i + "=" + str(conditions)
|
||||||
|
print(filter)
|
||||||
|
filterlist.append(filter)
|
||||||
|
sqlfilter = "(("+filterlist[0]+" OR "+filterlist[1]+") AND "+filterlist[2]+") OR "+filterlist[3]
|
||||||
|
_filter = "logType=" + logType + "&" + "filter=" + sqlfilter
|
||||||
|
Logurl = "http://" + host + ":" + port + "/v1/interface/gateway/sql/galaxy/log/filter/validation?" + _filter
|
||||||
|
print(Logurl)
|
||||||
|
responsebody = distributed_query(Logurl, token)
|
||||||
|
print(sqlfilter)
|
||||||
|
|
||||||
# 原始日志检索时间分布计算
|
# 原始日志检索时间分布计算
|
||||||
def timedistribution(logurl, token, starttime, endtime, logtype, granularity, filtervalue):
|
def timedistribution(logurl, token, starttime, endtime, logtype, granularity, filtervalue):
|
||||||
|
|||||||
Reference in New Issue
Block a user