jMeter系统属性来自Pom文件

huangapple go评论52阅读模式
英文:

jMeter System Properties from Pom File

问题

我必须使用以下POM文件来设置4个JMeter系统属性:

<plugin>
    <groupId>com.lazerycode.jmeter</groupId>
    <artifactId>jmeter-maven-plugin</artifactId>
    <version>${jmeter-maven-plugin.version}</version>
    <configuration>
        <skipTests>${skipNFTs}</skipTests>
        <generateReports>true</generateReports>
        <reportDirectory>${basedir}/target/reports/${performanceTest}</reportDirectory>
        <logsDirectory>${basedir}/target/reports/${performanceTest}</logsDirectory>
        <jmeterExtensions>
            <artifact>org.apache.activemq:activemq-all:jar:5.16.0</artifact>
        </jmeterExtensions>
        <junitLibraries/>
        <propertiesSystem>
            <javax.net.ssl.trustStore>${project.build.directory}/target/jmeter/keystore/eskort_keystore.keystore</javax.net.ssl.trustStore>
            <javax.net.ssl.trustStorePassword>P@ssw0rd</javax.net.ssl.trustStorePassword>
            <javax.net.ssl.keyStore>${basedir}/target/jmeter/keystore/eskort_keystore.keystore</javax.net.ssl.keyStore>
            <javax.net.ssl.keyStorePassword>P@ssw0rd</javax.net.ssl.keyStorePassword>
        </propertiesSystem>
    </configuration>
</plugin>

我获取的输出是:

#Thu Jun 08 17:42:06 EEST 2023 javax.net.ssl.keyStore=C\:\\MyTools\\GitRepo\\Compliance\\performance/target/jmeter/keystore/eskort_keystore.keystore
javax.net.ssl.keyStorePassword=P@ssw0rd
avax.net.ssl.trustStore=C\:\\MyTools\\GitRepo\\Compliance\\performance\\targt/target/jmeter/keystore/eskort_keystore.keystore
javax.net.ssl.trustStorePassword=P@ssw0rd
sun.net.http.allowRestrictedHeaders=true

问题是路径开头的 C\ : 不可用。如何修复它?

英文:

I have to pom file as below to set a 4 JMeter system properties

&lt;plugin&gt;
	&lt;groupId&gt;com.lazerycode.jmeter&lt;/groupId&gt;
	&lt;artifactId&gt;jmeter-maven-plugin&lt;/artifactId&gt;
	&lt;version&gt;${jmeter-maven-plugin.version}&lt;/version&gt;
	&lt;configuration&gt;
		&lt;skipTests&gt;${skipNFTs}&lt;/skipTests&gt;
		&lt;generateReports&gt;true&lt;/generateReports&gt;
		&lt;reportDirectory&gt;${basedir}/target/reports/${performanceTest}&lt;/reportDirectory&gt;
		&lt;logsDirectory&gt;${basedir}/target/reports/${performanceTest}&lt;/logsDirectory&gt;
		&lt;jmeterExtensions&gt;
			&lt;artifact&gt;org.apache.activemq:activemq-all:jar:5.16.0&lt;/artifact&gt;
		&lt;/jmeterExtensions&gt;
		&lt;junitLibraries/&gt;
		&lt;propertiesSystem&gt;
			&lt;javax.net.ssl.trustStore&gt;${project.build.directory}/target/jmeter/keystore/eskort_keystore.keystore&lt;/javax.net.ssl.trustStore&gt;
			&lt;javax.net.ssl.trustStorePassword&gt;P@ssw0rd&lt;/javax.net.ssl.trustStorePassword&gt;
			&lt;javax.net.ssl.keyStore&gt;${basedir}/target/jmeter/keystore/eskort_keystore.keystore&lt;/javax.net.ssl.keyStore&gt;
			&lt;javax.net.ssl.keyStorePassword&gt;P@ssw0rd&lt;/javax.net.ssl.keyStorePassword&gt;
		&lt;/propertiesSystem&gt;
&lt;/plugin&gt;

the output that i take is :

 #Thu Jun 08 17:42:06 EEST 2023 javax.net.ssl.keyStore=C\:\\MyTools\\GitRepo\\Compliance\\performance/target/jmeter/keystore/eskort_keystore.keystore
 javax.net.ssl.keyStorePassword=P@ssw0rd
 avax.net.ssl.trustStore=C\:\\MyTools\\GitRepo\\Compliance\\performance\\targt/target/jmeter/keystore/eskort_keystore.keystore
 javax.net.ssl.trustStorePassword=P@ssw0rd
 sun.net.http.allowRestrictedHeaders=true

the problem is is not usable due to the C\ : at the beginning of the path .

how i can fix it ?

答案1

得分: 0

我看到你在混合使用变量:

${project.build.directory} 表示指向你的 "target" 目录的路径。

${basedir} 代表包含 pom.xml 的目录。

所以在系统属性 <javax.net.ssl.trustStore> 中,你多加了一个不必要的 "target"。
你应该检查/审查一下你的目标文件夹中有什么内容,然后相应地设置属性。

注意:
通常,密钥库文件通常具有 .jks 扩展名。

英文:

I see that you are mixing variables:

${project.build.directory} is results in the path to your "target" directory.

${basedir} represents the directory containing pom.xml

so in the system property <javax.net.ssl.trustStore> you are adding an extra "target" that is not needed.
you should check/review what do you have in your target folder and after set the properties accordingly.

Note:
normally a the keystore file usually has a .jks extension.

答案2

得分: 0

如果您的eskort_keystore.keystore位于与pom.xml相同的文件夹中 - 您应该使用${project.basedir}/eskort_keystore.keystore

我不知道您从哪里获得这个"output",但Maven和Java应该能够处理Windows文件路径而不会出现任何问题。

正如您可以在此处看到的,JSR223 Sampler中的Groovy脚本检查了给定路径下密钥库文件的路径和存在性,并成功执行。

更多信息:Maven属性指南

英文:

If your eskort_keystore.keystore lives at the same folder where pom.xml - you should use ${project.basedir}/eskort_keystore.keystore instead.

I don't know where did you get this "output" but Maven and Java should handle Windows file paths without any issues.

jMeter系统属性来自Pom文件

As you can see the Groovy script in the JSR223 Sampler checks the path and the presence of the keystore file under the given path and succeeds.

More information: Maven Properties Guide

huangapple
  • 本文由 发表于 2023年6月8日 22:48:39
  • 转载请务必保留本文链接:https://go.coder-hub.com/76433088.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定