Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making gatling generate random data per request using a feeder

Tags:

scala

gatling

I'm trying to get gatling to create random data per POST request. I've followed a few posts on stackoverflow and other places. I came up with this scenario -

def randomUuid = UUID.randomUUID().toString
val feeder = Iterator.continually(Map("user" -> randomUuid))

def createPostRequest = {
  http("createuser")
    .post("http://jsonplaceholder.typicode.com/posts")
    .body(StringBody("${user}"))
    .check(status.is(201))
}

val scn = scenario("some load test")
  .feed(feeder)
  .forever(exec(createPostRequest))

setUp(scn.inject(atOnceUsers(1)))
  .maxDuration(20 minutes)

However, when I run this code it just calls my feeder once to create a single UUID and just re-uses the same UUID throughout the load test.

I created the code above after following this thread. I'm using gatling 2.2.5. Here's my sbt config -

import sbt._

object Dependencies {
  private val gatlingHighcharts = "io.gatling.highcharts" % "gatling- 
  charts-highcharts" % "2.2.5"                    % "test"
  private val gatlingTest =       "io.gatling"            % "gatling-test-framework"    % gatlingHighcharts.revision % "test"

  val gatlingDependencies = Seq(gatlingHighcharts, gatlingTest)
}
like image 598
Vivek Rao Avatar asked Nov 07 '22 22:11

Vivek Rao


1 Answers

As you don't call feed inside a loop, typically your forever one, you will indeed only generate one single value per virtual user. If what you want is to have unique values per loop iteration, move the feed call inside the loop.

like image 130
Stéphane LANDELLE Avatar answered Nov 15 '22 07:11

Stéphane LANDELLE