Skip to content

Instantly share code, notes, and snippets.

@tquach
Last active November 25, 2020 16:34
Show Gist options
  • Select an option

  • Save tquach/9465556 to your computer and use it in GitHub Desktop.

Select an option

Save tquach/9465556 to your computer and use it in GitHub Desktop.
Custom feeder with random data for Gatling
class CreatePersonScenario extends Simulation {
val customFeeder = new Feeder[String] {
import faker._
import scala.util.Random
private val RNG = new Random
private def randInt(a: Int, b: Int) = RNG.nextInt(b - a) + a
// always return true as this feeder can be polled infinitively
override def hasNext = true
override def next: Map[String, String] = {
val email = scala.math.abs(java.util.UUID.randomUUID.getMostSignificantBits) + "_gatling@dontsend.com"
Map(
"first_name" -> Name.first_name,
"last_name" -> Name.last_name,
"organization" -> Company.name,
"email" -> email
}
}
// ... Add scenarios below, e.g.
val scn = scenario("Create Person")
.feed(customFeeder)
.exec(???)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment