Skip to content

Commit

Permalink
Pointless delay in AgentConnectionBase.isSuccessfullyConnected (#457)
Browse files Browse the repository at this point in the history
  • Loading branch information
jglick authored Dec 16, 2023
1 parent 22553bb commit 9eb126d
Showing 1 changed file with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.jvnet.hudson.test.JenkinsRule;
import hudson.model.Descriptor;
import hudson.model.Node;
import hudson.model.Slave;
import hudson.plugins.sshslaves.SSHLauncher;
import hudson.plugins.sshslaves.rules.CheckIsDockerAvailable;
import hudson.plugins.sshslaves.rules.CheckIsLinuxOrMac;
Expand All @@ -23,7 +24,6 @@
import com.cloudbees.plugins.credentials.common.StandardUsernameCredentials;
import com.cloudbees.plugins.credentials.domains.Domain;
import com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl;
import static org.junit.Assert.assertTrue;

/**
* Base class to test connections to a remote SSH Agent
Expand Down Expand Up @@ -53,24 +53,25 @@ public class AgentConnectionBase {
public Timeout globalTimeout= new Timeout(4, TimeUnit.MINUTES);

protected boolean isSuccessfullyConnected(Node node) throws IOException, InterruptedException {
boolean ret = false;
int count = 0;
while (count < 30) {
Thread.sleep(1000);
String log = node.toComputer().getLog();
ret = log.contains("Agent successfully connected and online");
count++;
if (log.contains("Agent successfully connected and online")) {
return true;
}
}
return ret;
return false;
}

protected void waitForAgentConnected(Node node) throws InterruptedException {
int count = 0;
while (!node.toComputer().isOnline() && count < 150) {
Thread.sleep(1000);
count++;
try {
j.waitOnline((Slave) node);
} catch (InterruptedException | RuntimeException x) {
throw x;
} catch (Exception x) {
throw new RuntimeException(x);
}
assertTrue(node.toComputer().isOnline());
}

protected Node createPermanentAgent(String name, String host, int sshPort, String keyResourcePath, String passphrase)
Expand Down

0 comments on commit 9eb126d

Please sign in to comment.