Skip to content

Using Multiple CSV Files with JMeter Engines in LoadFocus

When conducting load tests using Apache JMeter on the LoadFocus platform, there may be scenarios where your test runs on several load generators and each one needs its own CSV data file. Each load generator runs its own copy of JMeter, and the New JMeter Test page counts them as JMeter engines. This approach can be particularly useful when you want to simulate different sets of data for each load generator to mimic varied user behaviors or data sets in your load tests.

Using Multiple CSV Files with JMeter Engines

Setting Up Different CSV Files for Each Load Generator

Section titled “Setting Up Different CSV Files for Each Load Generator”

In a typical load test, you might use a single CSV file that is shared across all load generators. However, for more complex tests where each one needs to work with a unique data set, you'll need a way to dynamically specify which CSV file each load generator should use.

LoadFocus allows you to use environment variables to dynamically select the appropriate CSV file for each load generator. This method ensures that each one uses its designated data file, which is essential for accurately simulating different user scenarios.

  1. Prepare Your CSV Files:
  • For each load generator, prepare a separate CSV file.
  • Name these files in a sequential manner. For example, if you have two load generators, you might name your files config1.csv and config2.csv.
  1. Upload Your Files to LoadFocus:
  • Upload all your CSV files to the LoadFocus platform.
  • Ensure that each file is correctly named as per the sequence you have planned (e.g., config1.csv, config2.csv).
  1. Configure JMeter Test:
  • In your JMeter test plan, navigate to the component where you are specifying the CSV file (usually a CSV Data Set Config element).
  • In the Filename field, use the following format to dynamically select the file based on the load generator index:
    config${__env(LF_SESSION_INDEX)}.csv
  • This configuration uses JMeter's built-in function to retrieve the environment variable LF_SESSION_INDEX, which LoadFocus sets for each load generator.
  • When you run your test, LoadFocus gives each load generator its own LF_SESSION_INDEX, counting from 1 inside each location. The New JMeter Test page shows how many load generators the test uses ("This test will run using N machines.").
  • The first load generator will have LF_SESSION_INDEX set to 1, so it will read config1.csv.
  • The second load generator will have LF_SESSION_INDEX set to 2, thus reading config2.csv, and so on.
  • The count restarts in every location. If you run from more than one location, load generator 1 in each location reads config1.csv, so upload as many files as the largest number of load generators in any single location.

To inspect the results of your Apache JMeter load test, see Analyzing load test results.