[英]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.