This commit is contained in:
jack ning
2025-08-03 19:38:57 +08:00
parent c22b8cb32f
commit bf8d485a62
3 changed files with 12 additions and 106 deletions

View File

@@ -1,41 +0,0 @@
#!/usr/bin/env python3
import xml.etree.ElementTree as ET
import sys
def validate_jmx(file_path):
try:
tree = ET.parse(file_path)
root = tree.getroot()
# 检查TestPlan
test_plan = root.find('.//TestPlan')
if test_plan is None:
print("❌ 找不到TestPlan元素")
return False
# 检查用户定义变量
user_vars = test_plan.find('.//elementProp[@name="TestPlan.user_defined_variables"]')
if user_vars is None:
print("❌ 找不到用户定义变量配置")
return False
# 检查是否有空的name属性
empty_names = root.findall('.//elementProp[@name=""]')
if empty_names:
print(f"❌ 找到 {len(empty_names)} 个空的name属性")
return False
print("✅ 文件验证通过")
return True
except Exception as e:
print(f"❌ 验证失败: {e}")
return False
if __name__ == "__main__":
if len(sys.argv) != 2:
print("用法: python validate_fix.py <jmx_file>")
sys.exit(1)
success = validate_jmx(sys.argv[1])
sys.exit(0 if success else 1)

View File

