JMeter -- Getting Started

公司最近需要测试后台性能,所以学习使用了Jmeter,在此做记录,也分享给更多需要的人。

这篇文章是 JMeter 的第一部分,都是一些很枯燥的理论,但是如果你需要深入使用 JMeter,还是很有必要看一看的。

如何使用很快就会更新!!!!!

1.0 Getting Started

1.0 概述


  

1.0.1 建立测试计划(Test Plan)


建立测试计划就需要使用 JMeter 的 GUI(用户界面)模式。


JMeter GUI mode

你可以录制 Web 网页或者一个本地应用程序的脚本。录制步骤是文件--> Templates...--> Recording

Recording

也可以手动创建测试计划,可以阅读文档获取更多详情。

你还可以通过以下几个选项进行调试:

  • Run -->Start no pauses
  • Run --> Start
  • Validate onThread Group
    Run

查看结果树或者测试器(CSS/JQUERY, JSON, Regexp, XPath)。
在构建测试计划时,确保遵循官方指导

1.0.2 负载测试计划(Load Test running)


一旦测试计划就绪,就可以开始负载测试了。第一步是配置运行JMeter的注射器,这与任何其他负载测试工具一样,包括:

  • 确保电脑的 CPU、内存和网络符合JMeter 需求
  • 电脑操作系统符合JMeter的需求
  • 安装最新版的 JAVA
  • Increase the Java Heap size. 默认情况下,JMeter运行的堆(heap)是1GB,这对于您的测试来说可能不够,这取决于您的测试计划和希望运行的线程数。

一旦一切就绪,您将使用命令行模式(称为非GUI 模式)为负载测试运行它。

Don't run load test using GUI mode !

使用非GUI 模式,您可以生成一个包含结果的CSV(或XML)文件,并在负载测试结束时使用JMeter生成一个HTML报告。JMeter将在运行时提供负载测试的摘要。

您还可以使用后端侦听器在测试期间获得实时结果

1.0.3负载测试分析 (Load Test running)


一旦您的负载测试完成,您可以使用HTML报告来分析您的负载测试。

1.0.4开始使用


开始使用JMeter的最简单方法是首先下载最新的产品版本并安装它。这个版本包含了构建和运行大多数类型的测试所需的所有文件,例如Web (HTTP/HTTPS)、FTP、JDBC、LDAP、Java、JUnit等等。

如果您想要执行JDBC测试,那么您当然需要来自您的供应商的适当的JDBC驱动程序。JMeter没有任何JDBC驱动程序。

JMeter包括JMS API jar,但不包括JMS客户机实现。如果希望运行JMS测试,需要从JMS提供程序下载适当的jar。

有关安装其他jar的详细信息,请参阅JMeter类路径部分。

1.1 必备条件(Requirements)


JMeter要求您的计算环境满足一些最低要求。

1.1.1 java 版本

JMeter 4.0与Java 8或Java 9兼容。出于安全和性能的考虑,我们强烈建议您安装这些主要版本的最新版本。

由于JMeter只使用标准的Java api,如果您的JRE(Java Runtime Environment,指JAVA 运行环境)因为JRE实现问题而不能运行JMeter,请不要提交错误报告。

虽然您可以使用JRE,但是最好安装JDK作为记录HTTPS的工具,但是JMeter需要来自JDK的keytool实用工具

1.1.2 操作系统(Operating Systems)


JMeter是一个100%的Java应用程序,应该在任何具有兼容Java实现的系统上正确运行。

使用JMeter测试的操作系统可以在JMeter wiki上查看。

即使您的操作系统没有列在wiki页面上,JMeter也应该在它上运行,前提是JVM是兼容的。

1.2 可选项(Optional)


如果您计划进行JMeter开发,那么您将需要下面列出的一个或多个可选包。

1.2.1 JAVA 编辑器(Java Compiler)


如果您想构建JMeter源代码或开发JMeter插件,那么您将需要一个完全兼容的JDK 8或更高版本。

1.2.2 SAX XML 解析器(SAX XML Parser)


JMeter附带Apache的Xerces XML解析器。您可以选择告诉JMeter使用不同的XML解析器。为此,在JMeter的类路径中包含第三方解析器的类,并更新JMeter属性文件,具有解析器实现的完整类名。

1.2.3 Email Support


JMeter拥有广泛的电子邮件功能。它可以根据测试结果发送电子邮件,并且有一个POP3(S)/IMAP(S)采样器(sampler)。它还有一个SMTP(S)采样器。

1.2.4 SSL 加密 (SSL Encryption)


要使用SSL加密(HTTPS)测试web服务器,JMeter要求提供SSL的实现,就像Sun Java 1.4或更高版本那样。如果您的Java版本不包含SSL支持,那么可以添加外部实现。在JMeter的类路径中包含必要的加密包。同时,更新系统。用于注册SSL提供程序的属性。

JMeter HTTP缺省值为协议级TLS。可以通过在JMeter中编辑JMeter属性https.default.protocol in jmeter.propertiesuser.properties

JMeter HTTP取样器(samplers)被配置为接受所有证书,无论可信与否,无论有效性周期等。这是为了在测试服务器中实现最大的灵活性。

如果服务器需要客户端证书,可以提供该证书。

还有SSL管理器,用于更好地控制证书。

JMeter代理服务器(见下面)支持记录(recording)HTTPS (SSL).

SMTP取样器可以选择使用本地信任存储库或信任所有证书。

1.2.5 JDBC Driver


如果想要进行JDBC测试,需要将数据库供应商的JDBC驱动程序添加到类路径(classpath)中。确保该文件是一个jar文件,而不是一个zip文件。

1.2.6 JMS Client


JMeter现在包含来自Apache Geronimo的JMS API,因此只需从JMS提供者添加适当的JMS客户机实现jar。详情请参阅他们的文件。也可能有一些关于JMeter Wiki的信息。

1.2.7 Libraries for ActiveMQ JMS


您将需要添加jar activemq-all- x . x.x.jar到类路径(classpath),例如将它存储在lib/目录中。

See ActiveMQ initial configuration page for details.

See the JMeter Classpath section for more details on installing additional jars.

1.3 安装(Installation)


推荐使用最新版本

要安装发布(release)版本,只需将zip/tar文件解压到要安装JMeter的目录中。如果您已经正确地安装了JRE/JDK和JAVA_HOME环境变量集,那么就不需要做其他工作了。

如果目录路径包含任何空格,就会出现问题(特别是client-server模式)。

安装目录结构应该如下所示(其中X.Y是版本号):

apache-jmeter-X.Y
apache-jmeter-X.Y/bin
apache-jmeter-X.Y/docs
apache-jmeter-X.Y/extras
apache-jmeter-X.Y/lib/
apache-jmeter-X.Y/lib/ext
apache-jmeter-X.Y/lib/junit
apache-jmeter-X.Y/licenses
apache-jmeter-X.Y/printable_docs

如果需要,可以重命名父目录(即apache-jmeter-X.Y),但是不要更改任何子目录名。

1.4 运行 JMeter


要运行JMeter,运行JMeter。bat(用于Windows)或jmeter(用于Unix)文件。这些文件可以在bin目录中找到。短时间后,应该会出现JMeter GUI。

GUI模式只能用于创建测试脚本,非GUI模式必须用于负载测试。

在bin目录中有一些您可能会发现有用的附加脚本。Windows脚本文件(.CMD文件需要Win2K或更高版本):

jmeter.bat
  运行JMeter(GUI 模式)

jmeterw.cmd
  在没有windows shell控制台的情况下运行JMeter(默认为GUI模式)

jmeter-n.cmd
  在上面删除一个JMX文件以运行非gui测试

jmeter-n-r.cmd
  在此删除一个JMX文件以远程运行非gui测试。

jmeter-t.cmd
  在上面删除一个JMX文件,以GUI模式加载它

jmeter-server.bat
  start JMeter in server mode

mirror-server.cmd
  以非gui模式运行JMeter镜像服务器

shutdown.cmd
  运行Shutdown客户端以优雅地停止非gui实例

stoptest.cmd
  运行Shutdown客户端来突然停止非GUI(non-GUI)实例

bin目录

The special name LAST can be used with jmeter-n.cmd, jmeter-t.cmd and jmeter-n-r.cmd and means the last test plan that was run interactively.
最后的特殊名称可以与jmeter-n.cmd,jmeter-t.cmd和jmeter-n-r.cmd 一起使用。表示交互运行的最后一个测试计划。

有几个环境变量可用于为JMeter定制JVM设置。一个简单的设置方法是在 bin 目录创建一个名为setenv.bat的文件。这样的文件可以是:

rem This is the content of bin\setenv.bat,
rem it will be called by bin\jmeter.bat

set JVM_ARGS="-Xms1024m -Xmx1024m -Dpropname=value"

JVM_ARGS可用于覆盖jmeter中的JVM设置。启动JMeter时将设置bat脚本,例如:
jmeter -t test.jmx …

可以定义以下环境变量:

DDRAW
  JVM options to influence usage of direct draw, e.g. -Dsun.java2d.ddscale=true. Default is empty.
GC_ALGO
  JVM garbage collector options. Defaults to -XX:+UseG1GC -XX:MaxGCPauseMillis=250 -XX:G1ReservePercent=20
HEAP
  JVM memory settings used when starting JMeter. Defaults to -Xms1g -Xmx1g -XX:MaxMetaspaceSize=256m
JMETER_BIN
  JMeter bin directory (must end in ). Value will have been guessed, when setenv.bat is called.
JMETER_COMPLETE_ARGS
  If set indicates, that JVM_ARGS and JMETER_OPTS are to be used, only. All other options like HEAP and GC_ALGO will be ignored. Default is empty.
JMETER_HOME
  installation directory. Will be guessed from location of jmeter.bat
JMETER_LANGUAGE
  Java runtime options to specify used languauge. Defaults to: -Duser.language="en" -Duser.region="EN"
JM_LAUNCH
  Name of the java executable, like java.exe (default) or javaw.exe
JVM_ARGS
  Java options to be used when starting JMeter. These will be added last to the java command. Default is empty
Un*x script files; should work on most Linux/Unix systems:

jmeter
  run JMeter (in GUI mode by default). Defines some JVM settings which may not work for all JVMs.
jmeter-server
  start JMeter in server mode (calls jmeter script with appropriate parameters)
jmeter.sh
  very basic JMeter script (You may need to adapt JVM options like memory settings).
mirror-server.sh
  runs the JMeter Mirror Server in non-GUI mode
shutdown.sh
  Run the Shutdown client to stop a non-GUI instance gracefully
stoptest.sh
  Run the Shutdown client to stop a non-GUI instance abruptly

可能需要设置一些环境变量来配置JMeter使用的JVM。这些变量可以直接设置在shell启动jmeter脚本中。例如,设置变量JVM_ARGS将覆盖大多数预定义的设置

JVM_ARGS="-Xms1024m -Xmx1024m" jmeter -t test.jmx [etc.]
将重写脚本中的堆(HEAP)设置。

要永久性地设置这些变量,可以将它们放在一个名为setenv.sh的文件中在bin里。在运行JMeter时,通过调用JMeter脚本获得这个文件。bin / setenv.sh可能看起来像:

# This is the file bin/setenv.sh,
# it will be sourced in by bin/jmeter

# Use a bigger heap, but a smaller metaspace, than the default
export HEAP="-Xms1G -Xmx1G -XMaxMetaspaceSize=192m"

# Try to guess the locale from the OS. The space as value is on purpose!
export JMETER_LANGUAGE=" "

可以定义以下环境变量:

GC_ALGO
  Java runtime options to specify JVM garbage collection algorithm. Defaults to -XX:+UseG1GC -XX:MaxGCPauseMillis=250 -XX:G1ReservePercent=20
HEAP
  Java runtime options for memory management used when JMeter is started. Defaults to -Xms1g -Xmx1g -X:MaxMetaspaceSize=256m
JAVA_HOME
  Must point at your Java Development Kit installation. Required to run the with the "debug" argument. On some OSes it JMeter will try its best to guess the location of the JVM.
JMETER_COMPLETE_ARGS
  If set indicates, that JVM_ARGS and JMETER_OPTS are to be used, only. All other options like HEAP and GC_ALGO will be ignored. Default is empty.
JMETER_HOME
  May point to your JMeter install dir. If empty it will be set relative to the jmeter script.
JMETER_LANGUAGE
  Java runtime options to specify used language. Defaults to -Duser.language=en -Duser.region=EN
JMETER_OPTS
  Java runtime options used when JMeter is started. Special options for operating systems might be added by JMeter.
JRE_HOME
  Must point at your Java Runtime installation. Defaults to JAVA_HOME if empty. If JRE_HOME and JAVA_HOME are both empty, JMeter will try to guess JAVA_HOME. If JRE_HOME and JAVA_HOME are both set, JAVA_HOME is used.
JVM_ARGS
  Java options to be used when starting JMeter. These will be added before JMETER_OPTS and after the other JVM options. Default is empty

1.4.1 JMeter's Classpath


JMeter在以下目录中自动查找来自jar的类:

JMETER_HOME/lib
  用于 utility jars

JMETER_HOME/lib/ext
  用于JMeter组件和插件

如果您已经开发了新的JMeter组件,那么您应该将它们转化为jar 文件并将他们保存到JMeter的lib/ext目录中。JMeter将自动在这里找到的任何jar中找到JMeter组件。不要使用由插件使用的utility jar或依赖jar的lib/ext;它只用于JMeter组件和插件。

如果您不想在lib/ext目录中放置JMeter插件jar,那么在jmeter.properties中定义属性search_paths。

实用程序(Utility)和依赖项jar(库等)可以放在lib目录中。

如果不想将此类jar放到lib目录中,那么在jmeter.properties中定义属性user.classpathplugin_dependency_paths。有关差异的解释,请参见下面。

其他jar(如JDBC、JMS实现和JMeter代码所需要的其他支持库)应该放在lib目录中,而不是lib/ext目录,或者添加到user.classpath

JMeter will only find .jar files, not .zip.
Jmeter 只能识别 jar 格式文件,无法识别压缩(.zip)文件。

您还可以在$JAVA_HOME/jre/lib/ext中安装utility Jar文件,也可以在jmeter.properties中设置属性user.classpath

注意,设置CLASSPATH环境变量没有任何效果。这是因为JMeter是用“java -jar”启动的,java命令会在使用-jar时无声地忽略CLASSPATH变量和-classpath/-cp选项。

This occurs with all Java programs, not just JMeter.

  

1.4.2 从模板中创建测试计划(Create Test Plan from Template)


您可以从现有模板创建新的测试计划。

你可以通过 File-->Templates...或者 JMeter 的 GUI 的 Templates 图标开启Templates:


Template 图标

出现一个弹出窗口,您可以在列表中选择一个模板:
Templates窗口

每个模板的文档解释了从模板创建测试计划后该做什么。

1.4.3 在代理后面使用JMeter( Using JMeter behind a proxy)


如果您正在防火墙/代理服务器的后面进行测试,您可能需要向JMeter提供防火墙/代理服务器主机名和端口号。为此,运行jmeter[.bat]文件从命令行与以下参数:

-H
[proxy server hostname or ip address]
-P
[proxy server port]
-N
[nonproxy hosts] (e.g. *.apache.org|localhost)
-u
[username for proxy authentication - if required]
-a
[password for proxy authentication - if required]

示例:
jmeter -H my.proxy.server -P 8000 -u username -a password -N localhost

您还可以使用-proxyHost、-proxyPort、-username和-password作为参数名

命令行上提供的参数可能对系统上的其他用户可见。

如果提供代理主机和端口,则JMeter设置以下系统属性:

  • http.proxyHost
  • http.proxyPort
  • https.proxyHost
  • https.proxyPort

如果提供了非代理主机列表,则JMeter设置了以下系统属性:

  • http.nonProxyHosts
  • https.nonProxyHosts

因此,如果不希望同时设置http和https代理,可以在system.properties中定义相关属性,而不是使用命令行参数。

代理设置也可以在测试计划中定义,使用HTTP请求默认值(HTTP Request Defaults)配置或HTTP请求(HTTP Request)取样器元素。

JMeter还拥有自己的内置代理服务器——HTTP(S)测试脚本记录器。这只用于记录HTTP或HTTPS浏览器会话。不要将此与上面描述的代理设置混淆,这些设置在JMeter生成HTTP或HTTPS请求时使用。

1.4.4 Non-GUI Mode (Command Line mode)


对于负载测试(load testing),您必须以这种模式(没有GUI)运行JMeter,以获得最佳结果。为此,请使用以下命令选项:

-n
  This specifies JMeter is to run in non-gui mode
-t
  [name of JMX file that contains the Test Plan].
-l
  [name of JTL file to log sample results to].
-j
  [name of JMeter run log file].
-r
  Run the test in the servers specified by the JMeter property "remote_hosts"
-R
  [list of remote servers] Run the test in the specified remote servers
-g
  [path to CSV file] generate report dashboard only
-e
  generate report dashboard after load test
-o
  output folder where to generate the report dashboard after load test. Folder must not exist or be empty

The script also lets you specify the optional firewall/proxy server information:
-H
  [proxy server hostname or ip address]
-P
  [proxy server port]

示例
jmeter -n -t my_test.jmx -l log.jtl -H my.proxy.server -P 8000

如果属性jmeterengine.stopfail.system.exit被设置为true(默认为false),如果不能停止所有线程,JMeter将调用System.exit(1)。通常这是不必要的。

  

1.4.5 Server Mode


对于分布式测试,在远程节点上以服务器模式运行JMeter,然后从GUI控制服务器。您还可以使用非gui模式来运行远程测试。要启动服务器,请运行jmeter-server[。在每个服务器主机上。

该脚本还允许您指定可选的防火墙/代理服务器信息:

-H
  [proxy server hostname or ip address]

-P
  [proxy server port]

示例
jmeter-server -H my.proxy.server -P 8000

如果希望服务器在运行一个测试之后退出,那么定义JMeter属性server.exitaftertest=true

要在非GUI模式下从客户端运行测试,请使用以下命令:
jmeter -n -t testplan.jmx -r [-Gprop=val] [-Gglobal.properties] [-X]

参数错误:
-G
  用于定义在服务器中设置的JMeter属性

-X
  意味着在测试结束时退出服务器

-Rserver1,server2
  可以使用而不是-r来提供要启动的服务器列表。重写remote_hosts,但不定义属性。

如果属性jmeterengine.remote.system.exit被设置为true(默认为false),然后JMeter将在测试结束时停止RMI后调用System.exit(0)。通常这是不必要的。

  

1.4.6通过命令行重写属性( Overriding Properties Via The Command Line)


Java系统属性和JMeter属性可以直接在命令lin上重写(而不是修改JMeter .properties)。为此,请使用以下选项:

-D[prop_name]=[value]
  defines a java system property value.
-J[prop_name]=[value]
  defines a local JMeter property.
-G[prop_name]=[value]
  defines a JMeter property to be sent to all remote servers.
-G[propertyfile]
  defines a file containing JMeter properties to be sent to all remote servers.
-L[category]=[priority]
  overrides a logging setting, setting a particular category to the given priority level.
The** -L** flag can also be used without the category name to set the root logging level.

示例

jmeter -Duser.dir=/home/mstover/jmeter_stuff \
    -Jremote_hosts=127.0.0.1 -Ljmeter.engine=DEBUG

jmeter -LDEBUG

The command line properties are processed early in startup, but after the logging system has been set up.
命令行属性在启动时进行处理,但在设置日志系统之后。

  

1.4.7 日志和错误消息(Logging and error messages)

Since 3.2, JMeter logging is not configured through properties file(s) such as jmeter.properties any more, but it is configured through a Apache Log4j 2configuration file (log4j2.xml in the directory from which JMeter was launched, by default) instead. Also, every code including JMeter and plugins MUST use SLF4J library to leave logs since 3.2.
自3.2版本后,JMeter日志记录没有通过属性文件(如JMeter)进行配置。属性,但它是通过Apache Log4j 2配置文件(log4j2)配置的。默认情况下,JMeter是从哪个目录启动的xml)。而且,包括JMeter和插件在内的所有代码都必须使用SLF4J库来保存3.2以后的日志。

这里有一个log4j2.xml文件示例,为每个类别定义两个日志附件和日志记录器。

