You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by pk...@apache.org on 2026/07/30 14:53:00 UTC
(logging-flume) 02/06: Fix TestSyslogTcpSource.testSSLMessages on Windows
This is an automated email from the ASF dual-hosted git repository.
ppkarwasz pushed a commit to branch feat/fix-file-channel-windows
in repository https://gitbox.apache.org/repos/asf/logging-flume.git
commit 30bbd67821a4b4c4f074408a8f068caccdb5fefa
Author: Piotr P. Karwasz <pk...@apache.org>
AuthorDate: Thu Jul 30 16:32:42 2026 +0200
Fix TestSyslogTcpSource.testSSLMessages on Windows
The test wrote to the TLS socket and immediately closed it. The client
never reads the TLS 1.3 session tickets sent by the server, so close()
aborts the connection with a TCP RST, which on Windows discards the
syslog record before the server reads it. Keep the socket open, waiting
with Awaitility, until the server commits the event to the channel.
Assisted-By: Claude Fable 5 <no...@anthropic.com>
---
flume-ng-sources/flume-syslog-source/pom.xml | 6 ++++++
.../flume/source/syslog/TestSyslogTcpSource.java | 22 +++++++++++++++-------
flume-parent/pom.xml | 8 ++++++++
3 files changed, 29 insertions(+), 7 deletions(-)
diff --git a/flume-ng-sources/flume-syslog-source/pom.xml b/flume-ng-sources/flume-syslog-source/pom.xml
index f4bf49c1..d169d164 100644
--- a/flume-ng-sources/flume-syslog-source/pom.xml
+++ b/flume-ng-sources/flume-syslog-source/pom.xml
@@ -74,6 +74,12 @@
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.awaitility</groupId>
+ <artifactId>awaitility</artifactId>
+ <scope>test</scope>
+ </dependency>
+
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
diff --git a/flume-ng-sources/flume-syslog-source/src/test/java/org/apache/flume/source/syslog/TestSyslogTcpSource.java b/flume-ng-sources/flume-syslog-source/src/test/java/org/apache/flume/source/syslog/TestSyslogTcpSource.java
index cbc6f404..d6cf09a4 100644
--- a/flume-ng-sources/flume-syslog-source/src/test/java/org/apache/flume/source/syslog/TestSyslogTcpSource.java
+++ b/flume-ng-sources/flume-syslog-source/src/test/java/org/apache/flume/source/syslog/TestSyslogTcpSource.java
@@ -16,7 +16,9 @@
*/
package org.apache.flume.source.syslog;
+import static org.awaitility.Awaitility.await;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.any;
@@ -269,17 +271,23 @@ public class TestSyslogTcpSource {
},
null);
SocketFactory socketFactory = sslContext.getSocketFactory();
- Socket socket = socketFactory.createSocket();
- socket.connect(address);
- OutputStream outputStream = socket.getOutputStream();
- outputStream.write(bodyWithTandH.getBytes());
- socket.close();
- // Thread.sleep(100);
+ try (Socket socket = socketFactory.createSocket()) {
+ socket.connect(address);
+ OutputStream outputStream = socket.getOutputStream();
+ outputStream.write(bodyWithTandH.getBytes());
+ outputStream.flush();
+ // Close the socket only after the server has committed the event to the channel.
+ // The client never reads the TLS 1.3 session tickets sent by the server,
+ // so an earlier close() aborts the connection with a TCP RST,
+ // which on Windows can discard the data before the server reads it.
+ await().until(() -> source.getSourceCounter().getEventAcceptedCount() >= 1);
+ }
Transaction transaction = channel.getTransaction();
transaction.begin();
Event event = channel.take();
- assertEquals(new String(event.getBody()), data1);
+ assertNotNull("The source accepted an event, but the channel did not deliver one.", event);
+ assertEquals(data1, new String(event.getBody()));
transaction.commit();
transaction.close();
}
diff --git a/flume-parent/pom.xml b/flume-parent/pom.xml
index 56a3f80b..00c1969a 100644
--- a/flume-parent/pom.xml
+++ b/flume-parent/pom.xml
@@ -95,6 +95,7 @@
<test.include.pattern>**/Test*.java</test.include.pattern>
<redirectTestOutput>true</redirectTestOutput>
+ <awaitility.version>4.3.0</awaitility.version>
<curator.version>5.9.0</curator.version>
<fest-reflect.version>1.4.1</fest-reflect.version>
<hadoop.version>3.5.0</hadoop.version>
@@ -118,6 +119,13 @@
<scope>import</scope>
</dependency>
+ <dependency>
+ <groupId>org.awaitility</groupId>
+ <artifactId>awaitility</artifactId>
+ <version>${awaitility.version}</version>
+ <scope>test</scope>
+ </dependency>
+
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>