[ 
https://issues.apache.org/jira/browse/CAMEL-27106?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18146184#comment-18146184
 ] 

Guillaume Nodet commented on CAMEL-27106:
-----------------------------------------

Fixed in PR https://github.com/apache/camel/pull/30270.

*Root cause:* `RemoteFileConsumerWarnCapture.attach()` installs an appender on 
the global Log4j2 root logger. When `camel.failsafe.parallel=true` runs 
multiple `Sftp*IT` classes concurrently in the same JVM, WARN messages from 
`RemoteFileConsumer` in sibling test routes bleed into the shared appender, 
causing count-based assertions to see more messages than expected. This 
explains all three observed failure modes:
- `connectionFailureIsRetried` — expected one WARN, got two (second was a 
`ConnectException` from a concurrent FTP test)
- `wrongPasswordIsSentOncePerPoll` — extra `ConnectException` WARN from a 
sibling test
- `rightPasswordLogsIn` — `warnings.messages().isEmpty()` false because other 
test WARNs bled in

*Fix:* `@Isolated` on the test class forces JUnit 5 to run it sequentially (no 
other class runs concurrently), eliminating the bleed. Same as 
`SftpKeyExchangeProtocolsIT` and `SftpPublicKeyAcceptedAlgorithmsIT` in the 
same module.

_Hermes Agent (Claude Sonnet 4.6) on behalf of Guillaume Nodet_

> Fix flaky test SftpConsumerWrongPasswordIT
> ------------------------------------------
>
>                 Key: CAMEL-27106
>                 URL: https://issues.apache.org/jira/browse/CAMEL-27106
>             Project: Camel
>          Issue Type: Test
>          Components: camel-sftp
>    Affects Versions: 4.24.0
>            Reporter: Aurélien Pupier
>            Assignee: Guillaume Nodet
>            Priority: Major
>
> [newly test created 2 days ago was flaky 13 
> times|https://develocity.apache.org/scans/tests?search.startTimeMax=1794956399999&search.startTimeMin=1794265200000&search.timeZoneId=Europe%2FParis&tests.container=org.apache.camel.component.file.remote.sftp.integration.SftpConsumerWrongPasswordIT]
> different test methods can fail:
> {noformat}
> org.opentest4j.AssertionFailedError: No WARN: [Cannot connect/login to: 
> sftp://admin@localhost:35177 due to: java.net.ConnectException: Connection 
> refused (connect failed). Will skip this poll.] ==> expected: <true> but was: 
> <false>      
>       at org.junit.jupiter.api.Assertions.assertTrue(Assertions.java:232)     
>       at 
> org.apache.camel.component.file.remote.sftp.integration.SftpConsumerWrongPasswordIT.rightPasswordLogsIn(SftpConsumerWrongPasswordIT.java:122)
>         
> {noformat}
> {noformat}
> org.opentest4j.AssertionFailedError: expected: <[Cannot connect/login to: 
> sftp://admin@localhost:35517 due to: connection is closed by foreign host. 
> Will skip this poll.]> but was: <[Cannot connect/login to: 
> sftp://admin@localhost:35517 due to: connection is closed by foreign host. 
> Will skip this poll., Cannot connect/login to: sftp://admin@localhost:43365 
> due to: java.net.ConnectException: Connection refused (connect failed). Will 
> skip this poll.]> 
>       at org.junit.jupiter.api.Assertions.assertEquals(Assertions.java:1199)  
>       at 
> org.apache.camel.component.file.remote.sftp.integration.SftpConsumerWrongPasswordIT.connectionFailureIsRetried(SftpConsumerWrongPasswordIT.java:145)
>  
> {noformat}
> {noformat}
> org.opentest4j.AssertionFailedError: No WARN: [Cannot connect/login to: 
> sftp://admin@localhost:42533 due to: java.net.ConnectException: Connection 
> refused (connect failed). Will skip this poll., Cannot connect/login to: 
> ftp://admin@localhost:38483 due to: Connection refused (connect failed). Will 
> skip this poll.] ==> expected: <true> but was: <false>      
>       at org.junit.jupiter.api.Assertions.assertTrue(Assertions.java:232)     
>       at 
> org.apache.camel.component.file.remote.sftp.integration.SftpConsumerWrongPasswordIT.rightPasswordLogsIn(SftpConsumerWrongPasswordIT.java:122)
>         
> {noformat}
> {noformat}
> org.opentest4j.AssertionFailedError: expected: <[Cannot connect/login to: 
> sftp://admin@localhost:42469 due to: Auth fail for user 'admin': the server 
> did not accept the password. Will skip this poll.]> but was: <[Cannot 
> connect/login to: sftp://admin@localhost:42469 due to: Auth fail for user 
> 'admin': the server did not accept the password. Will skip this poll., Cannot 
> connect/login to: sftp://admin@localhost:39261 due to: 
> java.net.ConnectException: Connection refused (connect failed). Will skip 
> this poll.]>     
>       at org.junit.jupiter.api.Assertions.assertEquals(Assertions.java:1199)  
>       at 
> org.apache.camel.component.file.remote.sftp.integration.SftpConsumerWrongPasswordIT.wrongPasswordIsSentOncePerPoll(SftpConsumerWrongPasswordIT.java:90)
>       
> {noformat}



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to