描述
发现时间: 2026-03-27 测试轮 Round 8(场景 EFGH)
优先级: P2
状态: ✅ 已修复(commit b38b87c)
现象
pytest tests/test_scenario_d_stress.py::test_d3_100_sequential_messages 单独运行时,2~6 条消息返回 ERR_PEER_CONNECTING (503),导致 D3/D4 FAILED。
全套 pytest tests/ 时 D3/D4 偶发 FAILED(96~98/100 messages succeed)。
但完整文件运行 pytest tests/test_scenario_d_stress.py 始终 10/10 PASS。
复现步骤
# 必现(选择性运行 D3/D4)
python3 -m pytest tests/test_scenario_d_stress.py::test_d3_100_sequential_messages tests/test_scenario_d_stress.py::test_d4_beta_received_100 -v
预期行为
D3: 100/100 messages sent successfully.
实际行为
AssertionError: D3: only 96/100 messages sent successfully
msg #0: HTTP 503 -> {'ok': False, 'error_code': 'ERR_PEER_CONNECTING', ...}
msg #1: HTTP 503 -> {'ok': False, 'error_code': 'ERR_PEER_CONNECTING', ...}
...
根因
relay_pair fixture 等待条件是 p.get("connected") == True。
connected=True 由 _register_peer() 在 /peers/connect 返回时立即设置,此时 WebSocket 握手仍在后台 coroutine 中进行(guest_mode() 需要完成 P2P 握手才设置 ws 字段)。
D3 在 fixture yield 后立即发送 100 条消息,前几条命中 ws is None 守卫(BUG-016 修复逻辑),返回 ERR_PEER_CONNECTING。
当全文件运行时,D1 和 D2 的执行时间(~1-2s)正好给 WS 握手足够时间,所以不会触发。
修复
relay_pair fixture 改用 probe-send 循环:
# Wait for WS to fully establish — probe-send until ok=true (BUG-030 fix)
deadline = time.time() + 10
peer_ready = False
while time.time() < deadline:
ps, pr = post(ALPHA_PORT, f"/peer/{_PEER_ID[0]}/send", {
"role": "agent",
"parts": [{"kind": "text", "text": "__probe__"}],
})
if ps == 200 and isinstance(pr, dict) and pr.get("ok"):
peer_ready = True
break
time.sleep(0.3)
assert peer_ready, f"Peer {_PEER_ID[0]} not ready within 10s"
与 test_scenario_fg.py 的 wait_peer_ready() 模式一致。
验证
D3/D4 isolated: 2/2 PASS ✅
Full file: 10/10 PASS ✅
相关
- BUG-016: ERR_PEER_CONNECTING guard added to
/peer/{id}/send
- BUG-027: different class (port contention in full suite)
- commit: b38b87c
描述
发现时间: 2026-03-27 测试轮 Round 8(场景 EFGH)
优先级: P2
状态: ✅ 已修复(commit b38b87c)
现象
pytest tests/test_scenario_d_stress.py::test_d3_100_sequential_messages单独运行时,2~6 条消息返回 ERR_PEER_CONNECTING (503),导致 D3/D4 FAILED。全套
pytest tests/时 D3/D4 偶发 FAILED(96~98/100 messages succeed)。但完整文件运行
pytest tests/test_scenario_d_stress.py始终 10/10 PASS。复现步骤
# 必现(选择性运行 D3/D4) python3 -m pytest tests/test_scenario_d_stress.py::test_d3_100_sequential_messages tests/test_scenario_d_stress.py::test_d4_beta_received_100 -v预期行为
D3: 100/100 messages sent successfully.
实际行为
根因
relay_pairfixture 等待条件是p.get("connected") == True。connected=True由_register_peer()在/peers/connect返回时立即设置,此时 WebSocket 握手仍在后台 coroutine 中进行(guest_mode()需要完成 P2P 握手才设置ws字段)。D3 在 fixture yield 后立即发送 100 条消息,前几条命中
ws is None守卫(BUG-016 修复逻辑),返回ERR_PEER_CONNECTING。当全文件运行时,D1 和 D2 的执行时间(~1-2s)正好给 WS 握手足够时间,所以不会触发。
修复
relay_pairfixture 改用 probe-send 循环:与
test_scenario_fg.py的wait_peer_ready()模式一致。验证
相关
/peer/{id}/send