E0 Training Material JMeter

Embed Size (px)

Citation preview

  • 8/13/2019 E0 Training Material JMeter

    1/34

    JMeterA Performance Testing Tool

    Date:08/09/2009

  • 8/13/2019 E0 Training Material JMeter

    2/34

    May 13, 20092

    Testing:Performance/Load/Stress

    Performance Testing

    - How fast an application perform under particular work load.

    - Validation,verification of quality attributes (scalability, reliability, resource

    usage)

    - Demonstrates that the system meets performance criteria.

    Load Testing

    - Modeling the expected usage by simulating multiple users accessing the web

    services concurrently

    - Raised beyond normal usage

    Stress Testing

    - Determination of stability of an application

    - Tries to break the application by overwhelming its resources

  • 8/13/2019 E0 Training Material JMeter

    3/34

    May 13, 20093

    Before Starting

    What is our estimated number of users (normal load)?

    What is our anticipated peak number of users?

    When is a good time to load-test our application(i.e. Off-hours or weekends) keeping

    in mind that this may very well crash one or more of our servers?

    What is the testing intended to achieve?

    Sequential

    Functional (low volume)

    Benchmark ( the average number of users)

    Load-test (the maximum number of users)

    Test destructively (what is our hard limit)

  • 8/13/2019 E0 Training Material JMeter

    4/34

  • 8/13/2019 E0 Training Material JMeter

    5/34

    May 13, 20095

    Introduction -Features

    100% pure Java Open Source Desktop application

    Designed for performance/functional/load/stress testing

    Extensible- write your own tests

    Pluggable sampler allows unlimited testing capabilities

    Simulate heavy load (application, server and network)

    Gives instant visual feedback

    Distributed testing

    Various protocols- HTTP, JDBC, LDAP, SOAP, JMS, FTP

    Multi-platform

    Full multi-threading framework

    Test plans can be stored in XML and can be version controlled

    Caching and offline analysis/ replaying of test results

  • 8/13/2019 E0 Training Material JMeter

    6/34

    May 13, 20096

    JMeter Installation - Requirements

    Java Version

    - Requires fully complaint JVM 1.4 or higher

    - Version 2.2 and later no longer support Java 1.3

    Operating system

    - JMeter is a 100% Java application and should runs correctly on any machine

    with complaint Java implementation

    - Tested and works under Unix (Solaris, Linux, etc)

    Windows (98, NT, XP, etc)

    Open VMS alpha 7.3+

  • 8/13/2019 E0 Training Material JMeter

    7/34

    May 13, 20097

    JMeter Installation Setting up and Running

    Make sure the system contains Java 1.4 or later

    Make sure JAVA_HOME environment variable set correctly

    Download the latest binary from Jakarta

    -http://jakarta.apache.org/jmeter/

    Unpack the zip or tar.gz in any directory

    Go to the Jakarta-JMeter directory (directory in which the zip or tar.gz file isunpacked)

    Type ./bin/jmeter on command prompt (for Unix) or Run jmeter.bat (for windows)

    JMeter is ready to test application

    http://jakarta.apache.org/jmeter/http://jakarta.apache.org/jmeter/http://jakarta.apache.org/jmeter/
  • 8/13/2019 E0 Training Material JMeter

    8/34

    May 13, 20098

    JMeter Installation Directory Structure

    The installation directory structure should look something like this (for version 2.3.1):

    jakarta-jmeter-2.3.1

    jakarta-jmeter-2.3.1/bin

    jakarta-jmeter-2.3.1/docs

    jakarta-jmeter-2.3.1/extras

    jakarta-jmeter-2.3.1/lib/

    jakarta-jmeter-2.3.1/lib/ext

    jakarta-jmeter-2.3.1/lib/junit

    jakarta-jmeter-2.3.1/printable_docs

    We could rename the parent directory (i.e. jakarta-jmeter-2.3.1) but do not changeany of the sub-directory names.

  • 8/13/2019 E0 Training Material JMeter

    9/34

    May 13, 20099

    JMeter -After Installation

  • 8/13/2019 E0 Training Material JMeter

    10/34

    May 13, 200910

    JMeter Running Using a Proxy Server

    JMeter should be provided with the firewall/proxy server hostname and port numberif testing is done behind a firewall/proxy server

    Run the jmeter.bat/jmeter file from a command line with the following parameters:

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

    Example : jmeter -H my.proxy.server -P 8000 -u username -a password -Nlocalhost

    Alternatively, you can use --proxyHost, --proxyPort, --username, and --password

  • 8/13/2019 E0 Training Material JMeter

    11/34

    May 13, 200911

    JMeter Running Non-GUI Mode (Command Line Mode)

    For non-interactive testing, run JMeter without the GUI by using following command

    options

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

    -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

    The script also lets you specify the optional firewall/proxy server information:

    -H [proxy server hostname or ip address]

    -P [proxy server port]

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

  • 8/13/2019 E0 Training Material JMeter

    12/34

  • 8/13/2019 E0 Training Material JMeter

    13/34

    May 13, 200913

    Elements of Testplan contd...

    Configuration elements

    Work closely with samplers

    Can add or modify requests

    Pre-processor elements

    Executes some action prior to a Sampler Request being made

    most often used to modify the settings of a Sample Request just before it

    runs

    or to update variables that aren't extracted from response text

    Post-processor elements

    executes some action after a Sampler Request has been made

    most often used to process the response data, often to extract values from

    it

  • 8/13/2019 E0 Training Material JMeter

    14/34

    May 13, 200914

    Elements of Testplan contd...

    Timers

    Specifies the delay between sending consecutive requests

    Listeners

    Used for result analysis

    Assertions

    Allow you to assert facts about responses received from the server being

    tested

  • 8/13/2019 E0 Training Material JMeter

    15/34

    May 13, 200915

    Elements of Testplan

    Thread Group Logic Controller

    Configuration Element

    Samplers

    Preprocessor Elements

    Post-processor Elements

    Timers

    ListenersAssertions

  • 8/13/2019 E0 Training Material JMeter

    16/34

    May 13, 200916

    Execution Order

    Timers

    Preprocessors

    Samplers

    Post-processors

    Assertions

    Listeners

  • 8/13/2019 E0 Training Material JMeter

    17/34

    May 13, 200917

    Building a Test Plan :Adding an element

    To add an element,

    Right click on an element

    in the tree Choose the new element

    from the add list

  • 8/13/2019 E0 Training Material JMeter

    18/34

    May 13, 200918

    Building a Test Plan : Loading and saving element

    To load the element,

    right click on the existing

    tree element select the "open" option

  • 8/13/2019 E0 Training Material JMeter

    19/34

    May 13, 200919

    Building a Test Plan :Saving the Test Plan

    To save the test plan,

    select Save Test Plan from

    the File menu

  • 8/13/2019 E0 Training Material JMeter

    20/34

    May 13, 200920

    Building a Test Plan :Running the Test Plan

    To run the test plan,

    Go to Run menu

    Choose StartOR

    Press Ctrl+R

  • 8/13/2019 E0 Training Material JMeter

    21/34

    May 13, 200921

    Building a Test Plan :Stopping the Test

    There are two types of Stopcommand,

    Stop (Control + '.') stops the threads

    immediately ifpossible

    Shutdown (Control + ',')

    requests the

    threads to stop atthe end of anycurrent work

  • 8/13/2019 E0 Training Material JMeter

    22/34

    May 13, 200922

    Building a Test plan :Error Reporting

    JMeter reports warnings and errors to the jmeter.log file and some information on

    the test run itself.

    Some errors which are unable to trap and log by JMeter would be appeared on the

    command console.

    Sampling errors (e.g. HTTP 404 - file not found) are not normally reported in the log

    file. Instead these are stored as attributes of the sample result. The status of asample result can be seen in the various different Listeners

  • 8/13/2019 E0 Training Material JMeter

    23/34

    May 13, 200923

    Life-cycle

    Plan TestCreate

    ThreadGroup

    Create Test

    Script

    Run Test

    Plan

    Analyze

    Results

    Test Plan ThreadGroup

    Schedulers

    Samplers Timers Listeners

  • 8/13/2019 E0 Training Material JMeter

    24/34

    May 13, 200924

    Analyzing Results

    JMeter supports this step by:

    displaying the data visually (Graph Results)

    save data in file

    allows user to see one multiple views of the data

    displays the response from the server.

    shows the URL of each sample taken .

    listeners will show different sets of data.

  • 8/13/2019 E0 Training Material JMeter

    25/34

    May 13, 200925

    Advantages

    It is free

    Easy to install and use

    Compared to other load and performance testing tools, it is not only for web

    application, but also for other servers or objects

    Test results can be shown in different formats

    Highly extensible

  • 8/13/2019 E0 Training Material JMeter

    26/34

    May 13, 200926

    Demo

  • 8/13/2019 E0 Training Material JMeter

    27/34

    May 13, 200927

    Building a Web test plan

    Adding Users

    Adding Default HTTP Request Properties

    Add HTTP Request

    Add listener to view store the Test Result

  • 8/13/2019 E0 Training Material JMeter

    28/34

    May 13, 200928

    Building a Web test plan Adding Users

  • 8/13/2019 E0 Training Material JMeter

    29/34

    May 13, 200929

    Building a Web test plan Adding Default HTTPRequest Properties

  • 8/13/2019 E0 Training Material JMeter

    30/34

    May 13, 200930

    Building a Web test plan Adding HTTP Request

  • 8/13/2019 E0 Training Material JMeter

    31/34

    May 13, 200931

    Building a Web test plan -Add listener to view store theTest Result

  • 8/13/2019 E0 Training Material JMeter

    32/34

    May 13, 200932

    Building a Web test plan Result Summary

  • 8/13/2019 E0 Training Material JMeter

    33/34

    May 13, 200933

    Tips

    Use timers to avoid hammering the server

    Limit the Number of Threads- Hardware will limit the number of threads you can effectively run. A faster machine makes

    JMeter work harder since it returns request quicker.

    User variables

    - Create a text file containing the user names and passwords.

    - Add a CSV DataSet configuration element. Name the variables USER and PASS. Use${USER} and ${PASS} within samplers.

    Reducing resource requirements

    - Use non-GUI mode.

    - Use as few Listeners as possible.

    - Reduce samplers by looping (by thread and by controller), and use variables (CSV DataSet) to vary the sample.

    - Use CSV output rather than XML.

  • 8/13/2019 E0 Training Material JMeter

    34/34

    Thank You !