gnodet opened a new pull request, #24601: URL: https://github.com/apache/camel/pull/24601
## Summary _Claude Code on behalf of Guillaume Nodet_ Fixes widespread flaky SFTP tests in `camel-mina-sftp` by improving the embedded SFTP server readiness check in `SftpEmbeddedInfraService`. ### Root Cause The `waitForServerReady()` method was only verifying TCP socket connectivity — it checked that the port was accepting TCP connections but did **not** verify that the SSH protocol layer was fully initialized. This caused a race condition: 1. `sshd.start()` → kernel starts accepting TCP connections on the port 2. `waitForServerReady()` → TCP connect succeeds → returns immediately 3. Test tries SSH handshake → SSH protocol layer still initializing → **times out at 10 seconds** Additionally, the retry loop used `Thread.onSpinWait()` (CPU-burning busy-wait) instead of a proper backoff sleep, which on loaded CI machines would **starve the SSHD server thread** of CPU time, making the initialization slower — a self-reinforcing problem. ### Fix - **SSH version banner verification**: After TCP connectivity is confirmed, read the server's SSH version banner (`SSH-2.0-...`). The SSHD server only sends this banner when the SSH protocol layer is fully initialized and ready for handshakes. - **Proper retry backoff**: Replace `Thread.onSpinWait()` busy-wait with `Thread.sleep(100)` to avoid CPU starvation on loaded CI machines. - **Timeout adjustments**: Increase socket connect timeout from 1s to 2s, add 5s socket read timeout for the banner check. ### Impact This addresses the root cause of **20+ flaky SFTP test containers** (591 total with flaky outcomes in a single week) that have been failing intermittently on CI since February 2026 with: ``` SshException: [ssh-connection]: Failed to get operation result within specified timeout: 10000 msec ``` The same ~10 CI build IDs appear across ALL SFTP failure groups, confirming that when the server is slow in a CI run, all SFTP tests fail together — a shared infrastructure issue. **Develocity flaky test data (Jul 3–10, 2026):** - 8 distinct SFTP failure groups totaling 500+ failure events - All traced to the same SSH connection timeout root cause - Active since 2026-02-16 (~5 months) ### Files Changed - `test-infra/camel-test-infra-ftp/.../SftpEmbeddedInfraService.java` — improved `waitForServerReady()` ## Test plan - [x] Module compiles successfully - [x] Code formatting validation passes (`formatter:validate`, `impsort:check`) - [x] Verified tests fail identically on sandbox with and without change (sandbox-specific `AccessDeniedException: ~/.ssh/config` prevents local SFTP test execution — unrelated to this fix) - [ ] CI build passes on PR 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