<Configuration status="WARN" packages="org.apache.jmeter.gui.logging">

  <Appenders>

    <!-- The main log file appender to jmeter.log in the directory from which JMeter was launched, by default. -->
    <File name="jmeter-log" fileName="${sys:jmeter.logfile:-jmeter.log}" append="false">
      <PatternLayout>
        <pattern>%d %p %c{1.}: %m%n</pattern>
      </PatternLayout>
    </File>

    <!-- Log appender for GUI Log Viewer. See below. -->
    <GuiLogEvent name="gui-log-event">
      <PatternLayout>
        <pattern>%d %p %c{1.}: %m%n</pattern>
      </PatternLayout>
    </GuiLogEvent>

  </Appenders>

  <Loggers>

    <!-- Root logger -->
    <Root level="info">
      <AppenderRef ref="jmeter-log" />
      <AppenderRef ref="gui-log-event" />
    </Root>

    <!-- SNIP -->

    <!--
      # Apache HttpClient logging examples
    -->
    <!-- # Enable header wire + context logging - Best for Debugging -->
    <!--
    <Logger name="org.apache.http" level="debug" />
    <Logger name="org.apache.http.wire" level="error" />
    -->

    <!-- SNIP -->

  </Loggers>

</Configuration>

因此,如果您希望更改org.apache.http的日志级别。例如,可以在启动JMeter之前简单地在log4j2.xml中添加(或取消注释)以下日志记录器元素。

<Loggers>
    <!-- SNIP -->
    <Logger name="org.apache.http" level="debug" />
    <!-- SNIP -->
  </Loggers>

有关如何配置log4j2.xml文件的详细信息,请参阅Apache Log4j 2配置页面。

可以直接在命令行上覆盖特定类别或根日志记录器的日志级别(而不是修改log4j2.xml)。为此,请使用以下选项:

-L[category]=[priority]
  覆盖日志设置,将特定类别设置为给定的优先级。从3.2开始,建议使用一个完整的类别(category)名(例如org.apache.jmeter或者com.example.foo)。但是如果类别名以jmeterjorphanorg.apache开头。将在内部对类别名称输入进行预先处理,以构造一个完整的类别名称(比如org.apache.jmeterorg.apache.jorphan)以便向后兼容。

示例:
jmeter -Ljmeter.engine=DEBUG
jmeter -Lorg.apache.jmeter.engine=DEBUG
jmeter -Lcom.example.foo=DEBUG
jmeter -LDEBUG

日志记录的差异:旧的和新的实践:

由于自3.2以来,JMeter使用SLF4J作为日志API,而Apache Log4j2作为日志框架,因此在3.2之前使用的每个日志级别都不能与SLF4J/Log4j2提供的新日志级别之一完全匹配。因此,如果您需要迁移任何现有的日志配置和日志代码,请记住以下差异和新的建议实践。

Old vs New Practices

JMeter does not generally use pop-up dialog boxes for errors, as these would interfere with running tests. Nor does it report any error for a mis-spelt variable or function; instead the reference is just used as is. See Functions and Variables for more information.

如果JMeter在测试期间检测到错误,则将向日志文件写入一条消息。日志文件名称是在log4j2.xml文件中定义的。(或使用-j选项,参见下面)。默认是jmeter.log日志,并将在启动JMeter的目录中找到。

菜单 选项→日志(Options → Log Viewer)查看器显示日志文件在底部窗格中主要JMeter窗口。

在GUI模式中,日志文件中记录的错误/致命(error/fatal )消息的数量显示在右上角。


error/fatal

命令行选项-j jmeterlogfile允许在读取初始属性文件和处理任何进一步属性之前进行处理。因此,它允许jmeter的默认值。日志被覆盖。将测试计划名称作为参数(例如jmeter-n.cmd)的jmeter脚本已经被更新,以使用测试计划名称(例如测试计划Test27)定义日志文件。日志文件设置为Test27.log。

在Windows上运行时,文件可能会显示为jmeter,除非您已经设置了窗口来显示文件扩展名。(无论如何,你应该做的是,让检测病毒和其他伪装成文本文件的讨厌的东西变得更容易……)

除了记录错误外,还有jmeter.log文件记录了一些关于测试运行的信息。例如:

