You are on page 1of 62

Section 1

Http Basics
1.1 HTTP Request-Response Model
 HTTP requests are stateless
 Web server doesn’t keep track of client’s (browser’s) state
 Every request from the browser is a new request to the server by default

Web Browser Web Server


1.2 HTTP Request-Response Model
 Saving session state
 Web server can store session state within server-side objects and
associate the session with a session-id

Web Browser Web Server


1.2 HTTP Request-Response Model
 Saving session state, continued
 Server passes the session-id back to the client
 Client uses one of the two mechanisms to store and pass session-id to
the server
 By maintaining a cookie with the session-id. Cookie value gets automatically passed
to the server with every request
 By manually passing the session-id as part of the url (url-rewriting)

Web Browser Web Server


1.2 HTTP Request-Response Model
 Saving session state, continued
 Client keeps track of the session-id and passes the session-id back to
the server with the next request
 Server retrieves the current session state by the session-id it receives
from the client and processes the request for that client

Web Browser Web Server

Jsessionid=122232234455
Section 2

Apache JMeter
Overview
2.1 What Is JMeter?
 A load testing tool for
 Http static and dynamic resources
 Webservices
 JDBC connections
 JMS
 LDAP
 FTP
 Generic TCP connections
 Just about anything a java program can access (virtually
everything)
 A functional testing tool for all of the above
applications
 A monitoring solution for all of the above
applications
2.1 What Is JMeter?
 Can operate in GUI mode and non-GUI mode
 GUI mode is used for building the scripts, testing
the scripts and viewing results (graphical, tabular or
textual results)
 GUI mode could also be used for running tests on
systems with enough memory and processing
speed allocated to
 Run the JMeter GUI
 Run threads for the test
 Run data collection and display windows (graphical,
tabular and textual)
2.1 What Is JMeter?
 Non-GUI mode is used for medium-high load test
cases and in cases where accuracy is important.
This mode does not need the memory and
processing speed to run and render the GUI
 Results get written to log (.jtl) files. GUI could be
used to open and view the results stored in a .jtl
file.
2.1 What Is JMeter?
 Can operate in Controller-Server mode
 Useful when a single Jmeter instance is unable to
generate heavy load (Threads)
 One system could be used as a controller and one
or more other systems could be used as load
generating servers
 Controller is responsible for distributing the tests to
the load serves, starting test, collecting and
consolidating the test results.
2.1 What Is JMeter?
 Can operate in Controller-Server mode
 Useful when a single Jmeter instance is unable to
generate heavy load (Threads)
 One system could be used as a controller and one
or more other systems could be used as load
generating servers
 Controller is responsible for distributing the tests to
the load serves, starting test, collecting and
consolidating the test results.
Section 3

Elements of JMeter
http://jmeter.apache.org/usermanual/component_reference.html
3.1 Test Plan
3.2 Thread Group
3.2 Thread Group
3.3 Samplers
 Used to send requests to servers
 Http Request
 FTP Request
 SOAP Request
 LDAP Request
 JDBC Request
 Java Objects
 And counting…
 Requires a Thread Group to execute the
sampler
3.3.1 Http Sampler
3.3.1 Http Sampler
3.4 Listeners
 Used to listen to test results
 Test results could be viewed in graphical, tabular or
textual formats
 Test results could be saved to log files
 Saved test results could be read and viewed
 Several types of listeners
 Aggregate Graph
 Aggregate Report
 Distribution Graph
 Summary Report
 Results in Table
 Results in Tree
 etc.
3.4.1 Aggregate Report & Results in Tree
3.4.2 Aggregate Report

 # Samples: Number of requests sent to the server for a given


sampler
 Average: Average response time in milliseconds
 Median: Median response time (50th percentile) in milliseconds
 90% Line: 90th percentile in milliseconds
 Min: Minimum response time in milliseconds
 Max: Maximum response time in milliseconds
 Error%: Percentage of Assertion errors
 Throughput: Number of samples per second (or per minute)
3.4.3 View Results in Tree
3.4.3 View Results in Tree
3.5 Configuration Elements
 Used to setup defaults and/or initialize variables
 Http Request Defaults
 Http Cookie Manager
 CSV Data Set Config
 Ftp Request Defaults
 Http Header Manager
 Java Request Defaults
 JDBC Connection Configuration
 User Defined Variables
 Random Variable
 Counter
 …
 Configuration elements are processed at the beginning
of the scope in which they are added
3.5.1 HTTP Request Defaults
 Http Request Defaults node could be used to
define default values for fields used by Http
Samplers
 Fields values left empty in Http Sampler would
be defaulted to the value defined in Http
Request Defaults
3.5.1 HTTP Request Defaults
3.5.1 HTTP Request Defaults
3.5.2 HTTP Cookie Manager
 Http Cookie Manager stores cookies coming
back from an Http response and sends the
cookies back to the server as part of
subsequent Http requests
 Cookies received and sent could be viewed by
adding View Results Tree listener
3.5.2 HTTP Cookie Manager
3.5.3 Reading Configuration Data from CSV file
3.5.3 Reading Configuration Data from CSV file
3.5.3 Reading Configuration Data from CSV file
3.6 Logic Controllers
 Used to define the order of sampler execution or to
organize/group samplers
 Simple Controller
 If Controller
 While Controller
 ForEach Controller
 Loop Controller
 Switch Controller
 Interleave Controller
 Module Controller
 Recording Controller
 …
3.6.1 Recording HTTP Transactions
 Http Proxy Server could be added to the
Workbench to intercept http transactions
 Intercepted http transactions could be
redirected to a “Recording Controller”
3.6.2 Recording Controller & Http Proxy Server
3.6.3 Simple Controller
3.6.3 Simple Controller
3.6.4 If Controller
3.6.4 If Controller
3.6.5 Module Controller
3.6.5 Module Controller
3.7 Pre-Processors
 Used to alter Sampler requests within the scope of
the sampler
 BeanShell PreProcessor
 BSF PreProcessor
 JDBC PreProcessor
 User Parameters
 HTML Link Parser
 HTTP URL Re-writing Modifier
 …
 In order to modify a specific sampler, add the pre-
processor node as a child of the sampler
3.7.1 BeanShell PreProcessor
3.7.1 BeanShell PreProcessor
3.7.1 BeanShell PreProcessor
3.8 Post-Processors
 Used to process Sampler responses within the
scope of the sampler
 Regular Expression Extractor
 Xpath Extractor
 BeanShell PostProcessor
 BSF PostProcessor
 Debug PostProcessor
 JDBC PostProcessor
 Result Status Action Handler
 …
 In order to post-process a specific sampler, add
the post-processor node as a child of the sampler
3.8.1 Regular Expression Extractor
3.8.1 Regular Expression Extractor
3.8.1 Regular Expression Extractor
3.8.2 Debug PostProcessor
3.8.2 Debug PostProcessor
3.8.2 Debug PostProcessor
3.9 Assertions
 Used to validate sampler response
 BeanShell Assertion
 BSF Assertion
 Response Assertion
 Duration Assertion
 Size Assertion
 Xpath Assertion
 …
 Asserts the response of all samplers in scope
 In order to assert a specific sampler, add the
assertion node as a child of the sampler
3.9.1 Response Assertion
3.9.1 Response Assertion
3.9.1 Response Assertion
3.10 Functions
 Special routines used to populate values
dynamically into a sample
 Takes the form

${__functionName(arg1, arg2,…)}
 JMeter comes loaded with several built-in
functions
(http://jmeter.apache.org/usermanual/functio
ns.html)
Section 4

JMeter Non-GUI
Mode Execution
4.1 Non-GUI Mode
 GUI mode should used to build the test scripts
and to test it with small loads
 Non-GUI mode should be used for extensive
and accurate load testing
 Non-GUI mode is triggered by the command-
line argument “–n”
Example,
cmd:> jmeter –n –t MyTest.jmx –l MyTest.jtl
4.1 Opening a Log File
4.2 Passing Properties In Non-GUI Mode
 Properties (Key-Value pairs) could be passed
into Jmeter test script using –D or –G
command-line option
Example,
cmd:> jmeter –n –t MyTest.jmx –l MyTest.jtl
–DserverName=qaweb –DcontextPath=qa1
4.2 Passing Properties In Non-GUI Mode

You might also like