Showing posts with label Jmeter. Show all posts
Showing posts with label Jmeter. Show all posts

How to write a completed Jmeter Test Plan for load testing using Jmeter API in Java

 Jmeter is excellent tool used to do load testing on the application. Jmeter has graphical(GUI) and Non graphical(Non GUI) options. Non graphical option use Jmeter API to write a complete test plan for loading testing in java.
Pre-prerequisites:
1. JMeter install somewhere.
2. Add JMeter jars from /lib and especially /lib/ext folders in your project or module class path.

Load the jmeter properties:
 //Set jmeter home for the jmeter utils to load  
 String jmeterHomelocation = "F:\\apache-jmeter-2.13\\";  
 String jmeterPropertieslocation = jmeterHomelocation + "bin\\jmeter.properties";  
   
 //JMeter Engine  
 StandardJMeterEngine jmeter = new StandardJMeterEngine();  
   
 //JMeter initialization (properties, log levels, locale, etc)  
 JMeterUtils.setJMeterHome(new File(jmeterHomelocation).getPath());  
 JMeterUtils.loadJMeterProperties(new File(jmeterPropertieslocation).getPath());  
 // see extra log messages of i.e. DEBUG level  
 JMeterUtils.initLogging();  
 JMeterUtils.initLocale();  

Create "Test Plan" Object and JOrphan HashTree:
 // JMeter Test Plan, basically JOrphan HashTree  
 HashTree testPlanTree = new HashTree();  
             
 // Test Plan  
 TestPlan testPlan = new TestPlan("Java code Test Plan");  
 testPlan.setProperty(TestElement.TEST_CLASS, TestPlan.class.getName());  
 testPlan.setProperty(TestElement.GUI_CLASS, TestPlanGui.class.getName());  
 testPlan.setUserDefinedVariables((Arguments) new ArgumentsPanel().createTestElement());  

Graphical: Thread Group
Right-click on the Test Plan > Add > Threads (Users) > Thread Group
Type below values in corresponding field
Number of Threads (users)   : 1
Ramp-Up Period (in seconds) : 1
Loop Count  : 1
Non Graphical: Thread Group
 // Thread Group  
 ThreadGroup threadGroup = new ThreadGroup();  
 threadGroup.setName("Test Thread Group");  
 threadGroup.setNumThreads(1);  
 threadGroup.setRampUp(1);  
 threadGroup.setSamplerController(loopCtrl);  
 threadGroup.setProperty(TestElement.TEST_CLASS, ThreadGroup.class.getName());  
 threadGroup.setProperty(TestElement.GUI_CLASS, ThreadGroupGui.class.getName());  

Graphical: Sampler
Right-click on the Thread Group > Add > Sampler > HTTP request
Write below values in corresponding field
Server Name or IP : hiromia.blogspot.com
Port NUmber       : 80
Path              : /

Non Graphical: Sampler
 HTTPSampler examplecomSampler = new HTTPSampler();  
 examplecomSampler.setDomain("www.google.com");  
 examplecomSampler.setPort(80);  
 examplecomSampler.setPath("/");  
 examplecomSampler.setMethod("GET");  
 examplecomSampler.setName("google");  
 examplecomSampler.setProperty(TestElement.TEST_CLASS, HTTPSampler.class.getName());  
 examplecomSampler.setProperty(TestElement.GUI_CLASS, HttpTestSampleGui.class.getName());  
Loop Controller:
 // Loop Controller  
  LoopController loopCtrl = new LoopController();  
  loopCtrl.setLoops(10);  
  loopCtrl.setFirst(true);  
  loopCtrl.setProperty(TestElement.TEST_CLASS, LoopController.class.getName());  
  loopCtrl.setProperty(TestElement.GUI_CLASS, LoopControlPanel.class.getName());  
  loopCtrl.initialize();  

Graphical: Summary Report
Right-click on the Thread Group > Add > Listener > Summary Report