@@ -3,9 +3,7 @@
<hashTree>
<TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="微语登录性能测试">
<stringProp name="TestPlan.comments">微语登录性能测试计划</stringProp>
<boolProp name="TestPlan.functional_mode">false</boolProp>
<boolProp name="TestPlan.tearDown_on_shutdown">true</boolProp>
<boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
<elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments">
<collectionProp name="Arguments.arguments">
<elementProp name="host" elementType="Argument">
@@ -30,7 +28,6 @@
</elementProp>
</collectionProp>
</elementProp>
<stringProp name="TestPlan.user_define_classpath"></stringProp>
</TestPlan>
<hashTree>
<ConfigTestElement guiclass="HttpDefaultsGui" testclass="ConfigTestElement" testname="HTTP请求默认值">
@@ -40,13 +37,13 @@
<stringProp name="HTTPSampler.port">${port}</stringProp>
<stringProp name="HTTPSampler.protocol">${protocol}</stringProp>
<stringProp name="HTTPSampler.contentEncoding">UTF-8</stringProp>
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments">
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="用户定义的变量">
<collectionProp name="Arguments.arguments"/>
</elementProp>
<stringProp name="HTTPSampler.implementation"></stringProp>
</ConfigTestElement>
<hashTree/>
<HeaderManager guiclass="HeaderPanel" testclass="HeaderManager" testname="HTTP头管理器">
<HeaderManager guiclass="HeaderPanel" testclass="HeaderManager" testname="HTTP头管理器" enabled="true">
<collectionProp name="HeaderManager.headers">
<elementProp name="Content-Type" elementType="Header">
<stringProp name="Header.name">Content-Type</stringProp>
@@ -63,36 +60,7 @@
</collectionProp>
</HeaderManager>
<hashTree/>
<ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="获取验证码" enabled="true">
<intProp name="ThreadGroup.num_threads">100</intProp>
<intProp name="ThreadGroup.ramp_time">10</intProp>
<boolProp name="ThreadGroup.same_user_on_next_iteration">true</boolProp>
<stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
<elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="循环控制器">
<stringProp name="LoopController.loops">1</stringProp>
<boolProp name="LoopController.continue_forever">false</boolProp>
</elementProp>
</ThreadGroup>
<hashTree>
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="获取验证码" enabled="true">
<stringProp name="HTTPSampler.path">/kaptcha/api/v1/get</stringProp>
<boolProp name="HTTPSampler.follow_redirects">true</boolProp>
<stringProp name="HTTPSampler.method">GET</stringProp>
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
<boolProp name="HTTPSampler.postBodyRaw">false</boolProp>
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments">
<collectionProp name="Arguments.arguments"/>
</elementProp>
</HTTPSamplerProxy>
<hashTree>
<JSONPostProcessor guiclass="JSONPostProcessorGui" testclass="JSONPostProcessor" testname="提取验证码信息" enabled="true">
<stringProp name="JSONPostProcessor.referenceNames">captchaUid,captchaImage</stringProp>
<stringProp name="JSONPostProcessor.jsonPathExprs">$.data.captchaUid,$.data.captchaImage</stringProp>
<stringProp name="JSONPostProcessor.match_numbers"></stringProp>
</JSONPostProcessor>
<hashTree/>
</hashTree>
</hashTree>
<ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="用户名密码登录" enabled="true">
<intProp name="ThreadGroup.num_threads">500</intProp>
<intProp name="ThreadGroup.ramp_time">30</intProp>
@@ -125,15 +93,13 @@
<stringProp name="HTTPSampler.method">POST</stringProp>
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
<boolProp name="HTTPSampler.postBodyRaw">false</boolProp>
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments">
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="用户定义的变量">
<collectionProp name="Arguments.arguments">
<elementProp name="body" elementType="HTTPArgument">
<boolProp name="HTTPArgument.always_encode">false</boolProp>
<stringProp name="Argument.value">{
&quot;username&quot;: &quot;${username}&quot;,
&quot;password&quot;: &quot;${password}&quot;,
&quot;captchaUid&quot;: &quot;${captchaUid}&quot;,
&quot;captchaCode&quot;: &quot;1234&quot;,
&quot;platform&quot;: &quot;BYTEDESK&quot;,
&quot;channel&quot;: &quot;WEB&quot;,
&quot;device&quot;: &quot;JMeter Test&quot;
@@ -174,14 +140,12 @@
<stringProp name="HTTPSampler.method">POST</stringProp>
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
<boolProp name="HTTPSampler.postBodyRaw">false</boolProp>
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments">
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="用户定义的变量">
<collectionProp name="Arguments.arguments">
<elementProp name="body" elementType="HTTPArgument">
<boolProp name="HTTPArgument.always_encode">false</boolProp>
<stringProp name="Argument.value">{
&quot;mobile&quot;: &quot;${mobile}&quot;,
&quot;captchaUid&quot;: &quot;${captchaUid}&quot;,
&quot;captchaCode&quot;: &quot;1234&quot;,
&quot;platform&quot;: &quot;BYTEDESK&quot;,
&quot;channel&quot;: &quot;WEB&quot;,
&quot;type&quot;: &quot;mobile&quot;
@@ -200,15 +164,13 @@
<stringProp name="HTTPSampler.method">POST</stringProp>
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
<boolProp name="HTTPSampler.postBodyRaw">false</boolProp>
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments">
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="用户定义的变量">
<collectionProp name="Arguments.arguments">
<elementProp name="body" elementType="HTTPArgument">
<boolProp name="HTTPArgument.always_encode">false</boolProp>
<stringProp name="Argument.value">{
&quot;mobile&quot;: &quot;${mobile}&quot;,
&quot;code&quot;: &quot;123456&quot;,
&quot;captchaUid&quot;: &quot;${captchaUid}&quot;,
&quot;captchaCode&quot;: &quot;1234&quot;,
&quot;platform&quot;: &quot;BYTEDESK&quot;,
&quot;channel&quot;: &quot;WEB&quot;,
&quot;device&quot;: &quot;JMeter Test&quot;
@@ -242,14 +204,12 @@
<stringProp name="HTTPSampler.method">POST</stringProp>
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
<boolProp name="HTTPSampler.postBodyRaw">false</boolProp>
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments">
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="用户定义的变量">
<collectionProp name="Arguments.arguments">
<elementProp name="body" elementType="HTTPArgument">
<boolProp name="HTTPArgument.always_encode">false</boolProp>
<stringProp name="Argument.value">{
&quot;email&quot;: &quot;${email}&quot;,
&quot;captchaUid&quot;: &quot;${captchaUid}&quot;,
&quot;captchaCode&quot;: &quot;1234&quot;,
&quot;platform&quot;: &quot;BYTEDESK&quot;,
&quot;channel&quot;: &quot;WEB&quot;,
&quot;type&quot;: &quot;email&quot;
@@ -268,7 +228,7 @@
<stringProp name="HTTPSampler.method">POST</stringProp>
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
<boolProp name="HTTPSampler.postBodyRaw">false</boolProp>
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments">
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="用户定义的变量">
<collectionProp name="Arguments.arguments">
<elementProp name="body" elementType="HTTPArgument">
<boolProp name="HTTPArgument.always_encode">false</boolProp>
@@ -308,7 +268,7 @@
<stringProp name="HTTPSampler.method">POST</stringProp>
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
<boolProp name="HTTPSampler.postBodyRaw">false</boolProp>
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments">
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="用户定义的变量">
<collectionProp name="Arguments.arguments">
<elementProp name="body" elementType="HTTPArgument">
<boolProp name="HTTPArgument.always_encode">false</boolProp>
@@ -326,7 +286,7 @@
</HTTPSamplerProxy>
<hashTree/>
</hashTree>
<ResultCollector guiclass="ViewResultsFullVisualizer" testclass="ResultCollector" testname="察看结果树" enabled="true">
<ResultCollector guiclass="ViewResultsFullVisualizer" testclass="ResultCollector" testname="察看结果树">
<boolProp name="ResultCollector.error_logging">false</boolProp>
<objProp>
<name>saveConfig</name>
@@ -363,7 +323,7 @@
<stringProp name="filename"></stringProp>
</ResultCollector>
<hashTree/>
<ResultCollector guiclass="StatVisualizer" testclass="ResultCollector" testname="聚合报告" enabled="true">
<ResultCollector guiclass="StatVisualizer" testclass="ResultCollector" testname="聚合报告">
<boolProp name="ResultCollector.error_logging">false</boolProp>
<objProp>
<name>saveConfig</name>

View File

@@ -2,20 +2,7 @@
* @Author: jackning 270580156@qq.com
* @Date: 2024-01-29 16:21:24
* @LastEditors: jackning 270580156@qq.com
* @LastEditTime: 2025-08-03 18:41:49
* @Description: bytedesk.com https://github.com/Bytedesk/bytedesk
* Please be aware of the BSL license restrictions before installing Bytedesk IM
* selling, reselling, or hosting Bytedesk IM as a service is a breach of the terms and automatically terminates your rights under the license.
* Business Source License 1.1: https://github.com/Bytedesk/bytedesk/blob/main/LICENSE
* contact: 270580156@qq.com
*
* Copyright (c) 2025 by bytedesk.com, All Rights Reserved.
*/
/*
* @Author: jackning 270580156@qq.com
* @Date: 2024-01-29 16:21:24
* @LastEditors: jackning 270580156@qq.com
* @LastEditTime: 2025-07-17 12:16:23
* @LastEditTime: 2025-08-03 19:23:26
* @Description: bytedesk.com https://github.com/Bytedesk/bytedesk
* Please be aware of the BSL license restrictions before installing Bytedesk IM
* selling, reselling, or hosting Bytedesk IM as a service is a breach of the terms and automatically terminates your rights under the license.