2017-03-01 12:19:20,314 INFO o.a.j.JMeter: Version 3.2.20170301
2017-03-01 12:19:45,314 INFO o.a.j.g.a.Load: Loading file: c:\mytestfiles\BSH.jmx 
2017-03-01 12:19:52,328 INFO o.a.j.e.StandardJMeterEngine: Running the test! 
2017-03-01 12:19:52,384 INFO o.a.j.e.StandardJMeterEngine: Starting 1 threads for group BSH. Ramp up = 1. 
2017-03-01 12:19:52,485 INFO o.a.j.e.StandardJMeterEngine: Continue on error 
2017-03-01 12:19:52,589 INFO o.a.j.t.JMeterThread: Thread BSH1-1 started 
2017-03-01 12:19:52,590 INFO o.a.j.t.JMeterThread: Thread BSH1-1 is done 
2017-03-01 12:19:52,691 INFO o.a.j.e.StandardJMeterEngine: Test has ended

日志文件可以帮助确定错误的原因,因为JMeter不会中断测试以显示错误对话。

  

1.4.8 命令行选项的完整列表(Full list of command-line options)


调用JMeter作为“JMeter -?”将打印所有命令行选项的列表。这些如下所示。

--?
        print command line options and exit
    -h, --help
        print usage information and exit
    -v, --version
        print the version information and exit
    -p, --propfile <argument>
        the jmeter property file to use
    -q, --addprop <argument>
        additional JMeter property file(s)
    -t, --testfile <argument>
        the jmeter test(.jmx) file to run
    -l, --logfile <argument>
        the file to log samples to
    -i, --jmeterlogconf <argument>
        jmeter logging configuration file (log4j2.xml)
    -j, --jmeterlogfile <argument>
        jmeter run log file (jmeter.log)
    -n, --nongui
        run JMeter in nongui mode
    -s, --server
        run the JMeter server
    -H, --proxyHost <argument>
        Set a proxy server for JMeter to use
    -P, --proxyPort <argument>
        Set proxy server port for JMeter to use
    -N, --nonProxyHosts <argument>
        Set nonproxy host list (e.g. *.apache.org|localhost)
    -u, --username <argument>
        Set username for proxy server that JMeter is to use
    -a, --password <argument>
        Set password for proxy server that JMeter is to use
    -J, --jmeterproperty <argument>=<value>
        Define additional JMeter properties
    -G, --globalproperty <argument>=<value>
        Define Global properties (sent to servers)
        e.g. -Gport=123
         or -Gglobal.properties
    -D, --systemproperty <argument>=<value>
        Define additional system properties
    -S, --systemPropertyFile <argument>
        additional system property file(s)
    -f, --forceDeleteResultFile
        force delete existing results files before start the test
    -L, --loglevel <argument>=<value>
        [category=]level e.g. jorphan=INFO, jmeter.util=DEBUG or com.example.foo=WARN
    -r, --runremote
        Start remote servers (as defined in remote_hosts)
    -R, --remotestart <argument>
        Start these remote servers (overrides remote_hosts)
    -d, --homedir <argument>
        the jmeter home directory to use
    -X, --remoteexit
        Exit the remote servers at end of test (non-GUI)
    -g, --reportonly <argument>
        generate report dashboard only, from a test results file
    -e, --reportatendofloadtests
        generate report dashboard after load test
    -o, --reportoutputfolder <argument>
        output folder for report dashboard

注意:如果JMeter日志文件名包含成对的单引号,则将其格式化为SimpleDateFormat(应用于当前日期),例如。'jmeter_'yyyyMMddHHmmss '. log'

如果特殊名称LAST用于-t、-j或-l标志,那么JMeter表示在交互模式下运行的最后一个测试计划。

  

1.4.9 non-GUI shutdown


在2.5.1版本之前,JMeter在非gui测试完成时调用System.exit()。这给直接调用JMeter的应用程序带来了问题,因此JMeter不再调用System.exit()来完成正常的测试。[一些致命错误仍然可能调用System.exit()]] JMeter将退出它启动的所有非守护进程线程,但是可能仍然保留一些非守护进程线程;这将阻止JVM退出。为了检测这种情况,JMeter在退出之前启动一个新的守护进程线程。这个守护进程线程等待了很短的时间;如果它从等待中返回,那么很明显JVM无法退出,线程会打印一条消息说明原因。

属性jmeter.exit.check.pause可以使用覆盖2000ms (2secs)的默认暂停。如果设置为0,则JMeter不会启动守护线程。

  

1.5 配置JMeter(Configuring JMeter)


如果您希望修改JMeter运行的属性,您需要修改在/bin目录中de user.properties文件,或者创建自己的jmeter.properties副本并在命令行中指定它。

