feeder that makes a http call?

Is there a way to make use of gatling’s existing ability to make http calls (and perhaps even access the http baseUrl stuff) in a feeder? I want to create a feeder that obtains authenticated test-users using a special HTTP POST call on the service I’m testing.

Why not simply create the user as part of the scenario, you ask? I already do that, for some scenarios. However, I now want to find out how my system behaves in the presence of supernodes so want to create a (comparatively) small number of ultra-connected users. I plan to use a feeder to create the supernodes, and make each of the (much more numerous) regular users follow a few of the supernodes at random.

Any help appreciated! A custom feeder is the best I’ve come up with so far, but there might be better ways to do this.

Stig

Hi Stig,

I’m not sure I understand: do you want to create new users on the fly during the Simulation run, or just retrieve them from the system?

I want to create new users during the simulation run. (My service has a special API call that I can activate that allows me to create authenticated users for testing, tagged with a test session id. They’re normal users, but for this extra test session id tag, so a single “delete test users with this test session id” deletes all the test users and their relationships & data.)

I suppose I could create the supernode users up front and populate a CSV file, but I thought the custom feeder was a more elegant approach. It saves having to do multi-step run procedures if I can just run the gatling script and it sets up the data it needs.

As an aside, is there a tearDown() / cleanUp() step that will run after all the scenarios in setUp has finished? I’d love to hook my “delete test users” call in at that point.

Stig

Regarding users creation, you’d better no do that during the run, but when the Simulation instance is created. You can call such code in the Simulation class body. Gatling HTTP DSL can’t be used for this, but you can use the underlying async-http-client engine:

Regarding tear down hook, you can register one on the Akka Actor system’s shutdown:

  • io.gatling.core.action.system.registerOnTermination

Hi Stéphane, I am trying to follow your advice to register teardown, but I cant do it in the definition of the simulation because the akka system has not been started. In Runner.scala you have the following sequence:


                        val simulation = simulationClass.newInstance
                        GatlingActorSystem.start

The instance of the class is instantiated and the registration code is executed before the Akka Actor system is initialized, causing an exception. Please advise.
FYI, I am on 2.0.0-SNAPSHOT while I await the M4 release.

Thanks
Harold.

Hi Harold,

I think I’ll add those hooks for M4.
For now, they will be very simple, meaning that signature will be () => Unit.
Is it OK?

Thanks, () => Unit is perfect.

Will try to implement this tomorrow: https://github.com/excilys/gatling/issues/1475