From 3b84a4f7202018964bd13e9d22dededfdb2c547d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A9=AC=E7=90=A6=E9=92=A7?= Date: Thu, 24 Jun 2021 13:36:40 +0800 Subject: [PATCH] =?UTF-8?q?+=20=E5=A2=9E=E5=8A=A0=E5=90=8E=E7=AB=AF?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- be/test.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 be/test.py diff --git a/be/test.py b/be/test.py new file mode 100644 index 0000000..08c6257 --- /dev/null +++ b/be/test.py @@ -0,0 +1,32 @@ +import requests +import json +import threading + +headers = {'Content-Type': 'application/json'} +data = {"projectName":"demo5","fileName":"test11.txt","annoDetails":[{"name":"北","type":"person1","start":5,"end":6,"isSmall":False}]} +test_times = 20 +test_cnt = 0 +err_cnt = 0 + +def create_load(): + global test_times + global test_cnt + global err_cnt + result = requests.post('http://127.0.0.1:9060/v1/anno/create', data=json.dumps(data), headers=headers) + if result.json()['errMsg']: + err_cnt += 1 + print('Catch Err:', result.json()) + test_cnt += 1 + if test_cnt == test_times: + if err_cnt == 0: + print('Test success!') + else: + print('Test failed!') + +print('Start', test_times, 'test') +for i in range(test_times): + # 单线程测试 + # create_load() + # 多线程测试 + t = threading.Thread(target=create_load,args=()) + t.start()