Note: You can define additional JMeter properties in the file defined by the JMeter property** user.properties** which has the default value user.properties. The file will be automatically loaded if it is found in the current directory or if it is found in the JMeter bin directory. Similarly, system.properties is used to update system properties.
注意:可以在JMeter属性用户定义的文件中定义其他JMeter属性user.properties,具有默认值user.properties。如果在当前目录中找到该文件,或者在JMeter bin目录中找到该文件,该文件将被自动加载。同样,system.properties用于更新系统属性。

Parameters
Attribute Description Required
ssl.provider You can specify the class for your SSL implementation if you don't want to use the built-in Java implementation. No
xml.parser You can specify an implementation as your XML parser. The default value is: org.apache.xerces.parsers.SAXParser No
remote_hosts Comma-delimited list of remote JMeter hosts (or host:port if required). If you are running JMeter in a distributed environment, list the machines where you have JMeter remote servers running. This will allow you to control those servers from this machine's GUI No
not_in_menu A list of components you do not want to see in JMeter's menus. As JMeter has more and more components added, you may wish to customize your JMeter to show only those components you are interested in. You may list their classname or their class label (the string that appears in JMeter's UI) here, and they will no longer appear in the menus. No
search_paths List of paths (separated by ;) that JMeter will search for JMeter plugin classes, for example additional samplers. A path item can either be a jar file or a directory. Any jar file in such a directory will be automatically included in search_paths, jar files in sub directories are ignored. The given value is in addition to any jars found in the lib/ext directory. No
user.classpath List of paths that JMeter will search for utility and plugin dependency classes. Use your platform path separator to separate multiple paths. A path item can either be a jar file or a directory. Any jar file in such a directory will be automatically included in user.classpath, jar files in sub directories are ignored. The given value is in addition to any jars found in the lib directory. All entries will be added to the class path of the system class loader and also to the path of the JMeter internal loader. No
plugin_dependency_paths List of paths (separated by ;) that JMeter will search for utility and plugin dependency classes. A path item can either be a jar file or a directory. Any jar file in such a directory will be automatically included in plugin_dependency_paths, jar files in sub directories are ignored. The given value is in addition to any jars found in the lib directory or given by the user.classpath property. All entries will be added to the path of the JMeter internal loader only. For plugin dependencies using plugin_dependency_paths should be preferred over user.classpath. No
user.properties Name of file containing additional JMeter properties. These are added after the initial property file, but before the -q and -J options are processed. No
system.properties Name of file containing additional system properties. These are added before the -S and -D options are processed. No

命令行选项和属性文件按以下顺序处理:

1、-p propfile
2、jmeter.properties (or the file from the -p option) is then loaded
3、
-j logfile

4、Logging is initialised
5、user.properties is loaded
6、system.properties is loaded
7、all other command-line options are processed

参见jmeter.properties,user.propertiessystem.properties文件,以获取关于其他设置的进一步信息。

本篇文章译自官网

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 194,088评论 5 459
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 81,715评论 2 371
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 141,361评论 0 319
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 52,099评论 1 263
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 60,987评论 4 355
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 46,063评论 1 272
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 36,486评论 3 381
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 35,175评论 0 253
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 39,440评论 1 290
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 34,518评论 2 309
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 36,305评论 1 326
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 32,190评论 3 312
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 37,550评论 3 298
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 28,880评论 0 17
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 30,152评论 1 250
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 41,451评论 2 341
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 40,637评论 2 335

推荐阅读更多精彩内容

  • 在使用Jmeter进行接口的性能测试时,由于Jmeter 是JAVA应用,对于CPU和内存的消耗比较大,所以,当需...
    燕京博士阅读 4,145评论 0 16
  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 134,490评论 18 139
  • 孤独和热闹彼此交融,孤独和热闹又彼此陌生。我们坚守的地方不同,我们分别的地方相同。 孤独的人有他的孤独 热闹的人有...
    陈三巡阅读 309评论 1 5
  • 径直飞到了最后面的窗户玻璃上,还是舒舒服服睡一觉吧,夜里梦到了庄蝶,一夜辗转,谁让我是一只有思想的苍绳呢。 一股猪...
    我是素颜阅读 144评论 0 0