您的位置:首页 > 其它

【jmeter-maven-plugin】六、代理配置+远程服务器配置

2017-11-10 13:59 405 查看

代理配置

设置<proxyConfig>

如果配置JMeter使用的代理设置,代理设置将用于运行每个测试。
设置代理主机是强制性的,如果不设置代理主机,则代理配置的其余部分将被忽略。如果不设置代理端口,那么它始终默认为端口80。
<username><password>是不必设置的可选设置。
您还可以设置一个可选的<hostExclusions>元素来通知JMeter不应该被代理的主机,这是基于正则表达式的设置。
<project>
[...]
<build>
<plugins>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>2.2.0</version>
<executions>
<execution>
<id>jmeter-tests</id>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
</executions>
<configuration>
<proxyConfig>
<host>10.10.10.53</host>
<port>80</port>
<username>jimbob</username>
<password>correct horse battery staple</password>
<hostExclusions>localhost|*.lazerycode.com</hostExclusions>
</proxyConfig>
</configuration>
</plugin>
</plugins>
</build>
[...]
</project>

有关SOCKS代理配置,请参阅配置jmeter进程运行的jvm

远程服务器配置

通过<remoteConfig>远程启动和停止服务器

设置<startServersBeforeTests>选项将导致--runremote命令发送到JMeter,这将在您的第一个测试开始时启动您在jmeter.properties中定义的任何远程服务器。
设置<stopServersAfterTests>选项将导致--remoteexit命令发送到JMeter,它将在运行最后一次测试后关闭jmeter.properties中定义的所有远程服务器。
<startServersBeforeTests><stopServersAfterTests>可以独立使用,因此如果需要,可以使用另一个进程来启动和停止服务器。
<project>
[...]
<build>
<plugins>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>2.2.0</version>
<executions>
<execution>
<id>jmeter-tests</id>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
</executions>
<configuration>
<remoteConfig>
<startServersBeforeTests>true</startServersBeforeTests>
<stopServersAfterTests>true</stopServersAfterTests>
</remoteConfig>
</configuration>
</plugin>
</plugins>
</build>
[...]
</project>

您可以通过将<startAndStopServersForEachTest>变量设置为true 来配置插件来执行每个单独测试的远程启动和停止。如果设置此连同<startServersBeforeTests><stopServersAfterTests><startServersBeforeTests><stopServersAfterTests>设置将被忽略。

<project>
[...]
<build>
<plugins>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>2.2.0</version>
<executions>
<execution>
<id>jmeter-tests</id>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
</executions>
<configuration>
<remoteConfig>
<startAndStopServersForEachTest>false</startAndStopServersForEachTest>
</remoteConfig>
</configuration>
</plugin>
</plugins>
</build>
[...]
</project>

您可以使用<serverList>选项来指定启动所有远程服务器,而不是使用逗号分隔的JMeter启动服务器列表(这些服务器必须在jmeter.properties中定义,请参阅远程测试 JMeter手册中的页面)。

<project>
[...]
<build>
<plugins>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>2.2.0</version>
<executions>
<execution>
<id>jmeter-tests</id>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
</executions>
<configuration>
<remoteConfig>
<startServersBeforeTests>true</startServersBeforeTests>
<serverList>server1,server2</serverList>
<stopServersAfterTests>true</stopServersAfterTests>
</remoteConfig>
</configuration>
</plugin>
</plugins>
</build>
[...]
</project>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: