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.

Auto-Correlation requires recording Test Plan with Auto-Correlation Recording Template.

Auto-Correlation Recording Template is a modified version of Recording Template which uses Correlation Response Recorder instead of View Results Tree to record response data.

Steps to record a Test Plan

  1. Go to JMETER_HOME/bin and start JMeter with jmeter.bat on Windows and jmeter.sh on Linux/Unix.
  2. Select File → Templates... on the menu bar.
  3. Select Auto-Correlation Recording Template on the list and click Create button.
  4. Fill the parameters and click Create button.
  5. A complete Test Plan is generated

Please follow the Recording documentation here from Step 5 onwards.

25.1.1 JMX File

Auto-Correlation using a JMX Test Plan.

Steps

1. Record a Test Plan for a testing scenario using the steps mentioned here and save it (say TestPlan_recording_one.jmx).
2. Record another Test Plan with the same scenario. It is not required to save this test plan.
3. Click on Tools → Correlation → JMX File.

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

A file browse menu will open.

Figure 2 - The browse menu for JMX file
Figure 2 - The browse menu for JMX file
4. Browse for the Test Plan saved in Step 1 (TestPlan_recording_one.jmx)
5. Click on Correlation button.

A list of dynamic parameters for correlation will be displayed in the table.
For more details on the parameter naming convention refer here.

Figure 3 - The list of parameters which can be correlated
Figure 3 - The list of parameters which can be correlated
6. Select (click check-box) the parameters you want to correlate and Click OK button.
If successful, the following dialog box will be displayed and extractors will be added in the script.

Figure 4 - Successful Correlation
Figure 4 - Successful Correlation
If unsuccessful or partially successful, one of the following errors will be displayed.


Figure 5 - Failure and Partial failure dialog boxes
Figure 5 - Failure and Partial failure dialog boxes

If successful, you may try out the test plan.

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 into 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 button.
  4. 
Figure 6 - Export rule extractor list
    Figure 6 - Export rule extractor list
  5. Browse for the directory where you want to save the rule file and Click Save button.
    
Figure 7 - Save Rule File
    Figure 7 - Save Rule File
    A popup will be displayed for successful/failed rule export.
    
Figure 8 - Success/Failure dialog boxes
    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 using the steps mentioned here.
  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
    Figure 9 - Import Rule parameter list
  4. Select the parameters you want to correlate and Click OK button.

    Popups will be displayed for successful/failed correlation similar to the ones in correlation via JMX file.
    If successful, you may try out the test plan.

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.
    Go to top