[asterisk-dev] [Code Review] 4452: Testsuite: ARI channel subscription tests

jbigelow reviewboard at asterisk.org
Thu Mar 5 20:51:31 CST 2015



> On March 5, 2015, 1:53 p.m., Ashley Sanders wrote:
> > /asterisk/trunk/tests/rest_api/applications/channel-subscriptions/originate_to_dialplan/non_local_channels/test-config.yaml, line 5
> > <https://reviewboard.asterisk.org/r/4452/diff/2/?file=71751#file71751line5>
> >
> >     You are missing the description for the "Extension, Priority, Label, Context" case.

That is covered by this on line 13:
* All of the above repeated, this time specifying a context.


> On March 5, 2015, 1:53 p.m., Ashley Sanders wrote:
> > /asterisk/trunk/tests/rest_api/applications/channel-subscriptions/originate_to_other_stasis_app/non_local_channels/run-test, line 173
> > <https://reviewboard.asterisk.org/r/4452/diff/2/?file=71759#file71759line173>
> >
> >     I think I would rework this to either use this structure (which is used throughout this file), or the self.orig_dst_app and self.orig_src_app variables. From what I can tell, this is redundant.

Yea it could be redundant but I specifically did it this way so that it's easier to understand what specifically the test is doing and easier to just specify the apps and the src/dst apps as in different combinations if ever reused.


> On March 5, 2015, 1:53 p.m., Ashley Sanders wrote:
> > /asterisk/trunk/tests/rest_api/applications/channel-subscriptions/originate_to_other_stasis_app/non_local_channels/run-test, line 174
> > <https://reviewboard.asterisk.org/r/4452/diff/2/?file=71759#file71759line174>
> >
> >     Curious, what is the purpose of having a temporary variable at the class level?

See comment regarding issue opened on line 206.


> On March 5, 2015, 1:53 p.m., Ashley Sanders wrote:
> > /asterisk/trunk/tests/rest_api/applications/channel-subscriptions/originate_to_other_stasis_app/non_local_channels/run-test, line 206
> > <https://reviewboard.asterisk.org/r/4452/diff/2/?file=71759#file71759line206>
> >
> >     You could use a temporary variable here, in the local scope, w/o having to rely on something at the class level.

self.tmp_app_names is an instance variable which is used by both the run() and protocol_connected() methods.


> On March 5, 2015, 1:53 p.m., Ashley Sanders wrote:
> > /asterisk/trunk/tests/rest_api/applications/channel-subscriptions/originate_to_other_stasis_app/non_local_channels/run-test, line 67
> > <https://reviewboard.asterisk.org/r/4452/diff/2/?file=71759#file71759line67>
> >
> >     Just an observation... 
> >     
> >     Here, you are using the reStructuredText (reST) style for your docstring (with the :param), but you don't use that style on line 58 (or anywhere else from what I can tell).

Yea this was copied from another test. Fixed.


> On March 5, 2015, 1:53 p.m., Ashley Sanders wrote:
> > /asterisk/trunk/lib/python/asterisk/pjsua_mod.py, line 140
> > <https://reviewboard.asterisk.org/r/4452/diff/2/?file=71748#file71748line140>
> >
> >     Suggestion, you could remove the ua_cfg variable on line 136 and here, on line 140, use: self.lib.init(ua_cfg=pj.UAConfig())
> >     
> >     I checked and you aren't using the ua_cfg variable anywhere else that I can tell.

I'm using 'ua_cfg' to be able to set max_calls.


On March 5, 2015, 1:53 p.m., jbigelow wrote:
> > I see a lot of duplication in the run-test files. I suggest that we refactor and abstract the common pieces of code into a base class somewhere. For instance the check_results function could be abstracted and I saw a couple of more instances where we could apply some smart refactoring such that reuse would be possible.
> 
> Ashley Sanders wrote:
>     Also, if these tests are copies of other tests, with a few tweaks for this particular use-case, that would be a good reason to consider pushing some of this logic into lib/python.

There is duplication for the two tests with the run-test files. There is also some duplication between them and the test tests/rest_api/channels/redirect/nominal/run-test that was used as a base. Needing to create multiple websocket connections doesn't happen to often and I don't believe it will be needed much, at least in the short term. Therefore I'm not sure if refactoring and creating a library for just a few tests is worth the effort at this point. But if and when more tests need this functionality then it would be a good time then.


- jbigelow


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


