I'm looking for help to create simple feeder to increment an integer from 0.
I've found lot of feeder example to generate random UUID, Email, Strings...
I've looked at the doc
But nothing for increment a integer (I feel something related to some new java.util.concurrent.atomic.AtomicInteger(0)
but I can't have something that work), and I'm not looking for creating some CSV or file within "ïnfinite" rows.
So what I have is
val userId = Iterator.continually(
Map("userId" -> CAN'T FIND WHAT TO PUT HERE TO HAVE INCREMENT INTEGER FROM 0
)
object CreateUser {
val createUser = exec(
http("Create a random user")
.post("/users"))
.body(StringBody("""{
"Username": "Test-${userId}"
}""")).asJSON
}
val httpConf = http
.baseUrl("https://api.some.site/v1/")
val users = scenario("Create Users").exec(CreateUser.createUser)
setUp(
users.inject(rampUsers(100) during (10 seconds)),
).protocols(httpConf)
Thanks for the help
I tried using AtomicInteger and it worked fine for me:
val id = new AtomicInteger(0)
val userId: Iterator[Map[String, Int]] = Iterator.continually(Map("userId" -> id.getAndIncrement()))
After that you just need to add the 'feed' method to your scenario:
scenario("scenario")
.feed(userId)
.exec(request)