Hi,
I am trying to write my first Asterisk Testsuite test case. I don’t understand why I receive 404 response from asterisk instance 1.
My goal is that UAC call extension 2222 on ast2. Ext 2222 will answer the call and playback hello-world. Ext 2222 will then hangup the call, and UAC will reply 200 OK.
Topology:
UAC > ast1 > ast2
Is there anything wrong in general with my test case or configuration?
Best regards,
malacho
Configuration files:
run-test:
#!/usr/bin/env python
import sys
import os
import logging
sys.path.append("lib/python")
from asterisk.test_case import TestCase
from asterisk.sipp import SIPpScenario
from twisted.internet import reactor
LOGGER = logging.getLogger(__name__)
TEST_DIR = os.path.dirname(os.path.realpath(__file__))
class DialTest(TestCase):
def __init__(self):
super(DialTest, self).__init__()
self.events_passed = 0
self.expected_events_passed = 1
self.connectionEstablished = 0
self.create_asterisk(count=2)
self.sipp_scenario = {'scenario': 'dial.xml',
'-inf': 'users.csv'}
def ami_connect(self, ami):
TestCase.ami_connect(self, ami)
self.connectionEstablished += 1
if ami.id == 1:
self.ami[1].registerEvent('UserEvent', self.playback_event)
if self.connectionEstablished != 2:
return
LOGGER.warning("CONNECTIONS: {}".format(self.connectionEstablished))
self.execute_scenario()
def execute_scenario(self):
self.sipp_scenario = SIPpScenario(TEST_DIR, self.sipp_scenario)
self.sipp_scenario.run(self)
def playback_event(self, ami, event):
if event['userevent'] != 'PlaybackResult':
return
if event['result'] == "pass":
self.events_passed += 1
self.check_passed()
def check_passed(self):
LOGGER.warning("CHECK_EVENTS_PASSED: {}".format(self.events_passed))
if self.events_passed == self.expected_events_passed:
self.set_passed(True)
self.stop_reactor()
def run(self):
super(DialTest, self).run()
self.create_ami_factory(count=2)
def main():
test = DialTest()
reactor.run()
if not test.passed:
return 1
return 0
if __name__ == "__main__":
sys.exit(main())
ast1 sip.conf:
[general]
bindaddress=127.0.0.1
sipdebug=yes
disallow=all
allow=ulaw
[ast2]
type=friend
host=127.0.0.2
context=dialtest
qualify=no
insecure=invite
[1111]
type=friend
qualify=no
host=dynamic
context=dialtest
canreinvite=yes
insecure=invite
ast1 extensions.conf:
[dialtest]
exten => 2222,1,NoOp()
same => n,Dial(SIP/2222@ast2,20)
same => n,Hangup()
ast2 sip.conf:
[general]
bindaddress=127.0.0.2
sipdebug=yes
disallow=all
allow=ulaw
[ast1]
type=friend
host=127.0.0.1
context=ast2-incoming
qualify=no
insecure=invite
ast2 extensions.conf:
[ast2-incoming]
exten => 2222,1,NoOp()
same => n,Answer()
same => n,Playback(hello-world)
same => n,ExecIf($[${PLAYBACKSTATUS}=SUCCESS]?UserEvent(PlaybackResult,result:pass)
same => n,Hangup()
sipp xml:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE scenario SYSTEM "sipp.dtd">
<scenario name="Dial Test">
<send retrans="500">
<![CDATA[
INVITE sip:[field1]@[remote_ip]:[remote_port] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port]
From: [field0] <sip:[field0]@[local_ip]:[local_port]>;tag=[call_number]
To: [field1] <sip:[field1]@[remote_ip]:[remote_port]>
Call-ID: [call_id]
Cseq: 1 INVITE
Contact: sip:[field0]@[local_ip]:[local_port]
Content-Type: application/sdp
Content-Length: [len]
v=0
o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip]
s=-
t=0 0
c=IN IP[media_ip_type] [media_ip]
m=audio [media_port] RTP/AVP 0
a=rtpmap:0 PCMU/8000
]]>
</send>
<recv response="100" optional="true">
</recv>
<recv response="180" optional="true">
</recv>
<recv response="200">
</recv>
<send retrans="500">
<![CDATA[
ACK sip:[field1]@[remote_ip]:[remote_port] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port]
From: [field0] <sip:[field0]@[local_ip]:[local_port]>;tag=[call_number]
To: [field1] <sip:[field1]@[remote_ip]:[remote_port]>[peer_tag_param]
Call-ID: [call_id]
Cseq: 1 ACK
Contact: sip:[field0]@[local_ip]:[local_port]
Content-Length: 0
]]>
</send>
<recv request="BYE">
</recv>
<send retrans="500">
<![CDATA[
SIP/2.0 200 OK
[last_Via:]
[last_From:]
[last_To:]
[last_Call-ID:]
[last_CSeq:]
Contact: <sip:[local_ip]:[local_port];transport=[transport]>
Content-Length: 0
]]>
</send>
</scenario>
users.csv:
SEQUENTIAL
1111;2222;