Prechádzať zdrojové kódy

添加压力测试脚本

jiayongqiang 3 dní pred
rodič
commit
84818e8074

+ 1 - 1
agent/tests/test_sync_category.py

@@ -1,6 +1,6 @@
 import requests
 
-res = requests.post("http://localhost:9876/api/aitag/admin/v1/synchronize_category", json={
+res = requests.post("http://10.192.72.13:9876/api/aitag/admin/v1/synchronize_category", json={
     "category_id": "f47ac10b-58cc-4372-a567-0e02b2c3d479"
 })
 print(res.text)

+ 2 - 2
agent/tests/test_tagging.py

@@ -3,13 +3,13 @@ import logging
 logging.basicConfig(level=logging.INFO, force=True,format='%(asctime)s - %(levelname)s - %(message)s')
 logging.info("app starting!")
 
-res = requests.post("http://localhost:9876/api/aitag/v1/tagging", json={
+res = requests.post("http://10.192.72.13:9876/api/aitag/v1/tagging", json={
     # "app_id": "test_app",
     # "timestamp": 1234567890,
     # "sign": "test_sign",
     "esb_seq_no":"abc",
     "business_attr": "test_attr",
-    "phrase": "职业:水产养殖人员 投向:内陆养殖 用途:养殖鲍鱼"
+    "phrase": "职业:水产养殖人员1 投向:内陆养殖 用途:养殖鲍鱼"
 })
 
 logging.info(res.text)

+ 37 - 0
agent/tests/test_tagging_12w.py

@@ -0,0 +1,37 @@
+import requests
+import uuid
+from openpyxl import load_workbook
+
+wb = load_workbook('./data/样本数据打标结果-12w-终版.xlsx')
+ws = wb.active
+for row in ws.iter_rows(min_row=2, values_only=True):
+    zhiye = row[0] if row[0] is not None else ""
+    touxiang = row[1] if row[1] is not None else ""
+    yongtu = row[2] if row[2] is not None else ""
+    phrase = f"职业:{zhiye} 投向:{touxiang} 用途:{yongtu}"
+    res = requests.post("http://10.192.72.13:9876/api/aitag/v1/tagging", json={
+        "esb_seq_no": uuid.uuid4().hex,
+        "business_attr": uuid.uuid4().hex,
+        "phrase": phrase
+    })
+    print(f"输入: {phrase},输出: {res.json()}")
+
+
+#批量读取test_data.txt中的测试用例,并调用接口进行测试
+# with open("样本数据打标结果-12w-终版.xlsx", "r", encoding="utf-8") as f:
+#     for line in f:
+#         phrase = line.strip().split(" ")
+#         if len(phrase) < 2:
+#             continue
+#         if len(phrase) ==2:
+#             phrase = "职业:"+phrase[0]+" "+"投向:"+phrase[1]
+#         if len(phrase) == 3:
+#             phrase = "职业:"+phrase[0]+" "+"投向:"+phrase[1]+" "+"用途:"+phrase[2]
+
+#         res = requests.post("http://10.192.72.13:9876/api/aitag/v1/tagging", json={
+#             "esb_seq_no": uuid.uuid4().hex,
+#             "business_attr": uuid.uuid4().hex,
+#             "phrase": phrase
+#         })
+
+