<html>
<head>
<base href="https://wiki.asterisk.org/wiki">
<link rel="stylesheet" href="/wiki/s/en/2172/18/9/_/styles/combined.css?spaceKey=AST&forWysiwyg=true" type="text/css">
</head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
<h2><a href="https://wiki.asterisk.org/wiki/display/AST/Basic+Test+with+SIPp">Basic Test with SIPp</a></h2>
<h4>Page <b>added</b> by <a href="https://wiki.asterisk.org/wiki/display/~mjordan">Matt Jordan</a>
</h4>
<br/>
<div class="notificationGreySide">
<h2><a name="BasicTestwithSIPp-Introduction"></a>Introduction</h2>
<p>When are you writing a "Basic" test with SIPp?</p>
<ul>
        <li>When you only want to execute a SIPp scenario, and do not need any information from Asterisk itself to determine the pass/fail status of the test.</li>
        <li>When you have large numbers of related SIPp scenarios that do not need information from Asterisk.</li>
</ul>
<p>Lets assume we would like to test a nominal SIP REGISTER request. A very simple SIPp scenario can be used for this purpose. Note that this only tests that Asterisk can receive a REGISTER request and reply back with a "200 OK" response, not whether or not Asterisk has created a SIP peer internally or performed any decisions based on the receiving of the REGISTER request.</p>
<h2><a name="BasicTestwithSIPp-SIPpScenario"></a>SIPp Scenario</h2>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false"><?xml version="1.0" encoding="ISO-8859-1" ?>
<scenario name="UAC Register">
<send retrans="500">
<![CDATA[
REGISTER sip:v4-in@[remote_ip]:[remote_port] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: v4-in <sip:v4-in@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]
To: <sip:v4-in@[remote_ip]:[remote_port]>
Call-ID: [call_id]
CSeq: 1 REGISTER
Contact: sip:v4-in@[local_ip]:[local_port]
Max-Forwards: 70
Subject: REGISTER Test
Expires: 3600
Content-Length: 0
]]>
</send>
<recv response="200" rtd="true" />
</scenario></pre>
</div></div>
<h2><a name="BasicTestwithSIPp-AsteriskConfiguration"></a>Asterisk Configuration</h2>
<p>Since the SIPp scenario is attempting a REGISTER request for v4-in, we must have a corresponding sip.conf configuration file defining the peer.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false">[general]
bindaddr=[::]:5060
[v4-in]
type=friend
host=dynamic</pre>
</div></div>
<h2><a name="BasicTestwithSIPp-AsteriskTestSuiteruntest"></a>Asterisk Test Suite run-test</h2>
<p>The Asterisk Test Suite provides a class, SIPpTest, that inherits from TestCase and will automatically run a set of SIPp scenarios. The class looks for the scenarios in the 'sipp' folder and will execute the scenarios in parallel on a single instance of Asterisk. The results of the test are directly related to the success/failure of the SIPp scenario - if all scenarios pass, the test passes; if any scenario fails, the test fails. Creating a <em>run-test</em> script that executes a SIPp scenario is thus exceedingly simple.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false">#!/usr/bin/env python
import sys
import os
sys.path.append("lib/python")
from twisted.internet import reactor
from asterisk.sipp import SIPpTest
WORKING_DIR = "channels/SIP/sip_register"
TEST_DIR = os.path.dirname(os.path.realpath(__file__))
SIPP_SCENARIOS = [
{
'scenario' : 'registerv4.xml'
},
]
def main():
test = SIPpTest(WORKING_DIR, TEST_DIR, SIPP_SCENARIOS)
reactor.run()
if not test.passed:
return 1
return 0
if __name__ == "__main__":
sys.exit(main())</pre>
</div></div>
<div class='panelMacro'><table class='noteMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/wiki/images/icons/emoticons/warning.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>Any number of scenarios can be passed to the SIPpTest. The class takes in as its third parameter a list of dictionaries, where each dictionary specifies a scenario to execute.</td></tr></table></div>
</div>
<div id="commentsSection" class="wiki-content pageSection">
<div style="float: right;" class="grey">
<a href="https://wiki.asterisk.org/wiki/users/removespacenotification.action?spaceKey=AST">Stop watching space</a>
<span style="padding: 0px 5px;">|</span>
<a href="https://wiki.asterisk.org/wiki/users/editmyemailsettings.action">Change email notification preferences</a>
</div>
<a href="https://wiki.asterisk.org/wiki/display/AST/Basic+Test+with+SIPp">View Online</a>
|
<a href="https://wiki.asterisk.org/wiki/display/AST/Basic+Test+with+SIPp?showComments=true&showCommentArea=true#addcomment">Add Comment</a>
</div>
</div>
</div>
</div>
</div>
</body>
</html>