繁体   English   中英

加特林测试中未更新馈线值

[英]Feeder value not updated in gatling test

我是 Scala 和 gatling 的新手。 我正在尝试从 feeder 获取值并将 zip 文件发布到 service 。 但是 ${extensionId} 没有使用获取的值更新,而是保留为 ${extensionId} 。 如果我错过了这里的某些东西,请有人帮助我知道。

          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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM