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

Parameterization in JMeter / CSV Dataset Config

CSV Dataset Config (Parameterization):


To pass the different set of user inputs for different threads running on the server during the load test execution.
Configure the CSV file in CSV Data Set Config and add in the thread group where it is required

Replace the parameter value as ${Parameter} in corresponding HTTP Request.


Attributes in CSV Data Set Config:


Attribute
Description
Name
Descriptive name for the CSV Data set config that is shown in the tree
Filename
Name of the file to be read and it also specifies the path of the particular file
File Encoding
Used to read the data from the file in the specific encoding format
Variable Names
List of variable names are mentioned using comma delimiter (Parameter Names)
Delimiter
Used to split the records in the file
Allow quoted data?
Allow values to be quoted in double quote or a delimiter
Recycle on EOF?
To specify, file be re-read from the beginning on reaching EOF
Stop thread on EOF?
Specifies to stop reading the file on reaching the EOF
Sharing mode
All threads: File is shared between all the threads
Current thread group: Each file is opened once for each thread group in which the element appears
Current thread: Each file is opened separately for each thread
Identifier/Edit: All threads sharing the same identifier share the same file


Right Click on ThreadGroup–> Add–>Config Element–> CSV Data Set Config



How to do correlation in JMeter

Correlation in JMeter / Regular Expression Extractor

Allows user to extract values from the server response using a Perl-type regular expression. As a post-processor, this element will execute after each Sample request in its scope, applying the regular expression, extracting the requested values, generate the template string and store the result into the given variable name.


1.1     How to write a regular expression


Step 1:

Run the particular test and try to identify the dynamic value in the in the View Results Tree.

Note:
Need to run for multiple times and compare the results manually. Some external tool can be used to compare the response.

Step 2:

Identify the LB, RB of the dynamic value

Step 3:

Write the regular expression for the dynamic value using the LB and RB. Check the particular regular expression using View Results Tree.

Step 4:

Find the occurrence (match number) for the required dynamic value

Step 5:

Add the regular expression extractor for the previous request.


Note: In the above figure, the regular expression mentioned was an example. 

Some Regular Expressions Parameters:

Characters
Description
()
It captures null value between LB and RB
(.+?)
It captures the correlated value between LB and RB. This function is used for ord=1 case or ord=all case
(.\d)
It captures the correlated value as digit format between LB and RB
(.*)
It captures the correlated value as character between LB and RB


Attributes in Regular Expression Extractor:

Attribute
Description
Name
Descriptive name for this element that is shown in the tree.
Apply to
Main sample only - only applies to the main sample
Sub-samples only - only applies to the sub-samples
Main sample and sub-samples - applies to both.
JMeter Variable - assertion is to be applied to the contents of the named variable
Response Field to check
Body - Used to check only in the body of the response
Body (unescaped) - Used to check the body of the response, with all Html escapes codes replaced.
Headers - may not be present for non-HTTP samples
URL - Used to check in the URLs
Response Code - Used to check based on the response code
Response Message - Used to check based on the response message
Reference Name
Name of the parameter variable
Regular Expression
Need to substitute the regular expression created
Template
The template used to create a string from the matches found
Match No.
Indicates which match to use
Default Value
If the regular expression does not match, then the reference variable will be set to the default value.


How to create transactions in JMeter

To create transactions in JMeter we do have a separate assertion called Transaction Controller

The Transaction Controller generates an additional sample which measures the overall time taken to perform the nested test elements.

Attribute
Description
Generate Parent Sample
If checked, then the sample is generated as a parent of the other samples in View Results in Table, else it is generated as an independent sample in View Results in Table.
Include duration of timer and pre-post processors in generated sample
Whether to include timer, pre- and post-processing delays in the generated sample. Default is false

















Make sure that all the required elements under a transaction must be moved to a specific Transaction Controller to get the exact response times.

JMeter Installation Procedure


As we know that JMeter was developed using Java-Swings, it is mandatory to install Java Development Kit (JDK version above 1.6) to run.

Step 1:

Download and install the JDK version above 1.6 and set the environment variables to point the base directory location where Java was installed on the machine

Step 2:

Download the JMeter source file latest version from the apache link mentioned below 


As it is an open source it doesn’t required any license.
Extract the downloaded .zip file in the required location where it is need to be installed.

Step 3:

To run JMeter go to bin directory of the extracted folder and click on the



Operating System
File to run
Windows System
jmeter.bat
Linux System
jmeter.sh
Mac Operating System
jmeter.sh

Prerequisites to install JMeter

As JMeter is a light weight tool which does not have any installation procedure to do (Please refer JMeter Installation Procedure), the minimum hardware requirements for running the JMeter in a machine is mentioned below


Prerequisites for Jmeter
Software and Hardware
Minimum Hardware Requirement
Recommended Hardware
JDK
JDK 1.6 and above
JDK 1.6 and above
RAM
Not Specific
4 GB
Processor
Not Specific
Processors with Minimum 4 MB Cache
Memory
Not Specific
80 GB
Operating System
Windows, Unix and Mac
Windows, Unix and Mac
Jmeter
Any Version
Jmeter 2.11


Note: Recommendations mentioned above are given by my experiences and it is not specified by Apache

Pros and Cons of JMeter

Pros of JMeter

·         Very light weight tool and can be installed easily
·         As it is an open source tool you need not to be worried on license
·         There are multiple plugins that are available in the market and can be installed easily according to the requirement
·         Caching and offline analysis/replaying of test results

 Cons of JMeter

·         It can be used only on web applications
·         Consumption of memory is high in GUI Mode and performance testing like Load, Stress and Endurance with high user load are preferred to run in NON-GUI mode
·         Complex scenario cannot be done using JMeter thread group
·         Recording in this is complex, as we need to setup the proxy manually

·         It supports only Java coding for custom coding

About JMeter


JMeter is an open source performance testing tool which supports different types of protocols and technologies. It is initially developed in NON-GUI mode to do performance testing on the Apache JServer (Apache Tomcat) and later enhanced to GUI mode which is used to do performance testing with a graphical interface using the swing API interface. The developed application was enabled to run on different types of environment like Windows, UNIX, Linux and Mac OS.
List of protocols that JMeter supports
·         Web - HTTP, HTTPS
·         Web Services: SOAP / XML – RPC
·         FTP
·         Database via JDBC
·         LDAC
·         Message-oriented middleware (MOM) via JMS
·         Mail - SMTP(S), POP3(S) and IMAP(S)
·         MongoDB (NoSQL)
·         Native commands or shell scripts
·         TCP