Session 2
Session 2
Contents
I. GUI overview.....................................................................................................................................1
II. Test plans and components............................................................................................................2
1. ThreadGroup.................................................................................................................................2
2. Samplers........................................................................................................................................3
3. Logic controllers............................................................................................................................4
4. Listeners.........................................................................................................................................5
5. Timers.............................................................................................................................................5
6. Assertions......................................................................................................................................6
7. Configuration nodes......................................................................................................................6
8. Pre processors..............................................................................................................................7
9. Post processors.............................................................................................................................8
III. Practice Scenario..........................................................................................................................8
1. Scenario 1: Hard code to create a simple test..........................................................................8
2. Scenario 2: E...............................................................................................................................19
3. Scenario 3: Timer........................................................................................................................21
3.1. Constant Timer....................................................................................................................21
3.2. Uniform Random Timer......................................................................................................23
4. Scenario 4: CSV data set...........................................................................................................24
5. Scenario 5: Condition controller................................................................................................29
5.1. Loop controller.....................................................................................................................29
5.2. While controller....................................................................................................................31
6. Scenario 6: Pre-Processor.........................................................................................................33
6.1. User Paramerters................................................................................................................33
IV. JMeter best practices.................................................................................................................35
1
Performance testing sharing
I. GUI overview
2
Performance testing sharing
• Number of threads: The number of threads that are going to be used to execute
the test plan, very important to configure load and stress tests.
• Ramp-up period: Time that JMeter will need to start all threads.
• Loop count: Number of iterations, that is the amount of times that the test is
going to be executed.
• Error behavior: What to do in case of error: Stop current thread, stop the whole
test, continue...
A Thread Group has also the start and end time configuration options. By clicking the
checkbox "Scheduler" a new section with the schedule parameters will appear and you
can configure the start and end time of your test.
Once this is configured you can start adding other test plan elements to your Thread
group like samplers, listener and timers. We are going to explain all these in the next
chapters.
2. Samplers
Samplers are used for sending requests to different kind of servers. They are the basic
element of every test plan and everything works around them: they execute requests
(based on the configuration provided) and these requests produce one or more
responses that are analyzed afterwards.
Here is a list of the Samplers available in JMeter (we are going to see some of them in
this tutorial):
• Access log sampler
• AJP sampler
• Bean shell sampler
• BSF sampler
• Debug sampler
• FTP sampler
• HTTP sampler
• Java sampler
• JDBC sampler
• JMS (several) samplers
• JSR223 sampler
3
Performance testing sharing
• JUnit sampler
• LDAP (several) samplers
• Mail Reader
• MongoDB sampler
• OS process sampler
• SMTP sampler
• SOAP
• TCP samplers
• Test action
As we can see in the list above, there are a lot of different types of samplers; this list is
not complete since there are several others implemented in different JMeter plugins.
The configuration of each sampler depends on the request that it executes; that means
that some samplers have things in common but others are completely different because
of the nature of their requests.
3. Logic controllers
Logic controllers are elements that allow you to configure the order of execution of
different samplers inside a Thread group. This list contains all available logic controllers
in JMeter:
• Simple Controller
• Loop Controller
• Once Only Controller
• Interleave Controller
• Random Controller
• Random Order Controller
• Throughput Controller
• Runtime Controller
• If Controller
• While Controller
• Switch Controller
• ForEach Controller
• Module Controller
4
Performance testing sharing
• Include Controller
• Transaction Controller
• Recording Controller
4. Listeners
Listeners provide different ways to view the results produced by a Sampler requests.
Listeners parse results in form of tables, trees or plain log files.
They can be added anywhere in a test plan, but they will only parse and collect result
data from the samplers at their level or in the levels bellow.
These are the available listeners in JMeter:
• Sample Result Save Configuration
• Graph Full Results
• Graph Results
• Spline Visualizer
• Assertion Results
• View Results Tree
• Aggregate Report
• View Results in Table
• Simple Data Writer
• Monitor Results
• Distribution Graph (alpha)
• Aggregate Graph
• Mailer Visualizer
• BeanShell Listener
• Summary Report
5. Timers
You can define the time period that you want to wait between requests using timers. If
you do not specify any, JMeter will execute the next request immediately after the
current one is finished, without any waiting time.
Following timers are available in JMeter:
• Constant Timer
• Gaussian Random Timer
5
Performance testing sharing
6
Performance testing sharing
belong to, before the samplers are executed, that is why the samplers can rely on these
variables.
Here is a list of all the configuration nodes that can be used in JMeter:
• Counter
• CSV Data Set Config
• FTP Request Defaults
• HTTP Authorization Manager
• HTTP Cache Manager
• HTTP Cookie Manager
• HTTP Proxy Server
• HTTP Request Defaults
• HTTP Header Manager
• Java Request Defaults
• Keystore Configuration
• JDBC Connection Configuration
• Login Config Element
• LDAP Request Defaults
• LDAP Extended Request Defaults
• TCP Sampler Config
• User Defined Variables
• Simple Config Element
• Random Variable
8. Pre processors
Pre processors are elements (actions, assertions or basically whatever) that are going
to happen before a sampler is executed. They can be used to extract variables from a
response that can be used in the sampler afterwards via configuration elements.
These are the elements that can be used as pre processors:
• HTML Link Parser
• HTTP URL Re-writing Modifier
• HTTP User Parameter Modifier
• User Parameters
7
Performance testing sharing
• JDBC PreProcessor
• JSR223 PreProcessor
• RegEx User Parameters
• BeanShell PreProcessor
• BSF PreProcessor
9. Post processors
A post processor is basically an element that is executed after a sampler execution
finishes. It can be used to parse the response data and extract values that can be used
afterwards.
These elements can be used as post processors:
• Regular Expression Extractor
• XPath Extractor
• Result Status Action Handler
• JSR223 PostProcessor
• JDBC PostProcessor
• BSF PostProcessor
• CSS/JQuery Extractor
• BeanShell PostProcessor
8
Performance testing sharing
9
Performance testing sharing
10
Performance testing sharing
11
Performance testing sharing
12
Performance testing sharing
13
Performance testing sharing
14
Performance testing sharing
15
Performance testing sharing
16
Performance testing sharing
17
Performance testing sharing
18
Performance testing sharing
19
Performance testing sharing
"Auth_token: (.*?)"
{"cookie":"${access_token}","flag":true}
20
Performance testing sharing
3. Scenario 3: Timer
3.1. Constant Timer
21
Performance testing sharing
22
Performance testing sharing
23
Performance testing sharing
24
Performance testing sharing
25
Performance testing sharing
26
Performance testing sharing
27
Performance testing sharing
28
Performance testing sharing
29
Performance testing sharing
30
Performance testing sharing
31
Performance testing sharing
32
Performance testing sharing
6. Scenario 6: Pre-Processor
6.1. User Paramerters
33
Performance testing sharing
34
Performance testing sharing
35