【发布时间】:2021-05-03 20:39:54
【问题描述】:
我创建了一个 Gatling 项目,其中包含许多不同的数据集。这样做的原因是,我想在我向服务中抛出的每个 SOAP 请求中包含随机性和唯一性。示例:一个数据集有 ID 号,而另一个数据集有颜色。我想在我发送到我的网络服务的请求中注入这些值。
当我启动 gatling 时,它会生成带有随机值的请求(如预期的那样),但随后会重复使用相同的 id 和颜色组合。如果可能的话,我想每次都发送一个不同的请求(例如) id: 001 和 color: blue。然后发送一个 id: 001 和 color: red 的请求。现在它只是重新发送 id: 001 和 color: blue。
我有数百行的 id.scala 和 color.scala 文件和一个 xml 请求文件,所以组合应该是无穷无尽的。
val id = jsonFile("data/id.json").circular
val color = jsonFile("data/color.json").circular
def updateIdWithColor() = {
.exec(http("Add Color")
.post("/")
.body(ElFileBody("requests/addcolor.txt"))
.check(status.is(200)))
}
val scn = scenario("Load Testing")
.feed(id)
.feed(color)
.forever() {
exec(updateIdWithColor())
}
setUp(
scn.inject(
nothingFor(5 seconds),
atOnceUsers(5),
rampUsers(userCount) during(rampUpUsersOverSeconds seconds)
).protocols(httpConf)
).maxDuration(testDuration minutes)
//.assertions(
// global.responseTime.max.lt(2000),
// global.successfulRequests.percent.gt(99.9),
//)
}
有没有办法可以刷新 id 到颜色组合,以便我每次都可以发送不同的请求?如果我运行 15 分钟,它只会发送一个带有 001 -> 蓝色 15 分钟的 SOAP xml 请求。
如果我可以带其他东西,请告诉我。我相信在我提供的代码块中我可以(可能)使用一种方法。我只是不知道。提前致谢!
【问题讨论】:
标签: gatling scala-gatling