Ah, ok.
Well, I got the script to work beautifully. I can tell it how many rows to create, and it writes the CSV file just fine. Script consists of 7 requests that are chained together and share various attributes from the session object.
I now have a requirement to run this Scenario multiple times for a single virtual user. The number of times to repeat has to be a random Integer between 1 and some random max value that is provided at runtime (in this case from Jenkins).
I thought I could accomplish this by wrapping the entire Scenario inside a repeat block, but now I’m getting a runtime error from Gatling with text like this>
[ERROR] [02/10/2015 18:16:41.450] [GatlingSystem-akka.actor.default-dispatcher-2] [akka://GatlingSystem/user/$a] requirement failed: Scenario CreateFullDataSet is empty
java.lang.IllegalArgumentException: requirement failed: Scenario CreateFullDataSet is empty
at scala.Predef$.require(Predef.scala:233)
at io.gatling.core.scenario.Simulation$$anonfun$scenarios$2.apply(Simulation.scala:40)
at io.gatling.core.scenario.Simulation$$anonfun$scenarios$2.apply(Simulation.scala:40)
at scala.collection.immutable.List.foreach(List.scala:318)
at io.gatling.core.scenario.Simulation.scenarios(Simulation.scala:40)
at io.gatling.core.controller.Controller$$anonfun$1.applyOrElse(Controller.scala:80)
at akka.actor.Actor$class.aroundReceive(Actor.scala:465)
at io.gatling.core.akka.BaseActor.aroundReceive(BaseActor.scala:23)
at akka.actor.ActorCell.receiveMessage(ActorCell.scala:516)
at akka.actor.ActorCell.invoke(ActorCell.scala:487)
at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:238)
at akka.dispatch.Mailbox.run(Mailbox.scala:220)
at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:393)
at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
What would be the best way to fix this error?
Basic stripped layout of my code is below. My attempted changes are in Red.
val scnMyFullScenario = scenario(“CreateFullDataSet”)
// generate random number to set number of repeats
val start = 1
val rnd = new scala.util.Random
val hits = start + rnd.nextInt( (maxRepeatsPerUser - start) + 1 )
repeat( hits ) {
feed(senderFeeder)
.feed(receiverFeeder)
.feed(traceIdFeeder)
.feed(timestamp)
.feed(actionObjectFeeder)
// place part of payload into Session for further processing
.exec( session => { // doing stuff with session variables here
session })
.exec( http(“Request1”))).asJSON
.check(status.is(200)
, jsonPath("$.ids").saveAs(“PostId”))
)
.pause(50 milliseconds)
// remove unwanted characters from PostId
.exec(session => { // more session work
session })
.exec( http(“Request2” ))).asJSON
.check(status.is(204))
)
.exec(http(“Request3”))).asJSON
.check(status.is(204))
)
.exec(http(“Request4”))).asJSON
.check(status.is(204))
)
.exec(http(“Request5”))).asJSON
.check(status.is(204))
)
.exec(
http(“Request6”))).asJSON
.check(status.is(204))
)
.exec( http(“Request7”) )).asJSON
.check(status.is(200),
jsonPath("$.id").saveAs(“CommentId”))
)
// remove unwanted characters from CommentId
.exec(session => { // doing stuff with session attributes
session })
// extract values from Session and write to file
.exec(session => { // extract attributes and set them up to be written in CSV format
session })
}
setUp(
scnMyFullScenario.inject(rampUsers(numberRows) over (runTime seconds))
.protocols(httpProtocol)
)