public abstract class AbstractJavaTest
extends java.lang.Thread
Modifier and Type | Class and Description |
---|---|
static interface |
AbstractJavaTest.ResourceFiles
Additional files which are required to execute the test program, such as jar-files and input-files.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ABORT_TESTJOB_FILE_NAME
The existence of this file in the data output directory effects that the test is aborted.
|
static int |
ENCODE_ALGORITHM_DECODE
Decode percent-encoded variable value.
|
static int |
ENCODE_ALGORITHM_ENCODE
Encode variable value with percent-encoding algorithm.
|
static int |
ENCODE_ALGORITHM_NONE
No encoding or decoding of variable value (unchanged / keep it as is).
|
static java.lang.String |
ERROR_SEVERITY_ERROR
Error severity 'error': After the error has occurred then the simulated aborts the execution of the current session loop and starts the execution of the next session loop.
|
static java.lang.String |
ERROR_SEVERITY_FATAL
Error severity 'fatal': After the error has occurred then the simulated user aborts any further execution of the test, which means that the test has ended for this simulated user.
|
static java.lang.String |
ERROR_SEVERITY_WARNING
Error severity 'warning': After the error has occurred then the simulated user continues with the execution of the current session loop.
|
static int |
LOG_DEBUG
Debug log level.
|
static int |
LOG_ERROR
Error log level.
|
static int |
LOG_FATAL
Fatal log level - System.exit(1) may be called later.
|
static int |
LOG_INFO
Info log level.
|
static int |
LOG_TRACE
Trace log level.
|
static int |
LOG_WARN
Waring log level.
|
static int |
SESSION_STATUS_END_OF_TEST
Session status end of test: The execution of the session has failed and further execution of all users is stopped.
|
static int |
SESSION_STATUS_END_OF_USER
Session status end of user: The execution of the session has failed and further execution of the user is stopped.
|
static int |
SESSION_STATUS_FAILED
Session status failed: The execution of the session has failed, but the user continues to execute the next session.
|
static int |
SESSION_STATUS_SUCCESS
Session status success: The execution of user session was successful.
|
static java.lang.String |
STATISTIC_TYPE_AVERAGE_AND_CURRENT_VALUE
An average and current value.
|
static java.lang.String |
STATISTIC_TYPE_CUMULATIVE_COUNTER_LONG
A cumulative long counter.
|
static java.lang.String |
STATISTIC_TYPE_EFFICIENCY_RATIO_PERCENT
An efficiency ratio percent value.
|
static java.lang.String |
STATISTIC_TYPE_SAMPLE_EVENT_TIME_CHART
A chart with samples of event timestamp and (measured) long value..
|
static java.lang.String |
STATISTIC_TYPE_THROUGHPUT_TIME_CHART
A chart of a throughput per second.
|
static StdoutLogAdapter |
stdoutLog
The stdout log adapter.
|
static java.lang.String |
SUSPEND_TESTJOB_FILE_NAME
The existence of this file in the data output directory effects that the test is suspended.
|
static java.util.HashSet<java.lang.Integer> |
VALID_ENCODE_ALGORITHM_SET
A set of all valid encode algorithms for variable values.
|
static java.util.HashSet<java.lang.Integer> |
VALID_SESSION_STATUS_SET
A set of all valid session statuses.
|
Constructor and Description |
---|
AbstractJavaTest(int userNumber)
Constructor: Create a new instance.
|
Modifier and Type | Method and Description |
---|---|
static void |
abstractMain(java.lang.String[] args)
Static Main: Get all generic arguments passed from the command line of the main program.
|
void |
addAverageDeltaAndCurrentValue(long statisticId,
long sumValuesDelta,
long numValuesDelta,
long currentValue,
long currentValueTimestamp)
All Purpose Interface: Add delta values to the average and set the current value for a 'average-and-current-value' statistic.
|
void |
addCounterLong(long statisticId,
long value)
All Purpose Interface: Increment the counter of a declared 'cumulative-counter-long' statistic.
|
void |
addEfficiencyRatioDelta(long statisticId,
long efficiencyDeltaValue,
long inefficiencyDeltaValue)
All Purpose Interface: Add efficiency ratio delta values to a 'efficiency-ratio-percent' statistic.
|
void |
addSampleError(long statisticId,
java.lang.String errorSubject,
java.lang.String errorSeverity,
java.lang.String errorType,
java.lang.String errorLog,
java.lang.String errorContext)
All Purpose Interface: Add an error to a declared statistic (for example when measuring a data sample did fail).
|
void |
addSampleLong(long statisticId,
long value)
All Purpose Interface: Add a measured long value to a statistic.
|
static void |
addSimulatedUser(AbstractJavaTest abstractJavaTestInstance)
Add an instance of a simulated user.
|
int |
addTestResultAnnotationExecEvent(java.lang.String eventText)
All Purpose Interface: Add an execution annotation event to the test result.
|
void |
addThroughputDelta(long statisticId,
double deltaValue)
All Purpose Interface: Add a measured delta value to a throughput statistic.
|
void |
declareStatistic(long statisticId,
java.lang.String statisticType,
java.lang.String statisticTitle,
java.lang.String statisticSubtitle,
java.lang.String yAxisTitle,
java.lang.String unitText,
int sortPosition,
boolean addToSummaryStatistic,
java.lang.String backgroundColor)
All Purpose Interface: Declare a new statistic.
|
abstract void |
declareStatistics()
Declare all statistics which are known to be measured.
|
abstract void |
executeUserEnd(int userNumber)
Called when the user has ended.
|
abstract int |
executeUserSession(int userNumber,
int sessionLoopNumber)
Invoked when the user is supposed to execute an 'user session'.
|
abstract void |
executeUserSessionEnd(int sessionStatus,
int userNumber,
int sessionLoopNumber)
Invoked after the end of an executed 'user session'.
|
abstract void |
executeUserStart(int userNumber)
Called when the user is started.
|
static java.io.File |
getArgDataOutputDirectory()
Get the data output directory command line argument.
|
static int |
getArgDelayPerSessionLoopMillis()
Get the delay per session loop command line argument, or the default value if the argument was not passed.
|
static java.lang.String |
getArgJobDescription()
Get the job description command line argument.
|
static int |
getArgMaxSessionLoopsPerUser()
Get the max session loops per user command line argument, or the default value if the argument was not passed.
|
static int |
getArgMaxTestDuration()
Get the max test duration command line argument, or the default value if the argument was not passed,
|
static int |
getArgNumberOfUsers()
Get the number of users command line argument, or the default value if the argument was not passed.
|
static int |
getArgRampUpTime()
Get the ramp up time command line argument.
|
static long |
getExecuteEndTimestamp()
Get the execute end time stamp.
|
static long |
getExecuteStartTimestamp()
Get the execute start time stamp.
|
int |
getSessionLoopNumber()
Get the current session loop number.
|
StdoutLogAdapter |
getStdoutLogAdapter()
Get the stdout log adapter.
|
static long |
getTotalFailedSessions()
Get the total number of failed sessions, counted overall users.
|
static long |
getTotalPassedSessions()
Get the total number of passed sessions, counted overall users.
|
int |
getUserNumber()
Get the simulated user number.
|
static boolean |
isArgDebugExecution()
Get if debug test execution is enabled.
|
static boolean |
isArgDebugMeasuring()
Get if debug data measuring is enabled.
|
static boolean |
isGlobalAbortFlag()
Get if the test must aborted.
|
static void |
logTestSpecificResourceFileNames(java.lang.Class clazz)
Log the file names of all test specific resource files to stdout.
|
abstract void |
onUserResume(int userNumber)
Called when the user was previously suspended and was now resumed.
|
abstract void |
onUserSuspend(int userNumber)
Called when the user was suspended.
|
abstract void |
onUserTestAbort(int userNumber)
Called, per user, when the whole test is aborted by an abort action.
|
void |
registerSampleStart(long statisticId)
All Purpose Interface: Register that the measuring of a long value sample has started
|
void |
run()
User thread method.
|
static void |
sleep(long millis)
Sleep for a while of milliseconds, but wake up earlier when the test must be aborted.
|
static void |
startUserThreads()
Start the user threads and set the 'execute start' timestamp.
|
static void |
waitUserThreadsEnd()
Wait for the end of all user threads an set then the 'execute end' timestamp.
|
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, start, stop, stop, suspend, toString, yield
public static final int LOG_DEBUG
public static final int LOG_TRACE
public static final int LOG_INFO
public static final int LOG_WARN
public static final int LOG_ERROR
public static final int LOG_FATAL
public static final java.lang.String STATISTIC_TYPE_SAMPLE_EVENT_TIME_CHART
public static final java.lang.String STATISTIC_TYPE_THROUGHPUT_TIME_CHART
public static final java.lang.String STATISTIC_TYPE_CUMULATIVE_COUNTER_LONG
public static final java.lang.String STATISTIC_TYPE_EFFICIENCY_RATIO_PERCENT
public static final java.lang.String STATISTIC_TYPE_AVERAGE_AND_CURRENT_VALUE
public static final int SESSION_STATUS_SUCCESS
public static final int SESSION_STATUS_FAILED
public static final int SESSION_STATUS_END_OF_USER
public static final int SESSION_STATUS_END_OF_TEST
public static final java.util.HashSet<java.lang.Integer> VALID_SESSION_STATUS_SET
public static final java.lang.String ERROR_SEVERITY_WARNING
public static final java.lang.String ERROR_SEVERITY_ERROR
public static final java.lang.String ERROR_SEVERITY_FATAL
public static final int ENCODE_ALGORITHM_NONE
public static final int ENCODE_ALGORITHM_ENCODE
public static final int ENCODE_ALGORITHM_DECODE
public static final java.util.HashSet<java.lang.Integer> VALID_ENCODE_ALGORITHM_SET
public static final java.lang.String SUSPEND_TESTJOB_FILE_NAME
public static final java.lang.String ABORT_TESTJOB_FILE_NAME
public static StdoutLogAdapter stdoutLog
public AbstractJavaTest(int userNumber) throws java.io.IOException
userNumber
- the simulated user number (1..n)java.lang.IllegalArgumentException
- if the user number less than 1java.io.IOException
- if the user statistics out file cannot be createdpublic static void logTestSpecificResourceFileNames(java.lang.Class clazz)
clazz
- the class of the test programAbstractJavaTest.ResourceFiles
public static void addSimulatedUser(AbstractJavaTest abstractJavaTestInstance)
abstractJavaTestInstance
- the instance of the simulated user.public static void startUserThreads() throws java.lang.InterruptedException
java.lang.InterruptedException
- if the program is aborted during ramp-uppublic static void waitUserThreadsEnd() throws java.lang.InterruptedException
java.lang.InterruptedException
- if the program is aborted during waiting for the end of all user threadspublic static long getTotalPassedSessions()
public static long getTotalFailedSessions()
public static long getExecuteStartTimestamp()
public static long getExecuteEndTimestamp()
public static boolean isGlobalAbortFlag()
public static void sleep(long millis) throws java.lang.InterruptedException
millis
- the sleep duration in millisecondsjava.lang.InterruptedException
- if the current thread is interruptedisGlobalAbortFlag()
public int getUserNumber()
public int getSessionLoopNumber()
public StdoutLogAdapter getStdoutLogAdapter()
public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
public abstract void declareStatistics() throws java.lang.Exception
java.lang.Exception
- if somewhat fails in the implementationpublic abstract void executeUserStart(int userNumber) throws java.lang.Exception
userNumber
- the current simulated user numberjava.lang.Exception
- if somewhat fails in the implementationpublic abstract int executeUserSession(int userNumber, int sessionLoopNumber) throws AbstractJavaTestPluginSessionFailedException, AbstractJavaTestPluginUserFailedException, AbstractJavaTestPluginTestFailedException, java.lang.Exception
userNumber
- the current simulated user number (1..n)sessionLoopNumber
- the session loop number (1..n)AbstractJavaTestPluginSessionFailedException
- if a plug-in signals that the 'user session' is abortedAbstractJavaTestPluginUserFailedException
- if a plug-in signals that the user has to be terminatedAbstractJavaTestPluginTestFailedException
- if a plug-in signals that the test has to be terminatedjava.lang.Exception
- if somewhat fails in the implementationSESSION_STATUS_SUCCESS
,
SESSION_STATUS_FAILED
,
SESSION_STATUS_END_OF_USER
,
SESSION_STATUS_END_OF_TEST
public abstract void executeUserSessionEnd(int sessionStatus, int userNumber, int sessionLoopNumber) throws java.lang.Exception
sessionStatus
- the session status of the executed sessionuserNumber
- the current simulated user number (1..n)sessionLoopNumber
- the session loop number (1..n)java.lang.Exception
- if somewhat fails in the implementationSESSION_STATUS_SUCCESS
,
SESSION_STATUS_FAILED
,
SESSION_STATUS_END_OF_USER
,
SESSION_STATUS_END_OF_TEST
public abstract void onUserSuspend(int userNumber) throws java.lang.Exception
userNumber
- the current simulated user numberjava.lang.Exception
- if somewhat fails in the implementationpublic abstract void onUserResume(int userNumber) throws java.lang.Exception
userNumber
- the current simulated user numberjava.lang.Exception
- if somewhat fails in the implementationpublic abstract void executeUserEnd(int userNumber) throws java.lang.Exception
userNumber
- the current simulated user numberjava.lang.Exception
- if somewhat fails in the implementationpublic abstract void onUserTestAbort(int userNumber) throws java.lang.Exception
userNumber
- the current simulated user numberjava.lang.Exception
- if somewhat fails in the implementationexecuteUserEnd(int)
public void declareStatistic(long statisticId, java.lang.String statisticType, java.lang.String statisticTitle, java.lang.String statisticSubtitle, java.lang.String yAxisTitle, java.lang.String unitText, int sortPosition, boolean addToSummaryStatistic, java.lang.String backgroundColor)
statisticId
- the unique ID of the statisticstatisticType
- the type of the statisticstatisticTitle
- the title shown in the UIstatisticSubtitle
- the subtitle shown in the UI, or an empty string = not shown in the UIyAxisTitle
- the Y-axis title of the diagram shown in the UI, or an empty string = not shown in the UIunitText
- the text for the measured unit shown in the UI, or an empty string = not shown in the UIsortPosition
- the UI sort position (sorting order: from small to large positions)addToSummaryStatistic
- if true = add the number of passed/failed/pending samples to the summary statisticbackgroundColor
- the background color either as #hex-triplet or as bootstrap class, or an empty string = no special background colorSTATISTIC_TYPE_SAMPLE_EVENT_TIME_CHART
,
STATISTIC_TYPE_THROUGHPUT_TIME_CHART
,
STATISTIC_TYPE_CUMULATIVE_COUNTER_LONG
,
STATISTIC_TYPE_EFFICIENCY_RATIO_PERCENT
,
STATISTIC_TYPE_AVERAGE_AND_CURRENT_VALUE
public void registerSampleStart(long statisticId)
statisticId
- the unique ID of the statisticaddSampleLong(long, long)
,
addSampleError(long, String, String, String, String, String)
,
STATISTIC_TYPE_SAMPLE_EVENT_TIME_CHART
public void addSampleLong(long statisticId, long value)
statisticId
- the unique ID of the statisticvalue
- the measured long valueregisterSampleStart(long)
,
STATISTIC_TYPE_SAMPLE_EVENT_TIME_CHART
public void addSampleError(long statisticId, java.lang.String errorSubject, java.lang.String errorSeverity, java.lang.String errorType, java.lang.String errorLog, java.lang.String errorContext)
statisticId
- the unique ID of the statisticerrorSubject
- the subject of the error. Note that multiple errors which contains the same subject can be grouped.errorSeverity
- the error severityerrorType
- the (optional) type of the error which reflects why the error did occur. Note that multiple errors which contains the same error type can be grouped.errorLog
- the (optional) error logerrorContext
- the (optional) error context that describes the circumstances under which the error occurred. It's recommended to pass a JSON object as string.ERROR_SEVERITY_WARNING
,
ERROR_SEVERITY_ERROR
,
ERROR_SEVERITY_FATAL
,
registerSampleStart(long)
,
STATISTIC_TYPE_SAMPLE_EVENT_TIME_CHART
public void addThroughputDelta(long statisticId, double deltaValue)
statisticId
- the unique ID of the statisticdeltaValue
- the measured delta valueSTATISTIC_TYPE_THROUGHPUT_TIME_CHART
public void addCounterLong(long statisticId, long value)
statisticId
- the unique ID of the statisticvalue
- the value by which the counter is incrementedSTATISTIC_TYPE_CUMULATIVE_COUNTER_LONG
public void addEfficiencyRatioDelta(long statisticId, long efficiencyDeltaValue, long inefficiencyDeltaValue)
statisticId
- the unique ID of the statisticefficiencyDeltaValue
- the efficiency delta value to addinefficiencyDeltaValue
- the inefficiency delta value to addSTATISTIC_TYPE_EFFICIENCY_RATIO_PERCENT
public void addAverageDeltaAndCurrentValue(long statisticId, long sumValuesDelta, long numValuesDelta, long currentValue, long currentValueTimestamp)
statisticId
- the unique ID of the statisticsumValuesDelta
- the sum of delta values to add to the averagenumValuesDelta
- the number of delta values to add to the averagecurrentValue
- the current value, or -1 if no such data is availablecurrentValueTimestamp
- the Unix-like timestamp of the current value, or -1 if no such data is availableSTATISTIC_TYPE_AVERAGE_AND_CURRENT_VALUE
public int addTestResultAnnotationExecEvent(java.lang.String eventText)
eventText
- the event textpublic static void abstractMain(java.lang.String[] args)
args
- all arguments passed from the command linegetArgNumberOfUsers()
,
getArgMaxTestDuration()
,
getArgMaxSessionLoopsPerUser()
,
getArgDelayPerSessionLoopMillis()
,
getArgRampUpTime()
,
getArgDataOutputDirectory()
,
getArgJobDescription()
,
isArgDebugExecution()
,
isArgDebugMeasuring()
public static int getArgNumberOfUsers()
abstractMain(String[])
public static int getArgMaxTestDuration()
abstractMain(String[])
public static int getArgMaxSessionLoopsPerUser()
abstractMain(String[])
public static int getArgDelayPerSessionLoopMillis()
abstractMain(String[])
public static int getArgRampUpTime()
abstractMain(String[])
public static java.io.File getArgDataOutputDirectory()
abstractMain(String[])
public static java.lang.String getArgJobDescription()
abstractMain(String[])
public static boolean isArgDebugExecution()
abstractMain(String[])
public static boolean isArgDebugMeasuring()
abstractMain(String[])