He-Pin commented on code in PR #3728:
URL: https://github.com/apache/pekko/pull/3728#discussion_r4407152843


##########
stream-tests/src/test/scala/org/apache/pekko/stream/io/TlsGraphStageIsolatedSpec.scala:
##########
@@ -247,19 +248,68 @@ class TlsGraphStageIsolatedSpec extends 
StreamSpec(TlsSpec.configOverrides) with
   }
 }
 
+class TlsGraphStageSmallBufferSpec
+    extends StreamSpec(
+      ConfigFactory.parseString("pekko.io.tcp.direct-buffer-size = 8192")
+        .withFallback(ConfigFactory.parseString(TlsSpec.configOverrides))) {
+
+  "TlsGraphStage" must {
+    for (protocol <- Seq("TLSv1.2", "TLSv1.3")) {
+      s"round-trip $protocol records larger than the TCP pool buffers" in {
+        assertAllStagesStopped {
+          val context = TlsSpec.initSslContext(protocol)
+          def tls(client: Boolean) =
+            BidiFlow.fromGraph(new TlsGraphStage(
+              () => {
+                val engine = context.createSSLEngine()
+                engine.setUseClientMode(client)
+                engine.setEnabledProtocols(Array(protocol))
+                engine
+              },
+              _ => Success(()),
+              
IgnoreComplete)).withAttributes(TlsGraphStage.StreamTlsAttributes)
+
+          val payload = 
ByteString.fromArray(Array.tabulate[Byte](32768)(_.toByte))
+          val echo = Flow[SslTlsInbound].collect { case SessionBytes(_, bytes) 
=> SendBytes(bytes) }
+          val received = Source.single[SslTlsOutbound](SendBytes(payload))
+            .via(tls(client = true).atop(tls(client = 
false).reversed).join(echo))
+            .collect { case SessionBytes(_, bytes) => bytes }
+            .scan(ByteString.empty)(_ ++ _)
+            .filter(_.size >= payload.size)
+            .runWith(Sink.head)
+
+          Await.result(received, remainingOrDefault) shouldBe payload
+        }
+
+        // TLS fallback buffers must not enter the shared, fixed-size TCP pool.
+        val pool = pekko.io.Tcp(system).bufferPool

Review Comment:
   Added an empty-buffer growth test that waits for stage termination, drains 
the pool, and checks every buffer's capacity, directness, and identity. The 
deferred-ciphertext case now verifies flushing without growth.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to