Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/performance/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Performance 在Scala中使用Gatling创建动态POST/用户调用_Performance_Scala_Testing_Gatling - Fatal编程技术网

Performance 在Scala中使用Gatling创建动态POST/用户调用

Performance 在Scala中使用Gatling创建动态POST/用户调用,performance,scala,testing,gatling,Performance,Scala,Testing,Gatling,我正在使用Gatling生成大量用户来测试我的产品的性能问题。我需要能够动态创建具有独特字段(如“电子邮件”)的用户。所以,我正在生成一个随机数并使用它,但它并不是每次都被重新实例化,所以电子邮件只在第一次传递时是唯一的 object Users { def r = new scala.util.Random; def randNumb() = r.nextInt(Integer.MAX_VALUE) val numb = randNumb() val createUser

我正在使用Gatling生成大量用户来测试我的产品的性能问题。我需要能够动态创建具有独特字段(如“电子邮件”)的用户。所以,我正在生成一个随机数并使用它,但它并不是每次都被重新实例化,所以电子邮件只在第一次传递时是唯一的

object Users {

  def r = new scala.util.Random;
  def randNumb() = r.nextInt(Integer.MAX_VALUE)
  val numb = randNumb()

  val createUser = {
    exec(http("Create User")
    .post("/users")
    .body(StringBody(raw"""{"email": "qa_user_$numb@company.com" }""")))
  }
}

val runCreateUsers = scenario("Create Users").exec(Users.createUser)

setUp(
  runCreateUsers.inject(constantUsersPerSec(10) during(1 seconds))
).protocols(httpConf)
我应该在哪里定义我的随机数?如何将其传递到createUser?

使用:


val createUser=execsession=>session.setrandomN,ThreadLocalRandom.current.nexting9999999.exechttpCreate User.post/users.bodyStringBody{email:${randomN}@company.com}}我从找到的其他一些代码中拼凑出了这个。这是可行的,但我很好奇这与您的解决方案相比如何。
object Users {
  val createUser = exec(http("Create User")
    .post("/users")
    .body(StringBody("""{"email": "qa_user_${numb}@Marqeta.com" }""")))
}

val numbers = Iterator.continually(Map("numb" -> scala.util.Random.nextInt(Int.MaxValue)))

val runCreateUsers = scenario("Create Users")
  .feed(numbers)
  .exec(Users.createUser)

...