diff --git a/core/src/test/java/hudson/LauncherTest.java b/core/src/test/java/hudson/LauncherTest.java
index 62ff200e96a1b158c5005ffcbb9e6d2fb7f87c11..4df308b41d17101081d63b3136a2a2d42f64320e 100644
--- a/core/src/test/java/hudson/LauncherTest.java
+++ b/core/src/test/java/hudson/LauncherTest.java
@@ -61,7 +61,8 @@ public class LauncherTest {
p.kill();
assertTrue(p.join()!=0);
long end = System.currentTimeMillis();
- assertTrue("join finished promptly", (end - start < 15000));
+ long terminationTime = end - start;
+ assertTrue("Join did not finish promptly. The completion time (" + terminationTime + "ms) is longer than expected 15s", terminationTime < 15000);
channels.french.call(NOOP); // this only returns after the other side of the channel has finished executing cancellation
Thread.sleep(2000); // more delay to make sure it's gone
assertNull("process should be gone",ProcessTree.get().get(Integer.parseInt(FileUtils.readFileToString(tmp).trim())));
diff --git a/pom.xml b/pom.xml
index 08779571c850f421ec881c5862e11ccfae017a60..7b45460d1fed5adda9e2a24cad62b4d626022a0c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -168,7 +168,7 @@ THE SOFTWARE.
org.jenkins-ci.main
remoting
- 3.7
+ 3.10
diff --git a/test/src/test/java/hudson/slaves/JNLPLauncherTest.java b/test/src/test/java/hudson/slaves/JNLPLauncherTest.java
index ccbdc43211b32b736f0e5acfe495e4f847217a5e..e30f365a6e4904b51def18be089ff4028fb9b472 100644
--- a/test/src/test/java/hudson/slaves/JNLPLauncherTest.java
+++ b/test/src/test/java/hudson/slaves/JNLPLauncherTest.java
@@ -54,15 +54,20 @@ import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.awt.*;
+import org.junit.rules.TemporaryFolder;
+import org.jvnet.hudson.test.Issue;
/**
+ * Tests of {@link JNLPLauncher}.
* @author Kohsuke Kawaguchi
*/
public class JNLPLauncherTest {
@Rule public JenkinsRule j = new JenkinsRule();
+
+ @Rule public TemporaryFolder tmpDir = new TemporaryFolder();
/**
- * Starts a JNLP slave agent and makes sure it successfully connects to Hudson.
+ * Starts a JNLP agent and makes sure it successfully connects to Jenkins.
*/
@Test
public void testLaunch() throws Exception {
@@ -71,6 +76,20 @@ public class JNLPLauncherTest {
Computer c = addTestSlave();
launchJnlpAndVerify(c, buildJnlpArgs(c));
}
+
+ /**
+ * Starts a JNLP agent and makes sure it successfully connects to Jenkins.
+ */
+ @Test
+ @Issue("JENKINS-39370")
+ public void testLaunchWithWorkDir() throws Exception {
+ Assume.assumeFalse("Skipping JNLPLauncherTest.testLaunch because we are running headless", GraphicsEnvironment.isHeadless());
+ File workDir = tmpDir.newFolder("workDir");
+
+ Computer c = addTestSlave();
+ launchJnlpAndVerify(c, buildJnlpArgs(c).add("-workDir", workDir.getAbsolutePath()));
+ assertTrue("Remoting work dir should have been created", new File(workDir, "remoting").exists());
+ }
/**
* Tests the '-headless' option.
@@ -83,6 +102,17 @@ public class JNLPLauncherTest {
// make sure that onOffline gets called just the right number of times
assertEquals(1, ComputerListener.all().get(ListenerImpl.class).offlined);
}
+
+ @Test
+ @Issue("JENKINS-39370")
+ public void testHeadlessLaunchWithWorkDir() throws Exception {
+ Assume.assumeFalse("Skipping JNLPLauncherTest.testLaunch because we are running headless", GraphicsEnvironment.isHeadless());
+ File workDir = tmpDir.newFolder("workDir");
+
+ Computer c = addTestSlave();
+ launchJnlpAndVerify(c, buildJnlpArgs(c).add("-arg","-headless", "-workDir", workDir.getAbsolutePath()));
+ assertEquals(1, ComputerListener.all().get(ListenerImpl.class).offlined);
+ }
@TestExtension("testHeadlessLaunch")
public static class ListenerImpl extends ComputerListener {