Search in sources :

Example 31 with CommandLine

use of com.thoughtworks.go.util.command.CommandLine in project gocd by gocd.

the class PipelineConfigServicePerformanceTest method takeHeapDump.

private void takeHeapDump(File dumpDir, int i) {
    InMemoryStreamConsumer outputStreamConsumer = inMemoryConsumer();
    CommandLine commandLine = CommandLine.createCommandLine("jmap").withArgs("-J-d64", String.format("-dump:format=b,file=%s/%s.hprof", dumpDir.getAbsoluteFile(), i), ManagementFactory.getRuntimeMXBean().getName().split("@")[0]);
    LOGGER.info(commandLine.describe());
    int exitCode = commandLine.run(outputStreamConsumer, "thread" + i);
    LOGGER.info(outputStreamConsumer.getAllOutput());
    assertThat(exitCode, is(0));
    LOGGER.info("Heap dump available at " + dumpDir.getAbsolutePath());
}
Also used : CommandLine(com.thoughtworks.go.util.command.CommandLine) InMemoryStreamConsumer(com.thoughtworks.go.util.command.InMemoryStreamConsumer)

Aggregations

CommandLine (com.thoughtworks.go.util.command.CommandLine)31 Test (org.junit.Test)16 InMemoryStreamConsumer (com.thoughtworks.go.util.command.InMemoryStreamConsumer)6 ConsoleResult (com.thoughtworks.go.util.command.ConsoleResult)5 File (java.io.File)5 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)3 CommandLineException (com.thoughtworks.go.util.command.CommandLineException)3 Matchers.containsString (org.hamcrest.Matchers.containsString)3 RunIf (com.googlecode.junit.ext.RunIf)2 EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)2 ProcessOutputStreamConsumer (com.thoughtworks.go.util.command.ProcessOutputStreamConsumer)2 LinkedList (java.util.LinkedList)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 Answer (org.mockito.stubbing.Answer)2 CheckedCommandLineException (com.thoughtworks.go.util.command.CheckedCommandLineException)1 CompositeConsumer (com.thoughtworks.go.util.command.CompositeConsumer)1 CruiseControlException (com.thoughtworks.go.util.command.CruiseControlException)1 ExecScript (com.thoughtworks.go.util.command.ExecScript)1 UrlArgument (com.thoughtworks.go.util.command.UrlArgument)1 IOException (java.io.IOException)1