Job Functions
The Job functions allow you to get information on the currently running job so that you can create tests that can work dynamically in relation to the current state of the simulation.
The various functions are listed below:
getRunSettings()
getRunSettings()
Use the getRunSettings()
function to retrieve the run settings for the currently running job. The function returns an object with all the data pertaining to the run settings.
jobClients()
jobClients()
This function returns the total number of clients that are being simulated in the current job.
jobId()
jobId()
Returns the assigned name of the simulation job. This could be used to store the results in a database.
jobInterval()
jobInterval()
Returns the time interval in seconds between each iteration.
jobRepeat()
jobRepeat()
Returns the total number of iterations specified in the job.
index() or iteration()
index() or iteration()
For the simulations, you will specify the number of iterations that a test should run for. To get the value of the current iteration that the simulation is in, you can use the index() or iteration() functions
client()
client()
For the simulations, you may need to implement client-specific behaviours. The current client ID can be determined within the test by using the client() function.
assert()
assert()
Usually, an iteration for a client will be marked as failed, when the client is unable to publish a message to the server within the given timeout period. However, there may be cases where you would like to declare a test as failed when certain criteria are not met.
When using IoTIFY for testing, you could force a test iteration to be failed even if message sending is successful using test assertion with the assert()
function.
The function takes two parameters:
condition: A boolean condition that should be tested for truth (true) message: A string describing the cause of assertion failure which can be stored in test results.
For example, the following statement checks for an assertion failure in your template and marks the test result as failed, if retval
does not equal to 123.
Last updated