[svn-commits] jrose: testsuite/asterisk/trunk r3158 - in /asterisk/trunk/tests/apps/bridge:...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Mar 27 09:49:38 CDT 2012


Author: jrose
Date: Tue Mar 27 09:49:34 2012
New Revision: 3158

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=3158
Log:
Create a test for bridge applications F option (transfer callee)

(issue ASTERISK-19282)
Reported by: To

Added:
    asterisk/trunk/tests/apps/bridge/bridge_transfer_callee/
    asterisk/trunk/tests/apps/bridge/bridge_transfer_callee/configs/
    asterisk/trunk/tests/apps/bridge/bridge_transfer_callee/configs/ast1/
    asterisk/trunk/tests/apps/bridge/bridge_transfer_callee/configs/ast1/extensions.conf   (with props)
    asterisk/trunk/tests/apps/bridge/bridge_transfer_callee/run-test   (with props)
    asterisk/trunk/tests/apps/bridge/bridge_transfer_callee/test-config.yaml   (with props)
Modified:
    asterisk/trunk/tests/apps/bridge/tests.yaml

Added: asterisk/trunk/tests/apps/bridge/bridge_transfer_callee/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/apps/bridge/bridge_transfer_callee/configs/ast1/extensions.conf?view=auto&rev=3158
==============================================================================
--- asterisk/trunk/tests/apps/bridge/bridge_transfer_callee/configs/ast1/extensions.conf (added)
+++ asterisk/trunk/tests/apps/bridge/bridge_transfer_callee/configs/ast1/extensions.conf Tue Mar 27 09:49:34 2012
@@ -1,0 +1,46 @@
+[call1]
+exten => local,1,Answer()
+exten => local,2,Echo()
+
+[call2]
+exten => local,1,Answer()
+exten => local,2,Echo()
+
+[test_context]
+exten => call,1,Answer()
+exten => call,2,Set(GLOBAL(BRIDGEECHAN)=${CHANNEL})
+exten => call,3,UserEvent(StartBridge)
+exten => call,4,Echo
+
+exten => bridge0,1,Answer()
+exten => bridge0,2,Bridge(${BRIDGEECHAN}, F)
+exten => bridge0,3,UserEvent(Alpha,Test: 0,Status: SUCCESS,Channel: ${CHANNEL})
+
+exten => bridge1,1,Answer()
+exten => bridge1,2,Bridge(${BRIDGEECHAN}, F(5))
+exten => bridge1,3,UserEvent(Alpha,Test: 1,Status: FAILURE,Channel: ${CHANNEL})
+exten => bridge1,4,HangUp
+exten => bridge1,5,UserEvent(Alpha,Test: 1,Status: SUCCESS,Channel: ${CHANNEL})
+exten => bridge1,6,HangUp
+
+exten => bridge2,1,Answer()
+exten => bridge2,2,Bridge(${BRIDGEECHAN}, F(bridge2transfer,3))
+exten => bridge2,3,UserEvent(Alpha,Test: 2,Status: FAILURE,Channel: ${CHANNEL})
+exten => bridge2,4,HangUp
+
+exten => bridge2transfer,1,UserEvent(Alpha,Test: 2,Status: FAILURE,Channel: ${CHANNEL})
+exten => bridge2transfer,2,HangUp
+exten => bridge2transfer,3,UserEvent(Alpha,Test: 2,Status: SUCCESS,Channel: ${CHANNEL})
+exten => bridge2transfer,4,HangUp
+
+exten => bridge3,1,Answer()
+exten => bridge3,2,Bridge(${BRIDGEECHAN}, F(bridgecontext,bridge3transfer,3))
+exten => bridge3,3,UserEvent(Alpha,Test: 3,Status: FAILURE,Channel: ${CHANNEL})
+exten => bridge3,4,HangUp
+
+[bridgecontext]
+exten => bridge3transfer,1,UserEvent(Alpha,Test: 3,Status: FAILURE,Channel: ${CHANNEL})
+exten => bridge3transfer,2,HangUp
+exten => bridge3transfer,3,UserEvent(Alpha,Test: 3,Status: SUCCESS,Channel: ${CHANNEL})
+exten => bridge3transfer,4,HangUp
+

