【发布时间】:2016-07-12 06:26:23
【问题描述】:
我正在尝试使用以下代码在加特林中使用 json feeder 为每个请求动态生成标头:
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import scala.concurrent.duration._
class LoadTest extends Simulation {
val httpConf = http
.baseURL("http://example.com")
val tokensFeeder = jsonFile("Tokens.json");
val user1 = scenario("Download")
feed(tokensFeeder)
.exec(
http("req")
.post("/download")
.headers("${header}")
.body(StringBody("""{ "Device_Type":"iOS","Locations":[{"Latitude":"51.50719197","Longitude":"-0.127214091"}] }""")).asJSON
)
setUp(
user1.inject(atOnceUsers(2))
).protocols(httpConf)
}
Tokens.json 有以下格式的数据:
[
{"header" : {"token" : "12234"}},
{"header" : {"token" : "12235"}},
{"header" : {"token" : "12236"}}
]
但是我得到以下错误:
type mismatch;
found : String("${header}")
required: Map[String,String]
11:23:07.862 [ERROR] i.g.c.ZincCompiler$ - .headers("${header}")
11:23:07.864 [ERROR] i.g.c.ZincCompiler$ - ^
11:23:07.908 [ERROR] i.g.c.ZincCompiler$ - one error found
11:23:07.910 [ERROR] i.g.c.ZincCompiler$ - Compilation crashed
sbt.compiler.CompileFailed: null
据我了解,馈线包含地图矢量,因此“${header}”不应评估为 {token : 12234} 吗?
任何帮助将不胜感激。
【问题讨论】:
标签: scala load-testing gatling