Hello All,<div><br></div><div>I have got the &quot;sip show channels&quot; working for me in the testsuite. I have defined a new testcondition sip-channels. Please find the global test-config.yaml defining this condition and python class</div>
<div>implementing the behaviour for this condition. I would request you to have a look at the code and if it seems fine then i assume there is no harm in merging this code in testsuite trunk.</div><div><br></div><div>Regards,</div>
<div>Nitesh Bansal<br><br><div class="gmail_quote">On Fri, Sep 28, 2012 at 4:41 PM, nitesh bansal <span dir="ltr">&lt;<a href="mailto:nitesh.bansal@gmail.com" target="_blank">nitesh.bansal@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">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 &#39;channels&#39; executes the command</div>
<div>&quot;core show channels&quot;, but in my test case, i need to check &quot;sip show channels&quot;, but i guess it won&#39;t be difficult to define a new test condition,</div><div>i&#39;ll do it and if it works, i&#39;ll post it in the mailing list.</div>

<div><br></div><div>Regards,</div><div>Nitesh Bansal</div><div class="HOEnZb"><div class="h5"><div> <br><div class="gmail_quote">On Fri, Sep 28, 2012 at 3:54 PM, Matthew  Jordan <span dir="ltr">&lt;<a href="mailto:mjordan@digium.com" target="_blank">mjordan@digium.com</a>&gt;</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>
&gt; From: &quot;nitesh bansal&quot; &lt;<a href="mailto:nitesh.bansal@gmail.com" target="_blank">nitesh.bansal@gmail.com</a>&gt;<br>
&gt; To: <a href="mailto:asterisk-dev@lists.digium.com" target="_blank">asterisk-dev@lists.digium.com</a><br>
&gt; Sent: Friday, September 28, 2012 7:29:43 AM<br>
&gt; Subject: [asterisk-dev] Question on the testconditions in the<br>
&gt; asterisk testsuite<br>
<div><div><br>
&gt; Hello All,<br>
<br>
&gt; I am using the asterisk test suite version 3478. I am writing some<br>
&gt; tests for which i would like to validate the testcondition &quot;<br>
&gt; channels &quot; after the test is executed and i tried defining the<br>
&gt; condition in the test-config.yaml for that specific<br>
&gt; test, but it did not work as it was undefined in the global<br>
&gt; test-config.yaml. I would like to know is there a way to just enable<br>
&gt; the condition for this particular test and not defining it in global<br>
&gt; test-config.yaml, please let me know if it<br>
&gt; is possible and if its not possible, is there any harm if i remove<br>
&gt; the check for the definition of a testcondition in the global<br>
&gt; test-config.yaml?<br>
<br>
</div></div>So, first of all: cool!  I&#39;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 &#39;bleeding edge&#39; 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&#39;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&#39;t see any harm in letting tests<br>
define their conditions only locally if they so choose.  To do so, you&#39;d want to<br>
remove this snippet of code in TestCase:<br>
<br>
        &quot;&quot;&quot; If there are no global conditions return &quot;&quot;&quot;<br>
        if (len(self.global_conditions) == 0):<br>
            return<br>
<br>
I&#39;ve removed it and set up a channel condition check in the dialplan test:<br>
<br>
properties:<br>
    minversion: &#39;1.8.0.0&#39;<br>
    dependencies:<br>
        - python : &#39;twisted&#39;<br>
        - python : &#39;starpy&#39;<br>
        - asterisk : &#39;res_crypto&#39;<br>
    tags:<br>
        - dialplan<br>
    testconditions:<br>
        - name: &#39;channels&#39;<br>
          allowedchannels: 0<br>
<br>
Note that you&#39;ll still need to define the actual &#39;channel&#39; 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 &#39;name&#39; 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: &#39;channels&#39;<br>
                pre:<br>
                    typename: &#39;asterisk.ChannelTestCondition.ChannelTestCondition&#39;<br>
                post:<br>
                    typename: &#39;asterisk.ChannelTestCondition.ChannelTestCondition&#39;<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 [&#39;/usr/sbin/asterisk&#39;, &#39;-C&#39;, &#39;/tmp/asterisk-testsuite/dialplan/ast6/etc/asterisk/asterisk.conf&#39;, &#39;-rx&#39;, &#39;core show channels&#39;] ...<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 [&#39;/usr/sbin/asterisk&#39;, &#39;-C&#39;, &#39;/tmp/asterisk-testsuite/dialplan/ast6/etc/asterisk/asterisk.conf&#39;, &#39;-rx&#39;, &#39;core show channels&#39;] ...<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&#39;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> &amp; <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>
</div></div></blockquote></div><br></div>