What is JMeter?

JMeter is a framework of Apache. It can use as a load testing tool for analyzing and determining the performance of a variety of services with a focus on web applications. Its latest version is 5.1 which was released on 19 Feb 2019 and, its first version was released in 1998. it uses Apache license 2.0. It is developed in Java and developed by Apache software foundation.

JMeter is an open source application. It also can be used as a unit testing tool for JDBC database connection, FTP, LDAP, Web services, JMS, HTTP any many moreIt runs on any environment accepting Java Virtual Machine, e.g., Windows, Linux, Mac, etc.

Let’s see an example: how the “Gmail” supporting server will perform when numbers of users access the Gmail account at the same time – basically they have to do performance testing holding performance testing tools like JMeter, LoadRunner, etc.

Apache Jmeter Introduction

Before understanding Overview of JMeter, let see these three testing approach,

Performance Test: This test generates the best possible performance of the system or application under a configuration of infrastructure. Very fast, it also points the change need to be made before the ultimately Application goes into production.

 Load Test: This test is useful for regulating and introducing the system under the top load it was trained to work under the process.

 Stress Test: This test tries to break the system by destroying its resources.

Features of JMeter

There are some important features of JMeter which are given below:

  • Open source application: JMeter is a free of cost open source application which maintains users or developers to use the source code for other enlargement or variation purpose.
  • User – friendly GUI: JMeter has natural GUI. It is straightforward and easy to use, and users get friendly very soon with it.
  • Platform independent: However, it is entirely a Java-based desktop application. It can run on any platform. It is hugely flexible and capable of loading the performance test in distinct server types: Web – HTTP, HTTPS, SOAP, Database via JDBC, LDAP, JMS, Mail – POP3.
  • Write your test: Using plugins, we can write our test case to extend the testing process. JMeter uses a text editor to create a test plan and supplies in XML format.
  • Support various testing approach: J Meter supports distinct testing proposition like Distributed t
  • Testing, load testing, and Functional Testing, etc.
  • Simulation: JMeter can pretend various users with the same threads, generate heavy load against web application under test.
  • Support multi-protocol: JMeter tests web application and database server, and it also supports protocols like; HTTP, JDBC, LDAP, SOAP, JMS, and FTP.
  • Script Test: JMeter is expert to perform automation testing by using Bean Shell & Selenium.
  • Multi-threading framework: It’s a fully multi-threading framework permits synchronize sampling by many threads and simple sampling of different functions by distinct thread groups.
  • Easily understandable test result: It conceptualizes the test result in a format such as a chart, table, tree, and log file are very simple to understand.
  • Easy installation step: run only the “*.bat” file to use JMeter. In Linux/Unix – JMeter can be preceded by clicking on JMeter shell script. In Windows – JMeter can be a move toward by starting the JMeter.bat file.

JMeter architecture working process

JMeter imitates the number of users send the request to an appropriate server which shows the performance of a proper server through tables, graphs, etc. The figure below depicts this process:

Architecture of Apache Jmeter

How to install J Meter

If Java is already in your desktop, then follow these steps otherwise install java firstly then follow these steps.

Start JMeter in three modes

We can open JMeter by using three modes – GUI Mode, Server Mode, and Command Line Mode:

1: In GUI Mode: there JMeter runs on a client computer

In Windows – Firstly, open Apache-JMeter-2.11 folder, click on the bin folder, and then click on JMeter.bat file will open v2.11 JMeter application. Shown in the following the figure:

How to install J Meter

If  you click on JMeter.bat, it opens JMeter – 2.11, given in the chart below:

How to install apache jmeter

2: In Server Mode: JMeter runs on the server computer:

It is fundamentally a client-server model distributed testing mode. In this activity, JMeter runs on the server computer as a server component.

If we want to start JMeter in server mode, run the bat file: bin\JMeter-server.bat.

shown in the figure below:

JMeter runs on the server computer

3: JMeter in Command line mode:

If we open JMeter in a GUI(Graphical user interface) method, it takes more memory space to open it.  If you don’t want your computer to consume more ways to run JMeter, then you can open JMeter in command line mode according to your choice.

Write this command in a command line prompt:

JMeter -n -t testPlan.JMX – l log.jtl -H 127.0.0.1 -P 8000”to open JMeter, shown in the figure below,

Where,

JMeter–n: Shows that JMeter will run on the command line approach.

-t testPlan.jmx: Name of the file contains the Test plan.

– log.jtl: Shows the log files which carries the test result.

-H 127.0.0.1 -P 8000: Proxy server hostname and port.

JMeter in Command line mode

The  Test Plan element of JMeter

There are some common elements of JMeter:

  • Test plan
  • Thread group
  • Controller
  • Listeners
  • Timers
  • Configuration Element
  • Pre-Processor Element
  • Post-Processor Element

Test plans: Test plan is a body of JMeter, which describe the sequence of steps run at a time.  A final test plan is made up of one or many Thread Groups, Sampler, logic controllers, listeners, timers, assertions, and configuration elements. Each Sampler can be introduced by one or more Pre-processor element, proceeding by Post-processor element, or Declaration element. It saves in “Java management extensions” (JMX) format.

Thread Group: Thread Group is the beginning stage of a test plan. The name, thread Groups, constitute a group of Threads. Under this group, each thread replicates one real user requests to the server.

A control on a thread group makes it possible to set the number of threads on each group. Also can control remaining time and the  test repetition.

Test Plan element of JMeter

Controllers of JMeter

There are two types of controllers:

 a) Samplers

b) Logical Controllers

1) Samplers:

Samplers make easy JMeter for delivering specific types of requests to the server. It simulates a user’s request for a page from the target server. So that, to avail POST, GET, DELETE functions on an HTTP service, user can add HTTP Request sampler. Aside from HTTP Request sampler, there are some other simpler too

  • HTTP Request
  • FTP Request
  • JDBC Request
  • Java Request

2) Logical Controllers

Logic Controllers determine the order of processing of Samplers in a Thread. It recommends a technique to control the flow of the thread group. Logic Controllers facilitates to accommodate the logic that JMeter uses to resolve when to send requests. The logic controllers can change the child element.

Logic Controllers of  JMeter are:

  • Runtime Controller
  • IF Controller
  • Transaction Controller
  • Recording Controller
  • Simple Controller
  • While Controller
  • Switch Controller
  • For Each Controller
  • Module Controller
  • Include Controller
  • Loop Controller

Test Fragments: Test Fragments is a different type of element detects at the same extent as Thread Group element. It is differentiated from a Thread Group in that it is not performed unless it is referenced by either a Module Controller or an Include Controller. This element is honorably for code re-use within Test Plans.

Listeners: Listeners ease viewers to view Samplers result in the structure of tables, graphs, trees or simple text in some log files and also give pictorial access to the data composed by JMeter about those test cases as a selection component of JMeter is executed.

  • Graph Results
  • Sp line Visualizer
  • Assertion Results
  • Simple Data Writer
  • Monitor Results
  • Distribution Graph
  • Aggregate Graph

Timers: We are using threads, controllers, and samplers then JMeter will blast your application with nonstop requests, To perform load/stress testing on your application. It is not the real domain or attribute of the actual traffic. JMeter thread sends a request without stopping between each sampler. This not as well as you want. We can sum a timer element which will permit us to define a period to wait between each request.

So, to replicate real traffic or create extreme stress – orderly, JMeter provides you Timer elements.

Types of timers are:

  • Synchronizing Timer
  • JSR223 Time
  • Bean Shell Time
  • Gaussian Random Timer

Configuration Elements: Configuration Element is a natural element where you can collect the corporate configuration values of all samples, e.g., webserver’s hostname or database URL.

These are some mainly used configuration elements in JMeter,

  • Java Request Defaults
  • LDAP Request Defaults
  • LDAP Extended Request Defaults
  • Key store Configuration
  • JDBC Connection Configuration
  • Login Configure Element
  • CSV Data Set Configuration.

Pre-processor Elements:

A Pre-Processor element is executed before the request constructed by the sampler. If a Pre-processor is appended to a sampler element, then it will achieve just preceding to that sampler element running.

A Pre-processor element is used to improve the settings of a sample request just before it runs, or to update variables that are not disengaged from response text.

This  is a list of all Pre-processor elements provided by JMeter:

  • JDBC Pre-processor
  • JSR223 Pre-processor
  • RegEx User Parameters
  • BeanShell Pre-processor
  • BSF Pre-processor
  • HTML Link Parser
  • HTTP URL Re-writing Modifier
  • HTTP User Parameter Modifier
  • User Parameters

Post-processor Elements:

A Post-processor element is executed after a sampler request has been generating. If a Post-Processor is attached to a Sample element, then it will execute just after that sampler element runs.

A Post-processor is most commonly used to process the response data, for example, to extract a particular value for future purpose.

Some of the Post-processor elements provided by JMeter are below:

  • CSS/JQuery Extractor
  • BeanShell Post-processor
  • JSR223 Post-processor
  • JDBC Post-processor
  • Debug Post-processor
  • Regular Expression Extractor
  • XPath Extractor

Performance Testing using JMeter

To focus on the speed, scalability, and stability of any software is performance testing. The target of performance testing is not only finding bugs but to find out the bottlenecks and overcome them. Performance testing also checks reliability, scalability and reliability and resource usage & how the application is resistant in workload situation. It can also be used to inspect complete server performance under heavy load.

Performance Testing using JMeter

Performance testing provides many benefits using JMeter

  • JMeter is useful to test the static resources and dynamic resources Like JavaScript and HTML(static resources) JSP, Servlets, Ajax.
  • JMeter is useful to determine the maximum number of users working at the same time the website can handle.
  • JMeter is useful to provide much graphical analysis of performance report.

JMeter Performance Testing contains

  • Load Testing: Load testing is a part of performance testing to analyze the performance of the system under the load situation. Load testing can be performed when a synchronous number of users shows of specific application at a particular period. Using JMeter, Load Testing models the evaluated usage by assuming multiple users get the web services at the same time.
  • Stress Testing: Stress testing is essential to identify the upper limits of capacity within the system. Usually, we go this testing to recognize the system’s activeness in terms of overload and accommodate application administrators to judge if the system will perform satisfactorily if the current load goes well above the ordinary maximum.

Any application or web server has a supreme load capacity when the server gets overloaded       afar its load capacity, and it will start responding slowly and generate errors. In JMeter, Stress    Testing is useful to resolute the maximum load the web server can hold.

How to use Assertion in JMeter

What is assertion: Assertion means mainly that your server under test returns the expected result.

Types of Assertions:

  • Response Assertion
  • Size Assertion
  • XML Assertion
  • HTML Assertion
  • Steps to use Response Assertion
  • duration Assertion

Response Assertion

Response Assertion

The response declaration lets you add pattern strings to be estimated against various fields of the server response.

E.g., you send a user request to the website http://www.google.com and get the server response. You can use Response Assertion mainly to verify if the server response contains assume pattern string. (e.g. “OK”).

Duration Assertion

Duration Assertion

The duration Assertion tests that every server response was received within a given amount of time. Any reaction that takes longer than the given number of milliseconds is showed a failed intervention.

For example, a request is sent to “www.google.com by JMeter and get a response in less then expected time 5 ms then Test Case pass, else, test case failed.

Size Assertion

The Size Assertion tests that each server hold the expected number of a byte in it. You can describe that the size can be equal to, higher than, less than, or not equivalent to a given amount of bytes.

JMeter sends a request to “www.google.com and gets response packet with size less than expected byte 5000 bytes a test case pass. If else, test case failed.

XML Assertion

The XML Assertion tests the response data consists of a regularly correct XML document.

XML Assertion

HTML Assertion

The HTML Assertion qualifies the user to check the HTML syntax of the response data. It means the response data must reach the HTML syntax.

HTML Assertion

