|
12 | 12 | import org.jvnet.hudson.test.JenkinsRule;
|
13 | 13 | import hudson.model.Descriptor;
|
14 | 14 | import hudson.model.Node;
|
| 15 | +import hudson.model.Slave; |
15 | 16 | import hudson.plugins.sshslaves.SSHLauncher;
|
16 | 17 | import hudson.plugins.sshslaves.rules.CheckIsDockerAvailable;
|
17 | 18 | import hudson.plugins.sshslaves.rules.CheckIsLinuxOrMac;
|
|
23 | 24 | import com.cloudbees.plugins.credentials.common.StandardUsernameCredentials;
|
24 | 25 | import com.cloudbees.plugins.credentials.domains.Domain;
|
25 | 26 | import com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl;
|
26 |
| -import static org.junit.Assert.assertTrue; |
27 | 27 |
|
28 | 28 | /**
|
29 | 29 | * Base class to test connections to a remote SSH Agent
|
@@ -53,24 +53,25 @@ public class AgentConnectionBase {
|
53 | 53 | public Timeout globalTimeout= new Timeout(4, TimeUnit.MINUTES);
|
54 | 54 |
|
55 | 55 | protected boolean isSuccessfullyConnected(Node node) throws IOException, InterruptedException {
|
56 |
| - boolean ret = false; |
57 | 56 | int count = 0;
|
58 | 57 | while (count < 30) {
|
59 | 58 | Thread.sleep(1000);
|
60 | 59 | String log = node.toComputer().getLog();
|
61 |
| - ret = log.contains("Agent successfully connected and online"); |
62 |
| - count++; |
| 60 | + if (log.contains("Agent successfully connected and online")) { |
| 61 | + return true; |
| 62 | + } |
63 | 63 | }
|
64 |
| - return ret; |
| 64 | + return false; |
65 | 65 | }
|
66 | 66 |
|
67 | 67 | protected void waitForAgentConnected(Node node) throws InterruptedException {
|
68 |
| - int count = 0; |
69 |
| - while (!node.toComputer().isOnline() && count < 150) { |
70 |
| - Thread.sleep(1000); |
71 |
| - count++; |
| 68 | + try { |
| 69 | + j.waitOnline((Slave) node); |
| 70 | + } catch (InterruptedException | RuntimeException x) { |
| 71 | + throw x; |
| 72 | + } catch (Exception x) { |
| 73 | + throw new RuntimeException(x); |
72 | 74 | }
|
73 |
| - assertTrue(node.toComputer().isOnline()); |
74 | 75 | }
|
75 | 76 |
|
76 | 77 | protected Node createPermanentAgent(String name, String host, int sshPort, String keyResourcePath, String passphrase)
|
|
0 commit comments