Iteratively send list of bodies to endpoint

My desired scenario is as follows: I have a list of URLs. I would like to obtain load testing results for GET requests to every single URL separately. In other words, I want it to perform N (say 100) requests per URL and show the results separately in the Gatling dashboard.

Currently, the code looks like this

private final ScenarioBuilder scenario =
    scenario("Requests")
      .exec(
        http("Single request")
          .get(<URL from list of URLs>));

I then set up and activate the scenario like this

    setUp(scenario.injectOpen(
      constantUsersPerSec(5)
        .during(Duration.ofSeconds(5))))
      .protocols(httpProtocol);

And for any future Gatling beginners, I use the following protocol setup

private final HttpProtocolBuilder httpProtocol =
  http.userAgentHeader("Gatling response profiling");

How do I adapt my code such that a load test is executed for every URL in the list?

Hi @GIGATeun,

Did you consider using Feeders?

Cheers!

@sbrevet yes. Let’s give a full working example. Suppose we use

  FeederBuilder feeder = listFeeder(Arrays.asList(
    Collections.singletonMap("url", <URL 1>),
    Collections.singletonMap("url", <URL 2>)
  )).random();

and adapt our code as follows

private final ScenarioBuilder scenario =
    scenario("Requests")
      .feed(feeder)
      .exec(
        http("Single request")
          .get("#{url}"));

Then the Gatling dashboard will aggregate all of the requests under the same name under the “Details” view. What I want is for Gatling to split them up, and analyze them separately as if they were different load tests. I don’t want to manually change the parameters and rerun Gatling.

Under which does Gatling aggregate? I guess under "Single request".
You may try to put it in your request name. Beware that the amount of different names is limited for performance reason.

private final ScenarioBuilder scenario =
    scenario("Requests")
      .feed(feeder)
      .exec(
        http("#{url}")
          .get("#{url}"));

Cheers!

Yes, the Gatling dashboard appears to aggregate under "Single request". Your example provides a great solution. I was unaware you could use feeders this flexibly. Thanks!

Also the topic title is incorrect I see now. Initially I wanted to send different bodies to one endpoint, but I decided to provide another use case halfway through. The core of the question remains the same though.