使用 @RequestParam 进行加特林负载测试 Restful Api
gatling load testing Restful Api with @RequestParam
我正在为 Restful api 测试编写 Gatling 负载测试。端点接受@RequestParam,但是当我从我的 scala 脚本调用其余端点时,我得到 400。这是我的设置方式。
Scala script for LoadTest with Gatling:
val getMails = exec(http("GET_MAILS")
.get("/api/v1/users/${userId}/mails")
.formParam("dateFrom", "1430987200")
.formParam("dateTo", "1432987200")
休息端点:
@RequestMapping(value="/users/{userId}/mails", method=RequestMethod.GET, headers="Accept=application/json")
public ResponseEntity getMailsB`enter code here`yFilter(@PathVariable("userId") Long userId,
@RequestParam(value="dateFrom") Long dateFrom,
@RequestParam(value="dateTo") Long dateTo);
首先,您可能应该使用 queryParam
在查询中传递 "dateFrom" 和 "dateTo",而不是 formParam
。
然后,您的@RequestMapping 显示它仅在 "Accept" header 为 "application/json" 时触发。您提供的 Gatling 示例中没有任何内容可以证明您确实正确地将此 header 设置为此值。
我正在为 Restful api 测试编写 Gatling 负载测试。端点接受@RequestParam,但是当我从我的 scala 脚本调用其余端点时,我得到 400。这是我的设置方式。
Scala script for LoadTest with Gatling:
val getMails = exec(http("GET_MAILS")
.get("/api/v1/users/${userId}/mails")
.formParam("dateFrom", "1430987200")
.formParam("dateTo", "1432987200")
休息端点:
@RequestMapping(value="/users/{userId}/mails", method=RequestMethod.GET, headers="Accept=application/json")
public ResponseEntity getMailsB`enter code here`yFilter(@PathVariable("userId") Long userId,
@RequestParam(value="dateFrom") Long dateFrom,
@RequestParam(value="dateTo") Long dateTo);
首先,您可能应该使用 queryParam
在查询中传递 "dateFrom" 和 "dateTo",而不是 formParam
。
然后,您的@RequestMapping 显示它仅在 "Accept" header 为 "application/json" 时触发。您提供的 Gatling 示例中没有任何内容可以证明您确实正确地将此 header 设置为此值。