Under Construction
- Retry function
- Skip Case function
- Pause test function
- Custom Thread class
- CHO framework
Retry Function
Available from driver functions or test cases as utilities.retry, this function allows the test to retry a function when certain conditions are met.
The retry function takes several arguments:
- f - A callable object such as a function
- retValue - Return value(s) of f to retry on. This can be a list or an object.
- args - (Optional) A tuple containing the arguments of f.
- kwargs - (Optional) A dictionary containing the keyword arguments of f.
- sleep - (Optional) Time in seconds to sleep between retries. If random is True, this is the max time to wait. Defaults to 1 second.
- attempts - (Optional) Max number of attempts before returning. If set to 1, f will only be called once. Defaults to 2 trys.
- random - (Optional) Boolean indicating if the wait time is random between 0 and sleep or exactly sleep seconds. Defaults to False.
Example:
# Retry on onosdriver's isup function. Will call isup up to 5 times with a 5 second sleep in between attempts. started = utilities.retry( main.ONOSbench.isup, main.FALSE, kwargs={"node":"10.0.0.1"}, sleep=5, attempts=5 )
Skip Case
Will skip the rest of the code in a test case. The case results will be determined as normal based on completed assertions unless the result argument is given.
Optional Arguments:
- result - Case insensitive string. Can be 'PASS' or 'FAIL' and will set the case result accordingly.
- msg - Message to be printed when the case is skipped in the reports.
Example:
# Init Step if not result: main.skipCase() # Other steps that require Init Step to succeed