Skip to content

Commit 370e647

Browse files
committed
test: some more teste
1 parent ef3ea5f commit 370e647

5 files changed

Lines changed: 14 additions & 29 deletions

File tree

pom.xml

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -219,20 +219,12 @@
219219
<plugin>
220220
<artifactId>maven-surefire-plugin</artifactId>
221221
<configuration>
222-
<systemProperties>
223-
<property>
224-
<name>java.util.logging.config.file</name>
225-
<value>src/test/resources/remoting_logger.properties</value>
226-
</property>
227-
<property>
228-
<name>hudson.remoting.Launcher.pingIntervalSec</name>
229-
<value>-1</value>
230-
</property>
231-
<property>
232-
<name>hudson.slaves.ChannelPinger.pingIntervalSeconds</name>
233-
<value>-1</value>
234-
</property>
235-
</systemProperties>
222+
<systemPropertyVariables>
223+
<java.util.logging.config.file>src/test/resources/remoting_logger.properties</java.util.logging.config.file>
224+
<hudson.remoting.Launcher.pingIntervalSec>-1</hudson.remoting.Launcher.pingIntervalSec>
225+
<hudson.slaves.ChannelPinger.pingIntervalSeconds>-1</hudson.slaves.ChannelPinger.pingIntervalSeconds>
226+
<jenkins.test.timeout>-1</jenkins.test.timeout>
227+
</systemPropertyVariables>
236228
</configuration>
237229
</plugin>
238230
</plugins>

src/main/java/io/jenkins/plugins/sshbuildagents/ssh/mina/ShellChannelImpl.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,18 @@
2323
*/
2424
package io.jenkins.plugins.sshbuildagents.ssh.mina;
2525

26-
import java.io.BufferedInputStream;
2726
import java.io.IOException;
2827
import java.io.InputStream;
2928
import java.io.OutputStream;
3029
import java.io.PipedInputStream;
3130
import java.io.PipedOutputStream;
32-
import java.time.Duration;
3331
import java.util.Collections;
3432
import java.util.concurrent.TimeUnit;
3533
import io.jenkins.plugins.sshbuildagents.ssh.ShellChannel;
3634
import org.apache.sshd.client.channel.ChannelSession;
3735
import org.apache.sshd.client.channel.ClientChannelEvent;
3836
import org.apache.sshd.client.session.ClientSession;
39-
import org.apache.sshd.common.channel.Channel;
40-
import org.apache.sshd.common.channel.ChannelListener;
41-
import org.apache.sshd.common.session.ReservedSessionMessagesHandler;
42-
import org.apache.sshd.common.session.Session;
43-
import org.apache.sshd.common.session.SessionHeartbeatController;
44-
import org.apache.sshd.common.util.buffer.Buffer;
37+
4538

4639
/**
4740
* Implements {@link ShellChannel} using the Apache Mina SSHD library https://github.com/apache/mina-sshd

src/test/java/io/jenkins/plugins/sshbuildagents/ssh/agents/AgentConnectionBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public class AgentConnectionBase {
5252
public Retry retry = new Retry(3);
5353

5454
@Rule
55-
public Timeout globalTimeout= new Timeout(4, TimeUnit.MINUTES);
55+
public Timeout globalTimeout= new Timeout(6, TimeUnit.MINUTES);
5656

5757
protected boolean isSuccessfullyConnected(Node node) throws IOException, InterruptedException {
5858
boolean ret = false;

src/test/java/io/jenkins/plugins/sshbuildagents/ssh/agents/AgentRSA512ConnectionTest.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package io.jenkins.plugins.sshbuildagents.ssh.agents;
22

33
import java.io.IOException;
4-
import org.junit.Before;
54
import org.junit.Rule;
65
import org.junit.Test;
76
import org.junit.experimental.categories.Category;
7+
import org.jvnet.hudson.test.recipes.WithTimeout;
88
import org.testcontainers.containers.GenericContainer;
99
import org.testcontainers.images.builder.ImageFromDockerfile;
1010
import hudson.model.Descriptor;
@@ -45,15 +45,14 @@ public void connectionTests() throws IOException, InterruptedException, Descript
4545
}
4646

4747
@Test
48+
@WithTimeout(300)
4849
public void longConnectionTests() throws IOException, InterruptedException, Descriptor.FormException {
4950
Node node = createPermanentAgent(SSH_AGENT_NAME, agentContainer.getHost(), agentContainer.getMappedPort(SSH_PORT),
5051
SSH_AGENT_NAME + "/" + SSH_KEY_PATH, "");
5152
waitForAgentConnected(node);
5253
assertTrue(isSuccessfullyConnected(node));
53-
for(int i=0;i<300;i++){
54-
Thread.sleep(1000);
55-
assertTrue(node.toComputer().isOnline());
56-
}
54+
Thread.sleep(60000);
55+
assertTrue(node.toComputer().isOnline());
5756
}
5857

5958
}

src/test/resources/remoting_logger.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
55

66
java.util.logging.FileHandler.append = false
77
java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter
8-
java.util.logging.FileHandler.pattern = log.%u.%g.log
8+
#the logs files are in the system temporal folder
9+
java.util.logging.FileHandler.pattern = %t/ssh-build-agents-test-log.%u.%g.log
910

1011
hudson.remoting.level = FINE
1112
hudson.slaves.level = FINE

0 commit comments

Comments
 (0)