Project

General

Profile

Actions

Task #798

closed
RA

[TASK-A-349] product-service 6 測全紅之診斷與修復(hostname→IPv4/SERVER_PORT 覆寫)

Task #798: [TASK-A-349] product-service 6 測全紅之診斷與修復(hostname→IPv4/SERVER_PORT 覆寫)

Added by Redmine Admin 7 days ago. Updated 7 days ago.

Status:
Closed
Priority:
P0-Urgent
Assignee:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Story Points:

Description

h2. 症狀
全量 @gradle test@ 時 @ParameterClosedLoopIntegrationTest@ 6/6 全紅:@HttpTimeoutException: request timed out@。

h2. 兩個疊在一起的根因

hostname 現在會解析到 IPv4:測試原以 @InetAddress.getLocalHost().getHostName()@ 連線,前提是「hostname 只解析到 IPv6」(10-16 當時如此)。換網路後 hostname 多了 @10.130.159.123@ → JDK HttpClient 取 IPv4 → 打到未監聽位址 → 掛住(timeout)。

@SERVER_PORT@ 覆寫隨機埠:@application.yml@ 為 @server.port: ${SERVER_PORT:8085}@,而 @SpringApplicationBuilder.properties()@ 是預設值(優先序低於環境變數)→ 沙箱注入的 @SERVER_PORT=49400@ 勝出,該埠正被 Electron 佔用 → @PortInUseException@。

h2. 修法(3 行,測試強度不變)

  • 伺服器與客戶端都固定 @127.0.0.1@(@server.address=127.0.0.1@),不依賴 DNS 順序
  • 改用系統屬性 @System.setProperty("server.port","0")@(優先序高於環境變數)

h2. 驗證

  • 單一類:6/6 通過
  • product-service 全模組:67 測/0 失敗
  • 全量 @gradle test@:重跑中

h2. 證據
@docs/08-evidence/N4_測試環境缺陷_20261019.md@

Actions

Also available in: PDF Atom