[asterisk-commits] mmichelson: branch mmichelson/bridge-tests r3359 - in /asterisk/team/mmichels...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jul 24 12:13:51 CDT 2012


Author: mmichelson
Date: Tue Jul 24 12:13:46 2012
New Revision: 3359

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=3359
Log:
Create a common set of configuration for Asterisk instances involved in bridge tests.

I modified TestCase.create_asterisk() to be able to take a location for common
configuration files to be used. This way, all bridge tests can install some base
configuration. Tests will only have to override specific configuration needed for
specific tests.


Added:
    asterisk/team/mmichelson/bridge-tests/configs/bridge/
    asterisk/team/mmichelson/bridge-tests/configs/bridge/ast1/
    asterisk/team/mmichelson/bridge-tests/configs/bridge/ast1/sip.conf
      - copied, changed from r3322, asterisk/team/mmichelson/bridge-tests/tests/bridge/simple_bridge/configs/ast1/sip.conf
    asterisk/team/mmichelson/bridge-tests/configs/bridge/ast2/
    asterisk/team/mmichelson/bridge-tests/configs/bridge/ast2/extensions.conf
      - copied, changed from r3322, asterisk/team/mmichelson/bridge-tests/tests/bridge/simple_bridge/configs/ast2/extensions.conf
    asterisk/team/mmichelson/bridge-tests/configs/bridge/ast2/sip.conf
      - copied unchanged from r3322, asterisk/team/mmichelson/bridge-tests/tests/bridge/simple_bridge/configs/ast2/sip.conf
    asterisk/team/mmichelson/bridge-tests/configs/bridge/ast3/
    asterisk/team/mmichelson/bridge-tests/configs/bridge/ast3/extensions.conf
      - copied, changed from r3322, asterisk/team/mmichelson/bridge-tests/tests/bridge/simple_bridge/configs/ast3/extensions.conf
    asterisk/team/mmichelson/bridge-tests/configs/bridge/ast3/sip.conf
      - copied unchanged from r3322, asterisk/team/mmichelson/bridge-tests/tests/bridge/simple_bridge/configs/ast3/sip.conf
Removed:
    asterisk/team/mmichelson/bridge-tests/tests/bridge/simple_bridge/configs/ast1/sip.conf
    asterisk/team/mmichelson/bridge-tests/tests/bridge/simple_bridge/configs/ast2/
    asterisk/team/mmichelson/bridge-tests/tests/bridge/simple_bridge/configs/ast3/
Modified:
    asterisk/team/mmichelson/bridge-tests/lib/python/asterisk/BridgeTestCase.py
    asterisk/team/mmichelson/bridge-tests/lib/python/asterisk/TestCase.py
    asterisk/team/mmichelson/bridge-tests/tests/bridge/simple_bridge/test-config.yaml

Copied: asterisk/team/mmichelson/bridge-tests/configs/bridge/ast1/sip.conf (from r3322, asterisk/team/mmichelson/bridge-tests/tests/bridge/simple_bridge/configs/ast1/sip.conf)
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/mmichelson/bridge-tests/configs/bridge/ast1/sip.conf?view=diff&rev=3359&p1=asterisk/team/mmichelson/bridge-tests/tests/bridge/simple_bridge/configs/ast1/sip.conf&r1=3322&p2=asterisk/team/mmichelson/bridge-tests/configs/bridge/ast1/sip.conf&r2=3359
==============================================================================
--- asterisk/team/mmichelson/bridge-tests/tests/bridge/simple_bridge/configs/ast1/sip.conf (original)
+++ asterisk/team/mmichelson/bridge-tests/configs/bridge/ast1/sip.conf Tue Jul 24 12:13:46 2012
@@ -2,11 +2,15 @@
 udpbindaddr = 127.0.0.1:5060
 
 [alice]
+send_rpid=pai
+callerid=Alice <1234>
 type = peer
 host = 127.0.0.1
 port = 5061
 
 [bob]
+send_rpid=pai
+callerid=Bob <4321>
 type = peer
 host = 127.0.0.1
 port = 5062

