Hello,<div><br></div><div>Thanks for the confirmation Matt. I had tested my testsuite with the same change but i was worried that it does not break anything.</div><div>The change proposed by you is working fine for me, so you can commit it. My only concern is that 'channels' executes the command</div>
<div>"core show channels", but in my test case, i need to check "sip show channels", but i guess it won't be difficult to define a new test condition,</div><div>i'll do it and if it works, i'll post it in the mailing list.</div>
<div><br></div><div>Regards,</div><div>Nitesh Bansal</div><div> <br><div class="gmail_quote">On Fri, Sep 28, 2012 at 3:54 PM, Matthew Jordan <span dir="ltr"><<a href="mailto:mjordan@digium.com" target="_blank">mjordan@digium.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
----- Original Message -----<br>
<br>
> From: "nitesh bansal" <<a href="mailto:nitesh.bansal@gmail.com">nitesh.bansal@gmail.com</a>><br>
> To: <a href="mailto:asterisk-dev@lists.digium.com">asterisk-dev@lists.digium.com</a><br>
> Sent: Friday, September 28, 2012 7:29:43 AM<br>
> Subject: [asterisk-dev] Question on the testconditions in the<br>
> asterisk testsuite<br>
<div><div class="h5"><br>
> Hello All,<br>
<br>
> I am using the asterisk test suite version 3478. I am writing some<br>
> tests for which i would like to validate the testcondition "<br>
> channels " after the test is executed and i tried defining the<br>
> condition in the test-config.yaml for that specific<br>
> test, but it did not work as it was undefined in the global<br>
> test-config.yaml. I would like to know is there a way to just enable<br>
> the condition for this particular test and not defining it in global<br>
> test-config.yaml, please let me know if it<br>
> is possible and if its not possible, is there any harm if i remove<br>
> the check for the definition of a testcondition in the global<br>
> test-config.yaml?<br>
<br>
</div></div>So, first of all: cool! I'm pretty excited that someone is making use<br>
of that feature in the Test Suite. You may want to be aware that the pre/post<br>
checking framework is a little on the 'bleeding edge' side of things, and<br>
usually takes some tweaking - and some knowledge of Asterisk to understand why<br>
things may be the way they are when a test finishes.<br>
<br>
Anyway, this does look like it could be viewed as a bug in the TestCase class.<br>
In general, the pre/post condition framework assumes you're turning it on for<br>
the Test Suite as a whole, and lets you tweak the settings on a test by test<br>
basis. The configuration of the pre/post-conditions grew a bit organically<br>
(they started off being only global, then got local overrides, then got aliases<br>
to the actual Python package/module to load and instantiate as people got tired<br>
of typing foo.bar.yackity all the time). I don't see any harm in letting tests<br>
define their conditions only locally if they so choose. To do so, you'd want to<br>
remove this snippet of code in TestCase:<br>
<br>
""" If there are no global conditions return """<br>
if (len(self.global_conditions) == 0):<br>
return<br>
<br>
I've removed it and set up a channel condition check in the dialplan test:<br>
<br>
properties:<br>
minversion: '1.8.0.0'<br>
dependencies:<br>
- python : 'twisted'<br>
- python : 'starpy'<br>
- asterisk : 'res_crypto'<br>
tags:<br>
- dialplan<br>
testconditions:<br>
- name: 'channels'<br>
allowedchannels: 0<br>
<br>
Note that you'll still need to define the actual 'channel' pre/post-condition<br>
in the global test-config.yaml:<br>
<br>
# Global settings<br>
global-settings:<br>
# The active test configuration. The value must match a subsequent key<br>
# in this file, which defines the global settings to apply to the test execution<br>
# run.<br>
test-configuration: config-standard<br>
<br>
# The following sequence defines for any test configuration the available pre-<br>
# and post-test conditions. The 'name' field specifies how the test configurations<br>
# refer to the pre- and post-test conditions in order to activate them.<br>
condition-definitions:<br>
-<br>
name: 'channels'<br>
pre:<br>
typename: 'asterisk.ChannelTestCondition.ChannelTestCondition'<br>
post:<br>
typename: 'asterisk.ChannelTestCondition.ChannelTestCondition'<br>
<br>
After doing this, running the dialplan test shows the channel condition object<br>
being created and run before and afer the test.<br>
<br>
[Sep 28 08:40:56] DEBUG[4840]: asterisk.TestConditions:117 evaluate_pre_checks: Evaluating pre checks<br>
[Sep 28 08:40:56] DEBUG[4840]: asterisk.TestConditions:172 __evaluate_check: Evaluating asterisk.ChannelTestCondition.ChannelTestCondition<br>
[Sep 28 08:40:56] DEBUG[4840]: asterisk.asterisk:590 cli_exec: Executing ['/usr/sbin/asterisk', '-C', '/tmp/asterisk-testsuite/dialplan/ast6/etc/asterisk/asterisk.conf', '-rx', 'core show channels'] ...<br>
[Sep 28 08:40:56] DEBUG[4840]: asterisk.asterisk:62 __cli_output_callback: Asterisk CLI 127.0.0.1 exited 0<br>
[Sep 28 08:40:56] DEBUG[4840]: asterisk.asterisk:63 __cli_output_callback: Channel Location State Application(Data)<br>
0 active channels<br>
0 active calls<br>
0 calls processed<br>
Asterisk ending (0).<br>
<br>
...<br>
<br>
<br>
[Sep 28 08:40:56] DEBUG[4840]: asterisk.TestConditions:133 evaluate_post_checks: Evaluating post checks<br>
[Sep 28 08:40:56] DEBUG[4840]: asterisk.TestConditions:172 __evaluate_check: Evaluating asterisk.ChannelTestCondition.ChannelTestCondition<br>
[Sep 28 08:40:56] DEBUG[4840]: asterisk.asterisk:590 cli_exec: Executing ['/usr/sbin/asterisk', '-C', '/tmp/asterisk-testsuite/dialplan/ast6/etc/asterisk/asterisk.conf', '-rx', 'core show channels'] ...<br>
[Sep 28 08:40:56] DEBUG[4840]: asterisk.asterisk:62 __cli_output_callback: Asterisk CLI 127.0.0.1 exited 0<br>
[Sep 28 08:40:56] DEBUG[4840]: asterisk.asterisk:63 __cli_output_callback: Channel Location State Application(Data)<br>
0 active channels<br>
0 active calls<br>
2 calls processed<br>
Asterisk ending (0).<br>
<br>
<br>
If you remove that code, I think your test should work. Note that your test<br>
does have to inherit from TestCase for the pre/post-condition checking framework<br>
to be enabled at all.<br>
<br>
If it does work for you, and you experience not other problems, let me know and<br>
I'll commit that change to TestCase.<br>
<br>
Thanks!<br>
<br>
--<br>
Matthew Jordan<br>
Digium, Inc. | Engineering Manager<br>
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA<br>
Check us out at: <a href="http://digium.com" target="_blank">http://digium.com</a> & <a href="http://asterisk.org" target="_blank">http://asterisk.org</a><br>
<br>
--<br>
_____________________________________________________________________<br>
-- Bandwidth and Colocation Provided by <a href="http://www.api-digital.com" target="_blank">http://www.api-digital.com</a> --<br>
<br>
asterisk-dev mailing list<br>
To UNSUBSCRIBE or update options visit:<br>
<a href="http://lists.digium.com/mailman/listinfo/asterisk-dev" target="_blank">http://lists.digium.com/mailman/listinfo/asterisk-dev</a><br>
</blockquote></div><br></div>