如何在加特林中使用这样的馈线

时间:2019-09-30 11:00:17

标签: scala gatling scala-gatling

我可以像这样使用供料器

val feeder_global_2 = Iterator.continually(Map("time"->System.currentTimeMillis()))

  var http_conf_api1424 = http.baseUrls("http://10.156.17.143:9327").disableCaching
  val api1424 = scenario("1424/v1/kol/user/info").during(60){
    feed(feeder_global_2).
      exec(http("0_1424/v1/kol/user/info")
        .post("/v1/kol/user/info")
        .header("Stress-Flag","true")
        .header("time","${uid}")

      )}

但是当我得到这样的文件时,如何使用feeder替换http路径,标题和帖子正文?

{"method":"POST","path":"url1","get":"","post":"xxx=1&.....","header":{"Accept-Encoding":"gzip","Content-Length":"118"}}
{"method":"POST","path":"url1","get":"","post":"yyy=1&....","header":{"Accept-Encoding":"gzip","Content-Length":"118"}}
{"method":"POST","path":"url1","get":"","post":"xxx=1&....","header":{"Accept-Encoding":"gzip","Content-Length":"118"}}
......

1 个答案:

答案 0 :(得分:0)

您可以通过将ELFileBody传递到.body语句中,在文件中使用加特林变量。

因此您可以将文件更新为

{"method":"POST","path":"${url}","get":"","post":"${body}","header":${headers.jsonStringify()}...