Load testing 转管负载测试错误:406响应不可接受
我是加特林负载测试的新手。我想对我的简单项目进行负载测试,但我在响应时出现了错误(406不可接受),下面是我的gatling代码Load testing 转管负载测试错误:406响应不可接受,load-testing,gatling,Load Testing,Gatling,我是加特林负载测试的新手。我想对我的简单项目进行负载测试,但我在响应时出现了错误(406不可接受),下面是我的gatling代码 import io.gatling.core.Predef._ import io.gatling.http.Predef._ class simu extends Simulation { val httpConf = http .baseURL("http://172.24.15.225:10050/sample") .header(HttpHeaderNa
import io.gatling.core.Predef._
import io.gatling.http.Predef._
class simu extends Simulation {
val httpConf = http
.baseURL("http://172.24.15.225:10050/sample")
.header(HttpHeaderNames.Accept, HttpHeaderValues.ApplicationJson)
.acceptHeader("application/json, text/plain, */*")
.acceptEncodingHeader("gzip, deflate")
.acceptLanguageHeader("en-US,en;q=0.5")
val scn = scenario("Scenario Name")
.exec(
http("request_1")
.post("http://172.24.15.225:10050/sample")
.header(HttpHeaderNames.Accept, HttpHeaderValues.ApplicationJson)
//.check(status.is(406))
.body(StringBody("""{ "inputData": "Wonderful" }""")).asJSON
)
setUp(scn.inject(atOnceUsers(30)).protocols(httpConf))
}
对上述问题的回答是
failed in Response
Errors ------------------------------------------------------------
status.find.in(200,304,201,202,203,204,205,206,207,208,209),
but actually found 406
有人请更正我的密码。
但是RestAPI(邮递员)返回的响应正确。我终于找到了答案。转管负载测试中没有错误。但问题是我的后端编码。我已将响应从字符串类型更改为JSON格式,如下所示
object ServiceJsonProtocol extends DefaultJsonProtocol {
implicit val RequestProtocol : RootJsonFormat[Text] = jsonFormat1(Text)//request json format
implicit val ResponseProtocol : RootJsonFormat[SampleText] = jsonFormat1(SampleText) // response json format
}
很好我终于找到了答案。转管负载测试中没有错误。但问题是我的后端编码。我已将响应从字符串类型更改为JSON格式,如下所示
object ServiceJsonProtocol extends DefaultJsonProtocol {
implicit val RequestProtocol : RootJsonFormat[Text] = jsonFormat1(Text)//request json format
implicit val ResponseProtocol : RootJsonFormat[SampleText] = jsonFormat1(SampleText) // response json format
}
它工作正常您是否检查它返回的响应类型..尝试删除一下accept标头..我使用了postman restapi。它正确返回响应。删除标题信息也会引发相同的错误。是否检查它返回的响应类型..请尝试删除accept标题片刻..我使用了postman restapi。它正确返回响应。同时删除标题信息也会引发相同的错误。