Locust测试Spring Tomcat服务某POST接口超时问题求助
Locust测试Spring POST接口超时问题
问题描述
搭建了基于Spring的Tomcat测试Web服务器,包含多个GET和POST控制器。多数控制器可通过Locust正常测试,但其中一个POST接口始终耗时极久,等待60秒后触发连接超时,被Locust判定为失败。Locust调试模式及日志中无任何错误信息,且日志显示该接口返回302状态码,Locust已跟随跳转至返回200的成功确认页面。
已排除JVM启动问题,同项目内其他控制器均工作正常,使用浏览器正常访问该POST接口时响应迅速。
相关代码
Locust测试代码
self.client.post( url="/stornieren/" + str(buchungs_id), headers=self.headers_stornieren, name="stornieren")
Spring控制器签名
@PostMapping("/stornieren/{buchungsId}") public ModelAndView stornieren( @PathVariable String buchungsId, ModelAndView modelAndView, OidcUser oidcUser)
预期与实际结果
- 预期结果:Locust应在数毫秒内成功测试该控制器,若存在问题应生成对应的错误日志。
- 实际结果:Locust等待60秒后判定失败,但已访问返回的跳转成功页面,全程无任何错误日志。
补充调试日志
[2024-01-17 09:15:27,824] (removed)/DEBUG/urllib3.connectionpool: Starting new HTTP connection (2): localhost:8080 send: b'POST /stornieren/a327743d-ed8f-4bde-b086-df7c8018cd55 HTTP/1.1\r\nUser-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:121.0) Gecko/20100101 Firefox/121.0\r\nAccept-Encoding: gzip, deflate\r\nAccept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8\r\nConnection: keep-alive\r\nHost: localhost:8080\r\nAccept-Language: de,en-US;q=0.7,en;q=0.3\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: 108\r\nOrigin: http://localhost:8080\r\nReferer: http://localhost:8080/meins\r\nUpgrade-Insecure-Requests: 1\r\nPragma: no-cache\r\nCache-Control: no-cache\r\n\r\n' reply: 'HTTP/1.1 302 \r\n' header: X-Content-Type-Options: nosniff header: X-XSS-Protection: 1; mode=block header: Cache-Control: no-cache, no-store, max-age=0, must-revalidate header: Pragma: no-cache header: Expires: 0 header: X-Frame-Options: DENY header: Location: http://localhost:8080/stornieren/erfolg header: Content-Language: de header: Content-Length: 0 header: Date: Wed, 17 Jan 2024 08:16:31 GMT header: Keep-Alive: timeout=60 header: Connection: keep-alive [2024-01-17 09:16:31,345] (removed)/DEBUG/urllib3.connectionpool: http://localhost:8080 "POST /stornieren/a327743d-ed8f-4bde-b086-df7c8018cd55 HTTP/1.1" 302 0 send: b'GET /stornieren/erfolg HTTP/1.1\r\nUser-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:121.0) Gecko/20100101 Firefox/121.0\r\nAccept-Encoding: gzip, deflate\r\nAccept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8\r\nConnection: keep-alive\r\nHost: localhost:8080\r\nAccept-Language: de,en-US;q=0.7,en;q=0.3\r\nOrigin: http://localhost:8080\r\nReferer: http://localhost:8080/meins\r\nUpgrade-Insecure-Requests: 1\r\nPragma: no-cache\r\nCache-Control: no-cache\r\n\r\n' reply: ''
相关截图
- POST接口失败的Locust统计数据截图
- 失败请求的Locust日志截图
- 正常工作的其他POST接口统计数据截图
内容的提问来源于stack exchange,提问作者Jochen Schüttler
相关产品推荐
相关产品推荐

