[asterisk-dev] [Code Review]: TestSuite pre- and post-test condition check framework

mjordan reviewboard at asterisk.org
Wed Sep 14 13:27:11 CDT 2011



> On Sept. 14, 2011, 1:06 p.m., Paul Belanger wrote:
> > /asterisk/trunk/lib/python/asterisk/TestCase.py, lines 206-211
> > <https://reviewboard.asterisk.org/r/1430/diff/1/?file=20541#file20541line206>
> >
> >     I'd like to see this moved outside the run() function, as this will add overhead to the tests reactor timeout.  Perhaps we can do this in start_asterisk()
> 
> mjordan wrote:
>     Not a problem.  Since each call to Asterisk::start blocks until we receive the 'wait fully booted', this shouldn't be a problem.

Although I would comment that this won't affect the reactor timeout, as we don't start the reactor timeout process until all the pre checks have fired.  But I'm good with it either way.


- mjordan


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/1430/#review4330
-----------------------------------------------------------


On Sept. 12, 2011, 12:01 p.m., mjordan wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/1430/
> -----------------------------------------------------------
> 
> (Updated Sept. 12, 2011, 12:01 p.m.)
> 
> 
> Review request for Asterisk Developers and Paul Belanger.
> 
> 
> Summary
> -------
> 
> This patch provides a framework for doing pre- and post-test condition checking for an individual test run.  This allows a test to take a snapshot of the state of its Asterisk instances before it executes and compare that against a snapshot of its Asterisk instances after the test executes.  Depending on the test configuration, the test can either pass or fail based on whether or not resources were left uncollected in Asterisk after test execution.
> 
> The place in the test workflow where the conditions are evaluated is shown below:
> main                   ConcreteTest   TestClass       TestConditionController
>  test.start_asterisk ----------------->start_asterisk
>                                          
>  reactor.run -------------> run
>                              |--------> run
>                                          |------------>evaluate_pre_checks()
>                                          |
> 
>  test.stop_asterisk ------------------>stop_asterisk
>                                          |------------>evaluate_post_checks()
>                                          | 
> 
> All pre- and post-test condition objects must inherit from the class TestCondition.  The objects are created dynamically using python reflection and registered as either a pre- or post- check based on the test-config.yaml file for each test.  Post TestConditions can be set to reference the Pre-Test condition object, such that the object is supplied to the post-test object during its evaluation.  This allows the post-test condition object to make its evaluation based on the initial state of Asterisk as captured by the pre-test object.  TestConditions are also allowed to have 'expected failure' states set to them, in case the tests in question are known to fail.
> 
> As part of this patch, a TestCondition set of objects were made to check for thread usage in Asterisk after a test.  The objects ensure that after a test run, the threads currently active in Asterisk are the same threads that were active prior to the test run.  The voicemail tests were updated to use this as an example.
> 
> Additionally, a few other enhancements were included with this patch:
> 1. A new class that allows tests to check what build options Asterisk was compiled with
> 2. Specifying the --test option now allows for a path to be specified as opposed to a specific test.  All tests under that path will be executed, e.g., --test=tests/channels/SIP/ will execute all SIP tests
> 3. XML returned by runtests.py now includes ERROR log statements in the Failure message attribute
> 4. Test configuration was moved to its own class in the asterisk libraries.  All TestClass-derived tests now have access to their configuration locally.
> 5. SIPpVersion was moved to the asterisk directory, as the other sipp related classes were already there and the TestConfig class in asterisk needed to reference it
> 
> 
> Diffs
> -----
> 
>   /asterisk/trunk/lib/python/asterisk/ThreadTestCondition.py PRE-CREATION 
>   /asterisk/trunk/lib/python/asterisk/buildoptions.py PRE-CREATION 
>   /asterisk/trunk/lib/python/asterisk/TestState.py 2176 
>   /asterisk/trunk/lib/python/asterisk/TestConditions.py PRE-CREATION 
>   /asterisk/trunk/lib/python/asterisk/TestConfig.py PRE-CREATION 
>   /asterisk/trunk/lib/python/asterisk/TestCase.py 2176 
>   /asterisk/trunk/lib/python/asterisk/sippversion.py PRE-CREATION 
>   /asterisk/trunk/lib/python/sipp/version.py 2090 
>   /asterisk/trunk/runtests.py 2090 
>   /asterisk/trunk/tests/apps/voicemail/authenticate_nominal/run-test 2177 
>   /asterisk/trunk/tests/apps/voicemail/authenticate_nominal/test-config.yaml 2094 
>   /asterisk/trunk/tests/apps/voicemail/check_voicemail_new_user/configs/ast1/extensions.conf 2094 
>   /asterisk/trunk/tests/apps/voicemail/check_voicemail_new_user/run-test 2176 
>   /asterisk/trunk/tests/apps/voicemail/check_voicemail_new_user/test-config.yaml 2094 
>   /asterisk/trunk/tests/apps/voicemail/check_voicemail_nominal/configs/ast1/extensions.conf 2094 
>   /asterisk/trunk/tests/apps/voicemail/check_voicemail_nominal/test-config.yaml 2094 
>   /asterisk/trunk/tests/apps/voicemail/func_vmcount/configs/ast1/extensions.conf 2094 
>   /asterisk/trunk/tests/apps/voicemail/func_vmcount/test-config.yaml 2094 
>   /asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/test-config.yaml 2094 
> 
> Diff: https://reviewboard.asterisk.org/r/1430/diff
> 
> 
> Testing
> -------
> 
> trunk on local system.
> 
> 
> Thanks,
> 
> mjordan
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20110914/a6768e72/attachment.htm>


More information about the asterisk-dev mailing list