[英]Feeder value not updated in gatling test
def installExtension() =
exec(http("template - Install Extension")
.post(url + "/v1/extensions")
.basicAuth("jack", "password")
.headers(namespaceHeader)
// using testUtils to get InputStream conte
.body(InputStreamBody(TestUtils.toStream(hashMap.get("${extensionId}").getOrElse(null))))
.check(status.is( 201)))
class extmgrSimulations extends Simulation {
val extensionIds = csv(s"${Configuration.dataDirectory}/extensionId.csv").circular
val extMgrScenerio = scenario("extensionMgr - Scenario")
.during(Configuration.duration) {
exitBlockOnFail(
group("load-test") {
exec(
pace(Configuration.paceFrom, Configuration.paceTo),
feed(extensionIds),feed(extensionIds)
randomSwitch(
50.00 -> group("Install and delete") {
exec(
extmgrChain.installExtension(),
extmgrChain.deleteExtension(),
)
},
50.00 -> extmgrChain.listExtension()
)
)
}
)
}
那行不通。 Gatling EL(字符串中的 ${} 语法)在任何地方都无法神奇地工作。 这在文档中进行了解释。
警告
此表达式语言仅适用于传递给 Gatling DSL 方法的字符串值。 在实例化 Gatling 模拟时,此类字符串仅解析一次。
例如 queryParam("latitude", session => "${latitude}") 不起作用,因为参数不是字符串,而是返回字符串的函数。
此外, queryParam("latitude", "${latitude}".toInt) 不会,因为 toInt 会在将参数传递给 queryParam 方法之前发生。
这里的解决方案是传递一个函数:
session => session("latitude").validate[Int]。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.