This is an automated email from the ASF dual-hosted git repository.
gnodet 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 258a55853230 CAMEL-23216: Fix flaky mina sftp tests
258a55853230 is described below
commit 258a5585323042b375ee622035c1edc0ab229ccc
Author: Guillaume Nodet <[email protected]>
AuthorDate: Wed May 6 18:23:34 2026 +0200
CAMEL-23216: Fix flaky mina sftp tests
Add server readiness probe in SftpEmbeddedInfraService to verify the
embedded SFTP server accepts TCP connections before tests run. Throws
IOException if the server is not ready within 30 seconds, failing fast
with a clear error instead of proceeding to confusing timeout errors.
---
.../services/embedded/SftpEmbeddedInfraService.java | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git
a/test-infra/camel-test-infra-ftp/src/main/java/org/apache/camel/test/infra/ftp/services/embedded/SftpEmbeddedInfraService.java
b/test-infra/camel-test-infra-ftp/src/main/java/org/apache/camel/test/infra/ftp/services/embedded/SftpEmbeddedInfraService.java
index 5fafd778f1b0..35b754ddd1cc 100644
---
a/test-infra/camel-test-infra-ftp/src/main/java/org/apache/camel/test/infra/ftp/services/embedded/SftpEmbeddedInfraService.java
+++
b/test-infra/camel-test-infra-ftp/src/main/java/org/apache/camel/test/infra/ftp/services/embedded/SftpEmbeddedInfraService.java
@@ -20,6 +20,7 @@ package org.apache.camel.test.infra.ftp.services.embedded;
import java.io.File;
import java.io.IOException;
import java.net.InetSocketAddress;
+import java.net.Socket;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
@@ -27,6 +28,7 @@ import java.security.KeyPair;
import java.security.PublicKey;
import java.util.Collections;
import java.util.List;
+import java.util.concurrent.TimeUnit;
import java.util.function.BiConsumer;
import org.apache.camel.spi.annotations.InfraService;
@@ -136,6 +138,23 @@ public class SftpEmbeddedInfraService extends
AbstractService implements FtpInfr
sshd.start();
port = ((InetSocketAddress)
sshd.getBoundAddresses().iterator().next()).getPort();
+
+ waitForServerReady();
+ }
+
+ private void waitForServerReady() throws IOException {
+ long deadline = System.nanoTime() + TimeUnit.SECONDS.toNanos(30);
+ IOException lastException = null;
+ while (System.nanoTime() < deadline) {
+ try (Socket socket = new Socket()) {
+ socket.connect(new InetSocketAddress("localhost", port), 1000);
+ return;
+ } catch (IOException e) {
+ lastException = e;
+ Thread.onSpinWait();
+ }
+ }
+ throw new IOException("SFTP server not ready after 30 seconds on port
" + port, lastException);
}
protected PublickeyAuthenticator getPublickeyAuthenticator() {