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)).execute(ProcessOutputStreamConsumer.inMemoryConsumer(), new EnvironmentVariableContext(), //60 mins
null);
assertThat(processWrapper.isRunning(), is(true));
BuildLogElement log = mock(BuildLogElement.class);
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(log, publisher, environmentVariableContext, null);
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