Package de.gebit.integrity.runner
Class DefaultTestRunner
- java.lang.Object
-
- de.gebit.integrity.runner.DefaultTestRunner
-
- All Implemented Interfaces:
TestRunner
public class DefaultTestRunner extends Object implements TestRunner
The test runner executes tests. This class is the core of the Integrity runtime system.- Author:
- Rene Schneider - initial API and implementation
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classDefaultTestRunner.PhaseTest execution is splitted in phases.protected classDefaultTestRunner.RemotingListenerThe listener used to respond on actions triggered by remoting clients.
-
Field Summary
Fields Modifier and Type Field Description protected ExceptionWrapperabortExecutionCauseIn case of anAbortExecutionExceptionaborting the test execution, this exception is stored here (actually, only the message and stack trace string are stored - this is because the data could just as well come from a fork, in which case an exception can not be transported over the remoting connection).protected Set<Integer>breakpointsAll enabled breakpoints.protected TestRunnerCallbackcallbackThe callback provided by the creator of theTestRunner.protected static intCHILD_PROCESS_KILL_TIMEOUT_DEFAULTThe default time to wait for child processes to be killed.protected static StringCHILD_PROCESS_KILL_TIMEOUT_PROPERTYThe system property that allows to override the single connect timeout used when connecting to forks.protected IntegrityClassLoaderclassLoaderThe classloader.protected String[]commandLineArgumentsThe original command line arguments, as given to the test runner by the test runner creator.protected Queue<org.eclipse.xtext.util.Pair<String,Runnable>>constantAndVariableDefinitionDelayedCallbackInvocationsThis list is used to collect invocations to callbacks during a parallel constant/variable definition phase.protected com.google.inject.Provider<ConversionContext>conversionContextProviderThe conversion context provider.protected TestRunnerCallbackcurrentCallbackThe currently used callback, that is, the callback that gets directly called during execution.protected DefaultTestRunner.PhasecurrentPhaseThe current execution phase.protected Set<ForkDefinition>diedForksCollects all forks that have died.protected SemaphoreexecutionWaiterA semaphore used for single-stepping tests.protected static intFORK_CONNECT_DELAYThe delay until connection attempts are made to a newly started fork.protected static intFORK_CONNECTION_TIMEOUT_DEFAULTThe default fork connection timeout, in seconds.protected static StringFORK_CONNECTION_TIMEOUT_PROPERTYThe system property that allows to override the timeout used when connecting to forks.protected static intFORK_PAUSE_WAIT_INTERVALThe interval in which the forks' execution state is checked on first connect.protected static intFORK_SINGLE_CONNECT_TIMEOUT_DEFAULTThe timeout in milliseconds used for a single connection attempt to a fork.protected static StringFORK_SINGLE_CONNECT_TIMEOUT_PROPERTYThe system property that allows to override the single connect timeout used when connecting to forks.protected static intFORK_STARTUP_RETRYCOUNT_DEFAULTThe default number of retries when starting forks.protected static StringFORK_STARTUP_RETRYCOUNT_PROPERTYThe system property that allows to override the number of retries to attempt when starting forked processes.protected static intFORK_WAIT_UNTIL_READY_TIMEOUT_DEFAULTThe default time to wait for a fork to become ready for execution.protected static StringFORK_WAIT_UNTIL_READY_TIMEOUT_PROPERTYThe system property that allows to override the time to wait for a fork to become ready for execution.protected ForkDefinitionforkInExecutionThe fork that is currently being executed.protected Map<ForkDefinition,Fork>forkMapMaps fork definitions to actual fork instances.protected Map<ForkDefinition,TimeSyncState>forkTimeSyncStatesMaps forks to their (intended) timesync states.protected com.google.inject.InjectorinjectorThe Guice injector.protected booleanisTimesetTracingEnabledWhether timeset tracing is enabled.protected ClassLoaderjavaClassLoaderThe classloader used to load model-related classes.protected Map<ForkDefinition,Integer>lastSuiteForForkMaps eachForkDefinitionto the suite call and a number that counts any suite invocations.protected TestModelmodelThe test model being executed.protected ModelCheckermodelCheckerThe model checker is used to validate the test model prior to execution.protected ModelSourceExplorermodelSourceExplorerThe model source explorer.protected static StringMY_FORK_NAMEIf this JVM instance is executing a fork, the name is stored here.protected intnumberOfSuiteInvocationsLeftOnThisForkThis counts the number of suite invocations ttill to be done on this fork.protected Map<String,String>parameterizedConstantValuesThis maps fully qualified constant names to parameter values.protected ParameterResolverparameterResolverThe parameter resolver.protected TestRunnerPerformanceLoggerperformanceLoggerThe performance logger.protected ProcessTerminatorprocessTerminatorThe process watchdog, used to govern other processes started by the test runner.protected DefaultTestRunner.RemotingListenerremotingListenerThe remoting listener, which allows the remoting server to influence test execution.protected IntegrityRemotingServerremotingServerThe remoting server.protected ResultComparatorresultComparatorThe result comparator to use.protected SetListsetListThe current setlist.protected SetListCallbacksetListCallbackThe setlist callback (used to create/update the setlist).protected ObjectsetListWaiterA waiter object used by remoting while waiting for the setlist to be created.protected Map<ForkDefinition,Set<SuiteDefinition>>setupSuitesExecutedThe setup suites that have been executed.protected booleanshallWaitBeforeNextStepWhether the test runner shall pause before executing the next step.protected Set<SuiteDefinition>singleRunSuitesExecutedThe single-run suites that have already been executed.protected TestFormattertestFormatterThe test formatter.protected TestTimeAdaptertestTimeAdapterThe test time adapter.protected static StringTIMESET_TRACE_OUTPUTSystem property to enable writing timeset trace output.protected TimeSyncResultMessagetimeSyncResultThe result of a time sync request from this fork sent to a master is stored here.protected ObjecttimeSyncResultSyncObjectA sync object used to synchronize accesses totimeSyncResult.protected Set<ForkDefinition>touchedForksCollects forks that are being used in the current test run.protected ValueConvertervalueConverterThe value converter.protected VariableManagervariableManagerThe variable manager, which keeps track of the variable values (local and global).protected VariantDefinitionvariantInExecutionThe currently executed test variant.protected WrapperFactorywrapperFactoryThe wrapper factory.
-
Constructor Summary
Constructors Constructor Description DefaultTestRunner()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected intcalculateMasterTimeSyncTimeout(int aNumberOfForks)Returns the timeout in seconds for timesync requests originating from this fork, sent to the master and distributed to a variable number of forks for execution.protected List<SuiteSummaryResult>callSuite(Suite aSuiteCall)Performs a specified suite call.protected SuiteSummaryResultcallSuiteSingle(Suite aSuiteCall)Performs a specified suite call (doesn't honor the multiplier!).protected booleancheckForAbortion()Checks whether a situation demanding for a quick test run abortion has occurred.protected voidcheckForValidationError(org.eclipse.emf.ecore.EObject anObject)Checks and ensures that the specified object has no validation errors.protected voidcreateBreakpoint(int anEntryReference)Creates a new breapoint.protected ForkcreateFork(Suite aSuiteCall)Creates a new fork instance.protected voiddefineConstant(ConstantDefinition aDefinition, SuiteDefinition aSuite)Defines a constant.protected voiddefineConstant(ConstantDefinition aDefinition, Object aValue, SuiteDefinition aSuite)Defines a constant.protected voiddefineVariable(VariableDefinition aDefinition, SuiteDefinition aSuite)Defines a variable.protected voiddefineVariable(VariableOrConstantEntity anEntity, Object anInitialValue, SuiteDefinition aSuite)Defines a variable.protected TimeSyncResultMessagedistributeTimeSyncRequest(Date aStartTime, List<org.eclipse.xtext.util.Pair<Long,TemporalUnit>> aDiffTime, BigDecimal aProgressionFactor, String[] someTargetedForks)This will be called when a master process either receives a time sync message from one of its forks and has to redistribute it to all the forks that this time sync is intended for, or when a master process encounters a time sync command by itself.protected voiddistributeTimeSyncRequestAsync(Date aStartTime, List<org.eclipse.xtext.util.Pair<Long,TemporalUnit>> aDiffTime, BigDecimal aProgressionFactor, String[] someTargetedForks, Fork aResultTarget)Like#distributeTimeSyncRequest(Date, BigDecimal, String[]), but performs the work in an asynchronous thread, so it returns instantly.protected List<CallResult>executeCall(Call aCall)Executes a call.protected CallResultexecuteCallSingle(Call aCall)Executes a call (a single time, doesn't honor the multiplier).protected List<SuiteDefinition>executeSetupSuites(SuiteDefinition aSuite, Map<SuiteDefinition,Result> aSetupResultMap)Executes the provided suite as a setup suite.protected Map<SuiteStatementWithResult,List<? extends Result>>executeSuite(SuiteDefinition aSuite)Executes a suite.protected TestResultexecuteTableTest(TableTest aTest)Executes a table test.protected voidexecuteTearDownSuites(List<SuiteDefinition> aSetupSuitesList, Map<SuiteDefinition,Result> aTearDownResultMap)Executes the teardown suites required by the provided setup suites.protected TestResultexecuteTest(Test aTest)Executes a test (doesn't pay attention to the multiplier).protected ResultexecuteTimeSet(TimeSet aTimeSet)Executes a time setting operation.protected voidexecuteVariableAssignment(VariableAssignment anAssignment, SuiteDefinition aSuite)Executes variable assignments.protected intgetChildProcessKillTimeout()protected intgetChildProcessKillTimeoutDefault()protected Class<?>getClassForJvmType(org.eclipse.xtext.common.types.JvmType aType)Loads a class by resolving a givenJvmType.protected intgetForkConnectDelay()The delay until connection attempts are made to a newly started fork.protected intgetForkConnectionTimeout()The fork connection timeout, in seconds.protected intgetForkConnectionTimeoutDefault()The default fork connection timeout, in seconds.protected intgetForkPauseWaitInterval()The interval in which the forks' execution state is checked on first connect.protected intgetForkSingleConnectTimeout()The timeout in milliseconds used for a single connection attempt to a fork.protected intgetForkSingleConnectTimeoutDefault()Default for the timeout in milliseconds used for a single connection attempt to a fork.protected intgetForkStartupRetryCount()The number of retries when starting forks.protected intgetForkStartupRetryCountDefault()The default number of retries when starting forks.protected intgetForkWaitUntilReadyTimeout()Returns the time to wait for a fork to become ready for execution.protected intgetForkWaitUntilReadyTimeoutDefault()Returns the default time to wait for a fork to become ready for execution.protected voidhandlePossibleAbortException(Throwable anException)If the exception provided is anAbortExecutionException, this method performs the necessary steps to enter "abort" mode locally.voidinitialize(TestModel aModel, Map<String,String> someParameterizedConstants, TestRunnerCallback aCallback, String aResultLocale, Integer aRemotingPort, String aRemotingBindHost, Long aRandomSeed, String[] someCommandLineArguments)Initializes a fresh test runner instance.protected voidinitializeParameterizedConstants()Initializes the parameterized constants from theparameterizedConstantValuesmap.static booleanisFork()Determines whether this JVM is a forked JVM from a master Integrity process.protected voidpauseIfRequiredByRemoteClient(boolean aForkSyncFlag)Pauses execution (blocks the method call) if the remoting client requested to do so via execution control or breakpoints.protected voidperformRemotingBinding(Integer aRemotingPort, String aRemotingBindHost)Performs the remoting port binding.protected voidremoveBreakpoint(int anEntryReference)Removes a specific breakpoint.protected voidreset()Resets the internal variable state.protected voidresetWaitBeforeNextStep()Resets a scheduled interruption (seescheduleWaitBeforeNextStep()).protected ObjectresolveConstantValue(ConstantValue aConstantValue)Resolves a constant value (either it's a static value anyway, or it's a constant which needs to be resolved).SuiteSummaryResultrun(SuiteDefinition aRootSuite, VariantDefinition aVariant, boolean aBlockForRemotingFlag)Executes a specified suite.protected SuiteSummaryResultrun(Suite aRootSuiteCall, VariantDefinition aVariant, boolean aBlockForRemotingFlag)Executes a specific suite call.protected SuiteSummaryResultrunInternal(Suite aRootSuiteCall)Actually executes a root suite call.protected voidscheduleWaitBeforeNextStep()Schedules a "wait for the master" before the next execution step.protected TimeSyncResultMessagesetTestTimeGuarded(long aRealtimeOffset, long aRealtimeDecouplingTime, double aProgressionFactor)Performs a guarded call to theTestTimeAdapter.protected voidsetVariableValue(VariableOrConstantEntity anEntity, Object aValue, boolean aDoSendUpdateFlag)Sets the value of a variable.protected voidsetVariableValue(String aQualifiedVariableName, Object aValue, boolean aDoSendUpdateFlag)Updates a variables' value.protected voidsetVariableValueConverted(VariableOrConstantEntity anEntity, ValueOrEnumValueOrOperationCollection aValue, boolean aDoSendUpdateFlag)Sets the value of a variable.protected booleanshouldExecuteFixtures()Determines whether we should actually execute fixture method calls at the moment.voidshutdown(boolean anEmptyRemotingOutputQueueFlag)Shuts down this test runner instance.protected voidtimesetTraceLog(String anAction, String aLogMessage)Outputs a timeset trace log.protected voidtimesetTraceLog(String anAction, String aLogMessage, Date aStartDate, List<org.eclipse.xtext.util.Pair<Long,TemporalUnit>> aDiffTime, BigDecimal aProgressionFactor, String[] someTargetedForks)Outputs a timeset trace log.protected voidundefineVariable(VariableOrConstantEntity anEntity)Undefines a variable (= clears its value, which is NOT exactly the same as setting it to null).protected voidunsetVariableValue(VariableOrConstantEntity anEntity, boolean aDoSendUpdateFlag)Unsets the value of a variable.protected voidunsetVariableValue(String aQualifiedVariableName, boolean aDoSendUpdateFlag)Unsets a variables' value.protected voidwaitForContinue(boolean aForkSyncFlag)Pause execution (blocks method call) until continuation is triggered by remoting.protected voidwaitForSetListInjection()If this is a fork, we now need to wait for the setlist and test scripts to be injected by the master! Otherwise this method returns immediately.
-
-
-
Field Detail
-
model
protected TestModel model
The test model being executed.
-
setList
protected SetList setList
The current setlist.
-
setListWaiter
protected Object setListWaiter
A waiter object used by remoting while waiting for the setlist to be created.
-
executionWaiter
protected Semaphore executionWaiter
A semaphore used for single-stepping tests.
-
shallWaitBeforeNextStep
protected boolean shallWaitBeforeNextStep
Whether the test runner shall pause before executing the next step.
-
callback
protected TestRunnerCallback callback
The callback provided by the creator of theTestRunner.
-
setListCallback
protected SetListCallback setListCallback
The setlist callback (used to create/update the setlist).
-
currentCallback
protected TestRunnerCallback currentCallback
The currently used callback, that is, the callback that gets directly called during execution.
-
currentPhase
protected DefaultTestRunner.Phase currentPhase
The current execution phase.
-
variableManager
@Inject protected VariableManager variableManager
The variable manager, which keeps track of the variable values (local and global).
-
valueConverter
@Inject protected ValueConverter valueConverter
The value converter.
-
parameterResolver
@Inject protected ParameterResolver parameterResolver
The parameter resolver.
-
wrapperFactory
@Inject protected WrapperFactory wrapperFactory
The wrapper factory.
-
resultComparator
@Inject protected ResultComparator resultComparator
The result comparator to use.
-
processTerminator
@Inject protected ProcessTerminator processTerminator
The process watchdog, used to govern other processes started by the test runner.
-
injector
@Inject protected com.google.inject.Injector injector
The Guice injector.
-
modelSourceExplorer
@Inject protected ModelSourceExplorer modelSourceExplorer
The model source explorer.
-
conversionContextProvider
@Inject protected com.google.inject.Provider<ConversionContext> conversionContextProvider
The conversion context provider.
-
testFormatter
@Inject protected TestFormatter testFormatter
The test formatter.
-
performanceLogger
@Inject protected TestRunnerPerformanceLogger performanceLogger
The performance logger.
-
testTimeAdapter
@Inject protected TestTimeAdapter testTimeAdapter
The test time adapter.
-
remotingServer
protected IntegrityRemotingServer remotingServer
The remoting server.
-
remotingListener
protected DefaultTestRunner.RemotingListener remotingListener
The remoting listener, which allows the remoting server to influence test execution.
-
forkMap
protected Map<ForkDefinition,Fork> forkMap
Maps fork definitions to actual fork instances.
-
diedForks
protected Set<ForkDefinition> diedForks
Collects all forks that have died. If forks die after they have executed their last statement, this is perfectly fine, but if forks die earlier, this set is used to detect that erroneous situation.
-
touchedForks
protected Set<ForkDefinition> touchedForks
Collects forks that are being used in the current test run. This is filled during dry run execution and is ONLY USABLE ON MASTER.
-
forkTimeSyncStates
protected Map<ForkDefinition,TimeSyncState> forkTimeSyncStates
Maps forks to their (intended) timesync states.
-
commandLineArguments
protected String[] commandLineArguments
The original command line arguments, as given to the test runner by the test runner creator.
-
parameterizedConstantValues
protected Map<String,String> parameterizedConstantValues
This maps fully qualified constant names to parameter values. Defined during initialization. This allows to define the values for "parameterized" constants.
-
modelChecker
@Inject protected ModelChecker modelChecker
The model checker is used to validate the test model prior to execution.
-
classLoader
@Inject protected IntegrityClassLoader classLoader
The classloader.
-
javaClassLoader
@Inject protected ClassLoader javaClassLoader
The classloader used to load model-related classes.
-
constantAndVariableDefinitionDelayedCallbackInvocations
protected Queue<org.eclipse.xtext.util.Pair<String,Runnable>> constantAndVariableDefinitionDelayedCallbackInvocations
This list is used to collect invocations to callbacks during a parallel constant/variable definition phase. Callbacks are not expected to be thread-safe, so we need to synchronize those calls anyway, and we want to have them in deterministic order, so we have to sort them by the variable/constant name.
The existence of this queue defines that all callback invocations should be delayed. If it does not exist, immediate invocation is necessary.
-
MY_FORK_NAME
protected static final String MY_FORK_NAME
If this JVM instance is executing a fork, the name is stored here.
-
FORK_STARTUP_RETRYCOUNT_PROPERTY
protected static final String FORK_STARTUP_RETRYCOUNT_PROPERTY
The system property that allows to override the number of retries to attempt when starting forked processes.- See Also:
- Constant Field Values
-
FORK_STARTUP_RETRYCOUNT_DEFAULT
protected static final int FORK_STARTUP_RETRYCOUNT_DEFAULT
The default number of retries when starting forks. By default, use "fail fast" and abort test runs immediately.- See Also:
- Constant Field Values
-
FORK_CONNECTION_TIMEOUT_PROPERTY
protected static final String FORK_CONNECTION_TIMEOUT_PROPERTY
The system property that allows to override the timeout used when connecting to forks.- See Also:
- Constant Field Values
-
FORK_CONNECTION_TIMEOUT_DEFAULT
protected static final int FORK_CONNECTION_TIMEOUT_DEFAULT
The default fork connection timeout, in seconds.- See Also:
- Constant Field Values
-
FORK_SINGLE_CONNECT_TIMEOUT_PROPERTY
protected static final String FORK_SINGLE_CONNECT_TIMEOUT_PROPERTY
The system property that allows to override the single connect timeout used when connecting to forks.- See Also:
- Constant Field Values
-
FORK_SINGLE_CONNECT_TIMEOUT_DEFAULT
protected static final int FORK_SINGLE_CONNECT_TIMEOUT_DEFAULT
The timeout in milliseconds used for a single connection attempt to a fork. If this timeout is hit, but the total timeout for connecting is not yet over, another attempt is being started.- See Also:
- Constant Field Values
-
FORK_CONNECT_DELAY
protected static final int FORK_CONNECT_DELAY
The delay until connection attempts are made to a newly started fork.- See Also:
- Constant Field Values
-
FORK_PAUSE_WAIT_INTERVAL
protected static final int FORK_PAUSE_WAIT_INTERVAL
The interval in which the forks' execution state is checked on first connect.- See Also:
- Constant Field Values
-
FORK_WAIT_UNTIL_READY_TIMEOUT_PROPERTY
protected static final String FORK_WAIT_UNTIL_READY_TIMEOUT_PROPERTY
The system property that allows to override the time to wait for a fork to become ready for execution.- See Also:
- Constant Field Values
-
FORK_WAIT_UNTIL_READY_TIMEOUT_DEFAULT
protected static final int FORK_WAIT_UNTIL_READY_TIMEOUT_DEFAULT
The default time to wait for a fork to become ready for execution.
-
CHILD_PROCESS_KILL_TIMEOUT_PROPERTY
protected static final String CHILD_PROCESS_KILL_TIMEOUT_PROPERTY
The system property that allows to override the single connect timeout used when connecting to forks.- See Also:
- Constant Field Values
-
CHILD_PROCESS_KILL_TIMEOUT_DEFAULT
protected static final int CHILD_PROCESS_KILL_TIMEOUT_DEFAULT
The default time to wait for child processes to be killed.- See Also:
- Constant Field Values
-
forkInExecution
protected ForkDefinition forkInExecution
The fork that is currently being executed. This is set regardless of whether we are a fork ourselves and are currently executing our own stuff, or whether we are a master or different fork and skipping over a bunch of invocations due to them being executed by another fork.
-
variantInExecution
protected VariantDefinition variantInExecution
The currently executed test variant.
-
setupSuitesExecuted
protected Map<ForkDefinition,Set<SuiteDefinition>> setupSuitesExecuted
The setup suites that have been executed.
-
singleRunSuitesExecuted
protected Set<SuiteDefinition> singleRunSuitesExecuted
The single-run suites that have already been executed.
-
abortExecutionCause
protected ExceptionWrapper abortExecutionCause
In case of anAbortExecutionExceptionaborting the test execution, this exception is stored here (actually, only the message and stack trace string are stored - this is because the data could just as well come from a fork, in which case an exception can not be transported over the remoting connection).
-
lastSuiteForFork
protected Map<ForkDefinition,Integer> lastSuiteForFork
Maps eachForkDefinitionto the suite call and a number that counts any suite invocations. The fork should die after this number of suites has executed. Since suite invocation numbers are predeterminable in the dry run and deterministic, this can be used to find out whether a suite during the test run has been the last one to run on a particular fork. During this real test run, the counter is decremented on each suite invocation on a fork, so in the end, we know when the fork has finished execution (= counter reaches zero).
This map is only used by the master to keep track of when the forks should die. It will then wait until they do. The forks still carry the responsibility to terminate their execution in a clean way!
-
numberOfSuiteInvocationsLeftOnThisFork
protected int numberOfSuiteInvocationsLeftOnThisFork
This counts the number of suite invocations ttill to be done on this fork. Is only used if this test runner is indeed a fork (otherwise this value has no meaning). Is somewhat related tolastSuiteForForkin that this is the individual number of invocations on a fork that is left; it is initially seeded with the correspondinglastSuiteForForkvalue from the master process and then counted down to know when a fork can take the quick path to termination. Basically this is an optimization to allow for quicker termination on forks that would otherwise have a huge bunch of test scripts to run through in dry mode when they're finished.
-
timeSyncResult
protected TimeSyncResultMessage timeSyncResult
The result of a time sync request from this fork sent to a master is stored here.
-
timeSyncResultSyncObject
protected final Object timeSyncResultSyncObject
A sync object used to synchronize accesses totimeSyncResult.
-
TIMESET_TRACE_OUTPUT
protected static final String TIMESET_TRACE_OUTPUT
System property to enable writing timeset trace output.- See Also:
- Constant Field Values
-
isTimesetTracingEnabled
protected boolean isTimesetTracingEnabled
Whether timeset tracing is enabled.
-
-
Method Detail
-
getForkStartupRetryCount
protected int getForkStartupRetryCount()
The number of retries when starting forks.
-
getForkStartupRetryCountDefault
protected int getForkStartupRetryCountDefault()
The default number of retries when starting forks.
-
getForkConnectionTimeout
protected int getForkConnectionTimeout()
The fork connection timeout, in seconds.
-
getForkConnectionTimeoutDefault
protected int getForkConnectionTimeoutDefault()
The default fork connection timeout, in seconds.
-
getForkSingleConnectTimeout
protected int getForkSingleConnectTimeout()
The timeout in milliseconds used for a single connection attempt to a fork. If this timeout is hit, but the total timeout for connecting is not yet over, another attempt is being started.
-
getForkSingleConnectTimeoutDefault
protected int getForkSingleConnectTimeoutDefault()
Default for the timeout in milliseconds used for a single connection attempt to a fork. If this timeout is hit, but the total timeout for connecting is not yet over, another attempt is being started.
-
getForkConnectDelay
protected int getForkConnectDelay()
The delay until connection attempts are made to a newly started fork.
-
getForkPauseWaitInterval
protected int getForkPauseWaitInterval()
The interval in which the forks' execution state is checked on first connect.
-
getForkWaitUntilReadyTimeout
protected int getForkWaitUntilReadyTimeout()
Returns the time to wait for a fork to become ready for execution.
-
getForkWaitUntilReadyTimeoutDefault
protected int getForkWaitUntilReadyTimeoutDefault()
Returns the default time to wait for a fork to become ready for execution.
-
getChildProcessKillTimeout
protected int getChildProcessKillTimeout()
-
getChildProcessKillTimeoutDefault
protected int getChildProcessKillTimeoutDefault()
-
calculateMasterTimeSyncTimeout
protected int calculateMasterTimeSyncTimeout(int aNumberOfForks)
Returns the timeout in seconds for timesync requests originating from this fork, sent to the master and distributed to a variable number of forks for execution.- Parameters:
aNumberOfForks- the number of forks involved in this timesync- Returns:
- a timeout in seconds
-
initialize
public void initialize(TestModel aModel, Map<String,String> someParameterizedConstants, TestRunnerCallback aCallback, String aResultLocale, Integer aRemotingPort, String aRemotingBindHost, Long aRandomSeed, String[] someCommandLineArguments) throws IOException
Description copied from interface:TestRunnerInitializes a fresh test runner instance. In case of forks, this method guarantees that when it exits without an exception, the master has successfully connected and injected the test scripts and a setlist into it.- Specified by:
initializein interfaceTestRunner- Parameters:
aModel- the model to execute (may not contain any test script data yet in case of forks!)someParameterizedConstants- Maps fully qualified constant names (must be those with the "parameterized" keyword) to their desired value. This way, test execution can be parameterized from outside.aCallback- the callback to use to report test resultsaResultLocale- the locale to be used for the test result generation (if not provided, use the non-localized default strings, which usually are in English)aRemotingPort- the port on which the remoting server should listen, or null if remoting should be disabledaRemotingBindHost- the host name (or IP) to which the remoting server should bindaRandomSeed- the seed for theRandomNumberOperation(optional; randomly determined if not given).someCommandLineArguments- all command line arguments as given to the original Java programs' main routine (required for forking!)- Throws:
IOException- if the remoting server startup fails, or if the connection from the master process does not complete in time (for forks only)
-
performRemotingBinding
protected void performRemotingBinding(Integer aRemotingPort, String aRemotingBindHost) throws IOException
Performs the remoting port binding.- Parameters:
aRemotingPort- the port to bind to, or null if no remoting is desiredaRemotingBindHost- the host/IP to bind to- Throws:
IOException
-
waitForSetListInjection
protected void waitForSetListInjection() throws IOExceptionIf this is a fork, we now need to wait for the setlist and test scripts to be injected by the master! Otherwise this method returns immediately.- Throws:
IOException
-
shutdown
public void shutdown(boolean anEmptyRemotingOutputQueueFlag)
Shuts down this test runner instance.- Specified by:
shutdownin interfaceTestRunner- Parameters:
anEmptyRemotingOutputQueueFlag- true if the remoting server shall be given time to send all remaining messages to clients while closing connections
-
run
public SuiteSummaryResult run(SuiteDefinition aRootSuite, VariantDefinition aVariant, boolean aBlockForRemotingFlag)
Description copied from interface:TestRunnerExecutes a specified suite. Designated starting point for test execution.- Specified by:
runin interfaceTestRunner- Parameters:
aRootSuite- the suite to executeaBlockForRemotingFlag- whether execution should pause before actually starting until execution is resumed via remoting- Returns:
- the suite execution result (this may also be null in case there is no tangible "result", like when the test runner is actually just running the part of a single fork within a bigger test suite - the partial result in this case is not relevant, but is automatically integrated in the result of the master process)
-
run
protected SuiteSummaryResult run(Suite aRootSuiteCall, VariantDefinition aVariant, boolean aBlockForRemotingFlag)
Executes a specific suite call. Internal starting point for test execution.- Parameters:
aRootSuiteCall- the suite call to executeaBlockForRemotingFlag- whether execution should pause before actually starting until execution is resumed via remoting- Returns:
- the suite execution result
-
handlePossibleAbortException
protected void handlePossibleAbortException(Throwable anException)
If the exception provided is anAbortExecutionException, this method performs the necessary steps to enter "abort" mode locally.- Parameters:
anException-
-
checkForAbortion
protected boolean checkForAbortion()
Checks whether a situation demanding for a quick test run abortion has occurred. This is true if either anAbortExecutionExceptionhas been thrown (locally or by a fork) or if we are a fork and our last suite has executed. This method does NOT only check something, but also ensures that thesetListCallbackis also removed from the current callback hierarchy - a very important step, since after this method has returned true for the first time, a different execution path than normally is expected, which would cause the set list callback to throw an inconsistency exception.- Returns:
- true if the test execution shall take the quick path to an end
-
initializeParameterizedConstants
protected void initializeParameterizedConstants()
Initializes the parameterized constants from theparameterizedConstantValuesmap.
-
reset
protected void reset()
Resets the internal variable state.
-
runInternal
protected SuiteSummaryResult runInternal(Suite aRootSuiteCall)
Actually executes a root suite call.- Parameters:
aRootSuiteCall- the suite call to execute- Returns:
- the result
-
callSuite
protected List<SuiteSummaryResult> callSuite(Suite aSuiteCall)
Performs a specified suite call.- Parameters:
aSuiteCall- the suite call to execute- Returns:
- the suite results (multiple if the suite has an execution multiplier)
-
callSuiteSingle
protected SuiteSummaryResult callSuiteSingle(Suite aSuiteCall)
Performs a specified suite call (doesn't honor the multiplier!).- Parameters:
aSuiteCall- the suite call to execute- Returns:
- the suite result
-
executeSetupSuites
protected List<SuiteDefinition> executeSetupSuites(SuiteDefinition aSuite, Map<SuiteDefinition,Result> aSetupResultMap)
Executes the provided suite as a setup suite. This includes executing further nested setup suites (but not teardown suites, as those will intentionally be executed when the original suite which caused this setup suite to be executed has finished).- Parameters:
aSuite- the suite to be executed as setup suiteaSetupResultMap- the map of setup results to add the result to- Returns:
- a list of executed setup suites
-
executeTearDownSuites
protected void executeTearDownSuites(List<SuiteDefinition> aSetupSuitesList, Map<SuiteDefinition,Result> aTearDownResultMap)
Executes the teardown suites required by the provided setup suites.- Parameters:
aSetupSuitesList- the list of setup suitesaTearDownResultMap- a map into which teardown suite execution results will be stored
-
executeSuite
protected Map<SuiteStatementWithResult,List<? extends Result>> executeSuite(SuiteDefinition aSuite)
Executes a suite.- Parameters:
aSuite- the suite to execute- Returns:
- a map that maps statements to results
-
defineVariable
protected void defineVariable(VariableDefinition aDefinition, SuiteDefinition aSuite)
Defines a variable.- Parameters:
aDefinition- the variable definitionaSuite- the suite in which the variable is defined
-
defineConstant
protected void defineConstant(ConstantDefinition aDefinition, SuiteDefinition aSuite) throws ClassNotFoundException, InstantiationException, UnexecutableException
Defines a constant.- Parameters:
aDefinition- the constant definitionaSuite- the suite in which the constant is defined- Throws:
InstantiationExceptionClassNotFoundExceptionUnexecutableException
-
defineConstant
protected void defineConstant(ConstantDefinition aDefinition, Object aValue, SuiteDefinition aSuite) throws ClassNotFoundException, InstantiationException, UnexecutableException
Defines a constant.- Parameters:
aDefinition- the constant definitionaValue- the value to define (if null, the value in the constant definition is used; this should only be set in case of parameterizable constants!)aSuite- the suite in which the constant is defined- Throws:
InstantiationExceptionClassNotFoundExceptionUnexecutableException
-
defineVariable
protected void defineVariable(VariableOrConstantEntity anEntity, Object anInitialValue, SuiteDefinition aSuite)
Defines a variable.- Parameters:
anEntity- the variable entityanInitialValue- the initial variable value, or null if the variable is not initializedaSuite- the suite in which the variable is defined
-
undefineVariable
protected void undefineVariable(VariableOrConstantEntity anEntity)
Undefines a variable (= clears its value, which is NOT exactly the same as setting it to null).- Parameters:
anEntity- the variable entity
-
setVariableValueConverted
protected void setVariableValueConverted(VariableOrConstantEntity anEntity, ValueOrEnumValueOrOperationCollection aValue, boolean aDoSendUpdateFlag) throws InstantiationException, ClassNotFoundException, UnexecutableException
Sets the value of a variable.- Parameters:
anEntity- the variable entity to updateaValue- the new value (which will be converted to its default type before assigning it!)aDoSendUpdateFlag- whether this update should be sent to connected master/slaves- Throws:
InstantiationExceptionClassNotFoundExceptionUnexecutableException
-
setVariableValue
protected void setVariableValue(VariableOrConstantEntity anEntity, Object aValue, boolean aDoSendUpdateFlag)
Sets the value of a variable.- Parameters:
anEntity- the variable entity to updateaValue- the new valueaDoSendUpdateFlag- whether this update should be sent to connected master/slaves
-
setVariableValue
protected void setVariableValue(String aQualifiedVariableName, Object aValue, boolean aDoSendUpdateFlag)
Updates a variables' value.- Parameters:
aQualifiedVariableName- the name of the variable to updateaValue- the new valueaDoSendUpdateFlag- whether this update should be sent to connected master/slaves
-
unsetVariableValue
protected void unsetVariableValue(VariableOrConstantEntity anEntity, boolean aDoSendUpdateFlag)
Unsets the value of a variable.- Parameters:
anEntity- the variable entity to unsetaDoSendUpdateFlag- whether this update should be sent to connected master/slaves
-
unsetVariableValue
protected void unsetVariableValue(String aQualifiedVariableName, boolean aDoSendUpdateFlag)
Unsets a variables' value.- Parameters:
aQualifiedVariableName- the name of the variable to unsetaDoSendUpdateFlag- whether this update should be sent to connected master/slaves
-
resolveConstantValue
protected Object resolveConstantValue(ConstantValue aConstantValue)
Resolves a constant value (either it's a static value anyway, or it's a constant which needs to be resolved).- Parameters:
aConstantValue- the constant value- Returns:
- the value
-
executeVariableAssignment
protected void executeVariableAssignment(VariableAssignment anAssignment, SuiteDefinition aSuite)
Executes variable assignments.- Parameters:
anAssignment- the assignment to executeaSuite- the suite that the assignment is in
-
executeTest
protected TestResult executeTest(Test aTest)
Executes a test (doesn't pay attention to the multiplier).- Parameters:
aTest- the test to execute- Returns:
- the result
-
executeTableTest
protected TestResult executeTableTest(TableTest aTest)
Executes a table test.- Parameters:
aTest- the test to execute- Returns:
- the result
-
getClassForJvmType
protected Class<?> getClassForJvmType(org.eclipse.xtext.common.types.JvmType aType) throws ClassNotFoundException
Loads a class by resolving a givenJvmType.- Parameters:
aType- the type to load- Returns:
- the class
- Throws:
ClassNotFoundException
-
executeCall
protected List<CallResult> executeCall(Call aCall)
Executes a call.- Parameters:
aCall- the call to execute- Returns:
- the results (multiple if the call has an execution multiplier)
-
executeCallSingle
protected CallResult executeCallSingle(Call aCall)
Executes a call (a single time, doesn't honor the multiplier).- Parameters:
aCall- the call to execute- Returns:
- the result
-
executeTimeSet
protected Result executeTimeSet(TimeSet aTimeSet)
Executes a time setting operation.- Parameters:
aTimeSet- the timeset command
-
shouldExecuteFixtures
protected boolean shouldExecuteFixtures()
Determines whether we should actually execute fixture method calls at the moment.- Returns:
- true if calls should be executed, false otherwise
-
pauseIfRequiredByRemoteClient
protected void pauseIfRequiredByRemoteClient(boolean aForkSyncFlag)
Pauses execution (blocks the method call) if the remoting client requested to do so via execution control or breakpoints.- Parameters:
aForkSyncFlag- true if we are pausing for fork synchronization reasons
-
waitForContinue
protected void waitForContinue(boolean aForkSyncFlag) throws InterruptedExceptionPause execution (blocks method call) until continuation is triggered by remoting.- Parameters:
aForkSyncFlag- true if we are pausing for fork synchronization reasons- Throws:
InterruptedException
-
removeBreakpoint
protected void removeBreakpoint(int anEntryReference)
Removes a specific breakpoint.- Parameters:
anEntryReference- the setlist entry reference at which the breakpoint is set
-
createBreakpoint
protected void createBreakpoint(int anEntryReference)
Creates a new breapoint.- Parameters:
anEntryReference- the setlist entry reference at which the breakpoint will be created
-
distributeTimeSyncRequest
protected TimeSyncResultMessage distributeTimeSyncRequest(Date aStartTime, List<org.eclipse.xtext.util.Pair<Long,TemporalUnit>> aDiffTime, BigDecimal aProgressionFactor, String[] someTargetedForks)
This will be called when a master process either receives a time sync message from one of its forks and has to redistribute it to all the forks that this time sync is intended for, or when a master process encounters a time sync command by itself. In both cases it may have to execute it for itself. This method ONLY runs on the master! It calculates the actual internal state variables necessary for the test time proxies running in the individual fork processes and forwards those to the forks (and to the master itself), where these state variable values are then being used to call theTestTimeAdapter.
The method is also responsible for collecting the responses about successful or failed timesyncs and for aggregating them into a result object. It blocks until this has finished (or a timeout has hit).- Parameters:
aStartTime- the time to set to (if null, use current system time)aDiffTime- the time difference in case of relative timesetting (if used, start time is ignored, because relative time setting always works with the previously-set fake test time as basis)aProgressionFactor-someTargetedForks-- Returns:
- null if nothing went wrong, an exception wrapper containing all messages and all exceptions (textually merged) in case of (non-critical) errors
-
distributeTimeSyncRequestAsync
protected void distributeTimeSyncRequestAsync(Date aStartTime, List<org.eclipse.xtext.util.Pair<Long,TemporalUnit>> aDiffTime, BigDecimal aProgressionFactor, String[] someTargetedForks, Fork aResultTarget)
Like#distributeTimeSyncRequest(Date, BigDecimal, String[]), but performs the work in an asynchronous thread, so it returns instantly. The result of the operation is sent to the provided fork that shall receive it.- Parameters:
aStartTime-aDiffTime-aProgressionFactor-someTargetedForks-
-
setTestTimeGuarded
protected TimeSyncResultMessage setTestTimeGuarded(long aRealtimeOffset, long aRealtimeDecouplingTime, double aProgressionFactor)
Performs a guarded call to theTestTimeAdapter. If the call runs into any exception, it will be caught and returned.- Parameters:
aStartTime-aProgressionFactor-- Returns:
- null in case of success or an exception wrapper with errors in case of errors
-
isFork
public static boolean isFork()
Determines whether this JVM is a forked JVM from a master Integrity process.- Returns:
-
createFork
protected Fork createFork(Suite aSuiteCall) throws ForkException
Creates a new fork instance. This starts up the forked JVM and connects to it for remote control.- Parameters:
aSuiteCall- the suite call that shall be run on the fork- Returns:
- the new fork
- Throws:
ForkException- if any problem arises during forking
-
scheduleWaitBeforeNextStep
protected void scheduleWaitBeforeNextStep()
Schedules a "wait for the master" before the next execution step.
-
resetWaitBeforeNextStep
protected void resetWaitBeforeNextStep()
Resets a scheduled interruption (seescheduleWaitBeforeNextStep()).
-
checkForValidationError
protected void checkForValidationError(org.eclipse.emf.ecore.EObject anObject)
Checks and ensures that the specified object has no validation errors.- Parameters:
anObject- Object to be validated.
-
timesetTraceLog
protected void timesetTraceLog(String anAction, String aLogMessage, Date aStartDate, List<org.eclipse.xtext.util.Pair<Long,TemporalUnit>> aDiffTime, BigDecimal aProgressionFactor, String[] someTargetedForks)
Outputs a timeset trace log. Although this checks forisTimesetTracingEnabled, the caller may also check to save some cycles when generating expensive parameters.- Parameters:
anAction- the actionaLogMessage- the message to log
-
timesetTraceLog
protected void timesetTraceLog(String anAction, String aLogMessage)
Outputs a timeset trace log. Although this checks forisTimesetTracingEnabled, the caller may also check to save some cycles when generating expensive parameters.- Parameters:
anAction- the actionaLogMessage- the message to log
-
-