Gatling.io share data between virtual users

前端 未结 1 790
孤独总比滥情好
孤独总比滥情好 2021-01-24 07:29

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 = scenari         


        
相关标签:
1条回答
  • 2021-01-24 08:26

    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.

    0 讨论(0)
提交回复
热议问题