davsclaus commented on code in PR #22983:
URL: https://github.com/apache/camel/pull/22983#discussion_r3194716443


##########
test-infra/camel-test-infra-ftp/src/main/java/org/apache/camel/test/infra/ftp/services/embedded/SftpEmbeddedInfraService.java:
##########
@@ -136,6 +137,21 @@ public void setUpServer() throws Exception {
         sshd.start();
 
         port = ((InetSocketAddress) 
sshd.getBoundAddresses().iterator().next()).getPort();
+
+        waitForServerReady();
+    }
+
+    private void waitForServerReady() {
+        long deadline = System.nanoTime() + 5_000_000_000L; // 5 seconds
+        while (System.nanoTime() < deadline) {
+            try (Socket socket = new Socket()) {
+                socket.connect(new InetSocketAddress("localhost", port), 1000);
+                return;
+            } catch (IOException e) {
+                Thread.onSpinWait();
+            }
+        }
+        LOG.warn("SFTP server may not be ready after timeout on port {}", 
port);

Review Comment:
   -1
   
   This is an infra service (not an test). This startup a FTP server in a 
docker container and if that takes longer than 5 seconds then it should be 
given more time to do so. Maybe if it takes longer than 30 seconds then 
something is wrong.



-- 
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]

Reply via email to