Copied: asterisk/team/mmichelson/bridge-tests/configs/bridge/ast2/extensions.conf (from r3322, asterisk/team/mmichelson/bridge-tests/tests/bridge/simple_bridge/configs/ast2/extensions.conf)
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/mmichelson/bridge-tests/configs/bridge/ast2/extensions.conf?view=diff&rev=3359&p1=asterisk/team/mmichelson/bridge-tests/tests/bridge/simple_bridge/configs/ast2/extensions.conf&r1=3322&p2=asterisk/team/mmichelson/bridge-tests/configs/bridge/ast2/extensions.conf&r2=3359
==============================================================================
--- asterisk/team/mmichelson/bridge-tests/tests/bridge/simple_bridge/configs/ast2/extensions.conf (original)
+++ asterisk/team/mmichelson/bridge-tests/configs/bridge/ast2/extensions.conf Tue Jul 24 12:13:46 2012
@@ -4,9 +4,11 @@
 [default]
 ; Originated call is linked to this extension
 exten => test_call,1,UserEvent(Connected, Channel: ${CHANNEL(name)})
-same => n,Read(DIGIT,,1,,,1000)
-same => n,GotoIf($["${DIGIT}" = "1"]?:fail)
-same => n,UserEvent(DTMF, Success: True)
+;same => n,Wait(2)
+same => n,SendDTMF(1)
+;same => n,Read(DIGIT,,1,,,1000)
+;same => n,GotoIf($["${DIGIT}" = "1"]?:fail)
+;same => n,UserEvent(DTMF, Success: True)
 same => n,Echo()
 same => n,Hangup()
 same => n(fail),UserEvent(DTMF, Success: False)

Copied: asterisk/team/mmichelson/bridge-tests/configs/bridge/ast3/extensions.conf (from r3322, asterisk/team/mmichelson/bridge-tests/tests/bridge/simple_bridge/configs/ast3/extensions.conf)
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/mmichelson/bridge-tests/configs/bridge/ast3/extensions.conf?view=diff&rev=3359&p1=asterisk/team/mmichelson/bridge-tests/tests/bridge/simple_bridge/configs/ast3/extensions.conf&r1=3322&p2=asterisk/team/mmichelson/bridge-tests/configs/bridge/ast3/extensions.conf&r2=3359
==============================================================================
--- asterisk/team/mmichelson/bridge-tests/tests/bridge/simple_bridge/configs/ast3/extensions.conf (original)
+++ asterisk/team/mmichelson/bridge-tests/configs/bridge/ast3/extensions.conf Tue Jul 24 12:13:46 2012
@@ -3,11 +3,12 @@
 
 ; Incoming call comes here
 [default]
-exten => test_call,1,Answer()
-same => n,UserEvent(Connected, Channel: ${CHANNEL(name)})
-same => n,Read(DIGIT,,1,,,1000)
-same => n,GotoIf($["${DIGIT}" = "1"]?:fail)
-same => n,UserEvent(DTMF, Success: True)
+exten => test_call,1,UserEvent(Connected, Channel: ${CHANNEL(name)})
+same => n,Answer()
+;same => n,Read(DIGIT,,1,,,1000)
+;same => n,GotoIf($["${DIGIT}" = "1"]?:fail)
+;same => n,UserEvent(DTMF, Success: True)
+;same => n,SendDTMF(1)
 same => n,Echo()
 same => n,Hangup()
 same => n(fail),UserEvent(DTMF, Success: False)

Modified: asterisk/team/mmichelson/bridge-tests/lib/python/asterisk/BridgeTestCase.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/mmichelson/bridge-tests/lib/python/asterisk/BridgeTestCase.py?view=diff&rev=3359&r1=3358&r2=3359
==============================================================================
--- asterisk/team/mmichelson/bridge-tests/lib/python/asterisk/BridgeTestCase.py (original)
+++ asterisk/team/mmichelson/bridge-tests/lib/python/asterisk/BridgeTestCase.py Tue Jul 24 12:13:46 2012
@@ -10,12 +10,17 @@
 import sys
 import logging
 import uuid
+import os
 
 sys.path.append("lib/python")
 from TestCase import TestCase
 
 LOGGER = logging.getLogger(__name__)
 class BridgeTestCase(TestCase):
