public final class

LoadPlugin

extends ConcurrentPlugin
com.webmbt.plugin.ConcurrentPlugin
   ↳ com.webmbt.plugin.LoadPlugin

Class Overview

Load plugin contains the mScript method implementation to submit, control and monitor model execution on remote MBT 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.

Copyright © 2008 - 2017 TestOptimal LLC. All Rights Reserved.

Summary

Public Constructors
LoadPlugin()
Public Methods
void activateState(String stateID_p, 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 activateState(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 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.
String downloadMScriptLog(String sessID_p, String outputFilePath_p)
downloads the mscript log file for the model session id passed in from the runtime server to the current load model folder specified.
String getModelExecStatus(String sessID_p)
returns the execution status for the given MBT Session.
String getPluginID()
Returns the plugin ID: Load.
void limitToCatCodes(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(String hosts_p)
restrict from this point in time any model execution to only the hosts specified.
void resetBatch()
interrupts all existing models currently running on all runtime servers managed by the same SvrMgr.
void rmtActivateState(String stateID_p, String modelName_p, 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.
String rmtGetVar(String varName_p, String modelName_p, String svrCatCodes_p)
gets the user variable from a model execution running on a remote host.
void rmtSetVar(String varName_p, String varVal_p, String modelName_p, String svrCatCodes_p)
sets the user variable in a model execution running on a remote host.
void rmtTriggerTrans(String stateID_p, String transID_p, String modelName_p, String svrCatCodes_p)
triggers a specific transition in another model running in a remote host, causing the immediate execution of the transition.
String runModel(String modelName_p, String sequencer_p, String catCodes_p, String threadCount_p, String options_p, String localServerOnly_p)
dispatches model execution using the specified sequencer and thread count on a runtime server available with the additional options and stop conditions.
String runModel(String modelName_p, String sequencer_p, String catCodes_p, String threadCount_p, 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.
String runModel(String modelName_p, String sequencer_p, String catCode_p, 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.
void setBatchDesc(String batchDesc_p)
sets the description for this execution batch.
void setCheckIntervalMillis(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(String millis_p)
sets the number of milliseconds to timeout the retrying for available Runtime server for execution of a model.
void startBatchGroup(String batchGroup_p)
set up a new batch group within the current batch with the group code passed in.
void triggerTrans(String stateID_p, String transID_p)
triggers a specific transition in the current model causing the immediate execution of the transition.
void triggerTrans(String stateID_p, String transID_p, String modelName_p)
triggers a specific transition in another model running in the same server, causing the immediate execution of the transition.
String waitForBatchCompletion(String batchGroup_p, String timeoutMinutes_p)
wait for model executions in the batch group passed in to finish execution.
String waitForBatchCompletion(String timeoutMinutes_p)
wait for all model execution sessions in the current batch to finish.
String waitForCompletion(String sessionID_p, String timeoutMinutes_p, String stopOnTimeout_p)
waits for a model execution session to complete.
[Expand]
Inherited Methods
From class com.webmbt.plugin.ConcurrentPlugin

Public Constructors

public LoadPlugin ()

Since: API Level v2

Public Methods

public void activateState (String stateID_p, String modelName_p)

Since: API Level v2

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')

Throws
MBTException

public void activateState (String stateID_p)

Since: API Level v2

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')

Throws
Exception

public void connectSvrMgr ()

Since: API Level v2

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
Exception

public void disconnectSvrMgr ()

Since: API Level v2

Disconnects from SvrMgr to direct model execution to this server. This is equivalent to "File / Disconnect SvrMgr" menu action. Example:

$disconnectSvrMgr()

Throws
Exception
See Also

public String downloadMScriptLog (String sessID_p, String outputFilePath_p)

Since: API Level v2

downloads the mscript log file for the model session id passed in from the runtime server to the current load model folder specified.

Example:

$downloadMScriptLog('$runModel('abc','optimalSequence', '', '1','')', 'mscriptLog1.txt')

Parameters
sessID_p mbt session id
outputFilePath_p file path under current model folder, e.g. "dataset/mscriptlog/log1.txt".
Returns
  • OK for successful or error message if failed
Throws
Exception

public String getModelExecStatus (String sessID_p)

Since: API Level v2

returns the execution status for the given MBT Session.

  • RUNNING - model is still running
  • PASSED - execution has completed without failures
  • FAILED - execution completed with at least one failure
  • NOT-FOUND - supplied MBT Session ID is not valid

Parameters
sessID_p MBT session ID obtained from the call $runModel()
Returns
  • RUNNING, PASSED, FAILED, NOT-FOUND.
Throws
Exception

public String getPluginID ()

Since: API Level v2

Returns the plugin ID: Load. Example:

$getPluginID()

public void limitToCatCodes (String catCodes_p)

Since: API Level v2

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')

Throws
Exception

public void limitToHosts (String hosts_p)

Since: API Level v2

restrict from this point in time any model execution to only the hosts specified.

Example:

$limitToHosts('host1:8888,host2:9000')

Parameters
hosts_p list of host names with port separated by semi-colon or comma. e.g. myhost:8888,myhost2:9000
Throws
Exception

public void resetBatch ()

Since: API Level v2

interrupts all existing models currently running on all runtime servers managed by the same SvrMgr.

Example:

$resetBatch()

Throws
Exception

public void rmtActivateState (String stateID_p, String modelName_p, String svrCatCodes_p)

Since: API Level v2

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')

Throws
MBTException

public String rmtGetVar (String varName_p, String modelName_p, String svrCatCodes_p)

Since: API Level v2

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.

Throws
MBTException
See Also
  • #getVar()

public void rmtSetVar (String varName_p, String varVal_p, String modelName_p, String svrCatCodes_p)

Since: API Level v2

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.

Throws
MBTException
See Also
  • #setVar()

public void rmtTriggerTrans (String stateID_p, String transID_p, String modelName_p, String svrCatCodes_p)

Since: API Level v2

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
svrCatCodes_p to find server that has any of the cat codes specified
Throws
MBTException

public String runModel (String modelName_p, String sequencer_p, String catCodes_p, String threadCount_p, String options_p, String localServerOnly_p)

Since: API Level v2

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 ; or &. The available options are:

  1. ALM=Y - to enable defect raise/update to ALM system if ALM plugin is activated
  2. autoClose=Y/N - to close the model automatically after model execution
  3. appURL=AUT URL/Command - to set the AUT URL or command start AUT
  4. batchID=n - to set the batchID for the model execution.
  5. batchGropu=groupName - to set the batchGroup for the model execution.
  6. 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
    • safari - Safari
    • opera - Opera
    • Chrome - Google Chrome.
  7. exceptions=n - to stop model execution when number of failures detected exceeds n
  8. initVars=v1:xyz;v2:abc - to initialize user variables before the model execution starts
  9. iterations=n - to iterate model execution n times
  10. iterationDelay=n - to set a delay in minlliseconds between iterations
  11. threads=n - to set up multiple threads execution for load testing
  12. threadDelay=n - to set a delay in minlliseconds between thread startup to spread out the startup load on AUT
  13. mcase=mcaseName - name of the mcase to be executed
  14. modelVersion - to run a specific model version. This method requires exclusive lock on the model and thus it will fail if the model is already open by another session.
  15. notifyEmail=emailAddress - to send email notification upon completion to the address specified
  16. plugins= to set the plugin(s) to be activated for executing the models. This should be used with caution as disabling plugins required to run model may cause runtime error
  17. seed=num - positive integer, seed for the random number generator
  18. seqParams=params - parameters for the sequencers
  19. statDesc=description - to label the model execution stats, may not contain these chars: & = ; &
  20. stopMinutes=n - to stop model execution after n minutes of elapse time
  21. stopTraversals=n - to stop model execution after n transition traversals
  22. stopTransCoveragePct=n - to stop model execution after transition coverage reaches n%

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.
localServerOnly_p pass true/yes if the model must be run in the local server only.
Returns
  • model execution session id.
Throws
Exception
Exception
See Also
  • {@link #runModel(String, String, String, String)}
  • {@link #runModel(String, String, String, String, String)}
  • {@link #waitForCompletion(String, String, String)}

public String runModel (String modelName_p, String sequencer_p, String catCodes_p, String threadCount_p, String options_p)

Since: API Level v2

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 ; or &. The available options are:

  1. ALM=Y - to enable defect raise/update to ALM system if ALM plugin is activated
  2. autoClose=Y/N - to close the model automatically after model execution
  3. appURL=AUT URL/Command - to set the AUT URL or command start AUT
  4. batchID=n - to set the batchID for the model execution.
  5. batchGropu=groupName - to set the batchGroup for the model execution.
  6. 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
    • safari - Safari
    • opera - Opera
    • Chrome - Google Chrome.
  7. exceptions=n - to stop model execution when number of failures detected exceeds n
  8. initVars=v1:xyz;v2:abc - to initialize user variables before the model execution starts
  9. iterations=n - to iterate model execution n times
  10. iterationDelay=n - to set a delay in minlliseconds between iterations
  11. threads=n - to set up multiple threads execution for load testing
  12. threadDelay=n - to set a delay in minlliseconds between thread startup to spread out the startup load on AUT
  13. mcase=mcaseName - name of the mcase to be executed
  14. modelVersion - to run a specific model version. This method requires exclusive lock on the model and thus it will fail if the model is already open by another session.
  15. notifyEmail=emailAddress - to send email notification upon completion to the address specified
  16. plugins= to set the plugin(s) to be activated for executing the models. This should be used with caution as disabling plugins required to run model may cause runtime error
  17. seqParams=params - parameters for the sequencers
  18. seed=num - positive integer, seed for the random number generator
  19. statDesc=description - to label the model execution stats, may not contain these chars: & = ; &
  20. stopMinutes=n - to stop model execution after n minutes of elapse time
  21. stopTraversals=n - to stop model execution after n transition traversals
  22. stopTransCoveragePct=n - to stop model execution after transition coverage reaches n%

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
Exception
Exception
See Also
  • {@link #runModel(String, String, String, String)}
  • {@link #runModel(String, String, String, String, String, String)}
  • {@link #waitForCompletion(String, String, String)}

public String runModel (String modelName_p, String sequencer_p, String catCode_p, String threadCount_p)

Since: API Level v2

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
  • PathFinder
  • 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
Exception
Exception
See Also
  • {@link #runModel(String, String, String, String, String)}
  • {@link #runModel(String, String, String, String, String, String)}
  • {@link #waitForCompletion(String, String, String)}

public void setBatchDesc (String batchDesc_p)

Since: API Level v2

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')

Throws
Exception

public void setCheckIntervalMillis (String millis_p)

Since: API Level v2

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')

public void setRetryTimeoutMillis (String millis_p)

Since: API Level v2

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')

public void startBatchGroup (String batchGroup_p)

Since: API Level v2

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.

Throws
Exception

public void triggerTrans (String stateID_p, String transID_p)

Since: API Level v2

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')

Throws
Exception

public void triggerTrans (String stateID_p, String transID_p, String modelName_p)

Since: API Level v2

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')

Throws
MBTException

public String waitForBatchCompletion (String batchGroup_p, String timeoutMinutes_p)

Since: API Level v2

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:

$waitForBatchCompletion('IE_Group', '30')
The above expression 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".

Returns
  • ok for normal completion (with and without errors) or timeout if any executions had to be interrupted.
Throws
Exception on timeout

public String waitForBatchCompletion (String timeoutMinutes_p)

Since: API Level v2

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:

$waitForBatchCompletion('30')
The abobe expression 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".

Returns
  • ok for normal completion (with and without errors) or timeout if any executions had to be interrupted.
Throws
Exception on timeout

public String waitForCompletion (String sessionID_p, String timeoutMinutes_p, String stopOnTimeout_p)

Since: API Level v2

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
Exception