Class ForkStarter
- java.lang.Object
-
- org.apache.maven.plugin.surefire.booterclient.ForkStarter
-
public class ForkStarter extends java.lang.ObjectStarts 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 classForkStarter.CloseableCloserCloses stuff, with a shutdown hook to make sure things really get closed.private classForkStarter.ForkedNodeArg
-
Field Summary
Fields Modifier and Type Field Description private java.util.Queue<ForkClient>currentForkClientsprivate java.util.Collection<DefaultReporterFactory>defaultReporterFactoriesprivate static java.lang.StringEXECUTION_EXCEPTIONprivate ForkConfigurationforkConfigurationprivate static java.util.concurrent.ThreadFactoryFORKED_JVM_DAEMON_THREAD_FACTORYprivate intforkedProcessTimeoutInSecondsprivate ConsoleLoggerlogprivate java.util.Set<java.lang.String>logsAtEndprivate static longPING_IN_SECONDSprivate java.util.concurrent.ScheduledExecutorServicepingThreadSchedulerprivate ProviderConfigurationproviderConfigurationprivate ReportsMergerreportMergerprivate static java.util.concurrent.ThreadFactorySHUTDOWN_HOOK_THREAD_FACTORYprivate StartupConfigurationstartupConfigurationprivate StartupReportConfigurationstartupReportConfigurationprivate static java.util.concurrent.atomic.AtomicIntegerSYSTEM_PROPERTIES_FILE_COUNTERprivate static intTIMEOUT_CHECK_PERIOD_MILLISprivate java.util.concurrent.ScheduledExecutorServicetimeoutCheckScheduler
-
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 RunResultawaitResultsDone(java.util.Collection<java.util.concurrent.Future<RunResult>> results, java.util.concurrent.ExecutorService executorService)private static StoppablebindErrorStream(int forkNumber, CountdownCloseable countdownCloseable, CommandlineStreams streams, java.lang.Object errorStreamLock)private voidcloseExecutor(java.util.concurrent.ExecutorService executorService)private static java.lang.ThreadcreateCachableShutdownHookThread(TestLessInputStream.TestLessInputStreamBuilder builder, Shutdown shutdownType)private static java.lang.ThreadcreateImmediateShutdownHookThread(TestLessInputStream.TestLessInputStreamBuilder builder, Shutdown shutdownType)private static java.util.concurrent.ScheduledExecutorServicecreatePingScheduler()private static java.lang.ThreadcreateShutdownHookThread(java.lang.Iterable<TestProvidingInputStream> streams, Shutdown shutdownType)private static java.util.concurrent.ScheduledExecutorServicecreateTimeoutCheckScheduler()private RunResultfork(java.lang.Object testSet, PropertiesWrapper providerProperties, ForkClient forkClient, SurefireProperties effectiveSystemProperties, int forkNumber, AbstractCommandReader commandReader, ForkNodeFactory forkNodeFactory, boolean readTestsFromInStream)private java.lang.Iterable<java.lang.Class<?>>getSuitesIterator()private booleanhasSuiteXmlFiles()private booleanisForkOnce()voidkillOrphanForks()private static voidnotifyStreamsToSkipTests(java.util.Collection<? extends NotifiableTestStream> notifiableTestStreams)private RunResultrun(SurefireProperties effectiveSystemProperties)private RunResultrun(SurefireProperties effectiveSystemProps, java.util.Map<java.lang.String,java.lang.String> providerProperties)RunResultrun(SurefireProperties effectiveSystemProperties, DefaultScanResult scanResult)private RunResultrunSuitesForkOnceMultiple(SurefireProperties effectiveSystemProps, int forkCount)private RunResultrunSuitesForkPerTestSet(SurefireProperties effectiveSystemProps, 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
-
logsAtEnd
private final java.util.Set<java.lang.String> logsAtEnd
-
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
-
reportMerger
private final ReportsMerger reportMerger
-
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
- Throws:
SurefireBooterForkException
-
killOrphanForks
public void killOrphanForks()
-
run
private RunResult run(SurefireProperties effectiveSystemProps, 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 effectiveSystemProps, int forkCount) throws SurefireBooterForkException
- Throws:
SurefireBooterForkException
-
notifyStreamsToSkipTests
private static void notifyStreamsToSkipTests(java.util.Collection<? extends NotifiableTestStream> notifiableTestStreams)
-
runSuitesForkPerTestSet
private RunResult runSuitesForkPerTestSet(SurefireProperties effectiveSystemProps, 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, PropertiesWrapper providerProperties, ForkClient forkClient, SurefireProperties effectiveSystemProperties, int forkNumber, AbstractCommandReader commandReader, ForkNodeFactory forkNodeFactory, boolean readTestsFromInStream) throws SurefireBooterForkException
- Throws:
SurefireBooterForkException
-
bindErrorStream
private static Stoppable bindErrorStream(int forkNumber, CountdownCloseable countdownCloseable, CommandlineStreams streams, java.lang.Object errorStreamLock)
-
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()
-
-