JMeter Training Material

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 69

JMeter

A Performance Testing Tool


Date:05/01/2010

Introduction
Definition JMeter is an Apache Jakarta project that can be used as a load testing tool for analysing and measuring the performance of a variety of services, with a focus on web applications. Why JMeter JMeter can be used as a unit test tool for JDBC database connection, FTP,

LDAP, WebServices, JMS, HTTP and generic TCP connections. JMeter can also
be configured as a monitor, although this is typically considered an ad-hoc solution in lieu of advanced monitoring solutions.

May 13, 2009

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

May 13, 2009

JMeter License
JMeter comes under Apache Software License Version 2.0 The Apache License is a free-software license authored by the Apache Software Foundation (ASF). The Apache License (versions 1.0, 1.1, and 2.0) requires preservation of the

copyright notice and disclaimer, but it is not a copyleft license.


This means it allows use of the source code for the development of proprietary software as well as free and open source software. The complete license details for JMeter can be found here: http://jakarta.apache.org/jmeter/license.html

May 13, 2009

Elements of Test Plan


Thread Group Logic Controllers Samplers Configuration elements

Pre-processor elements
Post-processor elements Timers Listeners Assertions

May 13, 2009

Execution Order
Timers Preprocessors Samplers

Post-processors
Assertions Listeners

May 13, 2009

Functions and Variables


JMeter functions are special values that can populate fields of any Sampler or other element in a test tree. A function looks like ${__functionName(var1,var2,var3)}. A function with no parameter looks like ${__functionName}. If a function parameter contains a comma, then be sure to escape this with "\",

otherwise JMeter will treat it as a parameter delimiter. Example ${__time(EEE\, d


MMM yyyy)}. Variables are referenced as ${VARIABLE}. Variable and functions are all case-sensitive.

May 13, 2009

What can functions do ?


Two kinds of functions:

user-defined static values (or variables). built-in functions.

User-defined static values allow the user to define variables to be replaced with their
static value when a test tree is compiled and submitted to be run.

This replacement happens once at the beginning of the test run. Variables cannot be nested. With built-in functions users can compute new values at run-time based on previous response data.

These new values are generated fresh for every request throughout the course of the

test.

May 13, 2009

Where can functions and variables be used?


Functions and variables can be written into any field of any test component (apart from the TestPlan). Some fields do not allow random strings because they are expecting numbers, and thus will not accept a function. However, most fields will allow functions. Functions which are used on the Test Plan have some restrictions.

JMeter thread variables will have not been fully set up when the functions are
processed, so variable names passed as parameters will not be set up, and variable references will not work, so split() and regex() and the variable evaluation functions won't work.

The following functions should work OK on the test plan - intSum, longSum,
machineName, BeanShell, javaScript, jexl, random, time, property functions, log functions.

May 13, 2009

Functions
__functionless __counter __threadNum

__intSum
__longSum __StringFromFile __machineName __javaScript __Random __CSVRead

__property

10

May 13, 2009

Functions condt...
_P _log __logn __BeanShell __split

__Xpath
__setProperty __time __jexl __V

11

May 13, 2009

Functions condt...
__evalVar __eval __char __unescape __unescapeHtml

__escapeHtml

12

May 13, 2009

Pre-defined Variables
Most variables are set by calling functions or by test elements such as User Defined Variables. In user define variable the user has full control over the variable name

Some variables are defined internally by JMeter.


These are listed below.

Cookiename - contains the cookie value JMeterThread.last_sample_ok - whether or not the last sample was OK true/false

START variable

13

May 13, 2009

Building a Web test plan


Adding Users Adding Default HTTP Request Properties Add HTTP Request

Add listener to view store the Test Result

14

May 13, 2009

Building a Web test plan Adding Users

15

May 13, 2009

Building a Web test plan Adding Default HTTP


Request Properties

16

May 13, 2009

Building a Web test plan Adding HTTP Request

17

May 13, 2009

Building a Web test plan - Add listener to view store the


Test Result

18

May 13, 2009

Building a Advanced Web test plan


Handling User Sessions With URL Rewriting Using a Header Manager

