dadagen - Random Data Generating Feeder

Hi Peoples,

This is an announcement and a question rolled in one.

I have (a while back) created a Random Data Generator that is very helpful for test scenarios.
It is written in Scala, and I realised the other evening that Gatling will be easy to support.

https://github.com/inosion/dadagen

I have created a Feeder for Gatling that exposes a super super flexible way to provided data (mock) into your tests.

import org.inosion.dadagen.api.scaladsl._

val feeder = dadagen asMaps {
   field { "id".rownumber }.
   field { "gender".gender }.
   field { "firstname".name firstname }.
   field { "surname".name surname }.
   // Combine all the values together .. order (what it depends on) does not matter

   field { "message".template("${id} - ${firstname} ${surname} (${gender}) i:${int} ${ref}")}.
   field { "int".number between 10 and 99876 }.
   field { "ref".regexgen("[a-f]{6}-[0-9a-f]{8}") }
} generate() // call generate to make the Iterator


val scn = scenario("scenario").feed(feeder).exec(http(....))

So my question, I added a quick test to show the feeder in use, but have a problem with the Action. Gatling seems to be waiting for my code to say it is “complete” for each user.
What do I need to do to “close” the Action // move the messages to Done.

(it will just help with the test - the feeder works :slight_smile:

https://github.com/inosion/dadagen/blob/master/src/test/scala/org/inosion/dadagen/support/gatling/SimpleGatlingFeederExample.scala

class DoNothingAction(val next: ActorRef) extends Chainable with Failable with DataWriterClient{

  override def executeOrFail(session: Session): Validation[_] = {
      val now = new Date().getTime
      session.attributes.get("message") match {
        case None => Failure("missing the message from the dadagen")
        case Some(msg:String) => {
          writeRequestData(session, session.scenarioName, now, now + 1, now + 3, now + 4, Status("OK"), Some(msg))
          Success(msg)
        }
      }
  }

}

regards
Ramon

Hi Peoples,

Hi Ramon,

This is an announcement and a question rolled in one.

I have (a while back) created a Random Data Generator that is very helpful
for test scenarios.
It is written in Scala, and I realised the other evening that Gatling will
be easy to support.

https://github.com/inosion/dadagen

Fun.

Then, I suggest you make the Random implementation configurable, like an
implicit.
I see that you use SecureRandom: in most cases, you won't need such "safe"
randomness that's mostly required for cryptography.
Then, in Gatling, we try to use ThreadLocalRandom everywhere, as it's much
more efficient that a standard Random if you use just a few threads. But I
see you intend to support other tool that are way more thread expensive, so
you'll want a regular Random there.

I have created a Feeder for Gatling that exposes a super super flexible
way to provided data (mock) into your tests.

import org.inosion.dadagen.api.scaladsl._

val feeder = dadagen asMaps {

   field { "id".rownumber }.

   field { "gender".gender }.

   field { "firstname".name firstname }.

   field { "surname".name surname }.

   // Combine all the values together .. order (what it depends on) does not matter

   field { "message".template("${id} - ${firstname} ${surname} (${gender}) i:${int} ${ref}")}.

   field { "int".number between 10 and 99876 }.

   field { "ref".regexgen("[a-f]{6}-[0-9a-f]{8}") }

} generate() // call generate to make the Iterator

val scn = scenario("scenario").feed(feeder).exec(http(....))

Cool

So my question, I added a quick test to show the feeder in use, but have a
problem with the Action. Gatling seems to be waiting for my code to say it
is "complete" for each user.
What do I need to do to "close" the Action // move the messages to Done.

Sorry, I don't get it. What's your issue exactly?

Cheers,

*Stéphane Landelle*
*Lead developer*
slandelle@gatling.io

Then, I suggest you make the Random implementation configurable, like an implicit.
I see that you use SecureRandom: in most cases, you won’t need such “safe” randomness that’s mostly required for cryptography.
Then, in Gatling, we try to use ThreadLocalRandom everywhere, as it’s much more efficient that a standard Random if you use just a few threads. But I see you intend to support other tool that are way more thread expensive, so you’ll want a regular Random there.

Great, I created an issue for it and will add that in.
https://github.com/inosion/dadagen/issues/3

So my question, I added a quick test to show the feeder in use, but have a problem with the Action. Gatling seems to be waiting for my code to say it is “complete” for each user.
What do I need to do to “close” the Action // move the messages to Done.

Sorry, I don’t get it. What’s your issue exactly?

Yes, sorry, that was probably a bit opaque. :slight_smile:

The test looks like

https://github.com/inosion/dadagen/blob/b4ae70a1a721104e0db65bb1df16ab100f151e06/src/test/scala/org/inosion/dadagen/support/gatling/SimpleGatlingFeederExample.scala

And below (gist) is the output of running that test,… Gatling is clearly working, and the messages are generated from the feeder, but my test does not return, but rather the simulation is not receiving “10” Done messages … it just repeats the output each 5s… (have to kill it to get back).

https://gist.github.com/rbuckland/19c22f7d1962baa2df97

So what do I need to add in to my DoNothingAction to “move” each use case onto “Done” ?

You forgot to propagate the session to the next action:

next ! session