0
votes

Right now I'm having difficulty with a custom gatling feeder despite the fact that it's circular. I'm getting this error:

java.lang.IllegalStateException: Feeder is now empty, stopping engine

I'm reading this is the default behavior. However, I want to make sure each user users a different refurl from the feeder: refUrlFeederBuffer.

Also, why isn't it running my after method? I need my cleanup procedures to run regardless of the success or failure of the simulation. If I don't cleanup I can't restart the test!

var refUrlFeeder: Array [Map[String, String]] = Array()

before {
   //create stuff and put the refUrls from it in a map
     refUrlFeeder = refUrlFeeder :+ Map("refUrl" -> simpleUrl)
}

after {
   // delete whatever I created in the before method
   // THIS METHOD DOES NOT EXCUTE if the feeder is emptied
   // I need it to execute regardless of errors during the scenario
}

object ImportRecords {
    val someXml = "<some xml>"
    val feeder = RecordSeqFeederBuilder(refUrlFeeder).circular
    val update =
      feed(feeder)
      exec(http("Update stuff")
       .put("${refUrl}")
       .body(StringBody(someXml))
       .asXML
       .check(status.is(200))
)
}

val adminUpdaters = scenario("Admins who do updates").exec(ImportRecords.update) setUp(adminUpdaters.inject(atOnceUsers(1)).protocols(httpConf))

1

1 Answers

2
votes

When the feeder runs out of items Gatling stops whole engine. It is exceptional situation which is stated also in exception itself:

[error] java.lang.IllegalStateException: Feeder is now empty, stopping engine

Hook after is called only when simulation is completed. You can receive the errors in sense of logic in your simulation, but not developer bugs. Hook is not called when there is a developer bug, which in this case it is.

Simply running out of feeder is a bug, because it says that your setUp part of simulation is not in correlation with your provided data in this case your feeder.

Btw. what does your setUp part of the simulation looks like?

EDIT: Just looking at your code structure, I'm guessing (while not seeing the whole simulation), that initialisation of your ImportRecords happens before hook before is called and thus your val feeder contains empty array. Making an empty array circular will lead to just another empty array, hence you will get an exception when Gatling tries to take an element from feeder. Try to add:

println(refUrlFeeder)

into initialisation of your object ImportRecords to find out if this is the case.

Good luck