19

May 13, 2009

Building a Advanced Web test plan - Handling User


Sessions With URL Rewriting
Web application uses URL rewriting rather than cookies to save session information. JMeter needs to parse the HTML received from the server and retrieve the unique session ID. Use the appropriate HTTP URL Re-writing Modifier to accomplish this. Simply enter the name of your session ID parameter into the modifier, and it will find and add it to each request.

If the request already has a value, it will be replaced. If "Cache Session Id?" is
checked, then the last found session id will be saved, and will be used if the previous HTTP sample does not contain a session id.

20

May 13, 2009

Building a Advanced Web test plan - Handling User


Sessions With URL Rewriting condt
A test plan is shown using URL rewriting.

The URL Re-writing modifier is added


to the SimpleController, thus assuring that it will only affect requests under that SimpleController.

21

May 13, 2009

Building a Advanced Web test plan - Handling User


Sessions With URL Rewriting condt
Request Parameters

22

May 13, 2009

Building a Advanced Web test plan - Using a Header


Manager
The HTTP Header Manager customizes information JMeter sends in the HTTP request header . This header includes properties like "User-Agent", "Pragma", "Referer" etc. The HTTP Header Manager ( like the HTTP Cookie Manager) should probably be added at the Thread Group level, unless different headers for the different HTTP Request objects in test is specified.

23

May 13, 2009

Building a Database Test Plan


Adding Users Adding JDBC Requests Adding a Listener to View/Store the Test Results

24

May 13, 2009

Building a Database Test Plan Adding User


A Thread Group with Default Value

25

May 13, 2009

Building a Database Test Plan Adding User condt


JDBC User Thread Group

26

May 13, 2009

Building a Database Test Plan Adding JDBC Requests


JDBC Configuration JMeter creates a database connection pool with the configuration settings as specified in the Control Panel. The pool is referred to in JDBC Requests in the 'Variable Name' field. Several different JDBC Configuration elements can be used, but they must have unique names. Every JDBC Request must refer to a JDBC Configuration pool. More than one JDBC Request can refer to the same pool.

27

May 13, 2009

Building a Database Test Plan Adding JDBC Requests


condt

JDBC Request

28

May 13, 2009

Building a Database Test Plan Adding JDBC Requests


condt

JDBC Request for Kodak stock

29

May 13, 2009

Building a Database Test Plan Adding JDBC Requests


condt

JDBC Request for Pfizer stock

30

May 13, 2009

Building a Database Test Plan Adding a Listener to


View/Store the Test Results
Graph results Listener

31

May 13, 2009

Building an FTP Test Plan


Adding Users Adding Default FTP Request Properties Adding FTP Requests Adding a Listener to View/Store the Test Results

32

May 13, 2009

Building an FTP Test Plan - Adding Users


O'Reilly Users Thread Group

33

May 13, 2009

Building an FTP Test Plan - Adding Default FTP Request


Properties
FTP Request Defaults

34

May 13, 2009

Building an FTP Test Plan - Adding Default FTP Request


Properties condt
FTP Defaults for our Test Plan

35

May 13, 2009

Building an FTP Test Plan - Adding FTP Requests


FTP Request for O'Reilly mSQL Java README file

36

May 13, 2009

Building an FTP Test Plan - Adding FTP Requests condt


FTP Request for O'Reilly mSQL Java tutorial file

37

May 13, 2009

Building an FTP Test Plan - Adding a Listener to


View/Store the Test Results
Spline Visualizer Listener

38

May 13, 2009

Building an LDAP Test Plan


Adding Users Adding Login Config Element Adding LDAP Request Defaults Adding LDAP Requests Inbuilt Add Test Inbuilt Modify Test Inbuilt Delete Test Inbuilt Search Test Adding a Listener to View/Store the Test Results

39

May 13, 2009

Building an LDAP Test Plan - Adding Users


Thread Group with Default Values

40

May 13, 2009

Building an LDAP Test Plan - Adding Login Config


Element
Login Config Element for our Test Plan

41

May 13, 2009

Building an LDAP Test Plan Adding LDAP Request


