avocado
avocado copied to clipboard
Multiple timeouts within a test
Is your feature request related to a problem? Please describe. On more complex (and thus usually) longer tests, there may be multiple steps to complete. It may be known that some of these steps should not take more than a small percentage of the overall expected time for the test as whole. Example:
class MyTest(Test):
TIMETOUT = 100
def test(self):
# stimulation of a few bytes of entropy should not take
# more than 5 seconds
generate_entropy()
# the bulk of the work in the test is here, and can take
# as much as 90 seconds
verify_crypto_functions()
In the current situation, with a single TIMEOUT
per test, generate_entropy()
could take 20 times longer before the test is considered timed out.
Describe the solution you'd like Support for defining timeouts for different parts of the test, such as:
class MyTest(Test):
TIMETOUT = 100
def test(self):
# stimulation of a few bytes of entropy should not take
# more than 5 seconds
with wait_max(5):
generate_entropy()
# the bulk of the work in the test is here, and can take
# as much as 90 seconds
verify_crypto_functions()
The wait_max()
context manager would raise an exception if generate_entropy()
takes longer than 5 seconds. This exception should be treated by the runner so that the test ends with a proper INTERRUPTED
status and a description of where it timed out.
Additional information This feature is being proposed based on the discussions and requirements defined in https://gitlab.com/avocado-framework/dovetail/-/issues/4