From efcfbf596bfd9f5f623e2e05a92e140fd27f1838 Mon Sep 17 00:00:00 2001
From: hyb <kk_huangyangbo@163.com>
Date: Thu, 08 Jan 2026 08:57:48 +0000
Subject: [PATCH] 新增认证校验工具类,可实现将明文加密后,直接获取token,避免认证过期 已更新华东师范大学二期的压测脚本实现自动获取最新token功能,其他脚本后续更新
---
测试组/脚本/造数脚本2/华东师范大学二期/并发入驻笼位.py | 30 ++++++++++++++++++++++--------
1 files changed, 22 insertions(+), 8 deletions(-)
diff --git "a/\346\265\213\350\257\225\347\273\204/\350\204\232\346\234\254/\351\200\240\346\225\260\350\204\232\346\234\2542/\345\215\216\344\270\234\345\270\210\350\214\203\345\244\247\345\255\246\344\272\214\346\234\237/\345\271\266\345\217\221\345\205\245\351\251\273\347\254\274\344\275\215.py" "b/\346\265\213\350\257\225\347\273\204/\350\204\232\346\234\254/\351\200\240\346\225\260\350\204\232\346\234\2542/\345\215\216\344\270\234\345\270\210\350\214\203\345\244\247\345\255\246\344\272\214\346\234\237/\345\271\266\345\217\221\345\205\245\351\251\273\347\254\274\344\275\215.py"
index 923f493..a8c6add 100644
--- "a/\346\265\213\350\257\225\347\273\204/\350\204\232\346\234\254/\351\200\240\346\225\260\350\204\232\346\234\2542/\345\215\216\344\270\234\345\270\210\350\214\203\345\244\247\345\255\246\344\272\214\346\234\237/\345\271\266\345\217\221\345\205\245\351\251\273\347\254\274\344\275\215.py"
+++ "b/\346\265\213\350\257\225\347\273\204/\350\204\232\346\234\254/\351\200\240\346\225\260\350\204\232\346\234\2542/\345\215\216\344\270\234\345\270\210\350\214\203\345\244\247\345\255\246\344\272\214\346\234\237/\345\271\266\345\217\221\345\205\245\351\251\273\347\254\274\344\275\215.py"
@@ -10,18 +10,24 @@
"""
import sys
import os
-# 将上一级目录加入模块搜索路径
-sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import asyncio
import aiohttp
import time
import traceback
import datetime
from tqdm import tqdm
-from Util.random_util import RandomUtil
-from Util.dingtalk_helper import DingTalkHelper
import pymysql
+import pymysql.cursors
import random
+def get_parent_directory(file_path, levels=1):
+ """获取指定层级的父目录"""
+ path = os.path.abspath(file_path)
+ for _ in range(levels):
+ path = os.path.dirname(path)
+ return path
+parent_dir = get_parent_directory(__file__, 5) # 获取上五级目录
+sys.path.append(parent_dir)
+from 测试组.脚本.造数脚本2.Util import TokenValidator, DingTalkHelper, RandomUtil, RequestRecord, LoadTestReportGenerator
# --- 配置 ---
@@ -38,16 +44,24 @@
'charset': 'utf8mb4',
'cursorclass': pymysql.cursors.DictCursor
}
+# 账号密码配置
+username = "gly"
+password = "Baoyi@1341"
+# 创建获取token实例
+token_validator = TokenValidator()
+
+domain = "http://192.168.6.190:5561"
+token = token_validator.get_token(domain, username, password)
apiname = "入驻笼位"
-url = "http://192.168.6.190:5561/api/base/cage/cage/enterCage"
+url = f"{domain}/api/base/cage/cage/enterCage"
headers = {
- "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE3NjgwMzY0MzksInVzZXJuYW1lIjoiZ2x5In0.-LYYNbSJ-zb5RKaiBiPjntgUfnGRfvajA2B1N2v7a-o",
+ "token": token,
"Content-Type": "application/json"
}
NUM_WORKERS = 100
-TOTAL_REQUESTS = 10000
+TOTAL_REQUESTS = 1
MAX_RETRIES = 3
REQUEST_TIMEOUT = 60
OUTPUT_DIR = './load_test_report'
@@ -358,7 +372,7 @@
try:
import importlib.util
script_dir = os.path.dirname(os.path.abspath(__file__))
- report_path = os.path.join(script_dir, 'H:\\项目\\造数脚本\\Util\\stress_test_report_generator.py')
+ report_path = os.path.join(script_dir, 'H:\\项目\\archive\\测试组\\脚本\\造数脚本2\\Util\\stress_test_report_generator.py')
if os.path.exists(report_path):
spec = importlib.util.spec_from_file_location('report_module', report_path)
report_module = importlib.util.module_from_spec(spec)
--
Gitblit v1.9.1