• jmeter-00 JMeter 运行过程


    一.GUI mode 图形化界面运行

      to run JMeter, run the jmeter.bat (for Windows) or jmeter (for Unix) file. These files are found in the bin directory. 

    windows中,bin目录下可用脚本有:

    jmeter.bat

      run JMeter (in GUI mode by default)

    jmeterw.cmd

      run JMeter without the windows shell console (in GUI mode by default)

    jmeter-n.cmd

      drop a JMX file on this to run a non-GUI test

    jmeter-n-r.cmd

      drop a JMX file on this to run a non-GUI test remotely

    jmeter-t.cmd

      drop a JMX file on this to load it in GUI mode

    jmeter-server.bat

      start JMeter in server mode

    mirror-server.cmd

      runs the JMeter Mirror Server in non-GUI mode

    shutdown.cmd

      Run the Shutdown client to stop a non-GUI instance gracefully

    stoptest.cmd

      Run the Shutdown client to stop a non-GUI instance abruptly

    Linux/Unix 中,bin目录下可用脚本有:

    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

    二.Non-GUI mode( Command-line mode) 非图形化界面运行 

      For load testing, you must run JMeter in this mode

    命令选项有:

    D:apache-jmeter-3.3in>jmeter -?
        _    ____   _    ____ _   _ _____       _ __  __ _____ _____ _____ ____
       /   |  _  /   / ___| | | | ____|     | |  /  | ____|_   _| ____|  _ 
      / _  | |_) / _ | |   | |_| |  _|    _  | | |/| |  _|   | | |  _| | |_) |
     / ___ |  __/ ___  |___|  _  | |___  | |_| | |  | | |___  | | | |___|  _ <
    /_/   \_\_| /_/   \_\____|_| |_|_____|  \___/|_|  |_|_____| |_| |_____|_| \_ 3.3 r1808647
    
    Copyright (c) 1999-2017 The Apache Software Foundation
    
            --?
                    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. "-t LAST" will load last
                    used file
            -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 -n -t my_test.jmx -l log.jtl -H my.proxy.server -P 8000

    GUI mode should only be used for creating the test script, NON GUI mode must be used for load testing

    三、分布式运行

    (1)控制机:也可以参与脚本的运行,同时它也担负着管理远程负载机指挥远程负载机运行的任务,并且收集远程负载机的测试结果。

    (2)负载机:向被测应用服务器发起负载的机器。负载机首先要启动一个客户端程序(Agent:jmeter-server.bat),这样控制机才能接管负载机。控制机会把运行的脚本隐蔽地发送到远程负载机,但是如果运行的测试脚本有参数文件及依赖的jar包时,控制机并不能把它们发送到远程负载机,这种情况就需要手动拷贝了。

    (3)远程运行逻辑:

      远程负载机首先启动Agent程序,待控制机连接;

      控制机连接上远程负载机;

      控制机发送指令(脚本及启动命令)启动线程;

      负载机运行脚本,回传状态(包括测试结果)

      控制机收集结果并显示。

    举例:在10.1.102.68 机器中启动jmeter 作为控制机,在10.1.102.75 机器中启动jmeter作为负载机。

    方式一:控制机以GUI方式运行

    1.首先在68 jmeter 的jmeter.properties 中指定"remote_hosts" (修改了jmeter.properties 文件需要重新启动JMeter才可以生效)

    # Remote Hosts - comma delimited
    remote_hosts=10.1.102.75
    #remote_hosts=localhost:1099,localhost:2010

    2.在75 中,启动JMeter Agent 程序,如

    3. 在68中,启动jmeter,做一个简单配置,如下:

    点击远程全部启动即可。

     此时如果正常运行,则75中的agent 控制台中输出如下:

     方式二:控制机通过非GUI方式运行

    1. 配置测试计划

    2. 在75 中,启动JMeter Agent 程序,如

    3. 在68中, 命令行执行如下:

    D:apache-jmeter-3.3in>jmeter -n -t F:jmeter_workspace测试计划-远程运行实例.jmx -l F:jmeter_workspace
    emote.jtl -R 10.1.102.75
    Creating summariser <summary>
    Created the tree successfully using F:jmeter_workspace测试计划-远程运行实例.jmx
    Configuring remote engine: 10.1.102.75
    Starting remote engines
    Starting the test @ Fri Nov 03 17:19:54 CST 2017 (1509700794827)
    Remote engines have been started
    Waiting for possible Shutdown/StopTestNow/Heapdump message on port 4445

    此时如果正常运行,则75中的agent 控制台中输出如下:

     四、通过命令行覆盖属性配置

    Java system properties and JMeter properties can be overridden directly on the command lin (instead of modifying jmeter.properties). To do so, use the following options:

    -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

     举例:

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

    实例:从命令行中,指定运行线程数与url

    命令行执行命令:

    jmeter -n -t "mock_api .jmx" -JthreadCount=5 -Durl=10.1.102.75

    五、命令行选项与properties配置的处理顺序

    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

      

    ***微信扫一扫,关注“python测试开发圈”,了解更多测试教程!***
  • 相关阅读:
    2016年5月27日上午(妙味课堂js基础-3笔记一(事件))
    2016年5月26日晚上(妙味课堂js基础-2笔记四(BOM))
    2016年5月26日晚上(妙味课堂js基础-2笔记三(DOM))
    2016年5月26日晚上(妙味课堂js基础-2笔记二(DOM))
    2016年5月26日下午(妙味课堂js基础-2笔记一(DOM))
    2016年5月26日下午(妙味课堂js基础-1笔记四)
    2016年5月26日下午(妙味课堂js基础-1笔记三)
    2016年5月26日上午(妙味课堂js基础-1笔记二)
    【Django】不知道为什么就是想学一下 01
    【Ubuntu】安装Java和Eclipse
  • 原文地址:https://www.cnblogs.com/guanfuchang/p/7779371.html
Copyright © 2020-2023  润新知