com.webmbt.plugin
Class LoadPlugin

java.lang.Object
  extended by com.webmbt.plugin.PluginAncestor
      extended by com.webmbt.plugin.ConcurrentPlugin
          extended by com.webmbt.plugin.LoadPlugin
All Implemented Interfaces:
MScriptInterface, TriggerInterface

public class LoadPlugin
extends ConcurrentPlugin

Copyright TestOptimal, LLC Load plugin contains the mScript method implementation to submit, control and monitor model execution on remote TestOptimal servers. This is used for load testing and stress testing with many models executing concurrently. It requires SvrMgr which provides Runtime servers for submitting model for execution.

Author:
yxl01

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.webmbt.plugin.MScriptInterface
MScriptInterface.MSCRIPT_METHOD
 
Field Summary
static java.lang.String VAR_BATCH_DESC
           
static java.lang.String VAR_BATCH_GROUP
           
static java.lang.String VAR_BATCH_ID
           
static java.lang.String VAR_NEXT_CAT_CODE
           
static java.lang.String VAR_SESSION_ID
           
 
Constructor Summary
LoadPlugin()
           
 
Method Summary
 void activateState(java.lang.String stateID_p)
          activates a specific state in the current model resulting in all transitions originating from the specified state to be dispatched for immediate execution.
 void activateState(java.lang.String stateID_p, java.lang.String modelName_p)
          activates a specific state in the model currently executing in the same server, resulting in all transitions originating from the specified state to be dispatched for immediate execution.
 void close()
          INTERNAL USE ONLY.
 void connectSvrMgr()
          Connects to SvrMgr to run models on Runtime servers managed by SvrMgr.
 void disconnectSvrMgr()
          Disconnects from SvrMgr to direct model execution to this server.
 boolean execTriggerAfter(com.webmbt.ScriptDesc scriptObj_p)
           
 boolean execTriggerBefore(com.webmbt.ScriptDesc scriptObj_p)
          INTERNAL USE ONLY.
 java.lang.String getPluginID()
          Returns the plugin ID: Load.
 boolean isError(java.lang.Exception e_p)
          INTERNAL USE ONLY.
 void limitToCatCodes(java.lang.String catCodes_p)
          limit model execution from this point in time to only hosts that have been assigned any of the category codes passed in.
 void limitToHosts(java.lang.String hosts_p)
          restrict from this point in time any model execution to only the hosts specified.
 void resetBatch()
          interrupts all existing models.
 void rmtActivateState(java.lang.String stateID_p, java.lang.String modelName_p, java.lang.String svrCatCodes_p)
          activates a specific state in a model running on a remote host, resulting in transition(s) originating from the specified state to be dispatched for immediate execution according to the activation type defined for the state.
 java.lang.String rmtGetVar(java.lang.String varName_p, java.lang.String modelName_p, java.lang.String svrCatCodes_p)
          gets the user variable from a model execution running on a remote host.
 void rmtSetVar(java.lang.String varName_p, java.lang.String varVal_p, java.lang.String modelName_p, java.lang.String svrCatCodes_p)
          sets the user variable in a model execution running on a remote host.
 void rmtTriggerTrans(java.lang.String stateID_p, java.lang.String transID_p, java.lang.String modelName_p, java.lang.String svrCatCodes_p)
          triggers a specific transition in another model running in a remote host, causing the immediate execution of the transition.
 java.lang.String runModel(java.lang.String modelName_p, java.lang.String sequencer_p, java.lang.String catCode_p, java.lang.String threadCount_p)
          dispatches model execution using the specified sequencer and thread count on a runtime server available with the default stop condition specified with the model.
 java.lang.String runModel(java.lang.String modelName_p, java.lang.String sequencer_p, java.lang.String catCodes_p, java.lang.String threadCount_p, java.lang.String options_p)
          dispatches model execution using the specified sequencer and thread count on a runtime server available with the additional options and stop conditions.
 void setBatchDesc(java.lang.String batchDesc_p)
          sets the description for this execution batch.
 void setCheckIntervalMillis(java.lang.String millis_p)
          sets the number of milliseconds between retries to find available server to execute the model or for completion of model executions.
 void setRetryTimeoutMillis(java.lang.String millis_p)
          sets the number of milliseconds to timeout the retrying for available Runtime server for execution of a model.
static void shutdown()
          INTERNAL USE ONLY.
 java.lang.String snapScreen(java.lang.String fileName_p)
          INTERNAL USE ONLY.
 void start()
          INTERNAL USE ONLY.
 void startBatchGroup(java.lang.String batchGroup_p)
          set up a new batch group within the current batch with the group code passed in.
 void triggerTrans(java.lang.String stateID_p, java.lang.String transID_p)
          triggers a specific transition in the current model causing the immediate execution of the transition.
 void triggerTrans(java.lang.String stateID_p, java.lang.String transID_p, java.lang.String modelName_p)
          triggers a specific transition in another model running in the same server, causing the immediate execution of the transition.
 java.lang.String waitForCompletion(java.lang.String timeoutMinutes_p)
          wait for all model execution sessions in the current batch to finish.
 java.lang.String waitForCompletion(java.lang.String batchGroup_p, java.lang.String timeoutMinutes_p)
          wait for model executions in the batch group passed in to finish execution.
 java.lang.String waitForCompletion(java.lang.String sessionID_p, java.lang.String timeoutMinutes_p, java.lang.String stopOnTimeout_p)
          waits for a model execution session to complete.
 java.lang.String waitForPageToLoad()
          do not use.
 
Methods inherited from class com.webmbt.plugin.ConcurrentPlugin
setAsyncTransThreadPoolSize, setMaxAsyncTrans
 
Methods inherited from class com.webmbt.plugin.PluginAncestor
addException, getCurScript, getData, getData, getDataMgr, getDataSetRowNum, getInitParams, getMethodList, getMScriptAPI, getMScriptMethodList, getNativeMethod, getNativePluginObj, getPathVar, getScriptExecutor, getVar, initialize, isReady, next, registerVarChangeListener, replaceEscapeChar, rewind, setData, setInitParams, setPathVar, setReady, setVar, snapScreen, uiLocatorMap
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VAR_BATCH_ID

public static final java.lang.String VAR_BATCH_ID
See Also:
Constant Field Values

VAR_BATCH_DESC

public static final java.lang.String VAR_BATCH_DESC
See Also:
Constant Field Values

VAR_SESSION_ID

public static final java.lang.String VAR_SESSION_ID
See Also:
Constant Field Values

VAR_BATCH_GROUP

public static final java.lang.String VAR_BATCH_GROUP
See Also:
Constant Field Values

VAR_NEXT_CAT_CODE

public static final java.lang.String VAR_NEXT_CAT_CODE
See Also:
Constant Field Values
Constructor Detail

LoadPlugin

public LoadPlugin()
Method Detail

shutdown

public static void shutdown()
INTERNAL USE ONLY. performs plugin shutdown.


close

public void close()
Description copied from class: PluginAncestor
INTERNAL USE ONLY. closes the AUT, disconnect from the external resource e.g. session to Selenium server, closing watij IE object, etc.

Overrides:
close in class ConcurrentPlugin

start

public void start()
           throws java.lang.Exception
INTERNAL USE ONLY. Initializes plugin.

Overrides:
start in class ConcurrentPlugin
Throws:
java.lang.Exception

snapScreen

public java.lang.String snapScreen(java.lang.String fileName_p)
                            throws java.lang.Exception
Description copied from class: PluginAncestor
INTERNAL USE ONLY. snap the current testing app browser under testing (AUT) and save the screen in png into the file passed in.

Overrides:
snapScreen in class ConcurrentPlugin
Throws:
java.lang.Exception

getPluginID

public java.lang.String getPluginID()
Returns the plugin ID: Load. Example: $getPluginID()

Overrides:
getPluginID in class ConcurrentPlugin
Returns:

isError

public boolean isError(java.lang.Exception e_p)
Description copied from class: PluginAncestor
INTERNAL USE ONLY. returns true if the exception passed in is an error. returns false if the exception is an application exception and thus should not stop the MBT execution.

Overrides:
isError in class ConcurrentPlugin
Returns:

waitForPageToLoad

public java.lang.String waitForPageToLoad()
                                   throws java.lang.Exception
do not use.

Overrides:
waitForPageToLoad in class ConcurrentPlugin
Throws:
java.lang.Exception

execTriggerBefore

public boolean execTriggerBefore(com.webmbt.ScriptDesc scriptObj_p)
                          throws java.lang.Exception
INTERNAL USE ONLY. execute triggers based on state/trans names. Trigger types:

Specified by:
execTriggerBefore in interface TriggerInterface
Overrides:
execTriggerBefore in class ConcurrentPlugin
Throws:
java.lang.Exception

execTriggerAfter

public boolean execTriggerAfter(com.webmbt.ScriptDesc scriptObj_p)
                         throws java.lang.Exception
Specified by:
execTriggerAfter in interface TriggerInterface
Overrides:
execTriggerAfter in class ConcurrentPlugin
Throws:
java.lang.Exception

runModel

public java.lang.String runModel(java.lang.String modelName_p,
                                 java.lang.String sequencer_p,
                                 java.lang.String catCode_p,
                                 java.lang.String threadCount_p)
                          throws java.lang.Exception
dispatches model execution using the specified sequencer and thread count on a runtime server available with the default stop condition specified with the model. This method does not wait for the model execution to complete. To wait for model execution to complete refer to waitForCompletion(String, String, String).

Example: $runModel('demoModel','optimalSequencer','myCat1,myCat2','5')

Parameters:
modelName_p - - name of the model
sequencer_p - - sequencer to be used to execute the model
  • OptimalSequence
  • GreedySequence
  • RandomSequence
  • PriorityPath
  • mCaseSerial
  • mCaseOptimal
  • Concurrent
catCode_p - - category to choose which Runtime server to execute model. Blank to choose any Runtime server or specify a category code to run model on the Runtime server which has the category code. Multiple category codes may be specified separated by a comma. When multiple category codes are specified, Runtime server must contain all of the category codes specified.
threadCount_p - - number of virtual users(threads) to be used to execute the model
Returns:
model execution session id. You may want to store this sessionID in a variable for later use to call other method that requires the sessionID. The sessionID is also automatically stored in path variable named "SESSION_ID".
Throws:
java.lang.Exception

runModel

public java.lang.String runModel(java.lang.String modelName_p,
                                 java.lang.String sequencer_p,
                                 java.lang.String catCodes_p,
                                 java.lang.String threadCount_p,
                                 java.lang.String options_p)
                          throws java.lang.Exception
dispatches model execution using the specified sequencer and thread count on a runtime server available with the additional options and stop conditions. This method does not wait for the model execution to complete. To wait for model execution to complete refer to waitForCompletion(String, String, String).

Multiple stop conditions and options are seperated by semi-colon. The available options are:

  1. mcase=mcaseName - name of the mcase to be executed
  2. seed=num - positive integer, seed for the random number generator
  3. statDesc=description - to label the model execution stats, may not contain these chars: & = ; &
  4. stopMinutes=n - to stop model execution after n minutes of elapse time
  5. stopTraversals=n - to stop model execution after n transition traversals
  6. stopTransCoveragePct=n - to stop model execution after transition coverage reaches n%
  7. iterations=n - to iterate model execution n times
  8. exceptions=n - to stop model execution when number of failures detected exceeds n
  9. notifyEmail=emailAddress - to send email notification upon completion to the address specified
  10. browser=browser of choice - to use the specific browser type for model execution. You may add specific browser version by adding suffix "_n", e.g. iexplore_7 for IE 7:
    • iexplore - Internet Explore
    • firefox - Firefox
    • custom - customized browser as you configured in config.properties.
    • konqueror - Kongueror
    • chrome - Firefox in Chrome mode, this is not Google Chrome!
    • safari - Safari
    • opera - Opera
    • for Google Chrome, use custom.

Example: $runModel('demoModel','optimalSequencer','cat2','5','stopMinutes=5;browser=iexplore_8')

The MBT execution session ID is stored in path variable _sessionID

, which can be accessed with $getPathVar("_sessionID").

Parameters:
modelName_p - - name of the model
sequencer_p - - see runModel(String, String, String, String)
catCodes_p - - see runModel(String, String, String, String)
threadCount_p - - see runModel(String, String, String, String)
options_p - additional options for model executions including stop conditions. See description above.
Returns:
model execution session id.
Throws:
java.lang.Exception
See Also:
#runModel(String, String, String, String)}, #waitForCompletion(String, String, String)}

resetBatch

public void resetBatch()
                throws java.lang.Exception
interrupts all existing models.

Example: $resetBatch()

Throws:
java.lang.Exception

setBatchDesc

public void setBatchDesc(java.lang.String batchDesc_p)
                  throws java.lang.Exception
sets the description for this execution batch.

The MBT execution batch ID is stored in user variable _batchID

, which can be accessed with $getVar('_batchID') or [_batchID]

Only one batch can be started during model execution. Subsequent call to this function will just change the batch description.

Example: $setBatchDesc('my batch 1')

Parameters:
batchDesc_p -
Throws:
java.lang.Exception

setCheckIntervalMillis

public void setCheckIntervalMillis(java.lang.String millis_p)
sets the number of milliseconds between retries to find available server to execute the model or for completion of model executions. The default is 5000 milliseconds. This function overrides the default config setting "Load.RetryInterval" in config.properties. Example: $setRetryMillis('10000')

Parameters:
millis_p -

setRetryTimeoutMillis

public void setRetryTimeoutMillis(java.lang.String millis_p)
sets the number of milliseconds to timeout the retrying for available Runtime server for execution of a model. The default is 300000 milliseconds (5 minutes) set by "Load.RetryTimeoutMillis" in config.properties. Example: $setRetryTimeoutMillis('500000')

Parameters:
millis_p -

waitForCompletion

public java.lang.String waitForCompletion(java.lang.String timeoutMinutes_p)
                                   throws java.lang.Exception
wait for all model execution sessions in the current batch to finish. Timeout after specified number of minutes. When timeout occurs, executions will be signaled to interrupt.

Example: $waitForCompletion('30') - waits for all model executions to complete up to 30 minutes, if there is any model execution not completed after 30 minutes, it returns "TimedOut". Otherwise it returns "OK".

Parameters:
maxRuntimeMinutes_p - timeout in minutes.
Returns:
ok for normal completion (with and without errors) or timeout if any executions had to be interrupted.
Throws:
java.lang.Exception - on timeout

waitForCompletion

public java.lang.String waitForCompletion(java.lang.String batchGroup_p,
                                          java.lang.String timeoutMinutes_p)
                                   throws java.lang.Exception
wait for model executions in the batch group passed in to finish execution. Timeout after specified number of minutes. When timeout occurs, executions will be signaled to interrupt.

Example: $waitForCompletion('IE_Group', '30') - waits for all model executions to complete up to 30 minutes, if there is any model execution not completed after 30 minutes, it returns "TimedOut". Otherwise it returns "OK".

Parameters:
maxRuntimeMinutes_p - timeout in minutes.
Returns:
ok for normal completion (with and without errors) or timeout if any executions had to be interrupted.
Throws:
java.lang.Exception - on timeout

waitForCompletion

public java.lang.String waitForCompletion(java.lang.String sessionID_p,
                                          java.lang.String timeoutMinutes_p,
                                          java.lang.String stopOnTimeout_p)
                                   throws java.lang.Exception
waits for a model execution session to complete. If timed out, the model execution will be interrupted if true is passed in parameter stopOnTimeout_p. Else the model execution will be left to execute to completion.

Example: $waitForCompletion('$runModel('demoModel','optimalSequencer','myCat1,myCat2','5')', '30', 'true')

In the above example, it runs the model "demoModel". The sessionID returned form the runModel() is passed in to $waitForCompletion() function. The timeout is set to 30 minutes and the model execution is to be interrupted if it does not complete before the 30 minutes timeout setting.

Parameters:
sessionID_p - - sessionID returned from $runModel()
timeoutMinutes_p - timeout in minutes. if 0, negative or invalid timeout setting is specified, the timeout minutes will be set to 5 minutes.
Returns:
TimedOut if timeout triggered, or OK for other conditions
Throws:
java.lang.Exception

limitToHosts

public void limitToHosts(java.lang.String hosts_p)
                  throws java.lang.Exception
restrict from this point in time any model execution to only the hosts specified.

Example: $limitToHosts('host1,host2')

Parameters:
hosts_p - colon (or semi-colon) separated list of host names
Throws:
java.lang.Exception

limitToCatCodes

public void limitToCatCodes(java.lang.String catCodes_p)
                     throws java.lang.Exception
limit model execution from this point in time to only hosts that have been assigned any of the category codes passed in. Example: $limitToCatCodes('IE,FF')

Parameters:
catCodes_p -
Throws:
java.lang.Exception

connectSvrMgr

public void connectSvrMgr()
                   throws java.lang.Exception
Connects to SvrMgr to run models on Runtime servers managed by SvrMgr. The SvrMgr host port information is defined in config.properties with "SvrMgrURL=http://host:port". The connection is maintained until $disconnectSvrMgr() is called. This is equivalent to "File / Connect SvrMgr" menu action. Example: $connectSvrMgr()

Throws:
java.lang.Exception
See Also:
disconnectSvrMgr()

disconnectSvrMgr

public void disconnectSvrMgr()
                      throws java.lang.Exception
Disconnects from SvrMgr to direct model execution to this server. This is equivalent to "File / Disconnect SvrMgr" menu action. Example: $disconnectSvrMgr()

Throws:
java.lang.Exception
See Also:
connectSvrMgr()

rmtSetVar

public void rmtSetVar(java.lang.String varName_p,
                      java.lang.String varVal_p,
                      java.lang.String modelName_p,
                      java.lang.String svrCatCodes_p)
               throws com.webmbt.MBTException
sets the user variable in a model execution running on a remote host. If more than one servers are found to be executing the same model and with matching category code, this function will only set the variable on the first model execution found. Example: $rmtSetVar('var1', 'val2', 'modelX', 'IE')

In the above example, it sets the variable var1 to value val2 on the modelX running on a remote host which has the category code of IE. Category code is used to differentiate Runtime servers or group certain Runtime servers together. In this case, our Runtime servers that are running IE browsers are assigned IE while Runtime servers running Firefox browsers are assigned FF, etc. In our example above the same model may be executing simultaneously in multiple servers and we are only interested in setting the variable on the first model execution found running IE browser.

Parameters:
varName_p -
varVal_p -
modelName_p -
svrCatCodes_p -
Throws:
com.webmbt.MBTException
See Also:
#setVar()

rmtGetVar

public java.lang.String rmtGetVar(java.lang.String varName_p,
                                  java.lang.String modelName_p,
                                  java.lang.String svrCatCodes_p)
                           throws com.webmbt.MBTException
gets the user variable from a model execution running on a remote host. If more than one servers are found to be executing the same model and with same category code, this function will only get the variable on the first model execution. Example: $rmtGetVar('var1', 'modelX', 'IE')

