Gatling.io share data between virtual users

旧城冷巷雨未停 提交于 2019-12-02 06:01:31
James Warr

I think the default Gatling answer for this is to create the session and persist it in a file of some kind and in a new simulation read that value and have the users pick it up. 'Fanning out' is not really a scenario Gatling supports in a single simulation.

That said, you can fudge it if you really want - particularly if you just need one quick execution by the Admin user and you're prepared to define your scenarios within your simulation file.

class simulation extends Simulation {
  private var mySession = "NOT_SET"

val users = scenario("Users").exec(Session.browse)  
val admins = scenario("Admins").exec(Session.create) 
}

as part of the 'Admins' scenario save the value of your session into the 'mySession' var

as part of the users' scenario set a session variable from the 'mySession' var

then run your simulation something like...

setUp(
admins.inject(
  atOnceUsers(1)
),
users.inject(
  nothingFor(1 minutes), //enough time for admins to complete
  atOnceUsers(10) //or however many you need
)

it works ok for quick and dirty data seeding, but you're really cutting against the grain of how Gatling is designed.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!