[asterisk-dev] Question on the SIPPTest class in the testsuite

Matthew Jordan mjordan at digium.com
Thu Oct 4 08:33:45 CDT 2012


On 10/04/2012 04:37 AM, nitesh bansal wrote:
> Hello All,
> 
> I am using SIPPTest class to write my own test cases in the asterisk
> testsuite. In most of the cases, run-test looks as follows
> 
> <<<<<<
> 
> SIPP_SCENARIOS = [
>     {'scenario' : 'uas.xml',},
>     {'scenario' : 'uac.xml',},
>     
> ]
> 
> 
> def main():
>     test = SIPpTest(WORKING_DIR, TEST_DIR, SIPP_SCENARIOS)
>     reactor.run()
>     if not test.passed:
>         return 1
> 
>     return 0
> 
>>>>>>>
> 
> All of my cases need Asterisk to go to the diaplan, but i have observed
> that somtimes, my SIPP test cases start running before asterisk has even
> loaded the dialplan, which causes testcas to fail.
> 
> Is there any work around for this situation.

The SIPpTest class automatically starts the SIPp scenarios when it
detects Asterisk has started.  This works well when you have SIPp
scenarios acting as a UAC that do not need to wait on a condition in
Asterisk to start.  Many SIP scenarios fall into that category.  The
SIPpTest class was written to accommodate those scenarios specifically.

If, however, you have a scenario where you need to initiate something in
Asterisk prior to starting the SIPp scenario, then the SIPpTest class is
probably not appropriate.  In that case, you may want to write a test
that utilizes a SIPp scenario in the framework of a "regular" TestCase
derived test.  You can use one of the following:

* SIPpScenario - manages a single SIPp instance.  This class provides
methods to control the SIPp instance, and to report on the
success/failure of the scenario.

* SIPpScenarioSequence - manage a sequential sequence of SIPpScenario
executions.  This is useful when you have multiple SIPp scenarios that
have slight differences in behavior.

There are a number of tests in the Test Suite that make use of these
classes - you may want to look at any of the following tests for examples:
* info_dtmf
* SDP_attribute_passthrough
* sip_hold
* Any of the sip_custom_presence tests

As an aside, if you ever do find yourself only needing the functionality
exposed by SIPpTest, the capability to define the test completely in
YAML was added to the Test Suite relatively recently.  The
channels/SIP/subscribe test demonstrates how to write such a test.

-- 
Matthew Jordan
Digium, Inc. | Engineering Manager
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
Check us out at: http://digium.com & http://asterisk.org





More information about the asterisk-dev mailing list