如何使用进料器启动gatling场景



我有一个测试单个端点的简单场景。我的DSL有问题。无法弄清楚如何使用feeder启动场景。为了使它编译,我必须先进行无用的调用。

class GetDataSimulation extends Simulation {

val httpProtocol = http
.baseUrl("http://localhost:8080") // Here is the root for all relative URLs
.header("Content-Type", "application/json")
.header("Accept", "application/json")
object GetData {
val feeder = csv("data.csv").shuffle.circular
val getData = exec(
http("Home")
.get("/")
) // first call .get("/") is useless. I've added it only to make it compile
.pause(1.millisecond)
.feed(feeder)  // start feeder, want to start scenario from here.
.exec(
http("GetData") // interpolate params using CSV feeder.
.get("/api/v1/data?firstParam=${firstParam}&secondParam=${secondParam}") 
)
.pause(1)
}
setUp(
constantUsers.inject(constantUsersPerSec(3).during(60.seconds))
).protocols(httpProtocol)
}

我怎样才能摆脱

exec(
http("Home")
.get("/")
) // first call .get("/") is useless. I've added it only to make it compile

feed作为顶级功能可用,类似于exec本身:

val getData = feed(feeder)
.exec(
http("GetData") // interpolate params using CSV feeder.
.get("/api/v1/data?firstParam=${firstParam}&secondParam=${secondParam}") 
)
.pause(1)

您可以在Feeders文档中看到它。

最新更新