In the above example, it gets the variable var1 from the modelX running on a remote host which has the category code of IE. Category code is used to differentiate or group Runtime servers. In this case, our Runtime servers that are running IE browsers are assigned IE while Runtime servers running Firefox browsers are assigned FF, etc. In our example above the same model may be executing simultanenously in multiple servers and we are only interested in getting the variable on the model execution running IE browsers.

Parameters:
varName_p -
varVal_p -
modelName_p -
svrCatCodes_p -
Throws:
com.webmbt.MBTException
See Also:
#getVar()

rmtActivateState

public void rmtActivateState(java.lang.String stateID_p,
                             java.lang.String modelName_p,
                             java.lang.String svrCatCodes_p)
                      throws com.webmbt.MBTException
activates a specific state in a model running on a remote host, resulting in transition(s) originating from the specified state to be dispatched for immediate execution according to the activation type defined for the state. Any transitions with guard conditions must have guard conditions evaluated to true in order to participate in this operation. Example: $rmtActivateState('state1', 'modelX', 'IE')

Parameters:
stateID_p -
modelName_p -
svrCatCodes_p -
Throws:
com.webmbt.MBTException

rmtTriggerTrans

public void rmtTriggerTrans(java.lang.String stateID_p,
                            java.lang.String transID_p,
                            java.lang.String modelName_p,
                            java.lang.String svrCatCodes_p)
                     throws com.webmbt.MBTException
triggers a specific transition in another model running in a remote host, causing the immediate execution of the transition. Guard conditions are not evaluated as part of this operation. Example: $rmtTriggerTrans('state1', 'trans2', 'model3', 'IE')

Parameters:
stateID_p -
transID_p -
modelName_p -
svrCatCodes_p - to find server that has any of the cat codes specified
Throws:
com.webmbt.MBTException

activateState

public void activateState(java.lang.String stateID_p)
                   throws java.lang.Exception
activates a specific state in the current model resulting in all transitions originating from the specified state to be dispatched for immediate execution. Any transitions with guard conditions must have guard conditions evaluated to true in order to participate in this operation. Example: $activateState('state1')

Overrides:
activateState in class ConcurrentPlugin
Throws:
java.lang.Exception

activateState

public void activateState(java.lang.String stateID_p,
                          java.lang.String modelName_p)
                   throws com.webmbt.MBTException
activates a specific state in the model currently executing in the same server, resulting in all transitions originating from the specified state to be dispatched for immediate execution. Any transitions with guard conditions must have guard conditions evaluated to true in order to participate in this operation. Example: $activateState('state1', 'modelY')

Overrides:
activateState in class ConcurrentPlugin
Parameters:
stateID_p -
modelName_p -
Throws:
com.webmbt.MBTException

triggerTrans

public void triggerTrans(java.lang.String stateID_p,
                         java.lang.String transID_p)
                  throws java.lang.Exception
triggers a specific transition in the current model causing the immediate execution of the transition. Guard conditions are not evaluated as part of this operation. Example: $triggerTrans('state1', 'trans2')

Overrides:
triggerTrans in class ConcurrentPlugin
Parameters:
stateID_p -
transID_p -
Throws:
java.lang.Exception

triggerTrans

public void triggerTrans(java.lang.String stateID_p,
                         java.lang.String transID_p,
                         java.lang.String modelName_p)
                  throws com.webmbt.MBTException
triggers a specific transition in another model running in the same server, causing the immediate execution of the transition. Guard conditions are not evaluated as part of this operation. Example: $triggerTrans('state1', 'trans2', 'model2')

Overrides:
triggerTrans in class ConcurrentPlugin
Parameters:
stateID_p -
transID_p -
modelName_p -
Throws:
com.webmbt.MBTException

startBatchGroup

public void startBatchGroup(java.lang.String batchGroup_p)
                     throws java.lang.Exception
set up a new batch group within the current batch with the group code passed in. Any subsequent runModel() on the same path will be tagged to this batch group.

Parameters:
batchGroup_p -
Throws:
java.lang.Exception


Copyright © 2008. All Rights Reserved.