From 659af4fe78a830626707a84c9f593307627187ad Mon Sep 17 00:00:00 2001 From: Daniel McCoy Stephenson Date: Tue, 20 Oct 2026 03:38:14 -0600 Subject: [PATCH] Let the queue test tolerate a stray failed send, and say what was logged (#22) The drops-are-silent assertion from #20 required zero log lines, so one loopback send failing on the Java 8 runner turned main red after #21. Now only "could not deliver" lines are allowed, and far fewer of them than there were drops. A client that logged each drop still fails it, and the failure message prints the lines instead of only their count. Co-Authored-By: Claude Opus 5.5 --- .../stephenson/trace/TraceClientTest.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/test/java/software/stephenson/trace/TraceClientTest.java b/src/test/java/software/stephenson/trace/TraceClientTest.java index f990f2c..039de69 100644 --- a/src/test/java/software/stephenson/trace/TraceClientTest.java +++ b/src/test/java/software/stephenson/trace/TraceClientTest.java @@ -28,6 +28,7 @@ import java.util.logging.Level; import java.util.logging.LogRecord; import java.util.logging.Logger; +import java.util.stream.Collectors; import static org.junit.jupiter.api.Assertions.*; @@ -513,9 +514,17 @@ void queue_isBoundedAndDropsRatherThanGrows() throws Exception { "delivered " + delivered.get() + " of " + flood + "; at most the in-flight one plus a full queue may survive"); assertTrue(delivered.get() < flood, "an unbounded queue would have delivered all " + flood); client.close(); - // Every delivered report was a 201, so any log line would be about a - // dropped one; the README says those drops are silent. - assertTrue(log.records.isEmpty(), "a full queue drops without logging, but logged: " + log.records.size()); + // The README says drops are silent. The server only answers 201, so + // the one other line the send path can write is "could not deliver", + // for a loopback connection that failed -- one stray line was seen + // once on Java 8 CI. Allow a few of those, far fewer than there were + // drops: logging each drop would be hundreds of lines. + List messages = log.records.stream().map(LogRecord::getMessage).collect(Collectors.toList()); + int dropped = flood - (TraceClient.QUEUE_CAPACITY + 1); + assertTrue(messages.stream().allMatch(m -> m.startsWith("[trace] could not deliver ")), + "only a failed send may be logged, but logged: " + messages); + assertTrue(messages.size() < dropped / 10, + "a full queue drops without logging, but logged " + messages.size() + " lines: " + messages); slow.stop(0); }