Search in sources :

Example 1 with KillAllChildProcessTask

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));
}
Also used : Task(com.thoughtworks.go.domain.Task) KillAllChildProcessTask(com.thoughtworks.go.domain.KillAllChildProcessTask) NullTask(com.thoughtworks.go.domain.NullTask) PluggableTask(com.thoughtworks.go.config.pluggabletask.PluggableTask) NullTask(com.thoughtworks.go.domain.NullTask) KillAllChildProcessTask(com.thoughtworks.go.domain.KillAllChildProcessTask)

Example 2 with KillAllChildProcessTask

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)));
}
Also used : ProcessWrapper(com.thoughtworks.go.util.ProcessWrapper) DefaultGoPublisher(com.thoughtworks.go.work.DefaultGoPublisher) Builder(com.thoughtworks.go.domain.builder.Builder) EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext) KillAllChildProcessTask(com.thoughtworks.go.domain.KillAllChildProcessTask) Test(org.junit.jupiter.api.Test) Timeout(org.junit.jupiter.api.Timeout)

Example 3 with KillAllChildProcessTask

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)));
}
Also used : ProcessWrapper(com.thoughtworks.go.util.ProcessWrapper) DefaultGoPublisher(com.thoughtworks.go.work.DefaultGoPublisher) Builder(com.thoughtworks.go.domain.builder.Builder) EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext) KillAllChildProcessTask(com.thoughtworks.go.domain.KillAllChildProcessTask) Test(org.junit.Test)

Aggregations

KillAllChildProcessTask (com.thoughtworks.go.domain.KillAllChildProcessTask)3 Builder (com.thoughtworks.go.domain.builder.Builder)2 ProcessWrapper (com.thoughtworks.go.util.ProcessWrapper)2 EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)2 DefaultGoPublisher (com.thoughtworks.go.work.DefaultGoPublisher)2 PluggableTask (com.thoughtworks.go.config.pluggabletask.PluggableTask)1 NullTask (com.thoughtworks.go.domain.NullTask)1 Task (com.thoughtworks.go.domain.Task)1 Test (org.junit.Test)1 Test (org.junit.jupiter.api.Test)1 Timeout (org.junit.jupiter.api.Timeout)1