Test isolation: ports are reserved per process, so parallel ctest jobs can be handed the same port
还没有人认领这个 Issue。
评估
调研方向
Read tests/apps/isolate.py, especially freePort(), _pickPort() and _portFree(), then trace how the selected port reaches the Apache or broker startup. Check how ctest -j launches the apps_* tests and whether the service can retain a reserved socket. Done means concurrent tests cannot claim the same port and startup failures identify the service and port.
由索引模型根据 Issue 内容生成。
描述
tests/apps/isolate.py hands out ports with a process-local reservation set, so two
concurrent ctest jobs can be given the same port.
Mechanism. freePort() (tests/apps/isolate.py:154-163) binds a socket to
("127.0.0.1", 0), reads the port the OS offered, closes the socket, and then
only checks the number against _handedOut, a set that lives in the current Python
process:
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
sock.bind(("127.0.0.1", 0))
port = sock.getsockname()[1]
if port not in _handedOut:
_handedOut.add(port)
return port
Between the close and the moment the per-user Apache or the broker actually listens,
the port is unowned. Each apps_* ctest test is its own process with its own empty
_handedOut, so under ctest -j two tests can be offered the same number by the OS
and both proceed. _pickPort() (isolate.py:172-186) probes with _portFree() only
for a port given explicitly in the environment; the port that freePort() returns is
not probed again before the service is started.
Consequence. Not a clean "address already in use". The loser is the service that
starts second: the data server early-exits because something is already listening and
the test then talks to the other test's document root, or the broker fails to come up
and the app under test reports a messaging failure. The log shows an assertion failure
in the application, with no line naming a port, which is exactly the class of false
failure isolate.py's own module docstring (isolate.py:1-12) says it exists to
prevent -- it prevents overlap with a developer's live session, not overlap between
two tests of the same run.
Suggested fix: hold the bound socket open until the service has been handed the port
(bind with SO_REUSEADDR off and pass the fd or close it immediately before exec), or
re-probe with _portFree() and retry when the service fails to bind, and have the
failure message name the port and the service.
Not reproduced: this is read from the code. No run has been traced to a port
collision; under ctest -j the symptom would be an intermittent application-level
failure rather than anything that names a port, so an occurrence would not currently
be recognisable from the log.
- 主要语言
- C
- 星标
- 10
- 派生
- 8
- 平均合并
- 6 小时 32 分钟
- 30 天内合并 PR
- 1
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
FriendsofECCE/ECCE 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
FriendsofECCE/ECCE#1358 ·
-
bug
难度 2/5 1-3 小时 新手友好度 72/100
FriendsofECCE/ECCE#1353 ·
-
难度 2/5 1-3 小时 新手友好度 78/100
FriendsofECCE/ECCE#1348 ·
-
难度 2/5 1-3 小时 新手友好度 76/100
FriendsofECCE/ECCE#1347 ·
-
bug
难度 2/5 1-3 小时 新手友好度 72/100
FriendsofECCE/ECCE#1345 ·
查看 FriendsofECCE/ECCE 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
vincentarelbundock/xtx#11 ·
-
难度 1/5 1-3 小时 新手友好度 88/100
-
难度 2/5 1-3 小时 新手友好度 70/100
compiler-explorer/compiler-explorer#9738 ·
维护者通常 2 天内回复
-
难度 1/5 1-3 小时 新手友好度 88/100
维护者通常 3 天内回复
-
[Android Auto] MU1017 (MHI2Q_JP_AUG22_P1017) cluster map works with a pinned profile — values inside未关闭
难度 1/5 1 小时以内 新手友好度 92/100
kamgurgul/mib2q-carplay#74 ·