More on Feeders

Hi,

I have two more questions on feeders:

  1. Is there an idiom for repeating a block until a feeder is empty, feed()ing for each iteration? I’ve come up with something like this:


asLongAs(feeder.hasNext) {
feed(feeder)

}

Is that fine or is there a better approach? I’m trying to avoid “Feeder is now empty, stopping engine” errors. When the feeder is empty, the scenario should simply continue. At the same time I don’t want to need to know the size of the feeder in advance, otherwise I could just use repeat(). I’m streaming possibly very large JSON documents through a custom feeder, one object at a time, without loading them all in memory at once, so I don’t know how many there are in advance (it would be possible to encode the size in the very beginning of the JSON source, of course).

  1. Is there a specific requirement that calls for feeders to return Map[String, String] instead of Map[String, Any]? Since the results are injected into the current user session and the session is essentially Map[String, Any]. It would be nice to be able to inject more than just Strings into the session from a feeder.

Thanks.

  • Roman

Sorry the first example should’ve been:

asLongAs(session => feeder.hasNext) {
feed(feeder)

}

  • Roman

2012/11/16 Roman Borschel <roman.borschel@googlemail.com>

  1. There’s currently no built-in for what you’re trying to achieve (might be a good idea to have one though).

The limitation with your implementation is that you use your feeder in 2 different actors: the one in charge of the loop and the one in charge of your feed, so your custom feeder has to be thread-safe, which will have an impact on performance.

I’ll try to come with a solution, but I won’t be able to work on it before a few days.

Until then, please notice that if your feeder runs out, the simulation will stop abruptly but the simulation.log file is not lost and you can still generate the reports with the -ro option.

  1. You’re right, I’ll change the signature.

Cheers,

Stéphane

  1. There’s currently no built-in for what you’re trying to achieve (might be a good idea to have one though).

The limitation with your implementation is that you use your feeder in 2 different actors: the one in charge of the loop and the one in charge of your feed, so your custom feeder has to be thread-safe, which will have an impact on performance.

I’ll try to come with a solution, but I won’t be able to work on it before a few days.

Thanks for considering it, no rush!

Until then, please notice that if your feeder runs out, the simulation will stop abruptly but the simulation.log file is not lost and you can still generate the reports with the -ro option.

  1. You’re right, I’ll change the signature.

Great, thanks.

Have a nice weekend.

  • Roman

Hi Roman,

Are you sure that you hit a limitation with Feeders being based on Map[String, String]?

As Map is covariant in value type, if I change from Map[String, String] to Map[String, Any], people who have been using the current signature will have to downcast when popping a record.

Cheers,

Stéphane

Hi Stéphane,

I hit it when I wanted to put some arrays/lists into the session from a feeder. In other words, the problem exists under these circumstances:

  1. You want to construct a request body from session information which is aggregated from multiple feeders.
  2. A single feeder doesn’t have access to all the data to construct the request body itself as a string, because it doesn’t have access to the session (i.e. it would need session data put in previously by another feeder).
  3. So you end up with the idea of just putting the data structures into the session from each feeder and do the request body construction in another step that has access to the full session. That doesn’t work because the feeder must return strings.

So basically, the problem is a result of the precondition that feeders don’t have access to the session, which seemed fine to me but I didn’t see the obvious reason for only returning strings from feeders as that stuff is just put into the session.

I hope that sums it up.

Where does the downcast need to occur?

Regards

  • Roman

2012/11/19 Stéphane Landelle <slandelle@excilys.com>

Of course the described scenario implies that you have some more structured/nested data you’re parsing in the feeder, not just strings in which case it works just fine.

  • Roman

2012/11/19 Roman Borschel <roman.borschel@googlemail.com>

Hi Roman,

I’ve change the Feeder signature in master:
https://github.com/excilys/gatling/issues/829

Note that you can use templates for building request bodies (and those get injected with the session content):
https://github.com/excilys/gatling/wiki/HTTP#wiki-template-body

Also note that you can now easily map the output of a Feeder[String]. For example:

val richTestData = tsv(“test-data.tsv”).queue.map {
_.map {
case (key @ “keyOfAMultivaluedColumn”, value) => (key, value.split(","))
case keyVal => keyVal
}
}

Cheers,

Stéphane

PS: the downcast was an error of mine in my first attempt to change the Feeder signature