Tuesday, December 10, 2013

Jmeter Quick Tutorials

Tutorials:


JMETER TUTORIAL:
 
Before digging into the JMeter, let us first understand few jargons mostly associated with the testing of any application.
  • Performance Test: This test sets the ‘best possible’ performance expectation under a given configuration of infrastructure. It also highlights early in the testing process if changes need to be made before application goes into production.
  • Load Test: This test is basically used for exercising\discovering the system under the top load it was designed to operate under.
  • Stress Test: This test is an attempt to break the system by overwhelming its resources.
What is JMeter?
JMeter is a software allowing to load test or performance oriented business (functional) test on different protocols or technologies. Stefano Mazzocchi of the Apache Software Foundation was the original developer of JMeter. He wrote it primarily to test the performance of Apache JServ (Now called as Apache Tomcat project). Apache later redesigned JMeter to enhance the GUI and to add functional-testing capabilities.
This is a Java desktop application with a graphical interface using the Swing graphical API, can therefore run on any environment / workstation accepting a Java virtual machine, for example: Windows, Linux, Mac, etc.
The protocols supported by JMeter are:
  • Web: HTTP, HTTPS sites 'web 1.0' web 2.0 (ajax, flex and flex-ws-amf)
  • Web Services: SOAP / XML-RPC
  • Database via JDBC drivers
  • Directory: LDAP
  • Messaging Oriented service via JMS
  • Service: POP3, IMAP, SMTP
  • FTP Service
JMeter Features
Following are some of the features of JMeter:
  • Its free. Its an open source software.
  • It has simple and intuitive GUI.
  • JMeter can load and performance test many different server types: Web - HTTP, HTTPS, SOAP, Database via JDBC, LDAP, JMS, Mail - POP3
  • 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.
  • It has full Swing and lightweight component support (precompiled JAR uses packages javax.swing.* ).
  • JMeter store its test plans in XML format. This means you can generate a test plan using a text editor.
  • It's full multi-threading framework allows concurrent sampling by many threads and simultaneous sampling of different functions by separate thread groups.
  • It is highly Extensible.
  • Can also be used to perform automated and functional testing of your application.
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. The figure below depicts this process:



 
Environment Set-Up

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

System Requirement

JDK
1.6 or above.
Memory
no minimum requirement.
Disk Space
no minimum requirement.
Operating System
no minimum requirement.

Step 1 - verify Java installation in your machine

Now, open console and execute the following java command.

OS
Task
Command
Windows
Open Command Console
c:\> java -version
Linux
Open Command Terminal
$ java -version
Mac
Open Terminal
machine:~ joseph$ java -version

Let's verify the output for all the operating systems:

OS
Output
Windows
java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)
Linux
java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)
Mac
java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)

If you do not have Java installed, install the Java Software Development Kit (SDK) from http://www.oracle.com/technetwork/java/javase/downloads/index.html. We are assuming Java 1.7.0_25 as installed version for this tutorial.

Step 2: Set JAVA environment

Set the JAVA_HOME environment variable to point to the base directory location, where Java is installed on your machine. For example;

OS
Output
Windows
Set the environment variable JAVA_HOME to C:\Program Files\Java\jdk1.7.0_25
Linux
export JAVA_HOME=/usr/local/java-current
Mac
export JAVA_HOME=/Library/Java/Home

Append Java compiler location to System Path.

OS
Output
Windows
Append the string; C:\Program Files\Java\jdk1.7.0_25\bin to the end of the system variable, Path.
Linux
export PATH=$PATH:$JAVA_HOME/bin/
Mac
not required

Verify Java Installation using java -version command explained above.

Step 3: Download JMeter

Download latest version of JMeter from http://jmeter.apache.org/download_jmeter.cgi. At the time of writing this tutorial, I downloaded apache-jmeter-2.9 and copied it into C:\>JMeter folder.

The directory structure should look like as below:

  • apache-jmeter-2.9
  • apache-jmeter-2.9\bin
  • apache-jmeter-2.9\docs
  • apache-jmeter-2.9\extras
  • apache-jmeter-2.9\lib\
  • apache-jmeter-2.9\lib\ext
  • apache-jmeter-2.9\lib\junit
  • apache-jmeter-2.9\printable_docs

You can rename the parent directory (i.e. apache-jmeter-2.9) if you want, but do not change any of the sub-directory names.

Step 4: Run JMeter

Once the you download the JMeter, goto to the bin directory. In our case it would be /home/manisha/apache-jmeter-2.9/bin. Now click on the following:

OS
Output
Windows
jmeter.bat
Linux
jmeter.sh
Mac
jmeter.sh

Once clicked on the above file, after a short pause, the JMeter GUI should appear which is a Swing application as seen in the image below:

 
 
 

 

No comments:

Post a Comment

TestNG - Can i use the 2 different data providers to same @test methods in TestNG?

public Object [][] dp1 () { return new Object [][] { new Object [] { "a" , "b" }, new Obje...