1

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

我的pom.xml文件在下面

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

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

这是来自日志文件运行后的信息

[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] ------------------------------------------------------------------------

(在没有远程配置的情况下,pom 文件运行良好 - 在 localhost 中)(在任何地方都没有网络问题,并且远程服务器能够访问主机并且当服务器名称、端口、协议在 jmx 文件中硬编码时工作)这是一个已知的限制maven-jmeter插件的?

4

1 回答 1

1

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

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

    <propertiesJMeter>
         <BUILD_TAG>${project.version}</BUILD_TAG>
         <threads>7</threads>
         <duration>30</duration>
     </propertiesJMeter>

在 jmeter 中,例如,要使用线程,您将使用__P函数:

${__P(线程,5)

这个博客解释了整个过程。

于 2019-01-15T20:49:43.883 回答