Gatling - dynamic feed selection

前端 未结 2 947
無奈伤痛
無奈伤痛 2021-01-19 13:17

Here is what I NEED to do:

.feed(\"users.csv\") // includes username, password, groupid
// login...
.duration(x) {
    feed( csv(\"${groupid}.csv\")         


        
2条回答
  •  不思量自难忘°
    2021-01-19 13:50

    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.

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

    This can be generalized:

    def groupIdFeed(groupId: String) = groupId -> feed(csv(groupId + ".csv").random)
    
    .doSwitch("${groupid}") (
      groupIdFeed("foo"),
      groupIdFeed("bar")
    )
    

提交回复
热议问题