加特林-动态提要选择 [英] Gatling - dynamic feed selection

查看:91
本文介绍了加特林-动态提要选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我需要要做的事情:

.feed("users.csv") // includes username, password, groupid
// login...
.duration(x) {
    feed( csv("${groupid}.csv").random )
    // interact with the application using the data in the second .csv file
}

但是,当然,csv()函数采用字符串而不是EL表达式.我需要能够在场景执行的适当时刻编写该字符串.

But of course, the csv() function takes a string, not an EL expression. I need to be able to compose that string at the appropriate moment in the scenario execution.

我能够构建字符串,如下所示:

I am able to build the string, like so:

.exec( session => {
    feed( csv( session.getAttribute("groupid") + ".csv" ).random )
    session
})

但是不幸的是,以下执行人员看不到数据.对我来说,这似乎是一个范围界定问题.我猜feed()表达式确实在执行应该做的事情,但是由于它不是外链的一部分,因此不会放在所属位置.我是否应该在会话对象中的某个对象上调用.feed以便将其附加到进行中的链上?

But unfortunately, the following execs don't see the data. It looks like some kind of scoping issue to me. I'm guessing the feed() expression is doing exactly what it is supposed to be doing, but because it is not part of the outer chain, it's not being placed where it belongs. Am I supposed to be calling .feed on some object within the session object in order to attach it to the ongoing chain?

有关如何完成我要完成的工作的任何指导?谢谢!

Any guidance on how to accomplish what I have set out to do? Thanks!

推荐答案

与模拟同时实例化了馈送器.除非您使用基础工具,否则您不能将其推迟到Simulation运行时.

Feeders are instanciated at the same time as the Simulation. You can't defer it to the Simulation runtime, unless you hack with the underlying tools.

您有多少个"groupid"文件? 如果只有少数几个,则可以使用 doIf 如果使用加特林< = 2M3a运行,则会阻止.

How many of those "groupid" files do you have? If you have just a few of them, you can use either doSwitch from Gatling 2 current snapshot, or embedded doIf blocks if you run with Gatling <= 2M3a.

.doSwitch("${groupid}") (
  "foo" -> feed(csv("foo.csv").random),
  "bar" -> feed(csv("bar.csv").random)
)

这可以一概而论:

def groupIdFeed(groupId: String) = groupId -> feed(csv(groupId + ".csv").random)

.doSwitch("${groupid}") (
  groupIdFeed("foo"),
  groupIdFeed("bar")
)

这篇关于加特林-动态提要选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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