svn commit: r1936976 - in httpd/httpd/trunk/test/pytest_suite: . tests/t/modules

[email protected]
Newsgroups gmane.comp.apache.cvs
Message-ID <178611267271.3599997.5179447015591766915@svn03-he-fi>
Author: jorton
Date: Fri Aug  7 14:24:32 2026
New Revision: 1936976

Log:
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 <[email protected]>
GitHub: PR #701

Modified:
   httpd/httpd/trunk/test/pytest_suite/conftest.py
   httpd/httpd/trunk/test/pytest_suite/tests/t/modules/test_proxy_beacon.py

Modified: httpd/httpd/trunk/test/pytest_suite/conftest.py
==============================================================================
--- httpd/httpd/trunk/test/pytest_suite/conftest.py	Fri Aug  7 14:23:29 2026	(r1936975)
+++ httpd/httpd/trunk/test/pytest_suite/conftest.py	Fri Aug  7 14:24:32 2026	(r1936976)
@@ -250,6 +250,18 @@ def framework(request: pytest.FixtureReq
         )
         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:

Modified: httpd/httpd/trunk/test/pytest_suite/tests/t/modules/test_proxy_beacon.py
==============================================================================
--- httpd/httpd/trunk/test/pytest_suite/tests/t/modules/test_proxy_beacon.py	Fri Aug  7 14:23:29 2026	(r1936975)
+++ httpd/httpd/trunk/test/pytest_suite/tests/t/modules/test_proxy_beacon.py	Fri Aug  7 14:24:32 2026	(r1936976)
@@ -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}")
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.