Non Graphical: Summary Report
 Summariser summer = null;  
  String summariserName = JMeterUtils.getPropDefault("summariser.name", "summary");  
  if (summariserName.length() > 0) {  
    summer = new Summariser(summariserName);  
  }  
   
 // Store execution results into a .jtl file, we can save file as csv also  
  String reportFile = "report\\report.jtl";  
  String csvFile = "report\\report.csv";  
  ResultCollector logger = new ResultCollector(summer);  
  logger.setFilename(reportFile);  
  ResultCollector csvlogger = new ResultCollector(summer);  
  csvlogger.setFilename(csvFile);  
  testPlanTree.add(testPlanTree.getArray()[0], logger);  
  testPlanTree.add(testPlanTree.getArray()[0], csvlogger);  
   

Run Test Plan:
 // Run Test Plan  
 jmeter.configure(testPlanTree);  
 jmeter.run()  

Completed Jmeter Test Plan java source code:
 import java.io.File;  
 import java.io.FileOutputStream;  
 import org.apache.jmeter.config.Arguments;  
 import org.apache.jmeter.config.gui.ArgumentsPanel;  
 import org.apache.jmeter.control.LoopController;  
 import org.apache.jmeter.control.gui.LoopControlPanel;  
 import org.apache.jmeter.control.gui.TestPlanGui;  
 import org.apache.jmeter.engine.StandardJMeterEngine;  
 import org.apache.jmeter.protocol.http.control.gui.HttpTestSampleGui;  
 import org.apache.jmeter.protocol.http.sampler.HTTPSampler;  
 import org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy;  
 import org.apache.jmeter.reporters.ResultCollector;  
 import org.apache.jmeter.reporters.Summariser;  
 import org.apache.jmeter.save.SaveService;  
 import org.apache.jmeter.testelement.TestElement;  
 import org.apache.jmeter.testelement.TestPlan;  
 import org.apache.jmeter.threads.ThreadGroup;  
 import org.apache.jmeter.threads.gui.ThreadGroupGui;  
 import org.apache.jmeter.util.JMeterUtils;  
 import org.apache.jorphan.collections.HashTree;  
   
   
 public class CompleteNongraphicaljplan {  
   public static void main(String[] argv) throws Exception {  
   
     //Set jmeter home for the jmeter utils to load  
     String jmeterHomelocation = "F:\\apache-jmeter-2.13\\";  
     String jmeterPropertieslocation = jmeterHomelocation + "bin\\jmeter.properties";  
   
   
     //JMeter Engine  
     StandardJMeterEngine jmeter = new StandardJMeterEngine();  
   
     //JMeter initialization (properties, log levels, locale, etc)  
     JMeterUtils.setJMeterHome(new File(jmeterHomelocation).getPath());  
     JMeterUtils.loadJMeterProperties(new File(jmeterPropertieslocation).getPath());  
     // see extra log messages of i.e. DEBUG level  
     JMeterUtils.initLogging();  
     JMeterUtils.initLocale();  
   
     // JMeter Test Plan, basically JOrphan HashTree  
     HashTree testPlanTree = new HashTree();  
   
     // First HTTP Sampler - open google.com  
     HTTPSampler examplecomSampler = new HTTPSampler();  
     examplecomSampler.setDomain("www.google.com");  
     examplecomSampler.setPort(80);  
     examplecomSampler.setPath("/");  
     examplecomSampler.setMethod("GET");  
     examplecomSampler.setName("google");  
     examplecomSampler.setProperty(TestElement.TEST_CLASS, HTTPSampler.class.getName());  
     examplecomSampler.setProperty(TestElement.GUI_CLASS, HttpTestSampleGui.class.getName());  
   
   
     // Loop Controller  
     LoopController loopCtrl = new LoopController();  
     loopCtrl.setLoops(10);  
     loopCtrl.setFirst(true);  
     loopCtrl.setProperty(TestElement.TEST_CLASS, LoopController.class.getName());  
     loopCtrl.setProperty(TestElement.GUI_CLASS, LoopControlPanel.class.getName());  
     loopCtrl.initialize();  
   
     // Thread Group  
     ThreadGroup threadGroup = new ThreadGroup();  
     threadGroup.setName("Test Thread Group");  
     threadGroup.setNumThreads(1);  
     threadGroup.setRampUp(1);  
     threadGroup.setSamplerController(loopCtrl);  
     threadGroup.setProperty(TestElement.TEST_CLASS, ThreadGroup.class.getName());  
     threadGroup.setProperty(TestElement.GUI_CLASS, ThreadGroupGui.class.getName());  
   
     // Test Plan  
     TestPlan testPlan = new TestPlan("Java code Test Plan");  
     testPlan.setProperty(TestElement.TEST_CLASS, TestPlan.class.getName());  
     testPlan.setProperty(TestElement.GUI_CLASS, TestPlanGui.class.getName());  
     testPlan.setUserDefinedVariables((Arguments) new ArgumentsPanel().createTestElement());  
   
     // Construct Test Plan from previously initialized elements  
     testPlanTree.add(testPlan);  
     HashTree threadGroupHashTree = testPlanTree.add(testPlan, threadGroup);  
     threadGroupHashTree.add(examplecomSampler);  
       
   
     // save generated test plan to JMeter's .jmx file format  
     SaveService.saveTree(testPlanTree, new FileOutputStream("report\\jmeter_api_sample.jmx"));  
   
     //add Summarizer output to get test progress in stdout like:  
     // summary =   2 in  1.3s =  1.5/s Avg:  631 Min:  290 Max:  973 Err:   0 (0.00%)  
     Summariser summer = null;  
     String summariserName = JMeterUtils.getPropDefault("summariser.name", "summary");  
     if (summariserName.length() > 0) {  
       summer = new Summariser(summariserName);  
     }  
   
   
     // Store execution results into a .jtl file, we can save file as csv also  
     String reportFile = "summaryreport.jtl";  
     String csvFile = "summaryreport.csv";  
     ResultCollector logger = new ResultCollector(summer);  
     logger.setFilename(reportFile);  
     ResultCollector csvlogger = new ResultCollector(summer);  
     csvlogger.setFilename(csvFile);  
     testPlanTree.add(testPlanTree.getArray()[0], logger);  
     testPlanTree.add(testPlanTree.getArray()[0], csvlogger);  
       
           // Run Test Plan  
     jmeter.configure(testPlanTree);  
     jmeter.run();  
   
   
     System.exit(0);  
   
   
   }  
 }  
   

Output:

How to run Jmeter load testing script using java.

JMeter API has an option to run JMeter script which made by Jmeter GUI using java. StandardJMeterEngine is the 'heart' of JMeter. If you must execute a JMeter test from Java code, this is the best option. The absolute minimal code to read the existing .jmx file.
Pre-prerequisites:
1. JMeter install somewhere.
2. Add JMeter jars from /lib and especially /lib/ext folders in your project or module class path.

Build Jmeter load testing script using below steps:
1. Start Jmeter
Click on Jmeter_Home/bin/ApacheJMeter.jar or jmeter.sh to open Jmeter window

2. Add 'Thread Group' under 'Test Plan'
Right-click on the Test Plan > Add > Threads (Users) > Thread Group
Type below values in corresponding field
Number of Threads (users)   : 1
Ramp-Up Period (in seconds) : 1
Loop Count                  : 1

3. Add a Sampler under 'Thread Group'
Right-click on the Thread Group > Add > Sampler > HTTP request
Write below values in corresponding field
Server Name or IP : hiromia.blogspot.com
Port NUmber       : 80
Path              : /

4. Add Listener under 'Thread Group'
Right-click on the Thread Group > Add > Listener > View Results Tree

5. Finally Save Test plan with desired name

Demo Java Code:
 import org.apache.jmeter.engine.StandardJMeterEngine;  
 import org.apache.jmeter.reporters.ResultCollector;  
 import org.apache.jmeter.reporters.Summariser;  
 import org.apache.jmeter.save.SaveService;  
 import org.apache.jmeter.util.JMeterUtils;  
 import org.apache.jorphan.collections.HashTree;  
   
 import java.io.File;  
 import java.io.FileInputStream;  
   
 public class ProgramJmeterJMX {  
   
   public static void main(String[] argv) throws Exception {  
   
     //Set jmeter home for the jmeter utils to load  
     String jmeterHomelocation = "F:\\apache-jmeter-2.13\\";  
     String jmeterPropertieslocation = jmeterHomelocation + "bin\\jmeter.properties";  
   
     // JMeter Engine  
     StandardJMeterEngine jmeter = new StandardJMeterEngine();  
   
   
     // Initialize Properties, logging, locale, etc.  
     JMeterUtils.loadJMeterProperties(new File(jmeterPropertieslocation).getPath());  
     JMeterUtils.setJMeterHome(new File(jmeterHomelocation).getPath());  
     // you can comment this line out to see extra log messages of i.e. DEBUG level  
     JMeterUtils.initLogging();  
     JMeterUtils.initLocale();  
   
     // Initialize JMeter SaveService  
     SaveService.loadProperties();  
   
     // Load existing .jmx Test Plan  
     FileInputStream in = new FileInputStream(new File(jmeterHomelocation + "bin\\webloadtesting.jmx"));  
     HashTree testPlanTree = SaveService.loadTree(in);  
     in.close();  
             
     Summariser summer = null;  
     String summariserName = JMeterUtils.getPropDefault("summariser.name", "summary");  
   
     if (summariserName.length() > 0) {  
       summer = new Summariser(summariserName);  
     }  
   
     ResultCollector logger = new ResultCollector(summer);  
     testPlanTree.add(testPlanTree.getArray()[0], logger);  
   
     // Run JMeter Test  
     jmeter.configure(testPlanTree);  
     jmeter.run();  
   }  
 }     
   

Out put:

How to use selenium webdriver with jmeter.

Prerequisite
1. Download Apache JMeter from http://jmeter.apache.org/download_jmeter.cgi and UnZip
2. Download WebDriver plugins for JMeter from http://jmeter-plugins.org/downloads/all/#Latest-Stable-Release and UnZip
3. Download Mozilla Firefox 26 from http://mozilla_firefox.en.downloadastro.com/old_versions/ and install

How to install Selenium Webdriver in Jmeter
1. Copy the jar files from 'lib' folder of JMeterPlugins-WebDriver and paste to Jmeter_Home/lib folder.
2. Copy the files from ext folder and paste to Jmeter_Home/lib/ext folder.
3. Delete older / Duplicate http jars from Jmeter_Home/lib
Example:
    httpclient-4.2.6.jar (delect this jar)
    httpclient-4.5.jar
    httpcore-4.2.5.jar (delect this jar)
    httpcore-4.4.1.jar
    httpmime-4.2.6.jar (delect this jar)
    httpmime-4.5.jar

4. Now the Installation is Completed.

How to configure and run Jmeter
1. Start Jmeter
Click on Jmeter_Home/bin/ApacheJMeter.jar or jmeter.bat to open Jmeter window

2. Add 'Thread Group' under 'Test Plan'
Right-click on the Test Plan > Add > Threads (Users) > Thread Group
Number of Threads (users): 1
Ramp-Up Period (in seconds):  1
Loop Count: 1
3. Add 'jp@gc - Firefox Driver Config' under 'Thread Group'
Right-click on the Thread Group > Add > Config Element > jp@gc - Firefox Driver Config

4. Add 'jp@gc - WebDriver Sampler' Sampler under 'Thread Group' 
Right-click on the Thread Group > Add > Sampler > jp@gc - WebDriver Sampler

WDS.sampleResult.sampleStart()
WDS.browser.get('http://www.google.com')
WDS.sampleResult.sampleEnd()



5. Add 'View Results in Table' and View Results Tree Listener under 'Thread Group'
Right-click on the Thread Group > Add > Listener > View Results Tree
Right-click on the Thread Group > Add > Listener > View Results in Table

6. Finally Save Test plan then Press Menu > Run > Start or 'Ctrl'+ 'R' to run Test plan
  Open Firefox browser then navigate to 'http://www.google.com'



N.B: You can change all names like as 'Test Plan', 'Thread Group', 'Sampler' and 'Listener' name

How to perform load or performance test on FTP Server using Jmeter.

             How to make FTP server in local computer
1. Download and Install GOLDEN FTP Server Software
2. Run 'Golden FTP Server'
3. Select 'Open shares' then Click on 'Add' button

4. Enter your desired Path and Name, Enable full control then click on 'Ok' button.
5. Finally will show the access path to the file

You can connect to this file from another system of your network (if only firewall is disabled) through command prompt (ftp 10.6.0.38).Once it is connected you can check the connections to your server.

N.B: Off FTP Firewall

Configure FTP Server in Jmeter 
1. Start Jmeter
Click on Jmeter_Home/bin/ApacheJMeter.jar or jmeter.sh to open Jmeter window

2. Add 'Thread Group' under 'Test Plan'
Right-click on the Test Plan > Add > Threads (Users) > Thread Group
Number of Threads (users): 1
Ramp-Up Period (in seconds):  1
Loop Count: 1
3. Add 'FTP Request Defaults' under 'Thread Group'
Right-click on the Thread Group > Add > Config Element > FTP Request Defaults

Server Name or IP - 10.6.0.38
4. Add 'FTP Request' Sampler under 'Thread Group' to fetch file.
Right-click on the Thread Group > Add > Sampler > FTP Request
Remote File - /Uploaddownload/importanturl.txt
Local File - importanturl.txt
Select get(RETR)
Username - anonymous
Password - anonymous

5. Add 'FTP Request' Sampler under 'Thread Group' to upload file.
Right-click on the Thread Group > Add > Sampler > FTP Request

Remote File - /Uploaddownload/examplefile.txt
Local File - D:\ftpjmeter\examplefile.txt
Select .Select put (STOR)
Username - anonymous
Password - anonymous
6. Add 'View Results Tree' and 'Summary Report' Listener under 'Thread Group'
Right-click on the Thread Group > Add > Listener > View Results Tree
Right-click on the Thread Group > Add > Listener > Summary Report
View Results Tree:
You can see how many request successfully serve, how many request fail to serve and it reason.
Summary Report:
    Sample - number of requests sent
    Avg - an Arithmetic mean for all responses (sum of all times / count)
    Minimal response time (ms)
    Maximum response time (ms)
    Error rate - percentage of failed tests
    Throughput - how many requests per second does your server handle. Larger is better.
    KB/Sec - self expalanatory
    Avg. Bytes - average response size
   
7. Finally Save Test plan then Press Menu > Run > Start or 'Ctrl'+ 'R' to run Test plan


N.B: You can change all names like as 'Test Plan', 'Thread Group', 'Sampler' and 'Listener' name

How to perform load or performance test on wsdl web services using Jmeter.

Downlaod and install soapui and here is wsdl url: http://www.webservicex.com/CurrencyConvertor.asmx?wsdl

1. Start Jmeter
Click on Jmeter_Home/bin/ApacheJMeter.jar or jmeter.sh to open Jmeter window

2. Add 'Thread Group' under 'Test Plan'
Right-click on the Test Plan > Add > Threads (Users) > Thread Group

Number of Threads (users): The number of users that JMeter will attempt to simulate. Set the 'Number of Threads (users)' field to 10
Ramp-Up Period (in seconds): start the total number of threads. Set the 'Ramp-Up Period' field to 1
Loop Count: The number of times to execute the test. Set the 'Loop Count' field to 1.

3. Add 'SOAP/XML-RPC Request' Sampler  under 'Thread Group'
Right-click on the Thread Group > Add > Sampler > SOAP/XML-RPC Request

4. Open soap UI and create new soapui project using wsdl url as I used in below
 
5. After soap ui project created successfully. Copy soap request data as I copy below soap request.

6. Past copied soap request code into created Jmeter SOAP/XML-RPC Request” sampler in  Soap/XML-RPC data as below:

7. Add 'View Results Tree' and 'Summary Report' Listener under 'Thread Group'
Right-click on the Thread Group > Add > Listener > View Results Tree
Right-click on the Thread Group > Add > Listener > Summary Report

View Results Tree:
You can see how many request successfully serve, how many request fail to serve and it reason.
Summary Report:
    Sample - number of requests sent
    Avg - an Arithmetic mean for all responses (sum of all times / count)
    Minimal response time (ms)
    Maximum response time (ms)
    Error rate - percentage of failed tests
    Throughput - how many requests per second does your server handle. Larger is better.
    KB/Sec - self expalanatory
    Avg. Bytes - average response size
   
8. Finally Save Test plan then Press 'Ctrl'+ 'R' to run Test plan

N.B: You can change all names like as 'Test Plan', 'Thread Group', 'Sampler' and 'Listener' name

How to perform load or performance test on REST API using Jmeter.

1. Start Jmeter
Click on Jmeter_Home/bin/ApacheJMeter.jar or jmeter.sh to open Jmeter window

2. Add 'Thread Group' under 'Test Plan'
Right-click on the Test Plan > Add > Threads (Users) > Thread Group

Number of Threads (users): The number of users that JMeter will attempt to simulate. Set the 'Number of Threads (users)' field to 10
Ramp-Up Period (in seconds): start the total number of threads. Set the 'Ramp-Up Period' field to 1
Loop Count: The number of times to execute the test. Set the 'Loop Count' field to 1.

3. Add 'HTTP request' Sampler under 'Thread Group'
Right-click on the Thread Group > Add > Sampler > HTTP request

Method - Depending on the type of method, the API was build over, select Get, Put, Post, Delete etc (in our demo we will be working on Post method)
Path: Enter your desired request which page do you want to perform load or performance test.
Set the Path field to 'http://localhost:8080/execute?command=CheckEmailAvailability'
N.B: How many Sampler do you want to add?.
It is depend on how many request do you want to perform load or performance test. For example you want to perform load or performance test for get request and you must have add 5 Sampler.
Parameters/Post Body - Add request input josn in 'Body Data'


 4. Add HTTP Header Manager under 'Sampler'
Right-click on the Sampler > Add > Configure Element > HTTP Header Manager

Click on Add button on HTTP Header Manager and add "Content-Type" under Name and "application/x-www-form-urlencoded" under Value.

5. Add 'View Results Tree' and 'Summary Report' Listener under 'Thread Group'
Right-click on the Thread Group > Add > Listener > View Results Tree
Right-click on the Thread Group > Add > Listener > Summary Report

View Results Tree:
You can see how many request successfully serve, how many request fail to serve and it reason.
Summary Report:
    Sample - number of requests sent
    Avg - an Arithmetic mean for all responses (sum of all times / count)
    Minimal response time (ms)
    Maximum response time (ms)
    Error rate - percentage of failed tests
    Throughput - how many requests per second does your server handle. Larger is better.
    KB/Sec - self explanatory
    Avg. Bytes - average response size
   
6. Finally Save Test plan then Press 'Ctrl'+ 'R' to run Test plan



N.B: You can change all names like as 'Test Plan', 'Thread Group', 'Sampler' and 'Listener' name

How to perform get request load or performance test on application server using Jmeter.

 1. Start Jmeter
Click on Jmeter_Home/bin/ApacheJMeter.jar or jmeter.sh to open Jmeter window

2. Add 'Thread Group' under 'Test Plan'
Right-click on the Test Plan > Add > Threads (Users) > Thread Group

Number of Threads (users): The number of users that JMeter will attempt to simulate. Set the 'Number of Threads (users)' field to 50
Ramp-Up Period (in seconds):start the total number of threads. Set the 'Ramp-Up Period' field to 5
Loop Count: The number of times to execute the test. Set the 'Loop Count' field to 5

3. Add Sampler under 'Thread Group'
Right-click on the Thread Group > Add > Sampler > HTTP request

Path: Enter your desired get request which page do you want to perform load or performance test.
Set the Path field to 'http://localhost:8080/AppMetaDataServer/metaservice?operation=get&servicename=mobilemaps&servicekey=isthebest&code=Base_and_version_configured&version=1.0.1&platform=BB'
N.B: How many Sampler do you want to add?.
It is depend on how many get request do you want to perform load or performance test. For example you want to perform load or performance test for get request and you must have add 5 Sampler.

4. Add Listener under 'Thread Group'
Right-click on the Thread Group > Add > Listener > View Results Tree
Right-click on the Thread Group > Add > Listener > Summary Report

View Results Tree:
You can see how many request successfully serve, how many request fail to serve and it reason.
Summary Report:
    Sample - number of requests sent
    Avg - an Arithmetic mean for all responses (sum of all times / count)
    Minimal response time (ms)
    Maximum response time (ms)
    Error rate - percentage of failed tests
    Throughput - how many requests per second does your server handle. Larger is better.
    KB/Sec - self explanatory
    Avg. Bytes - average response size
   
5. Finally Save Test plan then Press 'Ctrl'+ 'R' to run Test plan

N.B: You can change all names like as 'Test Plan', 'Thread Group', 'Sampler' and 'Listener' name

How to perform load or performance test on Website using Jmeter.

1. Start Jmeter
Click on Jmeter_Home/bin/ApacheJMeter.jar or jmeter.sh to open Jmeter window

2. Add 'Thread Group' under 'Test Plan'
Right-click on the Test Plan > Add > Threads (Users) > Thread Group

Number of Threads (users): The number of users that JMeter will attempt to simulate. Set the 'Number of Threads (users)' field to 100
Ramp-Up Period (in seconds): start the total number of threads. Set the 'Ramp-Up Period' field to 10
Loop Count: The number of times to execute the test. Set the 'Loop Count' field to 1.

3. Add Sampler under 'Thread Group'
Right-click on the Thread Group > Add > Sampler > HTTP request

Path: Enter your desired website page url which page do you want to perform load or performance test. Set the 'Path' field to 'http://www.apache.org/foundation/preFAQ.html'
N.B: How many Sampler do you want to add?.
It is depend on how many page do you want to perform load or performance test. For example you want to perform load or performance test for 5 pages and you must have add 5 Sampler.

4. Add Listener under 'Thread Group'
Right-click on the Thread Group > Add > Listener > View Results Tree
Right-click on the Thread Group > Add > Listener > Summary Report

View Results Tree:
You can see how many request successfully serve, how many request fail to serve and it reason.
Summary Report:
    Sample - number of requests sent
    Avg - an Arithmetic mean for all responses (sum of all times / count)
    Minimal response time (ms)
    Maximum response time (ms)
    Error rate - percentage of failed tests
    Throughput - how many requests per second does your server handle. Larger is better.
    KB/Sec - self explanatory
    Avg. Bytes - average response size
   
5. Finally Save Test plan then Press 'Ctrl'+ 'R' to run Test plan

N.B: You can change all names like as 'Test Plan', 'Thread Group', 'Sampler' and 'Listener' name

How to perform load testing on MS SQL Server using jmeter.

1. Download Microsoft JDBC Driver for SQL Server: Download driver. put it to folder lib of JMETER.

2. Open Jmeter from : apache-jmeter_home/bin/jmeter.bat or ApacheJMeter.jar

3. Add Users

Select the Test Plan, right click on Test Plan, select Add> Threads(Users)> Thread Group
Set up the following fields for Users:
a. Set value for Numbers of Threads(users): 5
b. Set value for Ram-up Periods : 2.
It means that 5 users connect to MYSQL server withine 2 seconds.


4.Add JDBC Connection Configuration

Right click on the 'Thread Group', select Add > Config Element > JDBC Connection Configuration.
Set up the following fields for MySQL database:
a. Variable name bound to pool. This needs to uniquely identify the configuration. It is used by the JDBC Sampler to identify the configuration to be used. We have named it as 'mssqlpool'
b. Database URL: jdbc:sqlserver://host:port;DatabaseName=dbname
c. JDBC Driver class: com.microsoft.sqlserver.jdbc.SQLServerDriver
d. Username: username of database
e. Password: password of database
f.The other fields can be left as the defaults


