This is an automated email from the ASF dual-hosted git repository.
He-Pin pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pekko.git
The following commit(s) were added to refs/heads/main by this push:
new 57983ca930 test: make TCP pull-mode reads deterministic (#3321)
57983ca930 is described below
commit 57983ca930bb9483a55e8f80d990a88a3023c2a7
Author: He-Pin(kerr) <[email protected]>
AuthorDate: Sat Jul 11 18:16:02 2026 +0800
test: make TCP pull-mode reads deterministic (#3321)
Motivation:
TcpConnectionSpec assumed data written on the server side was immediately
readable by the client before ResumeReading. Under load, the non-blocking
client read could return zero and the fake selector never delivered the later
ChannelReadable notification.
Modification:
Assert each test payload is written in full and wait for the client channel
to become readable before each pull-mode ResumeReading command.
Result:
The test preserves its one-Received-per-pull assertions without depending
on loopback delivery timing.
Tests:
- JDK 25 focused pull-mode test, 10 consecutive runs: passed
- JDK 25 full TcpConnectionSpec: 35 passed, 0 failed
- sbt headerCreateAll +headerCheckAll checkCodeStyle: passed
- scalafmt --list --mode diff-ref=origin/main: passed
- git diff --check: passed
- Qoder stdout review: no must-fix findings
References:
Refs #3311
---
.../src/test/scala/org/apache/pekko/io/TcpConnectionSpec.scala | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git
a/actor-tests/src/test/scala/org/apache/pekko/io/TcpConnectionSpec.scala
b/actor-tests/src/test/scala/org/apache/pekko/io/TcpConnectionSpec.scala
index 5b0dc66100..f531a1a4a9 100644
--- a/actor-tests/src/test/scala/org/apache/pekko/io/TcpConnectionSpec.scala
+++ b/actor-tests/src/test/scala/org/apache/pekko/io/TcpConnectionSpec.scala
@@ -395,15 +395,18 @@ class TcpConnectionSpec extends PekkoSpec("""
val maxBufferSize = 1 * 1024
val ts = "t" * maxBufferSize
val us = "u" * (maxBufferSize / 2)
+ val tsAndUs = ts ++ us
// send a batch that is bigger than the default buffer to make sure
we don't recurse and
// send more than one Received messages
- serverSideChannel.write(ByteBuffer.wrap((ts ++
us).getBytes("ASCII")))
+ serverSideChannel.write(ByteBuffer.wrap(tsAndUs.getBytes("ASCII")))
should ===(tsAndUs.length)
+ clientSelectionKey should be(selectedAs(OP_READ, remainingOrDefault))
connectionHandler.expectNoMessage(100.millis)
connectionActor ! ResumeReading
connectionHandler.expectMsgType[Received].data.decodeString("ASCII")
should ===(ts)
+ clientSelectionKey should be(selectedAs(OP_READ, remainingOrDefault))
connectionHandler.expectNoMessage(100.millis)
connectionActor ! ResumeReading
@@ -412,7 +415,8 @@ class TcpConnectionSpec extends PekkoSpec("""
connectionHandler.expectNoMessage(100.millis)
val vs = "v" * (maxBufferSize / 2)
- serverSideChannel.write(ByteBuffer.wrap(vs.getBytes("ASCII")))
+ serverSideChannel.write(ByteBuffer.wrap(vs.getBytes("ASCII")))
should ===(vs.length)
+ clientSelectionKey should be(selectedAs(OP_READ, remainingOrDefault))
connectionActor ! ResumeReading
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]