+
+    ALICE_CONNECTED = '"Bob" <4321>'
+    BOB_CONNECTED = '"Alice" <1234>'
+
     '''
     Class that handles tests involving two-party bridges.
     There are three Asterisk instances used for this test.
@@ -26,7 +31,7 @@
 
     def __init__(self, test_path = '', test_config = None):
         TestCase.__init__(self, test_path)
-        self.create_asterisk(3)
+        self.create_asterisk(3, "%s/configs/bridge" % os.getcwd())
         self.test_runs = []
         self.current_run = 0
         self.ami_uut = None
@@ -36,8 +41,6 @@
         if test_config is None:
             LOGGER.warning("No configuration provided. Bailing.")
             raise Exception
-
-        LOGGER.info("HEY?!")
 
         # Just a quick sanity check so we can die early if
         # the tests are badly misconfigured
@@ -80,6 +83,8 @@
             self.start_test(self.test_runs[self.current_run])
         else:
             LOGGER.info("All calls executed, stopping")
+            self.set_passed(True)
+            self.stop_reactor()
 
     def start_test(self, test_run):
         # Step 0: Set up event handlers and initialize values for this test run
@@ -88,6 +93,7 @@
         self.ami_bob.registerEvent('UserEvent', self.user_callback)
         self.ami_bob.registerEvent('Hangup', self.hangup_callback)
         self.ami_uut.registerEvent('Bridge', self.uut_bridge_callback)
+        self.ami_alice.registerEvent('TestEvent', self.test_callback)
         self.hangup = test_run['hangup'] if 'hangup' in test_run else None
         self.alice_channel = None
         self.bob_channel = None
@@ -95,10 +101,10 @@
         self.uut_bob_channel = None
         self.alice_connected = False
         self.bob_connected = False
+        self.alice_dtmf = False
         self.bob_dtmf = False
-        self.alice_dtmf = False
+        self.alice_hungup = False
         self.bob_hungup = False
-        self.alice_hungup = False
 
         
         # Step 1: Initiate a call from Alice to Bob
@@ -118,20 +124,26 @@
                 self.alice_connected = True
                 self.alice_channel = event.get('channel')
                 LOGGER.info("Alice's channel is %s" % self.alice_channel)
-            if self.bob_connected and self.alice_connected:
-                # Both parties are connected. Move on to connectivity tests
-                self.check_audio_path()
+
+            if self.alice_connected and self.bob_connected:
+                self.check_identities()
 
         if (event.get('userevent') == 'DTMF'):
             if ami is self.ami_bob:
+                LOGGER.info("Bob received DTMF as expected")
                 self.bob_dtmf = True
             elif ami is self.ami_alice:
+                LOGGER.info("Alice received DTMF as expected")
                 self.alice_dtmf = True
             if self.bob_dtmf and self.alice_dtmf:
                 # Both parties have received audio properly. Move on to identity
                 # tests
                 self.check_identities()
 
+    def test_callback(self, ami, event):
+        if (event.get('state') == 'DTMFRECEIVED'):
+            LOGGER.info("Alice got DTMF: %s: " % event.get('value'))
+
     def hangup_callback(self, ami, event):
         if ami is self.ami_bob:
             self.bob_hungup = True
@@ -144,6 +156,7 @@
             self.run_tests()
 
     def uut_bridge_callback(self, ami, event):
+        LOGGER.info("Got bridge callback")
         self.uut_alice_channel = event.get('channel1')
         self.uut_bob_channel = event.get('channel2')
         if event.get('bridgestate') == 'Link':
@@ -152,27 +165,52 @@
         else:
             LOGGER.info("Bridge is down")
             self.bridged = False
-        LOGGER.info("Got bridge callback")
-
-    def check_audio_path(self):
-        LOGGER.info("Checking audio path")
-        self.ami_alice.playDTMF(self.alice_channel, '1')
-        self.ami_bob.playDTMF(self.bob_channel, '1')
 
     def check_identities(self):
-        alice_connected = self.ami_uut.getVar(self.uut_alice_channel, 'CONNECTEDLINE(all)')
-        bob_connected = self.ami_uut.getVar(self.uut_bob_channel, 'CONNECTEDLINE(all)')
-        alice_bridgepeer = self.ami_uut.getVar(self.uut_alice_channel, 'BRIDGEPEER')
-        bob_bridgepeer = self.ami_uut.getVar(self.uut_bob_channel, 'BRIDGEPEER')
-        # XXX Check the connected line values here
-        # If values check out, then move on to features tests. We'll save
-        # that for later. For now, move on to hanging up.
-        self.send_hangup()
+        def alice_connected(value):
+            LOGGER.info("Alice's Connected line is %s" % value)
+            if value != BridgeTestCase.ALICE_CONNECTED:
+                LOGGER.warning("Unexpected Connected line value for Alice: %s" %
+                        value)
+                self.set_passed(False)
+
+        def bob_connected(value):
+            LOGGER.info("Bob's Connected line is %s" % value)
+            if value != BridgeTestCase.BOB_CONNECTED:
+                LOGGER.warning("Unexpected Connected line value for Bob: %s" %
+                        value)
+                self.set_passed(False)
+
+        def alice_bridgepeer(value):
+            LOGGER.info("Alice's BRIDGEPEER is %s" % value)
+            if value != self.uut_bob_channel:
+                LOGGER.warning("Unexpected BRIDGEPEER value for Alice: %s" %
+                        value)
+                self.set_passed(False)
+
+        def bob_bridgepeer(value):
+            LOGGER.info("Bob's BRIDGEPEER is %s" % value)
+            if value != self.uut_alice_channel:
+                LOGGER.warning("Unexpected BRIDGEPEER value for Bob: %s" %
+                        value)
+                self.set_passed(False)
+            self.send_hangup()
+
+        self.ami_uut.getVar(self.uut_alice_channel,
+                'CONNECTEDLINE(all)').addCallback(alice_connected)
+        bob_connected = self.ami_uut.getVar(self.uut_bob_channel,
+                'CONNECTEDLINE(all)').addCallback(bob_connected)
+        alice_bridgepeer = self.ami_uut.getVar(self.uut_alice_channel,
+                'BRIDGEPEER').addCallback(alice_bridgepeer)
+        bob_bridgepeer = self.ami_uut.getVar(self.uut_bob_channel,
+                'BRIDGEPEER').addCallback(bob_bridgepeer)
 
     def send_hangup(self):
         if not self.hangup:
+            LOGGER.info("No hangup set. Hang up will happen elsewhere")
             return
 
+        LOGGER.info("Sending a hangup to %s" % self.hangup)
         if self.hangup == 'alice':
             ami = self.ami_alice
             channel = self.alice_channel
@@ -181,3 +219,5 @@
             channel = self.bob_channel
         else:
             raise Exception("Invalid hangup target specified: %s" % self.hangup)
+
+        ami.hangup(channel)

Modified: asterisk/team/mmichelson/bridge-tests/lib/python/asterisk/TestCase.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/mmichelson/bridge-tests/lib/python/asterisk/TestCase.py?view=diff&rev=3359&r1=3358&r2=3359
==============================================================================
--- asterisk/team/mmichelson/bridge-tests/lib/python/asterisk/TestCase.py (original)
+++ asterisk/team/mmichelson/bridge-tests/lib/python/asterisk/TestCase.py Tue Jul 24 12:13:46 2012
@@ -133,7 +133,7 @@
                     logger.warning("Unsupported type [%s] with related condition %s" % (c[1], c[2]))
         self.testConditionController.register_observer(self.handle_condition_failure, 'Failed')
 
-    def create_asterisk(self, count=1):
+    def create_asterisk(self, count=1, base_configs_path=None):
         """
         Create n instances of Asterisk
 
@@ -141,12 +141,21 @@
         count -- the number of Asterisk instances to create.  Each Asterisk instance
         will be hosted on 127.0.0.x, where x is the 1-based index of the instance
         created
+
+        base_configs_path -- provides common configuration for Asterisk
+        instances to use. This is useful for certain test types that use the
+        same configuration all the time. This configuration can be overwritten
+        by individual tests, however.
 
         """
         for c in range(count):
             logger.info("Creating Asterisk instance %d" % (c + 1))
             host = "127.0.0.%d" % (c + 1)
             self.ast.append(Asterisk(base=self.base, host=host))
+            """ If a base configuration for this Asterisk instance has been
+            provided, install it first"""
+            if base_configs_path:
+                self.ast[c].install_configs("%s/ast%d" % (base_configs_path, c + 1))
             """ Copy test specific config files """
             self.ast[c].install_configs("%s/configs/ast%d" %
                     (self.test_name, c + 1))

Modified: asterisk/team/mmichelson/bridge-tests/tests/bridge/simple_bridge/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/mmichelson/bridge-tests/tests/bridge/simple_bridge/test-config.yaml?view=diff&rev=3359&r1=3358&r2=3359
==============================================================================
--- asterisk/team/mmichelson/bridge-tests/tests/bridge/simple_bridge/test-config.yaml (original)
+++ asterisk/team/mmichelson/bridge-tests/tests/bridge/simple_bridge/test-config.yaml Tue Jul 24 12:13:46 2012
@@ -11,7 +11,7 @@
 
 bridge-config:
     -
-        extension: 'simple'
+        extension: 'test_call'
         hangup: 'alice'
 
 properties:




More information about the asterisk-commits mailing list