From: Joe Orton Date: Fri, 7 Aug 2026 14:24:32 +0000 (+0000) Subject: Fix false negatives checking error_log with test_proxy_beacon: [skip ci] X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=de7783015220fd384e5b5e56ec1e5b25e08d6e5c;p=thirdparty%2Fapache%2Fhttpd.git Fix false negatives checking error_log with test_proxy_beacon: [skip ci] * test/pytest_suite/conftest.py (framework): Record error_log's size before httpd starts, as session_log_start. * test/pytest_suite/tests/t/modules/test_proxy_beacon.py (test_proxy_beacon): Scope the "added backend" log check to session_log_start instead of the per-test window or byte 0. Assisted-by: Claude Sonnet 5 GitHub: PR #701 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1936976 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/test/pytest_suite/conftest.py b/test/pytest_suite/conftest.py index 5ffb1cbd79..9fbaa80efe 100644 --- a/test/pytest_suite/conftest.py +++ b/test/pytest_suite/conftest.py @@ -250,6 +250,18 @@ def framework(request: pytest.FixtureRequest): ) fpm_mgr.start() + # Record the error_log size right before this session's httpd starts. + # error_log is opened in append mode and t_logs/ is not cleaned between + # invocations, so it can carry entries from earlier, unrelated test runs + # (possibly hours/days old, with different pids). Tests that need "since + # this server session started" (as opposed to "since this individual + # test started") must scope their log reads to this offset, not to + # position 0 -- see test_proxy_beacon.py. + error_log = Path(config.vars["t_logs"]) / "error_log" + config.vars["session_log_start"] = str( + error_log.stat().st_size if error_log.exists() else 0 + ) + server = HttpdServer(config) server.start() try: diff --git a/test/pytest_suite/tests/t/modules/test_proxy_beacon.py b/test/pytest_suite/tests/t/modules/test_proxy_beacon.py index 2fa951c3d6..bab950c735 100644 --- a/test/pytest_suite/tests/t/modules/test_proxy_beacon.py +++ b/test/pytest_suite/tests/t/modules/test_proxy_beacon.py @@ -68,6 +68,19 @@ def test_proxy_beacon(http): fh.seek(start) loglines = fh.read().splitlines() + # "added backend" is logged once ever per url for the life of the + # (session-scoped) httpd process -- it dedups via ctx->seen in + # mod_proxy_beacon (beacon_try_add()/beacon_handle_announce()). Since this + # test may run long after server startup, that one-time event can predate + # `start` and must be searched for since session start instead. Do NOT + # scan from byte 0 of error_log: t_logs/ isn't cleaned between separate + # test runs, so the file can carry "added backend" lines from earlier, + # unrelated httpd sessions (different pids, possibly hours old). + session_start = int(http.vars("session_log_start") or 0) + with error_log.open("r", errors="replace") as fh: + fh.seek(session_start) + session_loglines = fh.read().splitlines() + # Announcements are received and carry a routable url=. received = [ln for ln in loglines if "received: BEACON" in ln] assert received, "no announcements received by the SUB" @@ -77,7 +90,7 @@ def test_proxy_beacon(http): # Phase 2: the backend was added exactly once (dedup), no add-failure spam. # Qualify by balancer://beacon so the capacity-test balancer (below) doesn't # perturb these counts. - added = [ln for ln in loglines + added = [ln for ln in session_loglines if "added backend" in ln and "balancer://beacon" in ln] assert len(added) == 1, ( f"backend should be added exactly once; saw {len(added)}: {added}") @@ -103,7 +116,9 @@ def test_proxy_beacon(http): # Slot exhaustion: balancer://cap has room for one member but two backends # announce to it. Exactly one must be added; the other can never fit. - cap_added = [ln for ln in loglines + # Same one-time-dedup-event caveat as the balancer://beacon "added" check + # above: search since session start, not just this test's window. + cap_added = [ln for ln in session_loglines if "added backend" in ln and "balancer://cap" in ln] assert len(cap_added) == 1, ( f"exactly one backend should fit balancer://cap; saw: {cap_added}")