Kevin Rave
Kevin Rave

Reputation: 14426

JMeter - Multiple requests at the same time but with different values

Can someone shed some light on how to structure JMeeter for the requirement below:

I have to send two requests.

  1. Send request and get some data back. This is not for performance test, but just to get the data.
  2. From the values, lets call it "tokens", we take 5 tokens and send 5 requests with those tokens simultaneously to get the response.

Currently, I have one "Thread Group" and two "HTTP Requests" under it. One is to get the data (step 1 above) and the 2nd one is to generate 5 requests (possible?).

I am using "Synchronizing timer" to generate 5 requests simultaneously. I know I can create "CSV data Config" element and generate a CSV from the 1st request and write 5 tokens into this CSV. But I am not sure if automatically generates 5 requests simultaneously.

Upvotes: 2

Views: 3153

Answers (1)

Zubair M Hamdani
Zubair M Hamdani

Reputation: 1733

This can not be done by using CSV Data set config alone, you will have to write some code using Beanshell Sampler

Thread 1

  1. Create HTTP requests to fetch data
  2. Extract your data using Regex Extractor
  3. See the sample code below to write your data to CSV file

    `import java.io.FileWriter;
    import java.io.IOException;

    String ID = vars.get("id");
    String Pass_wd = vars.get("password");

    //Change the file path below
    FileWriter writer = new FileWriter("F:\test_20140526.csv", true);

    if (ID != "")
    {
    writer.append(ID);
    writer.append(',');
    writer.append(Pass_wd);
    writer.append('\n');
    writer.flush();
    }
    writer.close();`

Thread 2

  1. Use CSV Data Set Config, use "test_20140526.csv" created in Thread 1
  2. Run 5 requests simultaneously using Synchronization Timer, pass CSV data in parameters.

Note: Click on Test Plan, Check/select setting "Run Thread Groups Consecutively"

Hope this will help.

Upvotes: 1

Related Questions