From 19c21b143104c0b32d2189cf8e857bba41d7e8c6 Mon Sep 17 00:00:00 2001 From: bneradt Date: Thu, 30 Jul 2026 16:10:49 -0500 Subject: [PATCH] Stabilize proxy protocol access log test Access log records for independent PROXY Protocol replay sessions can be finalized on different event threads. The test assumed replay order and failed intermittently when two otherwise correct records were reversed. This waits for all expected records and sorts them before comparing against the full gold output. It preserves content and count coverage without requiring transaction completion order. --- .../gold_tests/proxy_protocol/gold/access-cp.gold | 4 ++-- .../proxy_protocol/gold/access-nocp.gold | 4 ++-- .../proxy_protocol/proxy_protocol.test.py | 15 +++++++++++---- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/tests/gold_tests/proxy_protocol/gold/access-cp.gold b/tests/gold_tests/proxy_protocol/gold/access-cp.gold index 28d355ac6af..c2f386d799a 100644 --- a/tests/gold_tests/proxy_protocol/gold/access-cp.gold +++ b/tests/gold_tests/proxy_protocol/gold/access-cp.gold @@ -1,8 +1,8 @@ +127.0.0.1 0 127.0.0.1 +127.0.0.1 0 127.0.0.1 127.0.0.1 127.0.0.1 127.0.0.1 127.0.0.1 127.0.0.1 127.0.0.1 127.0.0.1 127.0.0.1 127.0.0.1 127.0.0.1 127.0.0.1 127.0.0.1 198.51.100.1 198.51.100.1 127.0.0.1 -127.0.0.1 0 127.0.0.1 -127.0.0.1 0 127.0.0.1 198.51.100.1 198.51.100.1 127.0.0.1 diff --git a/tests/gold_tests/proxy_protocol/gold/access-nocp.gold b/tests/gold_tests/proxy_protocol/gold/access-nocp.gold index 5511d71605f..ccd785d680a 100644 --- a/tests/gold_tests/proxy_protocol/gold/access-nocp.gold +++ b/tests/gold_tests/proxy_protocol/gold/access-nocp.gold @@ -1,8 +1,8 @@ +127.0.0.1 0 127.0.0.1 +127.0.0.1 0 127.0.0.1 127.0.0.1 127.0.0.1 127.0.0.1 127.0.0.1 127.0.0.1 127.0.0.1 127.0.0.1 127.0.0.1 127.0.0.1 127.0.0.1 127.0.0.1 127.0.0.1 127.0.0.1 198.51.100.1 127.0.0.1 -127.0.0.1 0 127.0.0.1 -127.0.0.1 0 127.0.0.1 127.0.0.1 198.51.100.1 127.0.0.1 diff --git a/tests/gold_tests/proxy_protocol/proxy_protocol.test.py b/tests/gold_tests/proxy_protocol/proxy_protocol.test.py index a3623930965..db4eede8a11 100644 --- a/tests/gold_tests/proxy_protocol/proxy_protocol.test.py +++ b/tests/gold_tests/proxy_protocol/proxy_protocol.test.py @@ -94,15 +94,22 @@ def checkAccessLog(self): """ check access log """ - Test.Disk.File(os.path.join(self.ts.Variables.LOGDIR, 'access.log'), exists=True, content=f"gold/access-{self.name}.gold") + log_file = os.path.join(self.ts.Variables.LOGDIR, 'access.log') + # Transactions can finish on different event threads, so their access + # log records are not guaranteed to be written in replay order. Test.AddAwaitFileContainsTestRun( f'Await PROXY protocol access log lines. {self.name}', - os.path.join(self.ts.Variables.LOGDIR, 'access.log'), - r'^127\.0\.0\.1 0 127\.0\.0\.1$', - 2, + log_file, + r'^(127\.0\.0\.1|198\.51\.100\.1) (0|127\.0\.0\.1|198\.51\.100\.1) 127\.0\.0\.1$', + 8, ) + tr = Test.AddTestRun(f'Verify PROXY protocol access log lines. {self.name}') + tr.Processes.Default.Command = f'LC_ALL=C sort < "{log_file}"' + tr.Processes.Default.Streams.stdout = f"gold/access-{self.name}.gold" + tr.Processes.Default.ReturnCode = 0 + def run(self): self.runTraffic() self.checkAccessLog()