This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new dcb2b8f45ebf CAMEL-24601: fix flakiness in SmbComponentConnectionIT
dcb2b8f45ebf is described below
commit dcb2b8f45ebf6daee3bac7340c49d14e821915d2
Author: Aurélien Pupier <[email protected]>
AuthorDate: Sat Sep 5 10:14:29 2026 +0200
CAMEL-24601: fix flakiness in SmbComponentConnectionIT
The SmbComponentConnectionIT was flaky because a broad SMB consumer route
interfered with testSendReceive/testDefaultIgnore/testOverride by consuming
files before those tests could read them back. Fixed by splitting
testSmbRead
and its consuming route into a separate @Isolated test class, eliminating
cross-test interference. Both classes are @Isolated since they share
SmbServiceFactory.createSingletonService(). Failure rate dropped from
~1 in 5 to 0 in 60 runs.
Closes #26132
---
.../component/smb/SmbComponentConnectionIT.java | 36 ++---------
...onIT.java => SmbComponentConnectionReadIT.java} | 72 ++--------------------
2 files changed, 12 insertions(+), 96 deletions(-)
diff --git
a/components/camel-smb/src/test/java/org/apache/camel/component/smb/SmbComponentConnectionIT.java
b/components/camel-smb/src/test/java/org/apache/camel/component/smb/SmbComponentConnectionIT.java
index 1a599abd89a0..4c180dbd8b36 100644
---
a/components/camel-smb/src/test/java/org/apache/camel/component/smb/SmbComponentConnectionIT.java
+++
b/components/camel-smb/src/test/java/org/apache/camel/component/smb/SmbComponentConnectionIT.java
@@ -16,7 +16,6 @@
*/
package org.apache.camel.component.smb;
-import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.concurrent.TimeUnit;
@@ -33,10 +32,12 @@ import org.apache.camel.test.junit6.CamelTestSupport;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
+import org.junit.jupiter.api.parallel.Isolated;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class SmbComponentConnectionIT extends CamelTestSupport {
+@Isolated
+class SmbComponentConnectionIT extends CamelTestSupport {
private static final Logger LOG =
LoggerFactory.getLogger(SmbComponentIT.class);
@RegisterExtension
@@ -46,16 +47,7 @@ public class SmbComponentConnectionIT extends
CamelTestSupport {
protected MockEndpoint mockResultEndpoint;
@Test
- public void testSmbRead() throws Exception {
- MockEndpoint mock = getMockEndpoint("mock:result");
- mock.expectedMessageCount(100);
-
- mock.assertIsSatisfied();
- }
-
- @Test
- public void testSendReceive() throws Exception {
-
+ void testSendReceive() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:received_send");
mock.expectedMessageCount(1);
@@ -68,7 +60,7 @@ public class SmbComponentConnectionIT extends
CamelTestSupport {
}
@Test
- public void testDefaultIgnore() throws Exception {
+ void testDefaultIgnore() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:received_ignore");
mock.expectedMessageCount(1);
@@ -83,7 +75,7 @@ public class SmbComponentConnectionIT extends
CamelTestSupport {
}
@Test
- public void testOverride() throws Exception {
+ void testOverride() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:received_override");
mock.expectedMessageCount(1);
@@ -99,14 +91,6 @@ public class SmbComponentConnectionIT extends
CamelTestSupport {
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
- private void process(Exchange exchange) throws IOException {
- final SmbFile data =
exchange.getMessage().getBody(SmbFile.class);
- final String name =
exchange.getMessage().getHeader(Exchange.FILE_NAME, String.class);
- new String((byte[]) data.getBody(), StandardCharsets.UTF_8);
- LOG.debug("Read exchange name {} at {} with contents: {}
(bytes {})", name, data.getAbsoluteFilePath(),
- new String((byte[]) data.getBody(),
StandardCharsets.UTF_8), data.getFileLength());
- }
-
public void configure() {
SmbConfig config = SmbConfig.builder()
.withTimeout(120, TimeUnit.SECONDS) // Timeout sets
Read, Write, and Transact timeouts (default is 60 seconds)
@@ -114,14 +98,6 @@ public class SmbComponentConnectionIT extends
CamelTestSupport {
.build();
context.getRegistry().bind("smbConfig", config);
-
fromF("smb:%s/%s?username=%s&password=%s&smbConfig=#smbConfig",
service.address(), service.shareName(),
- service.userName(), service.password())
- .to("seda:intermediate");
-
- from("seda:intermediate?concurrentConsumers=4")
- .process(this::process)
- .to("mock:result");
-
from("seda:send")
.toF("smb:%s/%s?username=%s&password=%s",
service.address(), service.shareName(),
service.userName(), service.password());
diff --git
a/components/camel-smb/src/test/java/org/apache/camel/component/smb/SmbComponentConnectionIT.java
b/components/camel-smb/src/test/java/org/apache/camel/component/smb/SmbComponentConnectionReadIT.java
similarity index 51%
copy from
components/camel-smb/src/test/java/org/apache/camel/component/smb/SmbComponentConnectionIT.java
copy to
components/camel-smb/src/test/java/org/apache/camel/component/smb/SmbComponentConnectionReadIT.java
index 1a599abd89a0..e34a0d5350ed 100644
---
a/components/camel-smb/src/test/java/org/apache/camel/component/smb/SmbComponentConnectionIT.java
+++
b/components/camel-smb/src/test/java/org/apache/camel/component/smb/SmbComponentConnectionReadIT.java
@@ -18,25 +18,24 @@ package org.apache.camel.component.smb;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
-import java.util.Map;
import java.util.concurrent.TimeUnit;
import com.hierynomus.smbj.SmbConfig;
import org.apache.camel.EndpointInject;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.file.GenericFileExist;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.test.infra.smb.services.SmbService;
import org.apache.camel.test.infra.smb.services.SmbServiceFactory;
import org.apache.camel.test.junit6.CamelTestSupport;
-import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
+import org.junit.jupiter.api.parallel.Isolated;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class SmbComponentConnectionIT extends CamelTestSupport {
+@Isolated
+class SmbComponentConnectionReadIT extends CamelTestSupport {
private static final Logger LOG =
LoggerFactory.getLogger(SmbComponentIT.class);
@RegisterExtension
@@ -46,56 +45,13 @@ public class SmbComponentConnectionIT extends
CamelTestSupport {
protected MockEndpoint mockResultEndpoint;
@Test
- public void testSmbRead() throws Exception {
+ void testSmbRead() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(100);
mock.assertIsSatisfied();
}
- @Test
- public void testSendReceive() throws Exception {
-
- MockEndpoint mock = getMockEndpoint("mock:received_send");
- mock.expectedMessageCount(1);
-
- template.sendBodyAndHeader("seda:send", "Hello World",
Exchange.FILE_NAME, "file_send.doc");
-
- mock.assertIsSatisfied();
- SmbFile file =
mock.getExchanges().get(0).getIn().getBody(SmbFile.class);
-
- Assertions.assertEquals("Hello World", new String((byte[])
file.getBody(), StandardCharsets.UTF_8));
- }
-
- @Test
- public void testDefaultIgnore() throws Exception {
-
- MockEndpoint mock = getMockEndpoint("mock:received_ignore");
- mock.expectedMessageCount(1);
-
- template.sendBodyAndHeader("seda:send", "Hello World",
Exchange.FILE_NAME, "file_ignore.doc");
- template.sendBodyAndHeaders("seda:send", "Good Bye",
Map.of(Exchange.FILE_NAME, "file_ignore.doc",
- SmbConstants.SMB_FILE_EXISTS, GenericFileExist.Ignore.name()));
-
- mock.assertIsSatisfied();
- SmbFile file =
mock.getExchanges().get(0).getIn().getBody(SmbFile.class);
- Assertions.assertEquals("Hello World", new String((byte[])
file.getBody(), StandardCharsets.UTF_8));
- }
-
- @Test
- public void testOverride() throws Exception {
-
- MockEndpoint mock = getMockEndpoint("mock:received_override");
- mock.expectedMessageCount(1);
- template.sendBodyAndHeader("seda:send", "Hello World22",
Exchange.FILE_NAME, "file_override.doc");
- template.sendBodyAndHeaders("seda:send", "Good Bye",
Map.of(Exchange.FILE_NAME, "file_override.doc",
- SmbConstants.SMB_FILE_EXISTS,
GenericFileExist.Override.name()));
-
- mock.assertIsSatisfied();
- SmbFile file =
mock.getExchanges().get(0).getIn().getBody(SmbFile.class);
- Assertions.assertEquals("Good Bye", new String((byte[])
file.getBody(), StandardCharsets.UTF_8));
- }
-
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@@ -114,30 +70,14 @@ public class SmbComponentConnectionIT extends
CamelTestSupport {
.build();
context.getRegistry().bind("smbConfig", config);
-
fromF("smb:%s/%s?username=%s&password=%s&smbConfig=#smbConfig",
service.address(), service.shareName(),
+ fromF("smb:%s/%s?username=%s&password=%s&smbConfig=#smbConfig",
+ service.address(), service.shareName(),
service.userName(), service.password())
.to("seda:intermediate");
from("seda:intermediate?concurrentConsumers=4")
.process(this::process)
.to("mock:result");
-
- from("seda:send")
- .toF("smb:%s/%s?username=%s&password=%s",
service.address(), service.shareName(),
- service.userName(), service.password());
-
-
fromF("smb:%s/%s?username=%s&password=%s&searchPattern=*_override.doc&initialDelay=3000",
service.address(),
- service.shareName(),
- service.userName(), service.password())
- .to("mock:received_override");
-
fromF("smb:%s/%s?username=%s&password=%s&searchPattern=*_ignore.doc&initialDelay=3000",
service.address(),
- service.shareName(),
- service.userName(), service.password())
- .to("mock:received_ignore");
-
fromF("smb:%s/%s?username=%s&password=%s&searchPattern=*_send.doc&initialDelay=3000",
service.address(),
- service.shareName(),
- service.userName(), service.password())
- .to("mock:received_send");
}
};
}