use of com.thoughtworks.go.domain.KillAllChildProcessTask in project gocd by gocd.
the class ConfigConverter method commonCRTaskMembers.
private void commonCRTaskMembers(CRTask crTask, AbstractTask task) {
Task taskOnCancel = task.cancelTask();
if (taskOnCancel != null && !(taskOnCancel instanceof KillAllChildProcessTask) && !(taskOnCancel instanceof NullTask))
crTask.setOnCancel(taskToCRTask(taskOnCancel));
crTask.setRunIf(crRunIfs(task.runIfConfigs));
}
use of com.thoughtworks.go.domain.KillAllChildProcessTask in project gocd by gocd.
the class KillAllChildProcessTaskBuilderTest method shouldKillAllChildProcessOnBuild.
@Test
@Timeout(value = 11, unit = MINUTES)
public void shouldKillAllChildProcessOnBuild() throws Exception {
ProcessWrapper processWrapper = platformSpecificSleepCommand().withArg(String.valueOf(10 * 60)).withEncoding("utf-8").execute(ProcessOutputStreamConsumer.inMemoryConsumer(), new EnvironmentVariableContext(), // 10 mins
null);
assertThat(processWrapper.isRunning(), is(true));
DefaultGoPublisher publisher = mock(DefaultGoPublisher.class);
EnvironmentVariableContext environmentVariableContext = mock(EnvironmentVariableContext.class);
long before = getSystemTime();
Builder builder = new KillAllChildProcessTaskBuilder().createBuilder(builderFactory, new KillAllChildProcessTask(), null, null);
builder.build(publisher, environmentVariableContext, null, null, null, "utf-8");
assertThat(processWrapper.waitForExit(), is(greaterThan(0)));
// min = 10; sec = 60*min; mills = 1000*sec; micro = 1000*mills; nano = 1000*micro;
assertThat(getSystemTime() - before, is(lessThan(10 * 60 * 1000 * 1000 * 1000L)));
}
use of com.thoughtworks.go.domain.KillAllChildProcessTask in project gocd by gocd.
the class KillAllChildProcessTaskBuilderTest method shouldKillAllChildProcessOnbuild.
// 11 minutes
@Test(timeout = 11 * 60 * 1000)
public void shouldKillAllChildProcessOnbuild() throws Exception {
ProcessWrapper processWrapper = CommandLine.createCommandLine("sleep").withArg(String.valueOf(10 * 60)).withEncoding("utf-8").execute(ProcessOutputStreamConsumer.inMemoryConsumer(), new EnvironmentVariableContext(), // 60 mins
null);
assertThat(processWrapper.isRunning(), is(true));
DefaultGoPublisher publisher = mock(DefaultGoPublisher.class);
EnvironmentVariableContext environmentVariableContext = mock(EnvironmentVariableContext.class);
long before = getSystemTime();
Builder builder = new KillAllChildProcessTaskBuilder().createBuilder(builderFactory, new KillAllChildProcessTask(), null, null);
builder.build(publisher, environmentVariableContext, null, null, null, "utf-8");
assertThat(processWrapper.waitForExit(), is(greaterThan(0)));
// min = 10; sec = 60*min; mills = 1000*sec; micro = 1000*mills; nano = 1000*micro;
assertThat(getSystemTime() - before, is(lessThan(10 * 60 * 1000 * 1000 * 1000L)));
}
Aggregations