apupier commented on code in PR #22983:
URL: https://github.com/apache/camel/pull/22983#discussion_r3194029712
##########
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:
Why is it a log?
Shouldn't we throw an exception? or use an assertion to prevent the test
from going further?
--
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]