[
https://issues.apache.org/jira/browse/CAMEL-27106?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18146170#comment-18146170
]
Guillaume Nodet commented on CAMEL-27106:
-----------------------------------------
Investigated the flaky test SftpConsumerWrongPasswordIT (on behalf of gnodet).
Root cause confirmed by code reading (commit c770e795acf0, introduced
2026-11-16):
1. RemoteFileConsumerWarnCapture attaches to the root Log4j2 logger, so WARN
messages from concurrent tests or leaked routes bleed into sibling tests in the
same JVM fork.
2. connectionFailureIsRetried test asserts warnings.messages() has exactly one
entry, but if another route is still running (e.g. from
wrongPasswordIsSentOncePerPoll), its WARN messages also appear, causing
failures like "expected <[msg1]> but was <[msg1, msg2]>".
3. rightPasswordLogsIn fails with ConnectException when the SFTP embedded
service port is briefly occupied (AvailablePortFinder race with other parallel
tests starting on the same CI node).
Fix approach:
- Add @ResourceLock or @Isolated to SftpConsumerWrongPasswordIT to prevent
parallel execution with other SFTP tests
- Alternatively, make RemoteFileConsumerWarnCapture capture messages after the
route starts (not from beforeEach), or scope log capture to a specific logger
instance per consumer
- The warnings.messages() assertion in connectionFailureIsRetried should use
containsExactly rather than assertEquals if warning ordering is not guaranteed
This is being investigated by a coding agent and a fix PR will be opened.
_Note: This comment was generated by an AI coding agent and requires manual
verification._
> 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)