Apache JMeter


25. Auto-Correlation

Auto-Correlation feature detects the dynamic parameters and adds response data extractors for them.
A Test Plan using HTTP(S) requests can be correlated using this functionality.

25.1 How to perform Auto-Correlation

There are two ways to perform Auto-Correlation.

Test Plan must be recorded using the documentation shared here.

25.1.1 JMX File

Using a JMX Test Plan.

Steps


(Important)
Tools → Correlation → JMX File

Figure 1 - The menu where correlation via JMX file is located


Figure 2 - The browse menu for JMX file

Correlation.

here

Figure 3 - The list of parameters which can be correlated
OK

Figure 4 - Successful Correlation


Figure 5 - Failure and Partial failure dialog boxes


25.1.2 Import/Export Rule

Before correlating a Test Plan using Import/Export rule functionality, you need to export the rule from an existing correlated Test Plan.



Export Rule

It allows you to export the response extractors in your Test Plan in a rule file.

Steps

  1. Create/Open a Test Plan which has correlated parameters in it.
  2. Click on Tools → Correlation → Export Rule .
    A list of extractors for which the rules can be created will be displayed.
  3. Select the extractors for which you want to create rule and Click Export.

  4. Figure 6 - Export rule extractor list
  5. Browse for the directory where you want to save the rule file and Click Save.

    Figure 7 - Save Rule File
    A popup will be displayed for successful/failed rule export.

    Figure 8 - Success/Failure dialog boxes


Import Rule

After you have created the rule file, a Test Plan can be correlated using that rule file.
Details about the rule file format can be referred here.

Steps

  1. Record a Test Plan.(Important)
  2. Click on Tools → Correlation → Import Rule .
    A list of parameters which can be correlated based on the rule will be displayed.

  3. Figure 9 - Import Rule parameter list
  4. Select the parameters you want to correlate and Click OK.
    A popup will be displayed for successful/failed correlation.


25.2 Mistakes to avoid and Best practices


Mistakes to avoid

  • Correlate an empty test plan or a test plan with no HTTP Requests.
    Example: Create a new test plan and try to correlate it using either JMX File or rule file.
    Error: Current GUI TestPlan doesn't have any HTTP(S) Requests. Please record a plan and try again.
  • Correlate a test plan which is not a recorded plan.
    Example: Open an existing test plan and try to correlate it using either JMX file or rule file.
    Error: No Response data found. Make sure you have recorded the script and not opened it.
  • Correlate using an empty/invalid JMX file.
    Example: Record a test plan and try to correlate it using an empty JMX test plan.
    Error: Could not load the JMX file. Please check the file and try again.
  • Correlate using a JMX file with no HTTP requests.
    Example: Record a test plan and try to correlate it using a JMX test plan with no HTTP Requests.
    Error: Imported JMX file doesn't have any HTTP(S) Requests. Please check the file and try again.
  • Rule file should not be created manually, and if you are creating manually then user should follow rule file format
  • User should not try to perform correlation multiple times on extracted parameters.
  • Correlate while recording is still running.
    This must be avoided in order to avoid any crashes.


Best practices

  • Only select the parameters which you thing should be correlated.
    Dynamic parameters' list include parameters which should not be correlated for example username, password, date, etc...
    Hence, select the parameters from the list who you think should be correlated for example authToken, csrf token, etc...

25.3 Correlatable parameter Naming Convention

Correlatable parameters are named as follows

  • Parameter in request header (Authorisation)
    Correlatable Parameter Name = "Authorisation"
  • Parameter in request body or query string
    Correlatable Parameter Name = Actual Parameter Name
    If parameter occurs twice or more then correlatable parameter name is appended by "(parameter count)"
    Example: authenticity_token, authenticity_token(1)

25.4 Rule file format

List of rule file Extractors and their attributes

Type of Extractors Details about extractor's attribute Example of Rule File
CSS Selector Extractor Rule
  • attribute
  • expr
  • name
  • type
  • { "rule": [{ "name": "$name", "expr": "$expr", "attribute": "$attribute", "type": "css_extractor" }] }

    JsonPathExtractor Rule
  • expr
  • name
  • type
  • { "rule": [{ "name": "$name", "expr": "$expr", "type": "jsonpath_extractor" }] }

    XPath Extractor Rule
  • expr
  • name
  • type
  • {{ "rule": [{ "name": "$name", "expr": "$expr", "type": "xpath2_extractor" }] }

    RegexExtractor Rule
  • expr
  • name
  • type
  • { "rule": [{ "name": "$name", "expr": "$expr", "type": "regex_extractor" }] }
    • type attribute value can be "regex_extractor" or "regex_header" based on the applied extractor type
    BoundaryExtractor Rule
  • name
  • type
  • lBoundary
  • rBoundary
  • { "rule": [{ "name": "$name", "lBoundary": "$lBoundary", "rBoundary": "$rBoundary", "type": "boundary_extractor" }] }

    25.5 Limitations
    • If the auto-correlation is done once then it cannot be undone, you need to record the plan again to correlate the script.




    Copyright © 1999-2020, Apache Software Foundation $Id$
    Apache, Apache JMeter, JMeter, the Apache feather, and the Apache JMeter logo are trademarks of the Apache Software Foundation.