Jmeter-maven-plugin高级配置之分布式设置

通过<remoteConfig>标签来设置远程机器

使用jmeter Gui时可以很方便的配置远程节点,来分布式地压测,具体方法,不在描述。现在来说使用jmeter-maven-plugin这个插件如何配置分布式。

通过这个<startServersBeforeTests>标签,可以将--runremote命令发送到jmeter.properties中配置的节点机器上,来开启远程服务。

通过这个<stopServersAfterTests>标签,可以将--remoteexit命令发送到jmeter.properties中配置的节点机器上,来关闭远程服务。

<startServersBeforeTests> 和 <stopServersAfterTests>标签可以分开使用,因此我们可以通过其他进程来开启和关闭jmeter的远程服务。

            <plugin>
                <groupId>com.lazerycode.jmeter</groupId>
                <artifactId>jmeter-maven-plugin</artifactId>
                <version>1.9.0</version>
                <executions>
                    <execution>
                        <id>jmeter-tests</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>jmeter</goal>
                        </goals>
                        <configuration>
                            <remoteConfig>
                                <startServersBeforeTests>true</startServersBeforeTests>
                                <stopServersAfterTests>true</stopServersAfterTests>
                            </remoteConfig>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

如果我们想在执行每个jmeter任务时,就重启一下远程服务,<startAndStopServersForEachTest>这个标签可以满足我们的需求,且这个标签的优先级比startServersBeforeTests和stopServersAfterTests的高,如果同时设置了这两种标签,后两者会被忽略。

            <plugin>
                <groupId>com.lazerycode.jmeter</groupId>
                <artifactId>jmeter-maven-plugin</artifactId>
                <version>1.9.0</version>
                <executions>
                    <execution>
                        <id>jmeter-tests</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>jmeter</goal>
                        </goals>
                        <configuration>
                            <remoteConfig>
                                <startAndStopServersForEachTest>false</startAndStopServersForEachTest>
                            </remoteConfig>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

默认情况下,jmeter-maven-plugin插件将会启动jmeter.properties中定义的所以机器节点,但是我们可以通过<serverList>标签来手动控制启动那些节点。

        <plugin>
                <groupId>com.lazerycode.jmeter</groupId>
                <artifactId>jmeter-maven-plugin</artifactId>
                <version>1.9.0</version>
                <executions>
                    <execution>
                        <id>jmeter-tests</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>jmeter</goal>
                        </goals>
                        <configuration>
                            <remoteConfig>
                                <startServersBeforeTests>true</startServersBeforeTests>
                                <serverList>server1,server2</serverList>
                                <stopServersAfterTests>true</stopServersAfterTests>
                            </remoteConfig>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
版权声明

本站文章、图片、视频等(除转载外),均采用知识共享署名 4.0 国际许可协议(CC BY-NC-SA 4.0),转载请注明出处、非商业性使用、并且以相同协议共享。

© 空空博客,本文链接:https://www.yeetrack.com/?p=916