Jmeter Maven插件 - 在pom.xml中带参数的远程服务器配置

时间:2015-09-11 02:54:07

标签: jmeter pom.xml dependency-management parent-pom jmeter-maven-plugin

我正在尝试使用远程服务器上的maven插件执行jmeter测试,利用pom.xml文件完全参数化,如下所示。(我能够成功运行{{1}远程测试,其中服务器名称,端口,协议和其他信息都在maven-jmeter文件中进行了硬编码。

我的 pom.xml 文件位于

之下
jmx

问题是.. jmeter-server检测到执行请求并几乎立即停止。

以下是日志文件运行后

的信息
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.example</groupId>
    <artifactId>jmeter-demo</artifactId>
    <packaging>jar</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>jmeter-demo</name>
    <url>http://maven.apache.org</url>
         <description>
    Executes a JMeter test.
  </description>
  <properties>
    <webapp.protocol>http</webapp.protocol>
    <!--<webapp.host>www.mozilla.com</webapp.host>-->
        <webapp.host>fsa-mia-dev2.fsalabs.io</webapp.host>
    <webapp.port>80</webapp.port>
    <test.duration>30</test.duration>
    <test.threads>10</test.threads>
  </properties>
    <build>
        <plugins>
            <plugin>
                <groupId>com.lazerycode.jmeter</groupId>
                <artifactId>jmeter-maven-plugin</artifactId>
                <version>1.9.0</version>

            <executions>
              <execution>
                <!--
                1)
                  first test run warms up the webserver.
                  Used to fill caches.
                  With a different set of properties since it runs much shorter than a normal test
                  and also the rate of requests/second may be much lower.
                  Maybe also use a different URL set.
                -->
                <id>warmup</id>
                <phase>integration-test</phase>
                <goals>
                  <goal>jmeter</goal>
                </goals>
                <configuration>
                  <propertiesUser>
                    <!--Accesses urls for warmup (compiles JSPs, fills caches, ...)-->

                                        <!--************Setup Config for Threadgroup 23***************-->
                                                            <threadgroup23.name>S23_SFA_Org_CO</threadgroup23.name>
                                        <threadgroup23.Transactionname>T23_SFA_Org_CO</threadgroup23.Transactionname>
                                        <threadgroup23.ThinkTime>5000</threadgroup23.ThinkTime>
                                          <threadgroup23.comment>T23_SFA_Org_CO</threadgroup23.comment>
                    <!--number of threads to use-->
                    <threadgroup23.numberOfThreads>5</threadgroup23.numberOfThreads>
                    <!--delay of the test in seconds-->
                    <threadgroup23.scheduledDelay>0</threadgroup23.scheduledDelay>
                    <!--duration of the test in seconds-->
                    <threadgroup23.scheduledDuration>60</threadgroup23.scheduledDuration>
                    <!--how long till all threads are up and running in seconds-->
                    <threadgroup23.rampUp>1</threadgroup23.rampUp>
                                        <threadgroup23.dataFile>/home/ubuntu/mproj/data/S23_SFA_Org_CO.dat</threadgroup23.dataFile>

                  </propertiesUser>
                </configuration>
              </execution>
              </executions>


  <configuration>
              <testFilesIncluded>
                <testFilesIncluded>01_SA_CU_GetCPS.jmx</testFilesIncluded>
              </testFilesIncluded>

              <!-- protocol, server and port of tested webapp -->
              <propertiesUser>
                <protocol>${webapp.protocol}</protocol>
                <server>${webapp.host}</server>
                <port>${webapp.port}</port>
              </propertiesUser>

<resultsFileFormat>csv</resultsFileFormat>
<testResultsTimestamp>false</testResultsTimestamp>
<ignoreResultFailures>true</ignoreResultFailures>
<remoteConfig>
<startServersBeforeTests>true</startServersBeforeTests>
<serverList>10.36.14.170</serverList>
</remoteConfig>
<suppressJMeterOutput>false</suppressJMeterOutput>
<propertiesSystem>

</propertiesSystem>
<propertiesJMeter><log_level.jmeter>DEBUG</log_level.jmeter></propertiesJMeter>
</configuration>
            </plugin>
        </plugins>
    </build>
</project>

(pom文件在没有remoteConfig的情况下运行良好 - 在localhost中) (任何地方都没有网络问题,远程服务器能够访问主机,并且当服务器名,端口,协议在jmx文件中硬编码时可以工作) 这是[debug] JMeter is called with the following command line arguments: -n -t /home/ubuntu/mProj/src/test/jmeter/01_SA_CU_GetCPS.jmx -l /home/ubuntu/mProj/target/jmeter/results/01_SA_CU_GetCPS.csv -d /home/ubuntu/mProj/target/jmeter -j /home/ubuntu/mProj/target/jmeter/logs/01_SA_CU_GetCPS.jmx.log -r -R 10.36.14.170 [info] Executing test: 01_SA_CU_GetCPS.jmx [info] Created the tree successfully using /home/ubuntu/mProj/src/test/jmeter/01_SA_CU_GetCPS.jmx [info] Configuring remote engine for 10.36.14.170 [info] Using remote object: UnicastRef [liveRef: [endpoint:[10.36.14.170:37913](remote),objID:[-10468c89:14fba100421:-7fff, -1854422229136130507]]] [info] Starting remote engines [info] Starting the test @ Fri Sep 11 01:42:27 UTC 2015 (1441935747716) [info] Remote engines have been started [info] Waiting for possible shutdown message on port 4445 [info] Tidying up remote @ Fri Sep 11 01:42:29 UTC 2015 (1441935749973) [info] Completed Test: 01_SA_CU_GetCPS.jmx [INFO] [INFO] Test Results: [INFO] [INFO] Tests Run: 1, Failures: 0 [INFO] [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 25.280s [INFO] Finished at: Fri Sep 11 01:42:35 UTC 2015 [INFO] Final Memory: 11M/57M [INFO] ------------------------------------------------------------------------ 插件的已知限制吗?

1 个答案:

答案 0 :(得分:0)

首先使用jmeter-maven-plugin的最新版本,截至2019年1月15日为2.8.3。

要传递参数,请在pom.xml中作为配置的子项输入:

while (tulosjoukko.next()) {

在jmeter中,例如要使用线程,可以使用__P函数:

  

$ {__ P(threads,5)

blog解释了整个过程。