Thursday, December 13, 2012

Correlation in Jmeter

JMeter correlation is a critical technique for robust performance testing, essential for effectively managing dynamic values within HTTP requests. This process is fundamental for creating reliable, repeatable, and scalable performance test scripts, primarily accomplished through the strategic use of the Regular Expression Extractor.

This demonstration utilizes a recorded login action on the IRCTC website. The subsequent steps meticulously detail how the dynamic Session_ID and Engine_ID parameters were successfully correlated, ensuring the script's consistent functionality and accuracy.

Examine the following HTTP request URL, which vividly illustrates the presence of dynamic parameters such as BV_SessionID:

https://www.irctc.co.in/cgi-bin/bv60.dll/irctc/booking/planner.do?screen=fromlogin&
BV_SessionID=[DYNAMIC_SESSION_ID_VALUE]&

{Left Boundary}     {Dynamic Value}     {Right Boundary}

This structure clearly demonstrates how dynamic values are consistently encapsulated between specific "Left" and "Right" boundary strings within the server's response, a pattern leveraged by the Regular Expression Extractor for extraction.

JMeter Correlation Steps:

  1. Identify Dynamic Values: The essential first step is to accurately pinpoint dynamic values within your recorded HTTP requests. For this case, Session_ID and Engine_ID were identified as parameters requiring correlation.
  2. Add Regular Expression Extractor for Session_ID: Attach a Regular Expression Extractor as a child to the HTTP Sampler responsible for retrieving the dynamic Session_ID. For example, a suitable regex would be: BV_SessionID=(.*?)&. Crucially, always verify the number of occurrences and the extracted value using JMeter's Regular Expression Tester to guarantee accurate data capture.
  3. Add Regular Expression Extractor for BV_EngineID: Similarly, add another Regular Expression Extractor for BV_EngineID. An illustrative regex for this parameter is: BV_EngineID=(.+)">. Again, confirm the number of occurrences and the extracted value using the Regular Expression Tester.
  4. Configure Template and Match No.: For each configured extractor, meticulously define the 'Template' field (e.g., $1$ to capture the content of the first matching group) and the 'Match No.' (e.g., 1 for the first occurrence, or -1 to capture all matches).
  5. Replace with Variables: The conclusive step involves replacing the hardcoded dynamic values of BV_SessionID and BV_EngineID in subsequent HTTP requests with their corresponding JMeter variables (e.g., ${S} and ${E}, where 'S' and 'E' are the variable names specified in your Regular Expression Extractors).

For a comprehensive visual walkthrough of these correlation steps within JMeter, please consult the screenshot provided below.

No comments: