Gatling.io在虚拟用户之间共享数据 [英] Gatling.io share data between virtual users

查看:103
本文介绍了Gatling.io在虚拟用户之间共享数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Gatling.io测试网站.我有一个包含多个虚拟用户的方案.

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 ?

推荐答案

我认为为此的默认加特林答案是创建会话并将其持久保存在某种文件中,并在新的模拟中读取该值并让用户拿起它.加特林在一次模拟中实际上并不支持出风".

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.

也就是说,如果您确实需要,可以进行修改-尤其是如果您只需要Admin用户快速执行一次,并且准备在模拟文件中定义方案的话.

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) 
}

作为管理员"方案的一部分,将会话的值保存到"mySession"变量中

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

作为用户方案的一部分,从"mySession"变量中设置会话变量

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.

这篇关于Gatling.io在虚拟用户之间共享数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