JMeter- 属性 值在来自 CLI 的 运行 时不会被替换
JMeter- property values are not substituted when running from CLI
我目前在 Mac 上使用 JMeter 5.1.1 并开发了一个非常简单的 JMeter 项目来测试通过命令行进行的 属性 值替换。我的 JMeter 项目非常简单,有一个 Dummy Sampler 试图打印出以下内容
${__P(resources.folder)}, ${__P(propertiesfile)} and ${__property(propertiesfile)}
Link to JMeter project image
我正在尝试 运行 通过 CLI 使用命令
这个项目
jmeter -n -t TestProj.jmx -l jmeter/TestProjResults.jtl -j jmeter/TestProj.log -Dresources.folder=/Users/h244955/Coding/bga/spogdashboard/tests/perf -Dpropertiesfile=baforgeperfproperties
这些值没有被替换,我在日志中看到以下内容:
2019-10-22 20:48:09,531 DEBUG o.a.j.e.u.ValueReplacer: About to replace in property of type: class org.apache.jmeter.testelement.property.StringProperty: ${__P(resources.folder)}
${__P(propertiesfile)}
${__property(propertiesfile)}
2019-10-22 20:48:09,533 DEBUG o.a.j.t.p.AbstractProperty: Not running version, return raw function string
2019-10-22 20:48:09,533 DEBUG o.a.j.e.u.ValueReplacer: Replacement result: ${__P(resources.folder)}
${__P(propertiesfile)}
${__property(propertiesfile)}
2019-10-22 20:48:09,534 DEBUG o.a.j.e.u.ValueReplacer: About to replace in property of type: class org.apache.jmeter.testelement.property.StringProperty: Dummy Sampler used to simulate requests and responses
without actual network activity. This helps debugging tests.
2019-10-22 20:48:09,534 DEBUG o.a.j.e.u.ValueReplacer: Replacement result: Dummy Sampler used to simulate requests and responses
without actual network activity. This helps debugging tests.
2019-10-22 20:48:09,534 DEBUG o.a.j.e.u.ValueReplacer: About to replace in property of type: class org.apache.jmeter.testelement.property.StringProperty: ${__Random(50,500)}
2019-10-22 20:48:09,534 DEBUG o.a.j.t.p.AbstractProperty: Not running version, return raw function string
2019-10-22 20:48:09,534 DEBUG o.a.j.e.u.ValueReplacer: Replacement result: ${__Random(50,500)}
但是,当我 运行 从 GUI 借助使用 JSR223 采样器声明相同属性的这个项目时,值会按预期在虚拟采样器中被替换。我试着四处寻找上面突出显示的日志的答案,但徒劳无功。
您需要 override JMeter property 使用 -J
:
jmeter -n -t TestProj.jmx -Jresources.folder=/Users/h244955/Coding/bga/spogdashboard/tests/perf -Jpropertiesfile=baforgeperfproperties -l jmeter/TestProjResults.jtl -j jmeter/TestProj.log
-D[prop_name]=[value]
defines a java system property value.
-J[prop_name]=[value]
defines a local JMeter property.
要添加额外的 JMeter 属性 文件,请使用 -q
-q, --addprop <argument>
additional JMeter property file(s)
我无法重现问题:
所以我的预期是您的 JMeter 安装以某种方式损坏,即确保 ApacheJMeter_functions.jar
文件存在于您的 JMeter 安装的 "lib/ext" 文件夹中
- 确保从 official downloads page and check the downloaded archive integrity, check How to Get Started With JMeter: Part 1 - Installation & Test Plans 文章中获取 JMeter 以获得详细信息。
确保从其 "bin" 文件夹启动 JMeter,即
cd /path/where/jmeter/lives/bin
./jmeter -Dpropertiesfile=baforgeperfproperties -n -t test.jmx ....
这个 ./jmeter
位对于确保从当前文件夹而不是 MacOS 中的另一个文件夹启动 JMeter 很重要 PATH
我目前在 Mac 上使用 JMeter 5.1.1 并开发了一个非常简单的 JMeter 项目来测试通过命令行进行的 属性 值替换。我的 JMeter 项目非常简单,有一个 Dummy Sampler 试图打印出以下内容
${__P(resources.folder)}, ${__P(propertiesfile)} and ${__property(propertiesfile)}
Link to JMeter project image
我正在尝试 运行 通过 CLI 使用命令
这个项目jmeter -n -t TestProj.jmx -l jmeter/TestProjResults.jtl -j jmeter/TestProj.log -Dresources.folder=/Users/h244955/Coding/bga/spogdashboard/tests/perf -Dpropertiesfile=baforgeperfproperties
这些值没有被替换,我在日志中看到以下内容:
2019-10-22 20:48:09,531 DEBUG o.a.j.e.u.ValueReplacer: About to replace in property of type: class org.apache.jmeter.testelement.property.StringProperty: ${__P(resources.folder)} ${__P(propertiesfile)} ${__property(propertiesfile)} 2019-10-22 20:48:09,533 DEBUG o.a.j.t.p.AbstractProperty: Not running version, return raw function string 2019-10-22 20:48:09,533 DEBUG o.a.j.e.u.ValueReplacer: Replacement result: ${__P(resources.folder)} ${__P(propertiesfile)} ${__property(propertiesfile)} 2019-10-22 20:48:09,534 DEBUG o.a.j.e.u.ValueReplacer: About to replace in property of type: class org.apache.jmeter.testelement.property.StringProperty: Dummy Sampler used to simulate requests and responses without actual network activity. This helps debugging tests. 2019-10-22 20:48:09,534 DEBUG o.a.j.e.u.ValueReplacer: Replacement result: Dummy Sampler used to simulate requests and responses without actual network activity. This helps debugging tests. 2019-10-22 20:48:09,534 DEBUG o.a.j.e.u.ValueReplacer: About to replace in property of type: class org.apache.jmeter.testelement.property.StringProperty: ${__Random(50,500)} 2019-10-22 20:48:09,534 DEBUG o.a.j.t.p.AbstractProperty: Not running version, return raw function string 2019-10-22 20:48:09,534 DEBUG o.a.j.e.u.ValueReplacer: Replacement result: ${__Random(50,500)}
但是,当我 运行 从 GUI 借助使用 JSR223 采样器声明相同属性的这个项目时,值会按预期在虚拟采样器中被替换。我试着四处寻找上面突出显示的日志的答案,但徒劳无功。
您需要 override JMeter property 使用 -J
:
jmeter -n -t TestProj.jmx -Jresources.folder=/Users/h244955/Coding/bga/spogdashboard/tests/perf -Jpropertiesfile=baforgeperfproperties -l jmeter/TestProjResults.jtl -j jmeter/TestProj.log
-D[prop_name]=[value] defines a java system property value. -J[prop_name]=[value] defines a local JMeter property.
要添加额外的 JMeter 属性 文件,请使用 -q
-q, --addprop <argument> additional JMeter property file(s)
我无法重现问题:
所以我的预期是您的 JMeter 安装以某种方式损坏,即确保 ApacheJMeter_functions.jar
文件存在于您的 JMeter 安装的 "lib/ext" 文件夹中
- 确保从 official downloads page and check the downloaded archive integrity, check How to Get Started With JMeter: Part 1 - Installation & Test Plans 文章中获取 JMeter 以获得详细信息。
确保从其 "bin" 文件夹启动 JMeter,即
cd /path/where/jmeter/lives/bin ./jmeter -Dpropertiesfile=baforgeperfproperties -n -t test.jmx ....
这个
./jmeter
位对于确保从当前文件夹而不是 MacOS 中的另一个文件夹启动 JMeter 很重要 PATH