1上传新的接口测试方法 2.上传接口测试用例

This commit is contained in:
byb11
2021-04-28 18:13:54 +08:00
parent ff24ca2b53
commit 253793312b
4 changed files with 208 additions and 22 deletions

View File

@@ -1,6 +1,7 @@
*** Settings ***
Resource ../../../03-Variable/BifangApiVariable.txt
Library ../../../04-CustomLibrary/Custometest/Schema.py
Library ../../../04-CustomLibrary/Custometest/LogResponseVAL.py
Library DateTime
Library json
Library OperatingSystem
@@ -143,3 +144,138 @@ LogApiVerifyCase-007
${responsebody} timedistribution ${logurl} ${token} ${StartTime} ${EndTime} ${logType} ${granularity} ${filter}
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}

View File

@@ -33,11 +33,11 @@ logtest
${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
${StartTime} add time to date ${EndTime} -03:00:00
${StartTime1} Get Substring ${StartTime} \ -4
${filter} Set Variable common_log_id=238734003578214400
${filter} Set Variable common_log_id=239883677236457472
${responsebody} loglistverify ${Logurl} ${Schemaurl} ${token} ${StartTime1} ${EndTime1} ${logType} ${filter}
${targetdict} create list common_log_id = 238734003578214400
${targetdict} create list common_log_i
log ${responsebody}
${strlist} FieldValidation ${responsebody} ${targetdict}
log ${strlist}

View File

@@ -22,6 +22,7 @@ def FieldValidation(responsedict, targetlist):
responsekeys = getKeys(response)
# 判断目的条件的Key在数据中是否存在
if target[0] in responsekeys:
if len(target) != 1:
#targetkey 判断的字段
targetkey = target[0]
# 判断条件

View File

@@ -270,7 +270,7 @@ def distributed_query(logurl, token):
url = logurl # url示例http://192.168.44.72:8080/v1/interface/gateway/sql/galaxy/security_event_hits_log/timedistribution?logType=security_event_hits_log&startTime=2021-03-26 12:27:03&endTime=2021-03-29 12:27:03&granularity=PT5M
headers = {"Content-Type": "application/json", "Authorization": token}
response = requests.get(url=url, headers=headers)
code = response1.json()["code"]
code = response.json()["code"]
print(response.json())
assert code == 200
print(response.json()["code"])
@@ -297,5 +297,54 @@ def timedistribution(logurl, token, starttime, endtime, logtype, granularity, fi
print(response1.json()["code"])
assert code == 200
return response1.json()
# 日志总数查询
def countlog_query(logurl, token, starttime, endtime, logtype):
url = logurl
headers = {"Content-Type": "application/json",
"Authorization": token}
data = {
"pageSize": 20,
"logType": logtype,
"start_common_recv_time": starttime,
"end_common_recv_time": endtime,
"filter": ""
}
print(data)
print(json.dumps(data))
response1 = requests.post(url=url, data=json.dumps(data), headers=headers)
code = response1.json()["code"]
print(response1.json())
print(response1.json()["code"])
assert code == 200
return response1.json()
# 日志导出接口
def exportlog(logurl, schemauerl, token, starttime, endtime, logtype, filtervalue):
a = schema(schemauerl, token)
fields = a["data"]["fields"]
print(fields)
url = logurl
headers = {"Content-Type": "application/json",
"Authorization": token}
data = {
"start_common_recv_time": starttime,
"end_common_recv_time": endtime,
"logType": logtype,
"fields": fields,
"filter": filtervalue
}
print(data)
print(json.dumps(data))
response1 = requests.post(url=url, data=json.dumps(data), headers=headers)
a=type(response1)
if a != "class 'requests.models.Response'":
assert 1 == 1
else:
assert 1 == 2
# if __name__ == '__main__':
# logapiverify("http://192.168.32.59:8080/v1/log/list","http://192.168.32.59:8080/v1/log/schema?logType=security_event_log","d475b20d-e2b8-4f24-87ee-d54af46e6aff&807&",'2021-03-20 16:36:41','2021-03-21 17:36:41',"security_event_log")