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

代理配置

设置<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>



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值