Skip to content

Commit

Permalink
Add test unit for JENKINS-22641
Browse files Browse the repository at this point in the history
(cherry picked from commit 0d4c0cb)
  • Loading branch information
christ66 authored and olivergondza committed Aug 6, 2014
1 parent 28b9a6c commit 86c44d8
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions test/src/test/java/hudson/util/ProcessTreeKillerTest.java
@@ -1,14 +1,13 @@
package hudson.util;

import hudson.model.FreeStyleProject;
import hudson.Functions;
import hudson.model.FreeStyleBuild;
import hudson.model.FreeStyleProject;
import hudson.tasks.Maven;

import org.easymock.EasyMock;
import hudson.tasks.Shell;
import org.jvnet.hudson.test.Bug;
import org.jvnet.hudson.test.ExtractResourceSCM;
import org.jvnet.hudson.test.HudsonTestCase;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;

public class ProcessTreeKillerTest extends HudsonTestCase {

Expand All @@ -34,4 +33,25 @@ public void testManualAbortProcess() throws Exception {

}

@Bug(22641)
public void testProcessProperlyKilledUnix() throws Exception {
ProcessTree.enabled = true;
if (Functions.isWindows()) return; // This test does not involve windows.

FreeStyleProject sleepProject = createFreeStyleProject();
FreeStyleProject processJob = createFreeStyleProject();

sleepProject.getBuildersList().add(new Shell("nohup sleep 100000 &"));

assertBuildStatusSuccess(sleepProject.scheduleBuild2(0).get());

processJob.getBuildersList().add(new Shell("ps -ef | grep sleep"));

String log = processJob.scheduleBuild2(0).get().getLog();

System.err.println("LOGS: " + log);

assertFalse("Did not properly kill task", log.contains("sleep 100000"));
}

}

0 comments on commit 86c44d8

Please sign in to comment.