[asterisk-commits] jrose: testsuite/asterisk/trunk r3150 - in /asterisk/trunk/tests/apps: ./ bri...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Mar 26 08:56:14 CDT 2012


Author: jrose
Date: Mon Mar 26 08:56:09 2012
New Revision: 3150

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=3150
Log:
Add baseline test for bridge


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

Added: asterisk/trunk/tests/apps/bridge/bridge_baseline/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/apps/bridge/bridge_baseline/configs/ast1/extensions.conf?view=auto&rev=3150
==============================================================================
--- asterisk/trunk/tests/apps/bridge/bridge_baseline/configs/ast1/extensions.conf (added)
+++ asterisk/trunk/tests/apps/bridge/bridge_baseline/configs/ast1/extensions.conf Mon Mar 26 08:56:09 2012
@@ -1,0 +1,18 @@
+[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 => call,5,Hangup()
+
+exten => bridge,1,Answer()
+exten => bridge,2,Bridge(${BRIDGEECHAN})
+exten => bridge,3,NoOp(Bridge Complete)

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

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

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

Added: asterisk/trunk/tests/apps/bridge/bridge_baseline/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/apps/bridge/bridge_baseline/run-test?view=auto&rev=3150
==============================================================================
--- asterisk/trunk/tests/apps/bridge/bridge_baseline/run-test (added)
+++ asterisk/trunk/tests/apps/bridge/bridge_baseline/run-test Mon Mar 26 08:56:09 2012
@@ -1,0 +1,105 @@
+#!/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 BridgeBaseline(TestCase):
+
+    def __init__(self):
+        TestCase.__init__(self)
+        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("BridgeExec", self.bridge_event)
+        ami.registerEvent("UserEvent", self.do_bridge)
+        #originate the bridgee
+        df = ami.originate(channel = "Local/local at call1", exten = "call", context = "test_context", priority = 1)
+        df.addErrback(self.handleOriginateFailure)
+
+    def do_bridge(self, ami, event):
+        if (event.get('userevent') != 'StartBridge'):
+            return
+        #originate the bridger
+        df = ami.originate(channel = "Local/local at call2", exten = "bridge", context = "test_context", priority = 1)
+        df.addErrback(self.handleOriginateFailure)
+
+    def bridge_event(self, ami, event):
+        #passes_needed should match the number of conditions
+        passes_needed = 3
+
+        #Condition 1: Event response must be Success to indicate successful bridge
+        if (event.get('response') == 'Success'):
+            passes_needed = passes_needed - 1
+        else:
+            logger.error( "Test failed, bridge event didn't indicate success." )
+
+        #Condition 2: The first channel name must start similar to what is indicated below
+        if event.get('channel1') and (self.match_starts("Local/local at call2-", event.get('channel1'))):
+            passes_needed = passes_needed - 1
+        else:
+            logger.error( "Failed to match channel1" )
+
+        #Condition 3: The second channel name must start similar to what is indicated below
+        if event.get('channel2') and (self.match_starts("Local/local at call1-", event.get('channel2'))):
+            passes_needed = passes_needed - 1
+        else:
+            logger.error( "Failed to match channel2" )
+
+        #Evaluate whether the number of conditions passed matched expectations to determine
+        #Success or Failure of the test.
+        if (passes_needed == 0):
+            logger.info("Test Successful")
+            self.passed = True
+        else:
+            logger.error("Test FAILED")
+            self.passed = False
+        ami.hangup(event.get('channel1')).addCallback(self.hangup)
+
+    def hangup(self, ami):
+        self.stop_reactor()
+
+    def match_starts(self, string1, string2):
+        pattern = re.compile(string1)
+        if not (pattern.match(string2)):
+            return False
+        else:
+            return True
+
+def main():
+    test = BridgeBaseline()
+    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_baseline/run-test
------------------------------------------------------------------------------
    svn:eol-style = native

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

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

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

Added: asterisk/trunk/tests/apps/bridge/bridge_baseline/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/apps/bridge/bridge_baseline/test-config.yaml?view=auto&rev=3150
==============================================================================
--- asterisk/trunk/tests/apps/bridge/bridge_baseline/test-config.yaml (added)
+++ asterisk/trunk/tests/apps/bridge/bridge_baseline/test-config.yaml Mon Mar 26 08:56:09 2012
@@ -1,0 +1,12 @@
+testinfo:
+    summary:     'Get a baseline for Bridge operations'
+    description: |
+        'This tests the bridging of two local channels using the Bridge application.
+         If successful, a BridgeExec event is sent which the test checks for the
+         expected results.  The test passes if the event indicates a successful bridge
+         and if the channels is the bridge are the expected channels.'
+
+properties:
+    minversion: '1.6.2'
+    tags:
+        - bridge

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

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

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

Added: asterisk/trunk/tests/apps/bridge/tests.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/apps/bridge/tests.yaml?view=auto&rev=3150
==============================================================================
--- asterisk/trunk/tests/apps/bridge/tests.yaml (added)
+++ asterisk/trunk/tests/apps/bridge/tests.yaml Mon Mar 26 08:56:09 2012
@@ -1,0 +1,3 @@
+# Enter tests here in the order they should be considered for execution:
+tests:
+    - test: 'bridge_baseline'

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

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

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

Modified: asterisk/trunk/tests/apps/tests.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/apps/tests.yaml?view=diff&rev=3150&r1=3149&r2=3150
==============================================================================
--- asterisk/trunk/tests/apps/tests.yaml (original)
+++ asterisk/trunk/tests/apps/tests.yaml Mon Mar 26 08:56:09 2012
@@ -3,6 +3,7 @@
     - test: 'directory_operator_exit'
     - test: 'directory_context_operator_exit'
     - test: 'directory_attendant_exit'
+    - dir: 'bridge'
     - dir: 'voicemail'
     - dir: 'incomplete'
     - dir: 'confbridge'




More information about the asterisk-commits mailing list