Last active
November 25, 2020 16:34
-
-
Save tquach/9465556 to your computer and use it in GitHub Desktop.
Custom feeder with random data for Gatling
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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