Skip to content
Snippets Groups Projects
Commit 66b08677 authored by Alexandre Savard's avatar Alexandre Savard
Browse files

[#2536] IP2IP call test suite

parent 8b644438
No related branches found
No related tags found
No related merge requests found
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE scenario SYSTEM "sipp.dtd">
<!-- This program is free software; you can redistribute it and/or -->
<!-- modify it under the terms of the GNU General Public License as -->
<!-- published by the Free Software Foundation; either version 2 of the -->
<!-- License, or (at your option) any later version. -->
<!-- -->
<!-- This program is distributed in the hope that it will be useful, -->
<!-- but WITHOUT ANY WARRANTY; without even the implied warranty of -->
<!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -->
<!-- GNU General Public License for more details. -->
<!-- -->
<!-- You should have received a copy of the GNU General Public License -->
<!-- along with this program; if not, write to the -->
<!-- Free Software Foundation, Inc., -->
<!-- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -->
<scenario name="accountcall_client">
<send retrans="500">
<![CDATA[
REGISTER sip:[remote_ip] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];rport;branch=[branch]
Max-Forward: 70
From: <sip:27182@[remote_ip]:[remote_port]>;tag=[call_number]
To: <sip:27182@[remote_ip]:[remote_port]>
Call-ID: REG///[call_id]
CSeq: 1 REGISTER
Contact: <sip:27182@[remote_ip]:[remote_port]>
Content-Length: 0
Expires: 300
]]>
</send>
<recv response="401" auth="true">
</recv>
<send retrans="500">
<![CDATA[
REGISTER sip:[remote_ip] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];rport;branch=[branch]
Max-Forwards: 70
From: <sip:27182@[remote_ip]:[remote_port]>;tag=[call_number]
To: <sip:27182@[remote_ip]:[remote_port]>
Call-ID: REG///[call_id]
CSeq: 2 REGISTER
Contact: <sip:27182@[remote_ip]:[remote_port]>
Content-Length: 0
Expires: 300
[authentication username=27182 password=1234]
]]>
</send>
<recv response="200">
</recv>
<pause milliseconds="200"/>
<send retrans="500">
<![CDATA[
INVITE sip:2000@[remote_ip] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];rport;branch=[branch]
From: <sip:27182@[remote_ip]:[remote_port]>;tag=[call_number]
To: <sip:2000@[remote_ip]:[remote_port]>
Call-ID: [call_id]
CSeq: 3 INVITE
Contact: sip:27182@[local_ip]:[local_port]
Max-Forwards: 70
Subject: Functional Test
Content-Type: application/sdp
Content-Length: [len]
v=0
o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip]
s=-
c=IN IP[media_ip_type] [media_ip]
t=0 0
m=audio [media_port] RTP/AVP 0
a=rtpmap:0 PCMU/8000
]]>
</send>
<recv response="401" auth="true">
</recv>
<pause milliseconds="200"/>
<send>
<![CDATA[
ACK sip:27182@[remote_ip] SIP/2.0
Max-Forwards: 70
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: <sip:27182@[remote_ip]:[remote_port]>;tag=[call_number]
To: <sip:2000@[remote_ip]:[remote_port]>
Call-ID: [call_id]
CSeq: 4 ACK
Subject: Functional Test
Content-Length: 0
]]>
</send>
<send retrans="500">
<![CDATA[
INVITE sip:2000@[remote_ip] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];rport;branch=[branch]
From: <sip:27182@:[remote_ip]:[remote_port]>;tag=[call_number]
To: <sip:2000@[remote_ip]:[remote_port]>
Call-ID: [call_id]
CSeq: 5 INVITE
Contact: sip:27182@[local_ip]:[local_port]
Max-Forwards: 70
Subject: Functional Test
Content-Type: application/sdp
Content-Length: [len]
[authentication username=27182 password=1234]
v=0
o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip]
s=-
c=IN IP[media_ip_type] [media_ip]
t=0 0
m=audio [media_port] RTP/AVP 0
a=rtpmap:0 PCMU/8000
]]>
</send>
<recv response="100">
</recv>
<recv response="180">
</recv>
<recv response="200">
</recv>
<send>
<![CDATA[
ACK sip:2000@192.168.50.79 SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: <sip:27182@[local_ip]:[local_port]>;tag=[call_number]
To: <sip:2000@192.168.50.79:[remote_port]>
Call-ID: [call_id]
CSeq: 5 ACK
Contact: sip:27182@[local_ip]:[local_port]
Max-Forwards: 70
Subject: Functional Test
Content-Length: 0
]]>
</send>
<send retrans="500">
<![CDATA[
BYE sip:2000@192.168.50.79 SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: <sip:27182@[local_ip]:[local_port]>;tag=[call_number]
To: <sip:2000@192.168.50.79:[remote_port]>
Call-ID: [call_id]
CSeq: 6 BYE
Contact: sip:27182@[local_ip]:[local_port]
Max-Forwards: 70
Subject: Functional Test
Content-Length: 0
]]>
</send>
<recv response="200">
</recv>
<pause milliseconds="1000"/>
</scenario>
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE scenario SYSTEM "sipp.dtd">
<!-- This program is free software; you can redistribute it and/or -->
<!-- modify it under the terms of the GNU General Public License as -->
<!-- published by the Free Software Foundation; either version 2 of the -->
<!-- License, or (at your option) any later version. -->
<!-- -->
<!-- This program is distributed in the hope that it will be useful, -->
<!-- but WITHOUT ANY WARRANTY; without even the implied warranty of -->
<!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -->
<!-- GNU General Public License for more details. -->
<!-- -->
<!-- You should have received a copy of the GNU General Public License -->
<!-- along with this program; if not, write to the -->
<!-- Free Software Foundation, Inc., -->
<!-- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -->
<scenario name="accountcall_client">
<send retrans="500">
<![CDATA[
REGISTER sip:[remote_ip] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];rport;branch=[branch]
Max-Forward: 70
From: <sip:27182@[remote_ip]:[remote_port]>;tag=[call_number]
To: <sip:27182@[remote_ip]:[remote_port]>
Call-ID: REG///[call_id]
CSeq: 1 REGISTER
Contact: <sip:27182@[remote_ip]:[remote_port]>
Content-Length: 0
Expires: 300
]]>
</send>
<recv response="401" auth="true">
</recv>
<send retrans="500">
<![CDATA[
REGISTER sip:[remote_ip] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];rport;branch=[branch]
Max-Forwards: 70
From: <sip:27182@[remote_ip]:[remote_port]>;tag=[call_number]
To: <sip:27182@[remote_ip]:[remote_port]>
Call-ID: REG///[call_id]
CSeq: 2 REGISTER
Contact: <sip:27182@[remote_ip]:[remote_port]>
Content-Length: 0
Expires: 300
[authentication username=27182 password=1234]
]]>
</send>
<recv response="200">
</recv>
<recv request="INVITE">
</recv>
<recv response="401" auth="true">
</recv>
<send>
<![CDATA[
SIP/2.0 180 Ringing
[last_Via:]
[last_From:]
[last_To:];tag=[call_number]
[last_Call-ID:]
[last_CSeq:]
Contact: <sip:[local_ip]:[local_port];transport=[transport]>
Content-Length: 0
]]>
</send>
<pause milliseconds="200"/>
<send retrans="500">
<![CDATA[
SIP/2.0 200 OK
[last_Via:]
[last_From:]
[last_To:];tag=[call_number]
[last_Call-ID:]
[last_CSeq:]
Contact: <sip:[local_ip]:[local_port];transport=[transport]>
Content-Type: application/sdp
Content-Length: [len]
v=0
o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip]
s=-
c=IN IP[media_ip_type] [media_ip]
t=0 0
m=audio [media_port] RTP/AVP 0
a=rtpmap:0 PCMU/8000
]]>
</send>
<recv request="ACK">
</recv>
<recv request="BYE">
</recv>
<send retrans="500">
<![CDATA[
SIP/2.0 200 OK
[last_Via:]
[last_From:]
[last_To:];tag=[call_number]
[last_Call-ID:]
[last_CSeq:]
Contact: <sip:[local_ip]:[local_port];transport=[transport]>
Content-Type: application/sdp
Content-Length: [len]
v=0
o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip]
s=-
c=IN IP[media_ip_type] [media_ip]
t=0 0
m=audio [media_port] RTP/AVP 0
a=rtpmap:0 PCMU/8000
]]>
</send>
</scenario>
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE scenario SYSTEM "sipp.dtd">
<!-- This program is free software; you can redistribute it and/or -->
<!-- modify it under the terms of the GNU General Public License as -->
<!-- published by the Free Software Foundation; either version 2 of the -->
<!-- License, or (at your option) any later version. -->
<!-- -->
<!-- This program is distributed in the hope that it will be useful, -->
<!-- but WITHOUT ANY WARRANTY; without even the implied warranty of -->
<!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -->
<!-- GNU General Public License for more details. -->
<!-- -->
<!-- You should have received a copy of the GNU General Public License -->
<!-- along with this program; if not, write to the -->
<!-- Free Software Foundation, Inc., -->
<!-- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -->
<scenario name="accountcall_client">
<send retrans="500">
<![CDATA[
INVITE sip:[remote_ip] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];rport;branch=[branch]
From: <sip:[remote_ip]:[remote_port]>;tag=[call_number]
To: <sip:[remote_ip]:[remote_port]>
Call-ID: [call_id]
CSeq: 1 INVITE
Contact: sip:[local_ip]:[local_port]
Max-Forwards: 70
Subject: Functional Test
Content-Type: application/sdp
Content-Length: [len]
v=0
o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip]
s=-
c=IN IP[media_ip_type] [media_ip]
t=0 0
m=audio [media_port] RTP/AVP 0
a=rtpmap:0 PCMU/8000
]]>
</send>
<recv response="100" optional="true">
</recv>
<recv response="180">
</recv>
<recv response="200">
</recv>
<send>
<![CDATA[
ACK sip:192.168.50.79 SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: <sip:[local_ip]:[local_port]>;tag=[call_number]
To: <sip:192.168.50.79:[remote_port]>
Call-ID: [call_id]
CSeq: 2 ACK
Contact: sip:[local_ip]:[local_port]
Max-Forwards: 70
Subject: Functional Test
Content-Length: 0
]]>
</send>
<send retrans="500">
<![CDATA[
BYE sip:192.168.50.79 SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: <sip:[local_ip]:[local_port]>;tag=[call_number]
To: <sip:192.168.50.79:[remote_port]>
Call-ID: [call_id]
CSeq: 3 BYE
Contact: sip:[local_ip]:[local_port]
Max-Forwards: 70
Subject: Functional Test
Content-Length: 0
]]>
</send>
<recv response="200">
</recv>
<pause milliseconds="1000"/>
</scenario>
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE scenario SYSTEM "sipp.dtd">
<!-- This program is free software; you can redistribute it and/or -->
<!-- modify it under the terms of the GNU General Public License as -->
<!-- published by the Free Software Foundation; either version 2 of the -->
<!-- License, or (at your option) any later version. -->
<!-- -->
<!-- This program is distributed in the hope that it will be useful, -->
<!-- but WITHOUT ANY WARRANTY; without even the implied warranty of -->
<!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -->
<!-- GNU General Public License for more details. -->
<!-- -->
<!-- You should have received a copy of the GNU General Public License -->
<!-- along with this program; if not, write to the -->
<!-- Free Software Foundation, Inc., -->
<!-- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -->
<scenario name="accountcall_client">
<send retrans="1000">
<![CDATA[
INVITE sip:[remote_ip] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];rport;branch=[branch]
From: <sip:[remote_ip]:[remote_port]>;tag=[call_number]
To: <sip:[remote_ip]:[remote_port]>
Call-ID: [call_id]
CSeq: 1 INVITE
Contact: sip:[local_ip]:[local_port]
Max-Forwards: 70
Subject: Functional Test
Content-Type: application/sdp
Content-Length: [len]
v=0
o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip]
s=-
c=IN IP[media_ip_type] [media_ip]
t=0 0
m=audio [media_port] RTP/AVP 0
a=rtpmap:0 PCMU/8000
]]>
</send>
<recv response="100" optional="true">
</recv>
<recv response="180">
</recv>
<recv response="200">
</recv>
<send>
<![CDATA[
ACK sip:192.168.50.79 SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: <sip:[local_ip]:[local_port]>;tag=[call_number]
To: <sip:192.168.50.79:[remote_port]>
Call-ID: [call_id]
CSeq: 2 ACK
Contact: sip:[local_ip]:[local_port]
Max-Forwards: 70
Subject: Functional Test
Content-Length: 0
]]>
</send>
<recv request="BYE">
</recv>
<send>
<![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>
<pause milliseconds="1000"/>
</scenario>
<?xml version="1.0" encoding="ISO-8859-1" ?> <!DOCTYPE scenario SYSTEM "sipp.dtd">
<scenario name="Basic UAS responder">
<recv request="INVITE" crlf="true">
</recv>
<send>
<![CDATA[
SIP/2.0 180 Ringing
[last_Via:]
[last_From:]
[last_To:];tag=[call_number]
[last_Call-ID:]
[last_CSeq:]
Contact: <sip:127.0.1.1:5062;transport=[transport]>
Content-Length: 0
]]>
</send>
<send retrans="500">
<![CDATA[
SIP/2.0 200 OK
[last_Via:]
[last_From:]
[last_To:];tag=[call_number]
[last_Call-ID:]
[last_CSeq:]
Contact: <sip:[local_ip]:[local_port];transport=[transport]>
Content-Type: application/sdp
Content-Length: [len]
v=0
o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip]
s=-
c=IN IP[media_ip_type] [media_ip]
t=0 0
m=audio [media_port] RTP/AVP 0
a=rtpmap:0 PCMU/8000
]]>
</send>
<recv request="ACK">
</recv>
<pause milliseconds="500"/>
<send retrans="500">
<![CDATA[
BYE sip:127.0.0.1:5060;transport=[transport] SIP/2.0
[last_Via:]
[last_From:]
[last_To:]
[last_Call-ID:]
CSeq: [cseq] BYE
Contact: <sip:[local_ip]:[local_port];transport=[transport]>
Max-Forwards: 70
Subject: Functional Test
Content-Length: 0
]]>
</send>
<recv response="200">
</recv>
<pause milliseconds="1000"/>
<ResponseTimeRepartition value="10, 20, 30, 40, 50, 100, 150, 200"/>
<CallLengthRepartition value="10, 50, 100, 500, 1000, 5000, 10000"/>
</scenario>
<?xml version="1.0" encoding="ISO-8859-1" ?> <!DOCTYPE scenario SYSTEM "sipp.dtd">
<scenario name="Basic UAS responder">
<recv request="INVITE" crlf="true">
</recv>
<send>
<![CDATA[
SIP/2.0 180 Ringing
[last_Via:]
[last_From:]
[last_To:];tag=[call_number]
[last_Call-ID:]
[last_CSeq:]
Contact: <sip:[local_ip]:[local_port];transport=[transport]>
Content-Length: 0
]]>
</send>
<send retrans="500">
<![CDATA[
SIP/2.0 200 OK
[last_Via:]
[last_From:]
[last_To:];tag=[call_number]
[last_Call-ID:]
[last_CSeq:]
Contact: <sip:[local_ip]:[local_port];transport=[transport]>
Content-Type: application/sdp
Content-Length: [len]
v=0
o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip]
s=-
c=IN IP[media_ip_type] [media_ip]
t=0 0
m=audio [media_port] RTP/AVP 0
a=rtpmap:0 PCMU/8000
]]>
</send>
<recv request="ACK"
optional="true"
rtd="true"
crlf="true">
</recv>
<recv request="BYE">
</recv>
<send>
<![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>
<pause milliseconds="4000"/>
<ResponseTimeRepartition value="10, 20, 30, 40, 50, 100, 150, 200"/>
<CallLengthRepartition value="10, 50, 100, 500, 1000, 5000, 10000"/>
</scenario>
......@@ -3,43 +3,121 @@
SERVERPORT=5062
function test_ip2ipcall {
function test_ip2ip_send_hangup {
# start sipp server to receive calls from sflphone
sipp -sf ip2ipcalluas.xml -p ${SERVERPORT} &
sipp -sf ip2ip_uas_recv_peer_hungup.xml -p ${SERVERPORT}
# start sflphoned
/usr/lib/sflphone/sflphoned&
# /usr/lib/sflphone/sflphoned&
# wait some time to make sure sflphoned is started
sleep 2;
# sleep 1;
# run python client and script to make calls
python ../tools/pysflphone/pysflphone_testdbus.py
# python ../tools/pysflphone/pysflphone_testdbus.py &
# kill every one
killall sipp
killall sflphoned
# bashtrap
}
function test_accountcall {
function test_ip2ip_send_peer_hungup {
# start sipp server to receive calls from sflphone and then hangup
sipp -sf ip2ip_uas_recv_hangup.xml -p ${SERVERPORT}
# start sflphoned
# /usr/lib/sflphone/sflphoned&
# wait some time to make sure sflphoned is started
#sleep 2;
# sleep 1;
# run python client and script to make calls
# python ../tools/pysflphone/pysflphone_testdbus.py &
#sleep 2;
# kill every one
bashtrap
}
function test_ip2ip_recv_hangup {
# start sflphoned
# /usr/lib/sflphone/sflphoned&
# wait some time to make sure sflphoned is started
# sleep 1;
# python ../tools/pysflphone/pysflphone_testdbus.py &
# wait some time to make sure client is bound
# sleep 1;
# start sipp client and send calls
sipp -sf accountcalluac.xml 192.168.50.79 -i 192.168.50.182 -p ${SERVERPORT} -l 1
sipp -sf ip2ip_uac_send_peer_hungup.xml 127.0.0.1:5060 -i 127.0.0.1 -p ${SERVERPORT} -l 1
# kill every one
killall sipp
killall sflphoned
# bashtrap
}
function test_ip2ip_recv_peer_hungup {
# start sflphoned
# /usr/lib/sflphone/sflphoned&
# wait some time to make sure sflphoned is started
# sleep 1;
# python ../tools/pysflphone/pysflphone_testdbus.py &
# wait some time to make sure client is bound
# sleep 1;
# start sipp client and send calls
sipp -sf ip2ip_uac_send_hangup.xml 127.0.0.1:5060 -i 127.0.0.1 -p ${SERVERPORT} -l 1
# kill every one
# bashtrap
}
function test_account_send_hangup {
# start sflphoned
# /usr/lib/sflphone/sflphoned&
# wait some time to make sure sflphoned is started
# sleep 1;
# python ../tools/pysflphone/pysflphone_testdbus.py &
# wait some time to make sure client is bound
# sleep 1;
# start sipp client and send calls
sipp -sf account_uas_recv_peer_hungup.xml 192.168.50.79 -i 192.168.50.182 -p ${SERVERPORT} -l 1
# kill every one
# bashtrap
}
function test_account_recv_peer_hungup {
# start sflphoned
# /usr/lib/sflphone/sflphoned&
# wait some time to make sure sflphoned is started
# sleep 1;
# python ../tools/pysflphone/pysflphone_testdbus.py &
# wait some time to make sure client is bound
# sleep 1;
# start sipp client and send calls
sipp -sf account_uac_send_hangup.xml 192.168.50.79 -i 192.168.50.182 -p ${SERVERPORT} -l 1
# kill every one
# bashtrap
}
# function called if CTRL-C detected
......@@ -50,8 +128,14 @@ bashtrap()
}
# Here Start the Test suite
# ============================ Test Suite ============================
# test_ip2ipcall
# SCENARIO 1: Normal flow calls (IP2IP)
# test_ip2ip_send_hangup
# test_ip2ip_send_peer_hungup
# test_ip2ip_recv_hangup
# test_ip2ip_recv_peer_hungup
test_accountcall
\ No newline at end of file
# SCENARIO X: Normal flow calls (Account)
test_account_send_hangup
# test_account_recv_peer_hungup
\ No newline at end of file
#!/usr/bin/env python
import signal
import time
import sys
import getopt
import gtk
from threading import Thread
from threading import Event
print "Import SFLphone"
from sflphonectrlsimple import SflPhoneCtrlSimple
# def killhandler(signum, frame):
# raise IOError("Couldn't open device!")
# signal.signal(signal.SIGKILL, killhandler)
def acceptOnIncomingCall(sflphone):
time.sleep(0.2)
sflphone.Accept(sflphone.currentCallId)
def acceptOnIncomingCallHangup(sflphone):
time.sleep(0.2)
sflphone.Accept(sflphone.currentCallId)
time.sleep(0.5)
sflphone.HangUp(sflphone.currentCallId)
class SflPhoneTests(SflPhoneCtrlSimple):
class SflPhoneTests():
def __init__(self, sfl):
print "Create test instance"
self.sflphone = sfl
def test_get_allaccounts_methods(self):
......@@ -26,85 +48,153 @@ class SflPhoneTests(SflPhoneCtrlSimple):
for account in self.getAllIaxAccounts():
print " " + account
def test_make_iptoip_call(self):
def test_create_account(self):
"""Create a new sip account"""
CONFIG_ACCOUNT_TYPE = "Account.type"
CONFIG_ACCOUNT_ALIAS = "Account.alias"
HOSTNAME = "hostname"
USERNAME = "username"
PASSWORD = "password"
accDetails = {CONFIG_ACCOUNT_TYPE:"SIP", CONFIG_ACCOUNT_ALIAS:"testsuiteaccount",
HOSTNAME:"192.168.50.79", USERNAME:"31416",
PASSWORD:"1234"}
accountID = self.sflphone.addAccount(accDetails)
print "New Account ID " + accountID
return accountID
def test_remove_account(self, accountID):
"""Remove test account"""
self.sflphone.removeAccount(accountID)
print "Account with ID " + accountID + " removed"
def test_ip2ip_send_hangup(self):
"""Make a call to a server (sipp) on port 5062"""
i = 0
while(i < 10):
callid = self.Call("sip:test@127.0.0.1:5062")
time.sleep(0.4)
callid = self.sflphone.Call("sip:test@127.0.0.1:5062")
time.sleep(0.5)
self.HangUp(callid)
time.sleep(0.4)
self.sflphone.HangUp(callid)
time.sleep(0.5)
i = i+1
def test_make_account_call(self):
"""Register an account on a remote server and make several calls"""
del self.sflphone
self.setAccount("Account:1258495784");
time.sleep(3)
def test_ip2ip_send_peer_hungup(self):
"""Make a call to a server (sipp) on port 5062"""
i = 0
while(i < 50):
while(i < 1):
callid = self.Call("5000")
time.sleep(0.4)
self.HangUp(callid)
time.sleep(0.4)
callid = self.sflphone.Call("sip:test@127.0.0.1:5062")
time.sleep(1.0)
i = i+1
del self.sflphone
def test_create_account(self):
"""Create a new sip account"""
CONFIG_ACCOUNT_TYPE = "Account.type"
CONFIG_ACCOUNT_ALIAS = "Account.alias"
HOSTNAME = "hostname"
USERNAME = "username"
PASSWORD = "password"
def test_ip2ip_recv_hangup(self):
"""Wait for calls, answer then hangup"""
accDetails = {CONFIG_ACCOUNT_TYPE:"SIP", CONFIG_ACCOUNT_ALIAS:"testsuiteaccount",
HOSTNAME:"192.168.50.79", USERNAME:"31416",
PASSWORD:"1234"}
# Add callback for this test
self.sflphone.onIncomingCall_cb = acceptOnIncomingCallHangup
# Start Glib mainloop
self.sflphone.start()
accountID = self.addAccount(accDetails)
print "New Account ID " + accountID
def test_ip2ip_recv_peer_hungup(self):
"""Wait for calls, answer, peer hangup"""
# Add callback for this test
self.sflphone.onIncomingCall_cb = acceptOnIncomingCall
return accountID
# Start Glib mainloop
self.sflphone.start()
def test_account_send_hangup(self):
"""Send new account call, hangup once peer answered"""
print "test account send hangup"
i = 0
while(i < 10):
callid = self.sflphone.Call("27182")
time.sleep(0.5)
def test_remove_account(self, accountID):
"""Remove test account"""
self.sflphone.HangUp(callid)
time.sleep(0.5)
self.removeAccount(accountID)
print "Account with ID " + accountID + " removed"
i = i+1
print "account hangup done"
del self.sflphone
def test_account_recv_call_peer_hungup(self):
"""Register an account and wait for incoming calls"""
# Add callback for this test
self.sflphone.onIncomingCall_cb = acceptOnIncomingCall
# Start Glib mainloop
self.sflphone.start()
# def test_account_send_call_peer_hungup(self):
# """Register an account on a remote server and make several calls"""
#
# self.setAccount("Account:1258495784");
# time.sleep(3)
#
# i = 0
# while(i < 50):
#
# callid = self.Call("5000")
# time.sleep(0.4)
#
# self.HangUp(callid)
# time.sleep(0.4)
#
# i = i+1
# Open sflphone and connect to sflphoned through dbus
sflphone = SflPhoneTests()
sflphone = SflPhoneCtrlSimple(True)
sflphone.start()
# Init test suite
testsuite = SflPhoneTests(sflphone)
# Test 1: Makke approximately one IP2IP call per second
# to a sipp uas on local addrress
#sflphone.test_make_iptoip_call()
# Register the first account available, should be the test account
sflphone.setFirstRegisteredAccount();
# SCENARIO 1: IP2IP Normal flow calls
# Test 1: - Send an IP2IP call
# - Hangup
# testsuite.test_ip2ip_send_hangup()
# testsuite.test_ip2ip_send_peer_hungup()
# testsuite.test_ip2ip_recv_hangup()
# testsuite.test_ip2ip_recv_peer_hungup()
# Test 2: - Create an account on Asterisk
# - Wait for incoming calls
# - Once a call is received, answer
# - The call should then be hung up by caller
# accountID = sflphone.test_create_account()
# sflphone.test_make_account_call()
# time.sleep(0.3)
# SCENARIO 2: IP2IP Normal flow calls
# Test 1: - Create an account on Asterisk
# - Wait for incoming calls
# - Answer
# - Call is hanged up by calle
testsuite.test_account_send_hangup()
# testsuite.test_account_recv_call_peer_hungup()
# sflphone.test_remove_account(accountID)
......@@ -23,8 +23,10 @@ import os
import random
from traceback import print_exc
import gtk
import gobject
from gobject import GObject
from gobject import MainLoop
import getopt
......@@ -44,12 +46,17 @@ except ImportError, e:
class SflPhoneCtrlSimple(Thread):
"""Simple class for controlling SflPhoned through DBUS"""
""" Simple class for controlling SflPhoned through DBUS
If option testSuite (ts) is put to true,
simple actions are implemented on incoming call.
"""
# list of active calls (known by the client)
activeCalls = {}
def __init__(self, name=sys.argv[0]):
def __init__(self, test=False, name=sys.argv[0]):
print "Create SFLphone instance"
Thread.__init__(self)
# current active account
self.account = None
......@@ -58,13 +65,19 @@ class SflPhoneCtrlSimple(Thread):
# client registered to sflphoned ?
self.registered = False
self.register()
self.event = Event()
self.currentCallId = ""
self.loop = MainLoop()
self.test = test
self.onIncomingCall_cb = None
self.event = Event()
def __del__(self):
if self.registered:
self.unregister()
self.loop.quit()
def register(self):
......@@ -112,12 +125,14 @@ class SflPhoneCtrlSimple(Thread):
raise SPdaemonError("Client registration failed")
try:
print "Adding Incoming call method"
proxy_callmgr.connect_to_signal('incomingCall', self.onIncomingCall)
proxy_callmgr.connect_to_signal('callStateChanged', self.onCallStateChanged)
except dbus.DBusException, e:
print e
def unregister(self):
if not self.registered:
......@@ -134,6 +149,21 @@ class SflPhoneCtrlSimple(Thread):
return self.registered
def getEvent(self):
return self.event
def wait(self):
self.event.wait()
def isSet(self):
self.event.isSet()
def set(self):
self.event.set()
def clear(self):
self.event.clear()
#
# Signal handling
#
......@@ -143,8 +173,14 @@ class SflPhoneCtrlSimple(Thread):
print "Incoming call: " + account + ", " + callid + ", " + to
self.activeCalls[callid] = {'Account': account, 'To': to, 'State': '' }
self.currentCallId = callid
self.event.set()
Answer(callid)
if(self.test):
# TODO fix this bug in daemon, cannot answer too fast
time.sleep(0.5)
if self.onIncomingCall_cb(self) is not None:
self.onIncomingCall_cb(self)
# On call state changed event, set the values for new calls,
# or delete the call from the list of active calls
......@@ -566,12 +602,5 @@ class SflPhoneCtrlSimple(Thread):
callid = m.hexdigest()
return callid
def run(self):
while(True):
print "Waiting Event"
self.event.wait()
sflphone.Accept(sflphone.currentCallId)
self.event.clear()
print "Call Accepted"
self.loop.run()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment