Wednesday, 11 March 2015

Published Wednesday, March 11, 2015 by with 1 comment

Apache Jmeter: Introduction and Tutorial -1

Apache JMeter


  • JMeter is an "Apache" project that can be used as a load testing tool for analyzing and measuring the performance of a variety of services, with a focus on web applications.
  • Stefano Mazzocchi of the Apache Software Foundation was the original developer of JMeter

  • JMeter Features

Following are some of the features of JMeter:
  1. Its free and open source software.
  2. It has simple GUI with desktop application
  3. JMeter can load and performance test many different server types: Web - HTTP, HTTPS, SOAP, Database via JDBC, LDAP, JMS, Mail - POP3
  4. It is platform-independent tool. On Linux/Unix, JMeter can be invoked by clicking on JMeter shell script. On Windows it can be invoked by starting the jmeter.bat file.
  5. JMeter store its test plans in XML format. This means you can generate a test plan using a text editor.
  6. It's full multi-threading framework allows concurrent sampling by many threads and simultaneous sampling of different functions by separate thread groups.


  • How JMeter Works ?





- JMeter simulates a group of users sending requests to a target server, and return statistics that show the performance/functionality of the target server / application via tables, graphs etc. 

It can be used to simulate a heavy load on a server, group of servers, network or object to test its strength or to analyze overall performance under different load types.



Environment Set-Up : 




JMeter is a framework for Java, so the very first requirement is to have JDK installed in your machine.

Verify the presence of Java in the machine using below commands.




Else, Download Java development Kit from http://www.oracle.com/technetwork/java/javase/downloads/index.html


Once JDK was set, go for downloading the JMeter latest version from http://jmeter.apache.org/download_jmeter.cgi.


Run JMeter : 

After downloading JMeter, go to the bin directory and Run JMeter.

Depending on OS select respective file





On clicking on above mentioned shortcut from the bin directory, JMeter GUI should appear which seems as below...





Script recording using JMeter.

Follow below steps to setup JMeter for recording.
Step:1

Test plan :
Right click (ADD -> Threads(Users) -> Thread Group) and add thread group.

Thread Group : Right Click (ADD -> Sampler -> HTTP Request) and add HTTP request.

Work Bench : Right Click (ADD -> Non-Test elements -> HTTP Proxy server.)
By adding all the above steps, your Application interface will looks like 



Step:2
Now set the proxy to your browser,( Prefer Firefox as its an independent browser.)
Firefox -> Tools -> Options -> Advanced Settings
Here Change to manual proxy Configuration and Configure respective PC ip here.


Step:3
After setting the proxy, if you try to send any request from the browser it should show the proxy screen.


Step:4

Now go to your app, select Thread Group :
Thread Group elements are the beginning points of your test plan. As the name suggests, the thread group elements control the number of threads JMeter will use during the test. We can also control the following via the Thread Group:
  • By setting the number of Threads.
  • By setting the Ramp Up Time
  • By setting the number of test iterations.



Step:5

Http Request Defaults : 



Step:6

Http Proxy server is a major part in recording, In that assign the port number, select target controller and then click on start button to start recording.


Once we start the proxy server, Just reload the proxy browser page by entering the URL which u wanted to record the script.
As an Example, I will enter https://www.google.com, as we set the target controller as Test plan> Thread group (Refer above image), all the scripts will be recorded under thread group (Refer below image for sample recording)


if the page got loaded completely, can go for Stop button.

Now we can say that we are done with recording part, and we can go for analyzing part..

View Result Tree : 

Once all the requests that sent to server for loading a page (which we recorded as shown in above steps), we can check for the server response from 'View result tree'

Thread Group, Right click and add View result tree from the Listener

then select "Run"/ Ctrl+R to check the response data.



HAPPY TESTING :)





Read More
      edit