Defaults
LDAP Defaults for our Test Plan

42

May 13, 2009

Building an LDAP Test Plan Adding LDAP Requests


Four LDAP request can be added.

Inbuilt Add Test Inbuil Modify Test Inbuilt Delete Test Inbuilt Search Test

JMeter sends requests in the order that you add them to the tree

43

May 13, 2009

Building an LDAP Test Plan Adding LDAP Requests


condt

LDAP Request for Inbuilt Add test LDAP Request for Inbuilt Modify test

44

May 13, 2009

Building an LDAP Test Plan Adding LDAP Requests


condt

LDAP Request for Inbuilt Delete test LDAP Request for Inbuilt Search test

45

May 13, 2009

Building an LDAP Test Plan Adding a Listener to


View/Store the Test Results
View result in Table Listener

46

May 13, 2009

Building an Extended LDAP Test Plan


Adding Users Adding LDAP Extended Request Defaults Adding LDAP Requests Adding a Thread bind Request Adding a search Request Adding a Compare Request Adding a Single bind/unbind Adding an Add Request Adding a Modify Request Adding a Delete Request Adding a Rename Request (moddn) Adding an unbind Request Adding a Listener to View/Store the Test Results

47

May 13, 2009

Building an Extended LDAP Test Plan - Adding Users


Thread Group with Default Values

48

May 13, 2009

Building an Extended LDAP Test Plan - Adding LDAP


Extended Request Defaults
LDAP Defaults for our Test Plan

49

May 13, 2009

Building an Extended LDAP Test Plan - Adding LDAP


Request

Nine LDAP request can be added.

Adding a Thread bind Request Adding a search Request Adding a Compare Request Adding a Single bind/unbind Adding an Add Request Adding a Modify Request Adding a Delete Request Adding a Rename Request (moddn) Adding an unbind Request

JMeter sends requests in the order that you add them to the tree.

50

May 13, 2009

Building an Extended LDAP Test Plan - Adding LDAP


Request condt
Adding a Thread bind Request

51

May 13, 2009

Building an Extended LDAP Test Plan - Adding LDAP


Request condt
Adding a Search Request

52

May 13, 2009

Building an Extended LDAP Test Plan - Adding LDAP


Request condt
Adding a Compare Request

53

May 13, 2009

Building an Extended LDAP Test Plan - Adding LDAP


Request condt
Adding a Single bind/unbind

54

May 13, 2009

Building an Extended LDAP Test Plan - Adding LDAP


Request condt
Adding an Add Request

55

May 13, 2009

Building an Extended LDAP Test Plan - Adding LDAP


Request condt
Adding a Modify Request

56

May 13, 2009

Building an Extended LDAP Test Plan - Adding LDAP


Request condt
Adding a Delete Request

57

May 13, 2009

Building an Extended LDAP Test Plan - Adding LDAP


Request condt
Adding a Rename Request (moddn)

58

May 13, 2009

Building an Extended LDAP Test Plan - Adding LDAP


Request condt
Adding an unbind Request

59

May 13, 2009

Building an Extended LDAP Test Plan - Adding a


Listener to View/Store the Test Results
View result Tree Listener

60

May 13, 2009

Building a WebService Test Plan


Adding Users Adding WebService Requests Adding a Listener to View Store the Test Results

61

May 13, 2009

Building a WebService Test Plan - Adding Users


Jakarta Users Thread Group

62

May 13, 2009

Building a WebService Test Plan - WebService


Requests

63

May 13, 2009

Building a WebService Test Plan - Building a


WebService Test Plan
Graph Results Listener

64

May 13, 2009

Case Study
Create and run a Database test plan to test Mysql database server. OR Create and run a FTP test plan to test a FTP site.

65

May 13, 2009

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

66

May 13, 2009

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 Data Set) to vary the sample. Use CSV output rather than XML.

67

May 13, 2009

References
JMeter has 2 types of mailing list

The JMeter User List The JMeter Developer List

To subscribe to any mailing list

http://jakarta.apache.org/site/mail2.html

68

May 13, 2009

Thank You !

You might also like