Jmeter Understanding
Jmeter Understanding
Document
Document
Document Revision History
Document Revision History
Created/
Created/ Modified Modified By By Reviewed Reviewed By By DateDate Vikas Singh
Table of Contents Table of Contents Introduction
Introduction ... ... 33 Getting
Getting Started Started ... ... 33 Requirements
Requirements ... ... 33 Apache
Apache JMeter JMeter Step-by-step Step-by-step ... 3... 3 Basic
Basic Proxy Proxy Instructions Instructions ... 3... 3 Configure y
Configure your our browser to browser to use use the the JMeter HTTP JMeter HTTP Proxy ...Proxy ... ... 77 Record
Record your your navigation navigation ... 9... 9 Start
Start the the test test ... . 1010 Building
Building a a Web Web Test Test Plan Plan ... 11. 11 Adding
Adding Users Users ... . 1111 Adding
Adding Default Default HTTP HTTP Request Request Properties...Properties... 12... 12 Adding
Adding Cookie Cookie Support Support ... . 1212 Adding
Adding HTTP HTTP Requests Requests ... . 1212 Adding
Adding a a Listener Listener to to View View Store Store the the Test Test Results Results ... ... 1414 Building
Building an an API API Test Test Plan Plan ... 14. 14 Adding
Adding Users Users ... . 1515 Adding
Adding the the Http Http Sampler ...Sampler ... 15... 15 Adding
Adding the the CSV CSV Data Data Set Set Config Config ... 17. 17 Add
Add Assertions Assertions ... ... 1818 Building
Building a a WebService WebService Test Test Plan ...Plan ... 21. 21 Adding
Adding Users Users ... . 2121 Adding
Adding WebService WebService Requests Requests ... ... 2121 Adding
Adding a a Listener to Listener to View View Store Store the the Test Test Results Results ... ... 2222 Building
Building a a Database Database Test Test Plan ...Plan ... 22... 22 Adding
Adding Users Users ... . 2222 Adding
Adding JDBC JDBC Requests Requests ... . 2323 Adding
Adding a a Listener to Listener to View/Store View/Store the the Test Test Results ...Results ... . 2626 Correlation
Correlation in in Jmeter Jmeter ... 26... 26 Steps
Steps of of Correlation: Correlation: ... 27... 27 Jmeter
Jmeter Parameterization Parameterization ... . 2929 Apache
Introduction
Introduction
Apache Jmeter
Apache Jmeter is a 100% pure Java desktop application designed to load test client/server softwareis a 100% pure Java desktop application designed to load test client/server software (such as a
(such as a web application). It may be used web application). It may be used to test performance both on static and to test performance both on static and dynamic resourcesdynamic resources such as static
such as static files, Java Servlets, CGI scripts, Java objects,files, Java Servlets, CGI scripts, Java objects, databases,databases, FTP servers, and more. Jmeter canFTP servers, and more. Jmeter can be used to simulate a heavy load on a server, network or object to test its strength or to analyze overall be used to simulate a heavy load on a server, network or object to test its strength or to analyze overall performance under different load types.
performance under different load types.
Additionally, Jmeter can help you regression test your application by letting you create test scripts Additionally, Jmeter can help you regression test your application by letting you create test scripts with
with assertions tassertions to validate that your application is returning the results you expect. For maximumo validate that your application is returning the results you expect. For maximum flexibility, Jmeter lets you create these assertions using regular expressions.
flexibility, Jmeter lets you create these assertions using regular expressions.
Getting Started
Getting Started
The easiest way to begin using JMeter is to first
The easiest way to begin using JMeter is to first download the latest production releasedownload the latest production release and install it.and install it. The release contains all of the files you need to
The release contains all of the files you need to build and run most types of tests, e.g. Webbuild and run most types of tests, e.g. Web (HTTP/HTTPS), FTP, JDBC, LDAP, Java, and JUnit.
(HTTP/HTTPS), FTP, JDBC, LDAP, Java, and JUnit.
Requirements
Requirements
JMeter requires a fully compliant JVM 1.5 or higher.JMeter requires a fully compliant JVM 1.5 or higher.
JMeter is a 100% Java application and should run correctly on any system that has a JMeter is a 100% Java application and should run correctly on any system that has a compliantcompliant
Java implementation. Java implementation.
Operating systems tested with JMeter can be view onOperating systems tested with JMeter can be view on this pagethis page on JMeter wiki.on JMeter wiki.
Even if your OS is not listed on the wiki page, JMeter should run on it provided that the JVM isEven if your OS is not listed on the wiki page, JMeter should run on it provided that the JVM is
compliant. compliant.
Apache JMeter Step-by-step
Apache JMeter Step-by-step
Basic Proxy Instructions
Basic Proxy Instructions
1. Go to JMETER_HOME/bin and start JMeter with jmeter.bat on Windows 1. Go to JMETER_HOME/bin and start JMeter with jmeter.bat on Windows 2. Select “Test Plan” on the tree
2. Select “Test Plan” on the tree 3. Right click on the “Test
3. Right click on the “Test Plan”Plan”and add a new thread group:and add a new thread group: Add > Threads (Users) > Add > Threads (Users) > Thread Group
4. Select the Thread Group 4. Select the Thread Group 5. Right click “Add
5. Right click “Add-> Config Element --> Config Element -> HTTP Request Defaults”> HTTP Request Defaults”
6. In new HTTP Request Defaults element: Server name
6. In new HTTP Request Defaults element: Server name – – enter “jmeter.apache.org”enter “jmeter.apache.org” 7. Path
7. Path – –leave blankleave blank
8. Right click on the “Thread Gr
8. Right click on the “Thread Group” and add a recording controller: Add > Logic oup” and add a recording controller: Add > Logic Controller >RecordingController >Recording Controller
9. Next, select Workbench 9. Next, select Workbench
10. Right click on Workbench and add the Http proxy: Add -> Non-Test Elements -> HTTP Proxy Server 10. Right click on Workbench and add the Http proxy: Add -> Non-Test Elements -> HTTP Proxy Server
11. On HTTP Proxy Server, click
11. On HTTP Proxy Server, click the “Add” button in “URL Patterns to Ithe “Add” button in “URL Patterns to I nclude”. This willnclude”. This will Create a blank entry.
Create a blank entry. 12. Enter “.*
12. Enter “.*\\.html”.html” 13. Click 3 times, the
13. Click 3 times, the “Add” button in “URL Patterns to Exclude”. This will create “Add” button in “URL Patterns to Exclude”. This will create 3 blank3 blank Entries.
Entries. 14. Enter “.*
15. Right click on “HTTP Proxy Server”
15. Right click on “HTTP Proxy Server” and add a listener: Addand add a listener: Add-> Listener -> View Results Tree-> Listener -> View Results Tree
16. Return to HTTP Proxy Server, and click the “Start” button at the bottom 16. Return to HTTP Proxy Server, and click the “Start” button at the bottom
Configure your browser to use the JMeter HTTP Proxy
Configure your browser to use the JMeter HTTP Proxy
At this point, JMeter's proxy is running. For this exercise, we will use Iceweasel/Firefox /IE to view some At this point, JMeter's proxy is running. For this exercise, we will use Iceweasel/Firefox /IE to view some pages on JMeter.
pages on JMeter.
13. Start Iceweasel/Firefox, but do not close JMeter. 13. Start Iceweasel/Firefox, but do not close JMeter. 14. From the tool bar, click “Edit
14. From the tool bar, click “Edit -> Preferenc-> Preferences” (or “Tools > Preferences”). This should bringes” (or “Tools > Preferences”). This should bringup theup the options.
options.
15. Select the “Advanced” tab, and “Network” tab 15. Select the “Advanced” tab, and “Network” tab 16. Click “Settings” button near the bottom. 16. Click “Settings” button near the bottom.
17. On the new popup, check
17. On the new popup, check “Manual proxy configuration”. The address and port fields“Manual proxy configuration”. The address and port fields should be enabled now.
should be enabled now. 18. Address
18. Address – – enter “localhost” or the IP address oenter “localhost” or the IP address of your systemf your system 19. Port
19. Port – – enter “8080”.enter “8080”. 20. Check “Use this proxy ser
20. Check “Use this proxy server for all protocols”ver for all protocols”
21. Click “ok” button 21. Click “ok” button
22. Click “ok” button again. This should return you to the
22. Click “ok” button again. This should return you to the browserbrowser
Record your navigation
Record your navigation
23. With your brows
23. With your browser, in the “Address” bar at the top, enterer, in the “Address” bar at the top, enter “http://jmeter.apache.org/index.html”“http://jmeter.apache.org/index.html” and hit the “enter” key.
and hit the “enter” key. 24. Click on a few links on
24. Click on a few links on JMeter's pages.JMeter's pages.
25. Close your browser and bring up the JMeter window. Expand the thread group and there should be 25. Close your browser and bring up the JMeter window. Expand the thread group and there should be several samplers. At this point, the test plan can be saved as is. If
several samplers. At this point, the test plan can be saved as is. If you forget to add default http requestyou forget to add default http request settings, you will have to manually delete the server name, and port.
settings, you will have to manually delete the server name, and port.
In this sample, there aren't any
In this sample, there aren't any default request parameterdefault request parameters. If a s. If a particular request parameparticular request parameter is requiredter is required by all
by all pages, the request defaults are where one would add pages, the request defaults are where one would add the entries.the entries. 25. Select “Thread Group”
25. Select “Thread Group” 26. Right click “Add
26. Right click “Add-> Listener --> Listener -> Summary Report” to add an summary listener.> Summary Report” to add an summary listener.
27. The summary listener will show some basic statistics. 27. The summary listener will show some basic statistics.
27. Select “Thread Group” 27. Select “Thread Group” 28. Number of Threads
28. Number of Threads – – enter “5”enter “5” 29. Ramp up Period
29. Ramp up Period – –do not changedo not change 30. Loop Count
30. Loop Count – –enter 100enter 100
Start the test
Start the test
At this point, we are ready to run our test plan and see what happens. Save the test plan. At this point, we are ready to run our test plan and see what happens. Save the test plan. When you're ready to run the test, there's two ways:
When you're ready to run the test, there's two ways: 1. Run -> Start
1. Run -> Start 2. Ctrl
2. Ctrl – –RR
Before you start the test, select “Summary Report”. As the test runs, the statistics will change Before you start the test, select “Summary Report”. As the test runs, the statistics will change until the test is done. At the end of
until the test is done. At the end of the test, the summary report should look like this.the test, the summary report should look like this.
While the test is running, in the upper right-hand corner, there should be a green square. While the test is running, in the upper right-hand corner, there should be a green square. When the test is done, the box should be grey.
Building a Web Test Plan
Building a Web Test Plan
In this section, you will learn how to create a basic
In this section, you will learn how to create a basic Test Plan tTest Plan to test a Web site. You will create five userso test a Web site. You will create five users that send requests to two pages on the JMeter Web site.
that send requests to two pages on the JMeter Web site.
Adding Users
Adding Users
The first step you want to do with every JMeter Test Plan is to
The first step you want to do with every JMeter Test Plan is to add aadd a Thread GroupThread Group element. The Threadelement. The Thread Group tells JMeter the number of
Group tells JMeter the number of users you want to simulate, how often the users you want to simulate, how often the users should sendusers should send requests, and the how many requests they should
requests, and the how many requests they should send.send.
Go ahead and add the Thread Group element by first selecting the Test Plan, clicking your right mouse Go ahead and add the Thread Group element by first selecting the Test Plan, clicking your right mouse button to get the Add menu, and then
button to get the Add menu, and then select Add --> Thread Group.select Add --> Thread Group.
For example, if you enter a Ramp-Up Period of 5 seconds, JMeter will finish starting all of your users by For example, if you enter a Ramp-Up Period of 5 seconds, JMeter will finish starting all of your users by the end of the 5 seconds. So, if
the end of the 5 seconds. So, if we have 5 users and a 5 we have 5 users and a 5 second Ramp-Up Period, then the delaysecond Ramp-Up Period, then the delay
between starting users would be 1 second (5 users / 5 seconds = 1 user per second). If you set the value between starting users would be 1 second (5 users / 5 seconds = 1 user per second). If you set the value to 0, then JMeter will immediately start all of your users.
to 0, then JMeter will immediately start all of your users.
Finally enter a value of 2 in the Loop Count field. This property tells JMeter how many times to repeat Finally enter a value of 2 in the Loop Count field. This property tells JMeter how many times to repeat your test. If you enter a loop count value of
your test. If you enter a loop count value of 1, then JMeter will run your test only once.1, then JMeter will run your test only once. To have JMeter repeatedly run your Test Plan, select the Forever checkbox.
Adding Default HTTP R
Adding Default HTTP Request Properties
equest Properties
Now that we have defined our users, it is time to define the tasks that they will be performing. In this Now that we have defined our users, it is time to define the tasks that they will be performing. In this section, you will specify the default settings for your
section, you will specify the default settings for your HTTP requests. And then, in section 5.3, you HTTP requests. And then, in section 5.3, you willwill add HTTP Request elements which use some of the default settings you specified here.
add HTTP Request elements which use some of the default settings you specified here.
Begin by selecting the JMeter Users (Thread Group) element. Click your right mouse button to get the Begin by selecting the JMeter Users (Thread Group) element. Click your right mouse button to get the Add menu, and then
Add menu, and then select Add --> Config Element --> HTTP Request Defaults.select Add --> Config Element --> HTTP Request Defaults. Then, select this newThen, select this new element to view its Control Panel
element to view its Control Panel
The HTTP Request Defaults element does not tell JMeter to send an HTTP request. It simply defines the The HTTP Request Defaults element does not tell JMeter to send an HTTP request. It simply defines the default values that the HTTP Request elements use.
default values that the HTTP Request elements use.
Adding Cookie Support
Adding Cookie Support
Nearly all web testing should use
Nearly all web testing should use cookie support, unless your application specifically doesn't usecookie support, unless your application specifically doesn't use cookies. To add cookie support, simply add an
cookies. To add cookie support, simply add an HTTP Cookie ManagerHTTP Cookie Manager to eachto each Thread GroupThread Group in your testin your test plan. This will ensure that each thread gets its own cookies, but shared across all
plan. This will ensure that each thread gets its own cookies, but shared across all HTTP RequestHTTP Request objects.objects. To add the
To add the HTTP Cookie ManagerHTTP Cookie Manager , simply select the, simply select the Thread Group ,Thread Group , and choose Add --> Config Element -and choose Add > Config Element --> HTTP Cookie Manager, either from the Edit Menu, or from the right-click pop-up menu.
-> HTTP Cookie Manager, either from the Edit Menu, or from the right-click pop-up menu.
Adding HTTP Requests
Adding HTTP Requests
In our Test Plan, we need to make two HTTP requests. The first one is for the JMeter home page In our Test Plan, we need to make two HTTP requests. The first one is for the JMeter home page (http://jmeter.apache.org/), and the second one is for the Changes page
(http://jmeter.apache.org/), and the second one is for the Changes page (http://jmeter.apache.org/changes.html)
Start by adding the first
Start by adding the first HTTP RequestHTTP Request to the JMeter Users element (Add --> Sampler --> HTTP Request).to the JMeter Users element (Add --> Sampler --> HTTP Request). Then, select the HTTP Request element in the tree and edit the following properties
Then, select the HTTP Request element in the tree and edit the following properties
Change the Name field to "Home Page".Change the Name field to "Home Page".
Set the Path field to "/". Remember that you do not have to set the Server Name field becauseSet the Path field to "/". Remember that you do not have to set the Server Name field because
you already specified this value in the HTTP Request Defaults element. you already specified this value in the HTTP Request Defaults element.
Next, add the second HTTP Request and edit the following properties Next, add the second HTTP Request and edit the following properties
Change the Name field to "Changes".Change the Name field to "Changes".
Adding a Listener to View Store the
Adding a Listener to View Store the Test Results
Test Results
The final element you need to add to your Test Plan
The final element you need to add to your Test Plan is ais a Listener.Listener. This element is responsible for storingThis element is responsible for storing all of the results of your
all of the results of your HTTP requests in a file and presenting a visual model of the data.HTTP requests in a file and presenting a visual model of the data. Select the JMeter Users element and add a
Select the JMeter Users element and add a Graph ResultsGraph Results listener (Add --> Listener --> listener (Add --> Listener --> SummarySummary Results).
Results).
Building an API Test Plan
Building an API Test Plan
In this section, you will learn how to create a
In this section, you will learn how to create a Test Plan tTest Plan to test a yahoo weather API.o test a yahoo weather API.
To show the how to create the API Test Plan i am using Yahoo Weather API for Demo purpose. To show the how to create the API Test Plan i am using Yahoo Weather API for Demo purpose.
http://weather.yahooapis.com/forecastrss?w=2442047&u=c http://weather.yahooapis.com/forecastrss?w=2442047&u=c Input 1 :
Input 1 : W = 2442047 >>> Location IdW = 2442047 >>> Location Id Input 2
Input 2: u = c >> Celsius( Temp ): u = c >> Celsius( Temp ) If User direct Request the
If User direct Request the above url then it would return respabove url then it would return response like :onse like : Yahoo! Weather - Los Angeles, CA
Yahoo! Weather - Los Angeles, CA Yahoo! Weather for Los Angeles, CA Yahoo! Weather for Los Angeles, CA
Conditions for Los Angeles, CA at 6:47 pm PST Friday, December 14, 2012 8:17 AM Conditions for Los Angeles, CA at 6:47 pm PST Friday, December 14, 2012 8:17 AM Current Conditions: Current Conditions: Fair, 12 C Fair, 12 C Forecast: Forecast:
Thu - Partly Cloudy. High: 16 Low: 8 Thu - Partly Cloudy. High: 16 Low: 8 Fri - Partly Cloudy. High: 14 Low: 9 Fri - Partly Cloudy. High: 14 Low: 9 Full Forecast at Yahoo! Weather Full Forecast at Yahoo! Weather (provided by The
(provided by The Weather Channel)Weather Channel)
To Automate the above requirement follow the Step below : To Automate the above requirement follow the Step below :
Adding Users
Adding Users
Add the Thread Group (Test plan
Add the Thread Group (Test plan >>Thread Group>>Thread Group
Adding the Http Sampler
Adding the Http Sampler
Add the Http Sampler (Thread Group >>Add>>Sampler HTTP Request) and add the Server name/ IP= Add the Http Sampler (Thread Group >>Add>>Sampler HTTP Request) and add the Server name/ IP= weather.yahooapis.com
1.
1. Now Server name/ IP= weather.yahooapiNow Server name/ IP= weather.yahooapis.com ,w=2442047 and s.com ,w=2442047 and u =c u =c need to beneed to be parameterized
Adding the CSV Data Set Config
Adding the CSV Data Set Config
Add CSV Data Set Config (Http Request >>Config Element>> CSV Data Set Config) provide the Add CSV Data Set Config (Http Request >>Config Element>> CSV Data Set Config) provide the File name of csv file and Variables location, format
Refer screenshot for details Refer screenshot for details
2.
2. Add Test data in CSV FileAdd Test data in CSV File
Add Assertions
Add Assertions
To verify the API is working or not Add the Assertion To verify the API is working or not Add the Assertion Response Assertion
In this case you can add the Location name in text response Pattern and parameterize In this case you can add the Location name in text response Pattern and parameterize the assertion text. Refer Snapshot below
the assertion text. Refer Snapshot below
Add XPath Assertion
Add XPath Assertion: To Verify the Nodes of XML (Http Request >>Assertions>> XPath: To Verify the Nodes of XML (Http Request >>Assertions>> XPath Assertion)
Assertion)
XML Schema Assertion
XML Schema Assertion>>To Verify the XML w.r.t to Schema (Http Request >>Assertions>> XML>>To Verify the XML w.r.t to Schema (Http Request >>Assertions>> XML Schema Assertion)
Schema Assertion)
Provide the Schema file name and Location Provide the Schema file name and Location..
XML Assertion:
XML Assertion: To Verify XML Format (Http Request >>Assertions>> XML Assertion)To Verify XML Format (Http Request >>Assertions>> XML Assertion)
Assertion Results:
Building a WebService Test Plan
Building a WebService Test Plan
In this section, you will learn how to create a Test Plan to test a
In this section, you will learn how to create a Test Plan to test a WebServiceWebService..
Adding Users
Adding Users
The first step you want to do with every JMeter Test Plan is to add a Thread Group element. The Thread The first step you want to do with every JMeter Test Plan is to add a Thread Group element. The Thread Group tells JMeter the number of
Group tells JMeter the number of users you want to simulate, how often the users you want to simulate, how often the users should sendusers should send requests, and the how many requests they should
requests, and the how many requests they should send.send.
Adding WebService Requests
Adding WebService Requests
Start by adding the sampler WebService (SOAP) Request to the Jakarta Users element (Add > Sampler Start by adding the sampler WebService (SOAP) Request to the Jakarta Users element (Add > Sampler --> WebService (SOAP) Request). Then, select the webservice Request element in the tree and edit the -> WebService (SOAP) Request). Then, select the webservice Request element in the tree and edit the following properties
following properties 1.
1. Change the Name field to "WebService (SOAP) Request".Change the Name field to "WebService (SOAP) Request". 2.
2. Enter the WSDL URL and click "Load WSDL".Enter the WSDL URL and click "Load WSDL".
If the WSDL file
down remains blank, it means there was a problem getting the WSDL. You can test the WSDL using a down remains blank, it means there was a problem getting the WSDL. You can test the WSDL using a browser that reads XML. For example, if you're testing an IIS webservice the URL will look like this: browser that reads XML. For example, if you're testing an IIS webservice the URL will look like this: http://localhost/myWebService/Service.asmx?WSDL. At this point, SOAPAction, URL and SOAP Data http://localhost/myWebService/Service.asmx?WSDL. At this point, SOAPAction, URL and SOAP Data should be blank.
should be blank.
Next, select the web method and click "Configure". The sampler should populate the "URL" and Next, select the web method and click "Configure". The sampler should populate the "URL" and "SOAPAction" text fields. Assuming the WSDL is valid, the correct soap action should be entered. "SOAPAction" text fields. Assuming the WSDL is valid, the correct soap action should be entered. The last step is to paste the SOAP message in the "SOAP/XML-RPC Data" text area. You can optionally The last step is to paste the SOAP message in the "SOAP/XML-RPC Data" text area. You can optionally save the soap message to a file and
save the soap message to a file and browse to the location. For convienancbrowse to the location. For convienance, there is a third option of e, there is a third option of using a message folder. The sampler will randomly select files from a given folder and use the text for using a message folder. The sampler will randomly select files from a given folder and use the text for the soap message.
the soap message.
If you do not want JMeter to read the response from the SOAP Webservice, uncheck "Read Soap If you do not want JMeter to read the response from the SOAP Webservice, uncheck "Read Soap Responses." If the test plan is intended to stress test a webservice, the box should be unchecked. If the Responses." If the test plan is intended to stress test a webservice, the box should be unchecked. If the test plan is a functional test, the box should be checked. When "Read Soap Responses" is unchecked, no test plan is a functional test, the box should be checked. When "Read Soap Responses" is unchecked, no result will be displayed in view result tree or view results in table.
result will be displayed in view result tree or view results in table. An important note on the
An important note on the sampler. It will automatically use the proxy host and sampler. It will automatically use the proxy host and port passed to JMeterport passed to JMeter from command line, if those fields in the sampler are left blank. If a sampler has values in the proxy host from command line, if those fields in the sampler are left blank. If a sampler has values in the proxy host and port text field, it will use the ones provided by the user. If no
and port text field, it will use the ones provided by the user. If no host or port are provided and JMeterhost or port are provided and JMeter wasn't started with command line options, the sampler will fail silently. This behavior may not be what wasn't started with command line options, the sampler will fail silently. This behavior may not be what users expect.
users expect.
Adding a Listener to View Store the
Adding a Listener to View Store the Test Results
Test Results
The final element you need to add to your Test Plan
The final element you need to add to your Test Plan is ais a Listener.Listener. This element is responsible for storingThis element is responsible for storing all of the results of your
all of the results of your HTTP requests in a file and presenting a visual model of the data.HTTP requests in a file and presenting a visual model of the data.
Building a Database Test Plan
Building a Database Test Plan
In this section, you will learn how to create a basic Test Plan to test a
In this section, you will learn how to create a basic Test Plan to test a database server. You will createdatabase server. You will create ten users that send
ten users that send five SQL requests to the database server.five SQL requests to the database server.
This example uses the MySQL database driver. To use this driver, its containing .jar file must be copied This example uses the MySQL database driver. To use this driver, its containing .jar file must be copied to the JMeter lib
to the JMeter lib directorydirectory
Adding Users
Adding Users
Go ahead and add the ThreadGroup element by first selecting the Test Plan, clicking your right mouse Go ahead and add the ThreadGroup element by first selecting the Test Plan, clicking your right mouse button to get the Add menu, and then select Add --> ThreadGroup.
Adding JDBC Requests
Adding JDBC Requests
Begin by selecting the JDBC Users element. Click your right mouse button to get the Add menu, and then Begin by selecting the JDBC Users element. Click your right mouse button to get the Add menu, and then select Add --> Config Element --> JDBC Connection Configuration. Then, select this new element to view select Add --> Config Element --> JDBC Connection Configuration. Then, select this new element to view its Control Panel
its Control Panel Set up the fo
Set up the following fields (these assume we will be llowing fields (these assume we will be using a local MySQL database called using a local MySQL database called test):test):
Variable name bound to pool. This Variable name bound to pool. This needs to uniquely identify the configuration. It is used needs to uniquely identify the configuration. It is used by theby the
JDBC Sampler to identify the configuration to be used. JDBC Sampler to identify the configuration to be used.
Database URL: jdbc:mysql://localhost:3306/testDatabase URL: jdbc:mysql://localhost:3306/test
JDBC Driver class: com.mysql.jdbc.DriverJDBC Driver class: com.mysql.jdbc.Driver
Username: guestUsername: guest
Password: password for guestPassword: password for guest
The other fields on the screen can be left as
The other fields on the screen can be left as the defaults.the defaults.
JMeter creates a database connection pool with the configuration settings as specified in
JMeter creates a database connection pool with the configuration settings as specified in the Controlthe Control Panel. The pool is referred to in JDBC Requests in the 'Variable Name' field. Several different JDBC 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 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.
Selecting the JDBC Users element again. Click your right mouse button to get the Add menu, and then Selecting the JDBC Users element again. Click your right mouse button to get the Add menu, and then select Add --> Sampler --> JDBC Request. Then, select this new element to view its Control Panel select Add --> Sampler --> JDBC Request. Then, select this new element to view its Control Panel
In our Test Plan, we will make two JDBC requests. The first one is for Eastman Kodak stock, and the In our Test Plan, we will make two JDBC requests. The first one is for Eastman Kodak stock, and the second is Pfizer stock (obviously you
second is Pfizer stock (obviously you should change these to examples appropriate for your particularshould change these to examples appropriate for your particular database). These are
database). These are illustrated below.illustrated below. Start by editing the following properties Start by editing the following properties
Change the Name to "Kodak".Change the Name to "Kodak".
Enter the Pool Name: MySQL (same as in the configuration element)Enter the Pool Name: MySQL (same as in the configuration element)
Enter the SQL Query String field.Enter the SQL Query String field.
Next, add the second JDBC Request and edit the following properties Next, add the second JDBC Request and edit the following properties
Change the Name to "Pfizer".Change the Name to "Pfizer".
Adding a Listener to View/Store the Test
Adding a Listener to View/Store the Test Results
Results
The final element you need to add to your Test Plan
The final element you need to add to your Test Plan is a Listener. This element is responsible for storingis a Listener. This element is responsible for storing all of the results of your
all of the results of your JDBC requestJDBC requests in a s in a file and presenting a visual model of the data.file and presenting a visual model of the data.
Correlation in Jmeter
Correlation in Jmeter
To remove the dynamic value of Http request correlation is used .Jmeter Script can be correlated with To remove the dynamic value of Http request correlation is used .Jmeter Script can be correlated with help of
help of Regular expression ExtractorRegular expression Extractor..
Refer the Screenshot below to
Refer the Screenshot below to view the Dynamic view the Dynamic Session_ID and Engine_IDSession_ID and Engine_ID
https://www.irctc.co.in/cgi-bin/bv60.dll/irctc/booking/planner.do?screen=fromlogin& https://www.irctc.co.in/cgi-bin/bv60.dll/irctc/booking/planner.do?screen=fromlogin& BV_SessionI
BV_SessionID= D= @@@@1502947175.1355111858@@@@ @@@@1502947175.1355111858@@@@ && {Left
Steps of Correlation:
Steps of Correlation:
1.
1. Find the Dynamic Value Find the Dynamic Value in Http Request in Http Request in this case in this case Session_ID and Engine_ID are DynamicSession_ID and Engine_ID are Dynamic values
values 2.
2. Add Add Regular Regular expression expression Extractor Extractor for for Seesion_ID Seesion_ID e.g e.g : : BV_SessionIBV_SessionID=(.*?)& D=(.*?)& check check number number of of occurrences
occurrences in in Regular Regular expression expression testertester 3.
3. Add Add Regular Regular expression expression Extractor Extractor for for BV_EngineID BV_EngineID e.g e.g : : BV_EngineID=(.+BV_EngineID=(.+)"> )"> check check number number of of occurrences
4.
4. Provide the Template and Match No e.g for First match $1$ and 1Provide the Template and Match No e.g for First match $1$ and 1
5.
5. ReplaceReplaceBV_SessionID and BV_SessionID and BV_EngineID values with VBV_EngineID values with Variable ${S} and ${E}ariable ${S} and ${E} Refer the screen Shot Below
Jmeter
Jmeter Parameterizatio
Parameterization
n
ParameterizatiParameterization is process of on is process of generalizing some user data so generalizing some user data so as to use as to use it for it for multiple multiple users , users , Suppose iSuppose i want to
want to the Log in the Log in the application with different set of the application with different set of data then i data then i have to Parameterize the have to Parameterize the UsernameUsername and Password .
and Password .
Steps of Parameterization:
Steps of Parameterization:
1. Go to the HTTP sampler where Username and Password are defined >> Change them with variable 1. Go to the HTTP sampler where Username and Password are defined >> Change them with variable
${user} and ${password} Refer the Snapshot below ${user} and ${password} Refer the Snapshot below
2. Add Config Element >> CSV data Set Config 2. Add Config Element >> CSV data Set Config
In CSV data Set Config add the variable name as defined above e.g user, passwordIn CSV data Set Config add the variable name as defined above e.g user, password
Provide CSV Provide CSV file Location file Location e.g. e.g. C:/Login.csvC:/Login.csv
Refer Screenshot 2 Refer Screenshot 2
5. Add Username and Password data in csv file 5. Add Username and Password data in csv file
Apache Jmeter Advantages
Apache Jmeter Advantages
Apache JMeter may be used to test functional and performance both on static and dynamic resources Apache JMeter may be used to test functional and performance both on static and dynamic resources (files, Servlets, Perl scripts, Java Objects, Data Bases and Queries, FTP Servers and more).
(files, Servlets, Perl scripts, Java Objects, Data Bases and Queries, FTP Servers and more).
It can be used to simulate a heavy load on a server, network or object to test its strength or to analyze It can be used to simulate a heavy load on a server, network or object to test its strength or to analyze overall performance under different load types.
overall performance under different load types.
You can also use it perform a functional test on websites, databases, LDAPs, web services etc. You can also use it perform a functional test on websites, databases, LDAPs, web services etc. Apache JMeter features include:
Apache JMeter features include:
Can load and performance test many different server types:Can load and performance test many different server types:
Web - HTTP, HTTPSWeb - HTTP, HTTPS SOAPSOAP Database via JDBC Database via JDBC
LDAPLDAP
JMSJMS
Mail - SMTP(S), POP3(S) and IMAP(S)Mail - SMTP(S), POP3(S) and IMAP(S)
Native commands or shell scriptsNative commands or shell scripts
Complete portability and 100% Java purity.Complete portability and 100% Java purity.
Full multithreading framework allows concurrent sampling by many threads and simultaneousFull multithreading framework allows concurrent sampling by many threads and simultaneous sampling of different functions by
sampling of different functions by separate thread groups.separate thread groups.
Careful GUI design allows faster operation and more precise timings.Careful GUI design allows faster operation and more precise timings.
Caching and offline analysis/replCaching and offline analysis/replaying of aying of test results.test results.
Highly Extensible:Highly Extensible:
Pluggable Samplers allow unlimited testing capabilities.Pluggable Samplers allow unlimited testing capabilities.
Several load statistics may be chosen with pluggable timers.Several load statistics may be chosen with pluggable timers.
Data analysis and visualization plug-in allow great extensibility as well as Data analysis and visualization plug-in allow great extensibility as well as personalizpersonalization.ation.
Functions can be used to Functions can be used to provide dynamic input to a provide dynamic input to a test or provide data manipulation.test or provide data manipulation.
Scriptable Samplers (Bean Shell is fully supported; and there is a sampler which supports BSF-Scriptable Samplers (Bean Shell is fully supported; and there is a sampler which supports BSF-compatible languages).
compatible languages).
Highly portable and supports 100% all the Java based appsHighly portable and supports 100% all the Java based apps
Less scripting efforts as compared to other tools because of Less scripting efforts as compared to other tools because of its user friendly GUIits user friendly GUI
Simple charts and graphs sufficient for analyzing key load related statistics and resource usageSimple charts and graphs sufficient for analyzing key load related statistics and resource usage monitors.