On March 4, 2015, 12:58 p.m., jbigelow wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/4452/
> -----------------------------------------------------------
> 
> (Updated March 4, 2015, 12:58 p.m.)
> 
> 
> Review request for Asterisk Developers.
> 
> 
> Bugs: ASTERISK-24586
>     https://issues.asterisk.org/jira/browse/ASTERISK-24586
> 
> 
> Repository: testsuite
> 
> 
> Description
> -------
> 
> This adds some local and non-local channel subscription tests for ARI. These tests ensure ARI events occur and/or don't occur for the appropriate stasis app(s). Due to the variations and small differences of these, the test-config.yaml descriptions of each is the best way to describe what they do.
> 
> Four tests have been added under 'tests/rest_api/applications/channel-subscriptions/'. :
> * originate_to_dialplan/non_local_channels - Similiar to the existing test that this patch modifies as mentioned below. This required modifying pjsua_mod.py to allow more calls.
> * originate_to_other_stasis_app/local_channels - Creates two websockets, one for for each stasis app. Originates a local channel from AppA where half is sent into AppB and the other half send into the dialplan.
> * originate_to_other_stasis_app/non_local_channels - Creates two websockets, one for for each stasis app. Originates a PJSIP channel from AppA to a pjsua phone where is is placed into AppB.
> * originate_to_stasis_app/local_channels
> 
> Note:  The test 'tests/rest_api/applications/subscribe-channel' test has been renamed to 'basic-subscribe' under the same location as the new tests. 
> 
> The following test has been modified to ensure no ARI events are received:
> * tests/rest_api/channels/originate_to_dialplan
> 
> 
> Diffs
> -----
> 
>   /asterisk/trunk/tests/rest_api/channels/originate_to_dialplan/test-config.yaml 6475 
>   /asterisk/trunk/tests/rest_api/applications/tests.yaml 6475 
>   /asterisk/trunk/tests/rest_api/applications/subscribe-channel/test-config.yaml 6475 
>   /asterisk/trunk/tests/rest_api/applications/subscribe-channel/subscribe_channel.py 6475 
>   /asterisk/trunk/tests/rest_api/applications/subscribe-channel/configs/ast1/extensions.conf 6475 
>   /asterisk/trunk/tests/rest_api/applications/channel-subscriptions/tests.yaml PRE-CREATION 
>   /asterisk/trunk/tests/rest_api/applications/channel-subscriptions/originate_to_stasis_app/tests.yaml PRE-CREATION 
>   /asterisk/trunk/tests/rest_api/applications/channel-subscriptions/originate_to_stasis_app/local_channels/test-config.yaml PRE-CREATION 
>   /asterisk/trunk/tests/rest_api/applications/channel-subscriptions/originate_to_stasis_app/local_channels/configs/ast1/extensions.conf PRE-CREATION 
>   /asterisk/trunk/tests/rest_api/applications/channel-subscriptions/originate_to_other_stasis_app/tests.yaml PRE-CREATION 
>   /asterisk/trunk/tests/rest_api/applications/channel-subscriptions/originate_to_other_stasis_app/non_local_channels/test-config.yaml PRE-CREATION 
>   /asterisk/trunk/tests/rest_api/applications/channel-subscriptions/originate_to_other_stasis_app/non_local_channels/run-test PRE-CREATION 
>   /asterisk/trunk/tests/rest_api/applications/channel-subscriptions/originate_to_other_stasis_app/non_local_channels/configs/ast1/pjsip.conf PRE-CREATION 
>   /asterisk/trunk/tests/rest_api/applications/channel-subscriptions/originate_to_other_stasis_app/non_local_channels/configs/ast1/http.conf PRE-CREATION 
>   /asterisk/trunk/tests/rest_api/applications/channel-subscriptions/originate_to_other_stasis_app/local_channels/test-config.yaml PRE-CREATION 
>   /asterisk/trunk/tests/rest_api/applications/channel-subscriptions/originate_to_other_stasis_app/local_channels/run-test PRE-CREATION 
>   /asterisk/trunk/tests/rest_api/applications/channel-subscriptions/originate_to_other_stasis_app/local_channels/configs/ast1/http.conf PRE-CREATION 
>   /asterisk/trunk/tests/rest_api/applications/channel-subscriptions/originate_to_other_stasis_app/local_channels/configs/ast1/extensions.conf PRE-CREATION 
>   /asterisk/trunk/tests/rest_api/applications/channel-subscriptions/originate_to_dialplan/tests.yaml PRE-CREATION 
>   /asterisk/trunk/tests/rest_api/applications/channel-subscriptions/originate_to_dialplan/non_local_channels/test-config.yaml PRE-CREATION 
>   /asterisk/trunk/tests/rest_api/applications/channel-subscriptions/originate_to_dialplan/non_local_channels/configs/ast1/pjsip.conf PRE-CREATION 
>   /asterisk/trunk/tests/rest_api/applications/channel-subscriptions/originate_to_dialplan/non_local_channels/configs/ast1/extensions.conf PRE-CREATION 
>   /asterisk/trunk/lib/python/asterisk/pjsua_mod.py 6475 
> 
> Diff: https://reviewboard.asterisk.org/r/4452/diff/
> 
> 
> Testing
> -------
> 
> * Executed each test successfully 30+ times.
> * Changed the code to force a failure to ensure tests properly failed.
> * Review logs to ensure operation is as expected.
> 
> 
> Thanks,
> 
> jbigelow
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20150306/bcda42cd/attachment-0001.html>


More information about the asterisk-dev mailing list