Gatling.io share data between virtual users

旧时模样 提交于 2019-12-02 07:16:15

问题


I'm using Gatling.io to test a website. I have a scenario with multiple virtual users.

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

I want the admin user to create a "session" on the website I'm testing, save the session name from the result returned by the website, and have the other users to visit the session previously created by getting the session name from the user admin.

How can I share the session name between users ?


回答1:


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.



来源:https://stackoverflow.com/questions/47857825/gatling-io-share-data-between-virtual-users

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