调整Log纯接口测试关键字及用例

This commit is contained in:
byb11
2021-05-08 14:42:29 +08:00
parent 3d8a75f8e5
commit f4e2eb0125
2 changed files with 40 additions and 46 deletions

View File

@@ -19,18 +19,15 @@ Library String
LogApiVerifyCase LogApiVerifyCase
[Documentation] 验证日志查询纯接口测试 [Documentation] 验证日志查询纯接口测试
${Logurl} Set Variable http://${host}:${port}/v1/log/list ${Logurl} Set Variable http://${host}:${port}/v1/log/list
${logTypelist} Set Variable 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
${logTypelist} create list security_event_log proxy_event_log connection_record_log radius_record_log voip_record_log transaction_record_log live_session_record_log gtpc_record_log
${EndTime} get current date ${EndTime} get current date
${EndTime1} Get Substring ${EndTime} \ -4 ${EndTime1} Get Substring ${EndTime} \ -4
${StartTime} add time to date ${EndTime} -01:00:00 ${StartTime} add time to date ${EndTime} -01:00:00
${StartTime1} Get Substring ${StartTime} \ -4 ${StartTime1} Get Substring ${StartTime} \ -4
FOR ${logType} in @{logTypelist}
logapiverify ${Logurl} ${token} ${StartTime1} ${EndTime1} ${host} ${port} ${logTypelist} ${Schemaurl} Set Variable http://${host}:${port}/v1/log/schema?logType=${logType}
${a} logapiverify ${Schemaurl} ${Logurl} ${token} ${StartTime1} ${EndTime1} ${logType}
END
LogFieldVerifyCase LogFieldVerifyCase
@@ -39,7 +36,7 @@ LogFieldVerifyCase
${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 ${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
${EndTime} get current date ${EndTime} get current date
${EndTime1} Get Substring ${EndTime} \ -4 ${EndTime1} Get Substring ${EndTime} \ -4
${StartTime} add time to date ${EndTime} -01:00:00 ${StartTime} add time to date ${EndTime} -03:00:00
${StartTime1} Get Substring ${StartTime} \ -4 ${StartTime1} Get Substring ${StartTime} \ -4
${filter} Set Variable ${filter} Set Variable
FOR ${logType} in @{logTypelist} FOR ${logType} in @{logTypelist}
@@ -69,7 +66,7 @@ LogRetrieveVerifyCase
${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 ${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
${EndTime} get current date ${EndTime} get current date
${EndTime1} Get Substring ${EndTime} \ -4 ${EndTime1} Get Substring ${EndTime} \ -4
${StartTime} add time to date ${EndTime} -01:00:00 ${StartTime} add time to date ${EndTime} -03:00:00
${StartTime1} Get Substring ${StartTime} \ -4 ${StartTime1} Get Substring ${StartTime} \ -4
${filter} Set Variable ${filter} Set Variable
FOR ${logType} in @{logTypelist} FOR ${logType} in @{logTypelist}

View File

@@ -7,12 +7,12 @@ import LogResponseVAL
import time, datetime import time, datetime
# import allure # import allure
list = []
# 请求schema接口得到返回数据用于其他接口 # 请求schema接口得到返回数据用于其他接口
def schema(schemauerl, token): def schema(schemauerl, token):
url = schemauerl # "http://192.168.44.72:8080/v1/log/schema?logType=security_event_log" url = schemauerl
headers = {"Content-Type": "application/x-www-form-urlencoded", "Authorization": token} headers = {"Content-Type": "application/x-www-form-urlencoded", "Authorization": token}
response = requests.get(url=url, headers=headers) response = requests.get(url=url, headers=headers)
return response.json() return response.json()
@@ -68,10 +68,13 @@ def randrom_url():
def Filter1(schemauerl, token): def Filter1(schemauerl, token):
list = []
json_str = schema(schemauerl, token) json_str = schema(schemauerl, token)
print("schemauerl",json_str)
print(type(json_str)) print(type(json_str))
# 获取日志属性定义 # 获取日志属性定义
fields = json_str["data"]["fields"] fields = json_str["data"]["fields"]
print("1111111111",fields)
# 获取不同属性支持的部不同操作 # 获取不同属性支持的部不同操作
operator = json_str["data"]["doc"]["schema_query"]["references"]["operator"] operator = json_str["data"]["doc"]["schema_query"]["references"]["operator"]
for i in fields: for i in fields:
@@ -189,22 +192,18 @@ def Filter1(schemauerl, token):
list.append(str1) list.append(str1)
print(list) print("22222222222",list)
return list return list
# 根据Filter1方法中的的数据写入log请求接口中来验证log请求接口 # 根据Filter1方法中的的数据写入log请求接口中来验证log请求接口
def logapiverify(logurl, token, starttime, endtime, host,port,logtypelist): def logapiverify(schemauerl,logurl, token, starttime, endtime,logtype):
for logtype in logtypelist:
schemauerl="http://"+host+":"+port+"/v1/log/schema?logType="+logtype
filter2 = Filter1(schemauerl, token) filter2 = Filter1(schemauerl, token)
a = schema(schemauerl, token) a = schema(schemauerl, token)
fields = a["data"]["fields"] fields = a["data"]["fields"]
print(fields) print("333333333333",filter2)
str2 = ""
for i in filter2: for i in filter2:
print("条件:",i) print("条件:", i)
str2 = str2 + i + " " + "and" + " "
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}
@@ -215,14 +214,12 @@ def logapiverify(logurl, token, starttime, endtime, host,port,logtypelist):
"fields": fields, "fields": fields,
"filter": i "filter": i
} }
print(data)
print(json.dumps(data)) 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"]
print("code",code)
assert code == 200 assert code == 200
print(response1.json()["code"]) print(response1.json()["code"])
# return response1.json() return response1.json()
# print("111111111111111111111111111111111111111111111111111111111111111111111111111111111111111") # print("111111111111111111111111111111111111111111111111111111111111111111111111111111111111111")
# print(str2) # print(str2)
# str3 = str2[0:-4] # str3 = str2[0:-4]