[asterisk-commits] mmichelson: testsuite/asterisk/trunk r3452 - in /asterisk/trunk: lib/python/a...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Sep 4 10:54:10 CDT 2012
Author: mmichelson
Date: Tue Sep 4 10:54:01 2012
New Revision: 3452
URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=3452
Log:
Test device state notifications for SIP devices.
This ensures that when a device state changes, that a SIP
device subscribed to that device receives a NOTIFY.
Review: https://reviewboard.asterisk.org/r/2090
Added:
asterisk/trunk/tests/channels/SIP/device_state_notification/
asterisk/trunk/tests/channels/SIP/device_state_notification/configs/
asterisk/trunk/tests/channels/SIP/device_state_notification/configs/ast1/
asterisk/trunk/tests/channels/SIP/device_state_notification/configs/ast1/extensions.conf (with props)
asterisk/trunk/tests/channels/SIP/device_state_notification/configs/ast1/sip.conf (with props)
asterisk/trunk/tests/channels/SIP/device_state_notification/originator.py (with props)
asterisk/trunk/tests/channels/SIP/device_state_notification/sipp/
asterisk/trunk/tests/channels/SIP/device_state_notification/sipp/uac-subscribe-unsubscribe.xml (with props)
asterisk/trunk/tests/channels/SIP/device_state_notification/test-config.yaml (with props)
Modified:
asterisk/trunk/lib/python/asterisk/TestCase.py
asterisk/trunk/tests/channels/SIP/tests.yaml
Modified: asterisk/trunk/lib/python/asterisk/TestCase.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/TestCase.py?view=diff&rev=3452&r1=3451&r2=3452
==============================================================================
--- asterisk/trunk/lib/python/asterisk/TestCase.py (original)
+++ asterisk/trunk/lib/python/asterisk/TestCase.py Tue Sep 4 10:54:01 2012
@@ -393,9 +393,9 @@
logger.info("AMI Connect instance %s" % (ami.id + 1))
self.ami[ami.id] = ami
try:
- self.ami_connect(ami)
for callback in self._ami_callbacks:
callback(ami)
+ self.ami_connect(ami)
except:
logger.error("Exception raised in ami_connect:")
logger.error(traceback.format_exc())
Added: asterisk/trunk/tests/channels/SIP/device_state_notification/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/channels/SIP/device_state_notification/configs/ast1/extensions.conf?view=auto&rev=3452
==============================================================================
--- asterisk/trunk/tests/channels/SIP/device_state_notification/configs/ast1/extensions.conf (added)
+++ asterisk/trunk/tests/channels/SIP/device_state_notification/configs/ast1/extensions.conf Tue Sep 4 10:54:01 2012
@@ -1,0 +1,6 @@
+[default]
+exten => subscriber,hint,Custom:Eggs
+
+exten => _[A-Za-z].,1,Answer()
+same => n,Set(DEVICE_STATE(Custom:Eggs)=${EXTEN})
+same => n,Hangup()
Propchange: asterisk/trunk/tests/channels/SIP/device_state_notification/configs/ast1/extensions.conf
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/channels/SIP/device_state_notification/configs/ast1/extensions.conf
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/channels/SIP/device_state_notification/configs/ast1/extensions.conf
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/channels/SIP/device_state_notification/configs/ast1/sip.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/channels/SIP/device_state_notification/configs/ast1/sip.conf?view=auto&rev=3452
==============================================================================
--- asterisk/trunk/tests/channels/SIP/device_state_notification/configs/ast1/sip.conf (added)
+++ asterisk/trunk/tests/channels/SIP/device_state_notification/configs/ast1/sip.conf Tue Sep 4 10:54:01 2012
@@ -1,0 +1,8 @@
+[general]
+allowsubscribe=yes
+udpbindaddr=127.0.0.1:5060
+
+[sipp]
+type = peer
+host = 127.0.0.1
+port = 5061
Propchange: asterisk/trunk/tests/channels/SIP/device_state_notification/configs/ast1/sip.conf
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/channels/SIP/device_state_notification/configs/ast1/sip.conf
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/channels/SIP/device_state_notification/configs/ast1/sip.conf
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/channels/SIP/device_state_notification/originator.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/channels/SIP/device_state_notification/originator.py?view=auto&rev=3452
==============================================================================
--- asterisk/trunk/tests/channels/SIP/device_state_notification/originator.py (added)
+++ asterisk/trunk/tests/channels/SIP/device_state_notification/originator.py Tue Sep 4 10:54:01 2012
@@ -1,0 +1,59 @@
+#!/usr/bin/env python
+'''
+Copyright (C) 2012, Digium, Inc.
+Mark Michelson <mmichelson at digium.com>
+
+This program is free software, distributed under the terms of
+the GNU General Public License Version 2.
+'''
+
+import sys
+import logging
+
+sys.path.append("lib/python")
+
+LOGGER = logging.getLogger(__name__)
+
+DESTINATIONS = [
+ 'RINGING',
+ 'INUSE',
+ 'NOT_INUSE'
+]
+
+class Originator(object):
+ def __init__(self, module_config, test_object):
+ self.ami = None
+ test_object.register_ami_observer(self.ami_connect)
+ test_object.register_scenario_started_observer(self.scenario_started)
+ self.test_object = test_object
+ self.current_destination = 0
+ return
+
+ def ami_connect(self, ami):
+ LOGGER.info("AMI connected")
+ self.ami = ami
+ return
+
+ def success(self, result):
+ LOGGER.info("Originate Successful")
+ self.current_destination += 1
+ if self.current_destination < len(DESTINATIONS):
+ self.originate_call()
+ return result
+
+ def originate_call(self):
+
+ LOGGER.info("Originating call to %s" %
+ DESTINATIONS[self.current_destination])
+
+ self.ami.originate(channel = 'Local/%s at default' %
+ DESTINATIONS[self.current_destination],
+ application = 'Echo').addCallback(self.success)
+
+ def scenario_started(self, result):
+ def failure(result):
+ self.test_object.set_passed(False)
+ return result
+
+ self.originate_call()
+ return result
Propchange: asterisk/trunk/tests/channels/SIP/device_state_notification/originator.py
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/channels/SIP/device_state_notification/originator.py
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/channels/SIP/device_state_notification/originator.py
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/channels/SIP/device_state_notification/sipp/uac-subscribe-unsubscribe.xml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/channels/SIP/device_state_notification/sipp/uac-subscribe-unsubscribe.xml?view=auto&rev=3452
==============================================================================
--- asterisk/trunk/tests/channels/SIP/device_state_notification/sipp/uac-subscribe-unsubscribe.xml (added)
+++ asterisk/trunk/tests/channels/SIP/device_state_notification/sipp/uac-subscribe-unsubscribe.xml Tue Sep 4 10:54:01 2012
@@ -1,0 +1,152 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<scenario name="Basic Sipstone UAC">
+ <send retrans="500">
+ <![CDATA[
+
+ SUBSCRIBE sip:[service]@[remote_ip]:[remote_port] SIP/2.0
+ Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+ From: sipp <sip:sipp@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]
+ To: sut <sip:[service]@[remote_ip]:[remote_port]>
+ Call-ID: [call_id]
+ CSeq: 1 SUBSCRIBE
+ Contact: sip:sipp@[local_ip]:[local_port]
+ Max-Forwards: 70
+ Subject: Performance Test
+ Event: [event]
+ Accept: [accept]
+ Expires: [expires]
+ Content-Length: 0
+
+ ]]>
+ </send>
+
+ <recv response="100"
+ optional="true">
+ </recv>
+
+ <recv response="200" rtd="true">
+ </recv>
+
+ <!-- Initial NOTIFY upon subscribing -->
+ <recv request="NOTIFY" crlf="true" />
+
+ <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>
+
+ <!-- We expect three NOTIFYs in this test -->
+
+ <recv request="NOTIFY" crlf="true" />
+
+ <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>
+
+ <recv request="NOTIFY" crlf="true" />
+
+ <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>
+
+ <recv request="NOTIFY" crlf="true" />
+
+ <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>
+
+ <send retrans="500">
+ <![CDATA[
+
+ SUBSCRIBE sip:[service]@[remote_ip]:[remote_port] SIP/2.0
+ Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+ From: sipp <sip:sipp@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]
+ To: sut <sip:[service]@[remote_ip]:[remote_port]>[peer_tag_param]
+ Call-ID: [call_id]
+ CSeq: [cseq] SUBSCRIBE
+ Contact: sip:sipp@[local_ip]:[local_port]
+ Max-Forwards: 70
+ Subject: Performance Test
+ Event: [event]
+ Accept: [accept]
+ Expires: 0
+ Content-Length: 0
+
+ ]]>
+ </send>
+
+ <recv response="200" crlf="true" />
+
+ <!-- NOTIFY terminating subscription -->
+ <recv request="NOTIFY" crlf="true" />
+
+ <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>
+
+ <timewait milliseconds="4000"/>
+
+ <!-- definition of the response time repartition table (unit is ms) -->
+ <ResponseTimeRepartition value="10, 20, 30, 40, 50, 100, 150, 200"/>
+
+ <!-- definition of the call length repartition table (unit is ms) -->
+ <CallLengthRepartition value="10, 50, 100, 500, 1000, 5000, 10000"/>
+
+</scenario>
+
Propchange: asterisk/trunk/tests/channels/SIP/device_state_notification/sipp/uac-subscribe-unsubscribe.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/channels/SIP/device_state_notification/sipp/uac-subscribe-unsubscribe.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/channels/SIP/device_state_notification/sipp/uac-subscribe-unsubscribe.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/channels/SIP/device_state_notification/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/channels/SIP/device_state_notification/test-config.yaml?view=auto&rev=3452
==============================================================================
--- asterisk/trunk/tests/channels/SIP/device_state_notification/test-config.yaml (added)
+++ asterisk/trunk/tests/channels/SIP/device_state_notification/test-config.yaml Tue Sep 4 10:54:01 2012
@@ -1,0 +1,38 @@
+testinfo:
+ summary: 'Test that device state change notifications are sent to a subscribed SIP channel'
+ description: |
+ 'A SIP device subscribes to the state of a custom device state. The custom
+ device state is changed to several different states. For each state change,
+ a NOTIFY should be sent to the subscriber.
+
+ Note that the purpose of this test is not to detect state changes in SIP
+ devices but to ensure that all state changes result in a notification
+ being sent to SIP subscribers.'
+
+test-modules:
+ add-test-to-search-path: 'True'
+ test-object:
+ config-section: test-object-config
+ typename: 'sipp.SIPpTestCase'
+ modules:
+ -
+ typename: 'originator.Originator'
+
+test-object-config:
+ fail-on-any: False
+ test-iterations:
+ -
+ scenarios:
+ - { 'key-args': {'scenario': 'uac-subscribe-unsubscribe.xml', '-s': 'subscriber'},
+ 'ordered-args': ['-key', 'accept', 'application/pidf+xml',
+ '-key', 'expires', '3600',
+ '-key', 'event', 'presence'] }
+
+properties:
+ minversion: '1.8.0.0'
+ dependencies:
+ - python: 'starpy'
+ - sipp:
+ version: 'v3.1'
+ tags:
+ - sip
Propchange: asterisk/trunk/tests/channels/SIP/device_state_notification/test-config.yaml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/channels/SIP/device_state_notification/test-config.yaml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/channels/SIP/device_state_notification/test-config.yaml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: asterisk/trunk/tests/channels/SIP/tests.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/channels/SIP/tests.yaml?view=diff&rev=3452&r1=3451&r2=3452
==============================================================================
--- asterisk/trunk/tests/channels/SIP/tests.yaml (original)
+++ asterisk/trunk/tests/channels/SIP/tests.yaml Tue Sep 4 10:54:01 2012
@@ -52,4 +52,4 @@
- test: 'sip_outbound_proxy'
- test: 'subscribe'
- test: 'rfc2833_dtmf_detect'
-
+ - test: 'device_state_notification'
More information about the asterisk-commits
mailing list