Class ForkStarter
- java.lang.Object
-
- org.apache.maven.plugin.surefire.booterclient.ForkStarter
-
public class ForkStarter extends java.lang.Object
Starts the fork or runs in-process.
Lives only on the plugin-side (not present in remote vms)
Knows how to fork new vms and also how to delegate non-forking invocation to SurefireStarter directly
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
ForkStarter.CloseableCloser
Closes stuff, with a shutdown hook to make sure things really get closed.
-
Field Summary
-
Constructor Summary
Constructors Constructor Description ForkStarter(ProviderConfiguration providerConfiguration, StartupConfiguration startupConfiguration, ForkConfiguration forkConfiguration, int forkedProcessTimeoutInSeconds, StartupReportConfiguration startupReportConfiguration, ConsoleLogger log)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static RunResult
awaitResultsDone(java.util.Collection<java.util.concurrent.Future<RunResult>> results, java.util.concurrent.ExecutorService executorService)
private void
closeExecutor(java.util.concurrent.ExecutorService executorService)
private static java.lang.Thread
createCachableShutdownHookThread(TestLessInputStream.TestLessInputStreamBuilder builder, Shutdown shutdownType)
private static java.lang.Thread
createImmediateShutdownHookThread(TestLessInputStream.TestLessInputStreamBuilder builder, Shutdown shutdownType)
private static java.util.concurrent.ScheduledExecutorService
createPingScheduler()
private static java.lang.Thread
createShutdownHookThread(java.lang.Iterable<TestProvidingInputStream> streams, Shutdown shutdownType)
private static java.util.concurrent.ScheduledExecutorService
createTimeoutCheckScheduler()
private RunResult
fork(java.lang.Object testSet, KeyValueSource providerProperties, ForkClient forkClient, SurefireProperties effectiveSystemProperties, int forkNumber, AbstractForkInputStream testProvidingInputStream, boolean readTestsFromInStream)
private RunResult
fork(java.lang.Object testSet, KeyValueSource providerProperties, ForkClient forkClient, SurefireProperties effectiveSystemProperties, AbstractForkInputStream testProvidingInputStream, boolean readTestsFromInStream)
private java.lang.Iterable<java.lang.Class<?>>
getSuitesIterator()
private boolean
hasSuiteXmlFiles()
private boolean
isForkOnce()
void
killOrphanForks()
private static void
notifyStreamsToSkipTests(java.util.Collection<? extends NotifiableTestStream> notifiableTestStreams)
private RunResult
run(SurefireProperties effectiveSystemProperties)
private RunResult
run(SurefireProperties effectiveSystemProperties, java.util.Map<java.lang.String,java.lang.String> providerProperties)
RunResult
run(SurefireProperties effectiveSystemProperties, DefaultScanResult scanResult)
private RunResult
runSuitesForkOnceMultiple(SurefireProperties effectiveSystemProperties, int forkCount)
private RunResult
runSuitesForkPerTestSet(SurefireProperties effectiveSystemProperties, int forkCount)
private java.util.concurrent.ScheduledFuture<?>
triggerPingTimerForShutdown(java.lang.Iterable<TestProvidingInputStream> streams)
private java.util.concurrent.ScheduledFuture<?>
triggerPingTimerForShutdown(TestLessInputStream.TestLessInputStreamBuilder builder)
private java.util.concurrent.ScheduledFuture<?>
triggerTimeoutCheck()
-
-
-
Field Detail
-
EXECUTION_EXCEPTION
private static final java.lang.String EXECUTION_EXCEPTION
- See Also:
- Constant Field Values
-
PING_IN_SECONDS
private static final long PING_IN_SECONDS
- See Also:
- Constant Field Values
-
TIMEOUT_CHECK_PERIOD_MILLIS
private static final int TIMEOUT_CHECK_PERIOD_MILLIS
- See Also:
- Constant Field Values
-
FORKED_JVM_DAEMON_THREAD_FACTORY
private static final java.util.concurrent.ThreadFactory FORKED_JVM_DAEMON_THREAD_FACTORY
-
SHUTDOWN_HOOK_THREAD_FACTORY
private static final java.util.concurrent.ThreadFactory SHUTDOWN_HOOK_THREAD_FACTORY
-
SYSTEM_PROPERTIES_FILE_COUNTER
private static final java.util.concurrent.atomic.AtomicInteger SYSTEM_PROPERTIES_FILE_COUNTER
-
pingThreadScheduler
private final java.util.concurrent.ScheduledExecutorService pingThreadScheduler
-
timeoutCheckScheduler
private final java.util.concurrent.ScheduledExecutorService timeoutCheckScheduler
-
currentForkClients
private final java.util.Queue<ForkClient> currentForkClients
-
forkedProcessTimeoutInSeconds
private final int forkedProcessTimeoutInSeconds
-
providerConfiguration
private final ProviderConfiguration providerConfiguration
-
startupConfiguration
private final StartupConfiguration startupConfiguration
-
forkConfiguration
private final ForkConfiguration forkConfiguration
-
startupReportConfiguration
private final StartupReportConfiguration startupReportConfiguration
-
log
private final ConsoleLogger log
-
defaultReporterFactory
private final DefaultReporterFactory defaultReporterFactory
-
defaultReporterFactories
private final java.util.Collection<DefaultReporterFactory> defaultReporterFactories
-
-
Constructor Detail
-
ForkStarter
public ForkStarter(ProviderConfiguration providerConfiguration, StartupConfiguration startupConfiguration, ForkConfiguration forkConfiguration, int forkedProcessTimeoutInSeconds, StartupReportConfiguration startupReportConfiguration, ConsoleLogger log)
-
-
Method Detail
-
run
public RunResult run(@Nonnull SurefireProperties effectiveSystemProperties, @Nonnull DefaultScanResult scanResult) throws SurefireBooterForkException, SurefireExecutionException
-
killOrphanForks
public void killOrphanForks()
-
run
private RunResult run(SurefireProperties effectiveSystemProperties, java.util.Map<java.lang.String,java.lang.String> providerProperties) throws SurefireBooterForkException
- Throws:
SurefireBooterForkException
-
run
private RunResult run(SurefireProperties effectiveSystemProperties) throws SurefireBooterForkException
- Throws:
SurefireBooterForkException
-
isForkOnce
private boolean isForkOnce()
-
hasSuiteXmlFiles
private boolean hasSuiteXmlFiles()
-
runSuitesForkOnceMultiple
private RunResult runSuitesForkOnceMultiple(SurefireProperties effectiveSystemProperties, int forkCount) throws SurefireBooterForkException
- Throws:
SurefireBooterForkException
-
notifyStreamsToSkipTests
private static void notifyStreamsToSkipTests(java.util.Collection<? extends NotifiableTestStream> notifiableTestStreams)
-
runSuitesForkPerTestSet
private RunResult runSuitesForkPerTestSet(SurefireProperties effectiveSystemProperties, int forkCount) throws SurefireBooterForkException
- Throws:
SurefireBooterForkException
-
awaitResultsDone
private static RunResult awaitResultsDone(java.util.Collection<java.util.concurrent.Future<RunResult>> results, java.util.concurrent.ExecutorService executorService) throws SurefireBooterForkException
- Throws:
SurefireBooterForkException
-
closeExecutor
private void closeExecutor(java.util.concurrent.ExecutorService executorService) throws SurefireBooterForkException
- Throws:
SurefireBooterForkException
-
fork
private RunResult fork(java.lang.Object testSet, KeyValueSource providerProperties, ForkClient forkClient, SurefireProperties effectiveSystemProperties, AbstractForkInputStream testProvidingInputStream, boolean readTestsFromInStream) throws SurefireBooterForkException
- Throws:
SurefireBooterForkException
-
fork
private RunResult fork(java.lang.Object testSet, KeyValueSource providerProperties, ForkClient forkClient, SurefireProperties effectiveSystemProperties, int forkNumber, AbstractForkInputStream testProvidingInputStream, boolean readTestsFromInStream) throws SurefireBooterForkException
- Throws:
SurefireBooterForkException
-
getSuitesIterator
private java.lang.Iterable<java.lang.Class<?>> getSuitesIterator() throws SurefireBooterForkException
- Throws:
SurefireBooterForkException
-
createImmediateShutdownHookThread
private static java.lang.Thread createImmediateShutdownHookThread(TestLessInputStream.TestLessInputStreamBuilder builder, Shutdown shutdownType)
-
createCachableShutdownHookThread
private static java.lang.Thread createCachableShutdownHookThread(TestLessInputStream.TestLessInputStreamBuilder builder, Shutdown shutdownType)
-
createShutdownHookThread
private static java.lang.Thread createShutdownHookThread(java.lang.Iterable<TestProvidingInputStream> streams, Shutdown shutdownType)
-
createPingScheduler
private static java.util.concurrent.ScheduledExecutorService createPingScheduler()
-
createTimeoutCheckScheduler
private static java.util.concurrent.ScheduledExecutorService createTimeoutCheckScheduler()
-
triggerPingTimerForShutdown
private java.util.concurrent.ScheduledFuture<?> triggerPingTimerForShutdown(TestLessInputStream.TestLessInputStreamBuilder builder)
-
triggerPingTimerForShutdown
private java.util.concurrent.ScheduledFuture<?> triggerPingTimerForShutdown(java.lang.Iterable<TestProvidingInputStream> streams)
-
triggerTimeoutCheck
private java.util.concurrent.ScheduledFuture<?> triggerTimeoutCheck()
-
-