Propchange: asterisk/trunk/tests/apps/bridge/bridge_transfer_callee/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/apps/bridge/bridge_transfer_callee/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/apps/bridge/bridge_transfer_callee/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/apps/bridge/bridge_transfer_callee/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/apps/bridge/bridge_transfer_callee/run-test?view=auto&rev=3158
==============================================================================
--- asterisk/trunk/tests/apps/bridge/bridge_transfer_callee/run-test (added)
+++ asterisk/trunk/tests/apps/bridge/bridge_transfer_callee/run-test Tue Mar 27 09:49:34 2012
@@ -1,0 +1,118 @@
+#!/usr/bin/env python
+# vim: sw=3 et:
+'''
+Copyright (C) 2012, Digium, Inc.
+Jonathan Rose <jrose at digium.com>
+
+This program is free software, distributed under the terms of
+the GNU General Public License Version 2.
+'''
+import sys
+import os
+import logging
+import re
+
+from twisted.internet import reactor
+
+sys.path.append("lib/python")
+
+from asterisk.TestCase import TestCase
+
+logger = logging.getLogger(__name__)
+
+class BridgeTransferTest(TestCase):
+
+    def __init__(self):
+        TestCase.__init__(self)
+        self.current_test = 0
+        self.total_tests = 4
+        self.create_asterisk()
+
+    def run(self):
+        TestCase.run(self)
+        self.create_ami_factory()
+
+    def ami_connect(self, ami):
+        TestCase.ami_connect(self, ami)
+        """ Register for all events we care about """
+
+        ami.registerEvent("UserEvent", self.user_event)
+        ami.registerEvent("BridgeExec", self.bridge_event)
+        #originate the bridgee
+        df = ami.originate(channel = "Local/local at call1", exten = "call", context = "test_context", priority = 1)
+        df.addErrback(self.handleOriginateFailure)
+
+    def user_event(self, ami, event):
+        if (event['userevent'] == 'StartBridge'):
+            self.start_next_test(ami)
+        elif (event['userevent'] == 'Alpha'):
+            self.process_test_event(ami, event)
+
+    def start_next_test(self, ami):
+        df = ami.originate(channel = "Local/local at call2", exten = "bridge%d" % self.current_test, context = "test_context", priority = 1)
+        df.addErrback(self.handleOriginateFailure)
+
+    def process_test_event(self, ami, event):
+        #evaluate pass/failure
+        logger.info("event: %s" % event)
+
+        if (event.get('test') != "%d" % self.current_test):
+            logger.error("test %d event didn't match expected test number. Test Failed." % self.current_test)
+            self.stop_reactor()
+            return
+
+        if (event.get('status') != "SUCCESS"):
+            logger.error("test %d event did not specify SUCCESS. Test Failed." % self.current_test)
+            self.stop_reactor()
+            return
+
+        channel = event.get('channel')
+        if channel is None:
+            logger.error("test %d did not include a channel in test event.")
+            self.stop_reactor()
+            return
+
+        if not self.match_starts("Local/local at call1-", channel):
+            logger.error("test %d SUCCESS was placed on the wrong channel. Test Failed." % self.current_test)
+            self.stop_reactor()
+            return
+
+        #get first call for next test set up
+        self.current_test = self.current_test + 1
+        if (self.current_test < self.total_tests):
+            df = ami.originate(channel = "Local/local at call1", exten = "call", context = "test_context", priority = 1)
+            df.addErrback(self.handleOriginateFailure)
+        else:
+            logger.info("All Bridge Transfer tests complete. Test Successful.")
+            self.passed = True
+            self.stop_reactor()
+
+    def bridge_event(self, ami, event):
+        if (event.get('response') == 'Success'):
+            channel = event.get('channel1')
+            if channel is not None:
+                ami.hangup(channel)
+            else:
+                logger.error("bridge event didn't include a channel1. That's not supposed to happen.")
+        else:
+            logger.error("A bridge failed. That's rather abnormal.")
+
+    def match_starts(self, string1, string2):
+        pattern = re.compile(string1)
+        if not (pattern.match(string2)):
+            return False
+        else:
+            return True
+
+
+def main():
+    test = BridgeTransferTest()
+    reactor.run()
+
+    if (test.passed):
+        return 0
+    else:
+        return 1
+
+if __name__ == "__main__":
+   sys.exit(main() or 0)

Propchange: asterisk/trunk/tests/apps/bridge/bridge_transfer_callee/run-test
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/apps/bridge/bridge_transfer_callee/run-test
------------------------------------------------------------------------------
    svn:executable = *

Propchange: asterisk/trunk/tests/apps/bridge/bridge_transfer_callee/run-test
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/apps/bridge/bridge_transfer_callee/run-test
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/apps/bridge/bridge_transfer_callee/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/apps/bridge/bridge_transfer_callee/test-config.yaml?view=auto&rev=3158
==============================================================================
--- asterisk/trunk/tests/apps/bridge/bridge_transfer_callee/test-config.yaml (added)
+++ asterisk/trunk/tests/apps/bridge/bridge_transfer_callee/test-config.yaml Tue Mar 27 09:49:34 2012
@@ -1,0 +1,13 @@
+testinfo:
+    summary:     'Test transfer bridgee after bridger hangup [F()] option for Bridge'
+    description: |
+        'This test verifies that when the F option is used to bridge two channels and
+         the appropriate channel hangs up first that the other channel will be directed
+         to the appropriate extension based on the arguments of F. The test passes if
+         it reaches all of the expected pass events on the appropriate channel in the
+         correct order.'
+
+properties:
+    minversion: '11'
+    tags:
+        - bridge

Propchange: asterisk/trunk/tests/apps/bridge/bridge_transfer_callee/test-config.yaml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/apps/bridge/bridge_transfer_callee/test-config.yaml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/apps/bridge/bridge_transfer_callee/test-config.yaml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: asterisk/trunk/tests/apps/bridge/tests.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/apps/bridge/tests.yaml?view=diff&rev=3158&r1=3157&r2=3158
==============================================================================
--- asterisk/trunk/tests/apps/bridge/tests.yaml (original)
+++ asterisk/trunk/tests/apps/bridge/tests.yaml Tue Mar 27 09:49:34 2012
@@ -1,3 +1,4 @@
 # Enter tests here in the order they should be considered for execution:
 tests:
     - test: 'bridge_baseline'
+    - test: 'bridge_transfer_callee'




More information about the svn-commits mailing list