Steps to use Response Assertion:

In this test, we are just using Response Assertion to generate the response packet from “www.google.com” meets your assumed string.

It is the roadmap for this test:

Steps to use Response Assertion

The response assertion control panel let you add pattern strings to be compared in opposition of various fields of the response.

JMeter Functions:

JMeter Function is mention as particular values that can occupy fields of any sampler or another element in the test tree.

Syntex of function in JMeter:

Here “__functionName” matches the name of a function and Parentheses edged the parameters sent to the function.

If a function parameter accommodates a comma, then be sure to escape this with “\,” else JMeter will behave it as a parameter delimiter.

For example:

List of functions:

Type of function Name Comment
Information ThreadNum Get thread number.
Information simpler name Get the sampler name.
Information machineName Get the machine name
Information log Display a message and return a value
Input FileToString Read  an entire file
Input StringFromFile Read a line from file
Input CSVRead Read from CSV Delimited file
Input XPath Used an XPath expression to read from a file
Calculation intSum Add integer numbers.
Calculation long Add large numbers.
Calculation Random Calculate a random number
Calculation RandomString Calculate a random string.
Calculation Counter Generate an incrementing number.
Scripting BeanShell Run a BeanShell Script.
Scripting JavaScript Run a JavaScript code.
Properties property Read a property
Properties P Read a property(Shorthand Method)
Variables Split Split a string into variable
Variables V Evaluate a variable name
Variables eval Evaluate a variable expression.
String Char Generate Unicode character from a list of no.
String Unescape Process string containing Java Escape seq.
String TestPlanName Return the name of the current test plan.

Note: JMeter functions and variables are always case sensitive.

 Syntex of JMeter Log functions:

Syntex for time function:

Testing Regular Expression of JMeter

Another resembles to use a simple test plan to test the regular expressions. The Java Request sampler can be used to generate a sample; otherwise, the HTTP Sampler can be used to load a file. Add a Debug Sampler, and a Tree View Listener then changes to the regular expression can be tested quickly, without the desire to access any external servers.

Adding Elements with Hotkeys in JMeter:

When you do earnest scripting with JMeter, there is a way to add elements to test plan briskly with keyboard shortcuts. Some Default bindings(shortcuts) are below:

Ctrl + 0

Thread Group

Ctrl + 1

HTTP Request

Ctrl + 2

Regular Expression Extractor

Ctrl + 3

Response Assertion

Ctrl + 4

Constant Timer

Ctrl + 5

Test Action

Ctrl + 6

JSR223 Post Processor

Ctrl + 7

JSR223 Pre Processor

Ctrl + 8

Debug Sampler

Ctrl + 9

View Results Tree

The binding above is considered for Windows QWERTY keyboards. For other platforms and keyboards assure you adapt those values.

To change these binding, please find “gui.quick_*” properties within JMeter. Properties file as an example, it is approved to put overrides for them into the user — properties file.

Glossary(Conclusion):

Elapsed time:  J Meter measures the expire time from just before sending the request to just after the last response has been received. JMeter does not include the time to deliver the intervention, nor does JMeter process any client code, e.g., JavaScript.

Latency: JMeter measures the latency just before sending the request to just after the first response has been received(completed). Thus the time includes all the processing needed to reunite the application as well as assembling the first part of the reaction, which in general will be longer than one byte.

Connect Time: JMeter measures the time that it took to empower the connection, including SSL handshake. Note that connect time is not approximately deducted from latency. In case of a connection error, the metric will be equal to the time it took to face the error, for example, In case of Timeout, it can be equivalent to connection timeout.

The Future of JMeter

I hope to see JMeter’s proficiency fastly expand as developers take advantage of its eligible architecture. The main goal of the developments will be:

  • Support of HTTP/2 protocol
  • Possible rework of core architecture to introduce a pool of threads or switch to the asynchronous model allowing us to take advantage of async io.
  • Enhancements to Webservices protocols (REST / SOAP)
  • Growth of JMS protocol implementation.

 

Pin It on Pinterest

Share This