5. Add JDBC Requests

Right click on the 'Thread Group', select Add > Sampler > JDBC Request.
Then, select this new element to view its Control Panel. Edit the properties as below:
a. Enter the Pool Name: mssqlpool (same as in the configuration element)
b. Query Type: Select statement
c. Enter the SQL Query String field.


6. Adding a Listener to View/Store the Test Results

Right click on the 'Thread Group', select Add --> Listener --> View Results Tree and Summary Report
Save the test plan, and run the test with the menu Run --> Start or Ctrl+R

How to perform load testing on Postgresql Database using jmeter.

1. download the postgresql driver class for JMeter: Download postgresql driver. put it to folder lib of JMETER.

2. Open Jmeter from : apache-jmeter_home/bin/jmeter.bat or ApacheJMeter.jar

3. Add Users

Select the Test Plan, right click on Test Plan, select Add> Threads(Users)> Thread Group
Set up the following fields for Users:
a. Set value for Numbers of Threads(users): 5
b. Set value for Ram-up Periods : 2.
It means that 5 users connect to MYSQL server withine 2 seconds.


4.Add JDBC Connection Configuration

Right click on the 'Thread Group', select Add > Config Element > JDBC Connection Configuration.
Set up the following fields for MySQL database:
a. Variable name bound to pool. This needs to uniquely identify the configuration. It is used by the JDBC Sampler to identify the configuration to be used. We have named it as 'Postgresqlpool'.
b. Database URL: jdbc:postgresql://IPAddress:PortNo/DatabaseName?autoReconnect=true
c. JDBC Driver class: org.postgresql.Drive
d. Username: username of database
e. Password: password of database
f.The other fields can be left as the defaults


5. Add JDBC Requests

Right click on the 'Thread Group', select Add > Sampler > JDBC Request.
Then, select this new element to view its Control Panel. Edit the properties as below:
a. Enter the Pool Name: Postgresqlpool (same as in the configuration element)
b. Query Type: Select statement
c. Enter the SQL Query String field.


6. Adding a Listener to View/Store the Test Results

Right click on the 'Thread Group', select Add --> Listener --> View Results Tree and Summary Report
Save the test plan, and run the test with the menu Run --> Start or Ctrl+R

How to perform load testing on Mysql Database using jmeter.

1. Mysql driver jar file for Jmeter: Download Mysql driver. Extract file 'com.mysql.jdbc_5.1.5.jar.zip' and put it to folder lib of JMETER.

2. Open Jmeter from : apache-jmeter_home/bin/jmeter.bat or ApacheJMeter.jar

3. Add Users

Select the Test Plan, right click on Test Plan, select Add> Threads(Users)> Thread Group
Set up the following fields for Users:
a. Set value for Numbers of Threads(users): 5
b. Set value for Ram-up Periods : 2.
It means that 5 users connect to MYSQL server withine 2 seconds.


4.Add JDBC Connection Configuration

Right click on the 'Thread Group', select Add > Config Element > JDBC Connection Configuration.
Set up the following fields for MySQL database:
a. Variable name bound to pool. This needs to uniquely identify the configuration. It is used by the JDBC Sampler to identify the configuration to be used. We have named it as 'dbconnectionpool'
b. Database URL: jdbc:mysql://IP:3306/databasename
c. JDBC Driver class: com.mysql.jdbc.Driver
d. Username: root
e. Password: password for root
f.The other fields can be left as the defaults


5. Add JDBC Requests

Right click on the 'Thread Group', select Add > Sampler > JDBC Request.
Then, select this new element to view its Control Panel. Edit the properties as below:
a. Enter the Pool Name: dbconnectionpool (same as in the configuration element)
b. Query Type: Select statement
c. Enter the SQL Query String field.


6. Adding a Listener to View/Store the Test Results

Right click on the 'Thread Group', select Add --> Listener --> View Results Tree and Summary Report
Save the test plan, and run the test with the menu Run --> Start or Ctrl+R