Commit 2768ad68 authored by zhanhuasheng's avatar zhanhuasheng

增加告警

parent c1dfa4af
import time import time
import jsonpath import jsonpath
import pymysql.err import pymysql.err
import warnings
import requests import requests
import re import re
import os import os
...@@ -139,6 +140,10 @@ class ReqHandler: ...@@ -139,6 +140,10 @@ class ReqHandler:
try: try:
assert res.status_code == 200 #先断言状态码是正确的 assert res.status_code == 200 #先断言状态码是正确的
time = res.elapsed.total_seconds()
if time >= 0.1:
warnings.warn(f'接口响应时间过长,耗时{time}秒')
logger.error(f'接口响应时间过长,耗时{time}秒')
if isinstance(expected,list): if isinstance(expected,list):
''' '''
穿进来的expected一定是 {"eq":{$.code : value}} 的形式,要断言的值一定是通过jsonpath去检索的 穿进来的expected一定是 {"eq":{$.code : value}} 的形式,要断言的值一定是通过jsonpath去检索的
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment