Test isolation: ports are reserved per process, so parallel ctest jobs can be handed the same port

Đang mở
#1,316 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
45/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
c, python
Lĩnh vực
devtools, testing

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug

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.

Ngôn ngữ chính
C
Star
10
Fork
8
Merge trung bình
6 giờ 32 phút
Pull request đã merge (30 ngày)
1

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của FriendsofECCE/ECCE

Tất cả issue của FriendsofECCE/ECCE

Issue tương tự

Thêm issue về C

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.