use of com.thoughtworks.go.util.ProcessWrapper 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.util.ProcessWrapper in project gocd by gocd.
the class CommandLine method execute.
/**
* @deprecated this should not be used outside of this CommandLine(in production code), as using it directly can bypass smudging of sensitive data
* this is used only in tests
*/
public ProcessWrapper execute(ConsoleOutputStreamConsumer outputStreamConsumer, EnvironmentVariableContext environmentVariableContext, String processTag) {
ProcessWrapper process = createProcess(environmentVariableContext, outputStreamConsumer, processTag, ERROR_STREAM_PREFIX_FOR_CMDS);
process.typeInputToConsole(inputs);
return process;
}
use of com.thoughtworks.go.util.ProcessWrapper in project gocd by gocd.
the class CommandLine method startProcess.
private ProcessWrapper startProcess(EnvironmentVariableContext environmentVariableContext, ConsoleOutputStreamConsumer consumer, String processTag) throws IOException {
ProcessWrapper process = createProcess(environmentVariableContext, consumer, processTag, ERROR_STREAM_PREFIX_FOR_SCRIPTS);
process.closeOutputStream();
return process;
}
use of com.thoughtworks.go.util.ProcessWrapper 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)));
}
use of com.thoughtworks.go.util.ProcessWrapper in project gocd by gocd.
the class CommandLine method execute.
/**
* This should not be used outside of this CommandLine(in production code), as using it directly can bypass smudging of sensitive data
*/
@TestOnly
public ProcessWrapper execute(ConsoleOutputStreamConsumer outputStreamConsumer, EnvironmentVariableContext environmentVariableContext, ProcessTag processTag) {
ProcessWrapper process = createProcess(environmentVariableContext, outputStreamConsumer, processTag, ERROR_STREAM_PREFIX_FOR_CMDS);
process.typeInputToConsole(inputs);
return process;
}
Aggregations