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

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Aug 9 17:50:09 CDT 2012


Author: mmichelson
Date: Thu Aug  9 17:50:05 2012
New Revision: 3422

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=3422
Log:
Progress towards a test for a Dial 'L' option.

The basis is here. I have new observers written for the
bridge test case, and things mostly work. The actual problem
I'm hitting is with the operation of the 'L' option itself.
It seems to be kind of finicky about when it plays warnings
and on what channels it plays them. I have a test right
now where I expect two warning sounds to be played, but only
one is being reported.

This has a companion test event added to Asterisk trunk that
reports when a warning sound is played on a bridge.


Added:
    asterisk/team/mmichelson/bridge-tests/tests/bridge/connected_line_update/
    asterisk/team/mmichelson/bridge-tests/tests/bridge/dial_L_option/
    asterisk/team/mmichelson/bridge-tests/tests/bridge/dial_L_option/Tester.py   (with props)
    asterisk/team/mmichelson/bridge-tests/tests/bridge/dial_L_option/configs/
    asterisk/team/mmichelson/bridge-tests/tests/bridge/dial_L_option/configs/ast1/
    asterisk/team/mmichelson/bridge-tests/tests/bridge/dial_L_option/configs/ast1/extensions.conf   (with props)
    asterisk/team/mmichelson/bridge-tests/tests/bridge/dial_L_option/test-config.yaml   (with props)
Modified:
    asterisk/team/mmichelson/bridge-tests/lib/python/asterisk/BridgeTestCase.py

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=3422&r1=3421&r2=3422
==============================================================================
--- asterisk/team/mmichelson/bridge-tests/lib/python/asterisk/BridgeTestCase.py (original)
+++ asterisk/team/mmichelson/bridge-tests/lib/python/asterisk/BridgeTestCase.py Thu Aug  9 17:50:05 2012
@@ -45,6 +45,7 @@
         self.ami_uut = None
         self.ami_alice = None
         self.ami_bob = None
+        self.call_end_observers = []
 
         if test_config is None:
             LOGGER.error("No configuration provided. Bailing.")
@@ -161,6 +162,8 @@
 
         if (self.bob_hungup and self.alice_hungup and self.uut_alice_hungup and
                 self.uut_bob_hungup):
+            for callback in self.call_end_observers:
+                callback(self.ami_uut, self.ami_alice, self.ami_alice)
             # Test call has concluded move on!
             self.current_run += 1
             self.run_tests()
@@ -297,3 +300,6 @@
             raise Exception("Invalid hangup target specified: %s" % self.hangup)
 
         ami.hangup(channel)
+
+    def register_call_end_observer(self, callback):
+        self.call_end_observers.append(callback)

Added: asterisk/team/mmichelson/bridge-tests/tests/bridge/dial_L_option/Tester.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/mmichelson/bridge-tests/tests/bridge/dial_L_option/Tester.py?view=auto&rev=3422
==============================================================================
--- asterisk/team/mmichelson/bridge-tests/tests/bridge/dial_L_option/Tester.py (added)
+++ asterisk/team/mmichelson/bridge-tests/tests/bridge/dial_L_option/Tester.py Thu Aug  9 17:50:05 2012
@@ -1,0 +1,87 @@
+#!/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
+import time
+
+sys.path.append("lib/python")
+
+LOGGER = logging.getLogger(__name__)
+TOLERANCE = 0.5
+
+class Tester(object):
+    def __init__(self, module_config, test_object):
+        self.ami = None
+        test_object.register_ami_observer(self.ami_connect)
+        test_object.register_call_end_observer(self.check_duration)
+        self.test_object = test_object
+        self.bridge_time = 0
+        self.end_time = 0
+        self.calls = []
+        # First call is a timed call with no warning
+        self.calls.append({'timeout': 4.0, 'numwarnings': 0})
+        # Second call is a timed call with a single warning played to the caller
+        self.calls.append({'timeout': 10.0, 'numwarnings': 1})
+        # Third call is a timed call with a single warning played to the callee
+        self.calls.append({'timeout': 10.0, 'numwarnings': 1})
+        # Fourth call is a timed call with a single warning played to both
+        # parties
+        self.calls.append({'timeout': 10.0, 'numwarnings': 2})
+        self.current_call = self.calls.pop(0)
+        self.num_warnings = 0
+        return
+
+    def ami_connect(self, ami):
+        # We only care about the UUT's AMI here
+        if ami.id != 0:
+            return
+
+        self.ami = ami
+        self.ami.registerEvent('Hangup', self.log_hangup_time)
+        self.ami.registerEvent('Bridge', self.log_bridge_time)
+        self.ami.registerEvent('TestEvent', self.log_warnings)
+
+    def log_bridge_time(self, ami, event):
+        if not self.bridge_time:
+            self.bridge_time = time.time()
+            LOGGER.info("Bridge started at time %f" % self.bridge_time)
+
+    def log_hangup_time(self, ami, event):
+        if not self.end_time:
+            self.end_time = time.time()
+            LOGGER.info("Got Timeout event at %f" % self.end_time)
+
+    def log_warnings(self, ami, event):
+        if not event.get('state') == 'PLAYED_WARNING':
+            return
+
+        self.num_warnings += 1
+
+    def check_duration(self, ami_uut, ami_alice, ami_bob):
+        if not self.bridge_time or not self.end_time:
+            LOGGER.error("We didn't get the notifications for duration")
+            self.test_object.set_passed(False)
+
+        duration = self.end_time - self.bridge_time
+
+        if (abs(duration - self.current_call['timeout']) > TOLERANCE):
+            LOGGER.error("Call duration was %f but we expected %f (+/- 0.5 sec)"
+                    % (duration, self.current_call['timeout']))
+            self.test_object.set_passed(False)
+
+        if self.current_call['numwarnings'] != self.num_warnings:
+            LOGGER.error("We expected %d warnings but got %d" %
+                    (self.current_call['numwarnings'], self.num_warnings))
+            self.test_object.set_passed(False)
+
+        # Reset the variables for the next call
+        self.bridge_time = self.end_time = self.num_warnings = 0
+        if len(self.calls) != 0:
+            self.current_call = self.calls.pop(0)

Propchange: asterisk/team/mmichelson/bridge-tests/tests/bridge/dial_L_option/Tester.py
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/team/mmichelson/bridge-tests/tests/bridge/dial_L_option/Tester.py
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/team/mmichelson/bridge-tests/tests/bridge/dial_L_option/Tester.py
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/team/mmichelson/bridge-tests/tests/bridge/dial_L_option/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/mmichelson/bridge-tests/tests/bridge/dial_L_option/configs/ast1/extensions.conf?view=auto&rev=3422
==============================================================================
--- asterisk/team/mmichelson/bridge-tests/tests/bridge/dial_L_option/configs/ast1/extensions.conf (added)
+++ asterisk/team/mmichelson/bridge-tests/tests/bridge/dial_L_option/configs/ast1/extensions.conf Thu Aug  9 17:50:05 2012
@@ -1,0 +1,15 @@
+[default]
+
+exten => no_warning,1,Dial(SIP/test_call at bob,,L(4000))
+same => n,Hangup()
+
+exten => caller_warning,1,Dial(SIP/test_call at bob,,L(10000:5000))
+same => n,Hangup()
+
+exten => callee_warning,1,Set(LIMIT_PLAYAUDIO_CALLER=no)
+same => n,Set(LIMIT_PLAYAUDIO_CALLEE=yes)
+same => n,Dial(SIP/test_call at bob,,L(10000:5000))
+
+exten => both_warning,1,Set(LIMIT_PLAYAUDIO_CALLEE=no)
+same => n,Set(LIMIT_PLAYAUDIO_CALLER=yes)
+same => n,Dial(SIP/test_call at bob,,L(10000:5000))

Propchange: asterisk/team/mmichelson/bridge-tests/tests/bridge/dial_L_option/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/team/mmichelson/bridge-tests/tests/bridge/dial_L_option/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/team/mmichelson/bridge-tests/tests/bridge/dial_L_option/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/team/mmichelson/bridge-tests/tests/bridge/dial_L_option/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/mmichelson/bridge-tests/tests/bridge/dial_L_option/test-config.yaml?view=auto&rev=3422
==============================================================================
--- asterisk/team/mmichelson/bridge-tests/tests/bridge/dial_L_option/test-config.yaml (added)
+++ asterisk/team/mmichelson/bridge-tests/tests/bridge/dial_L_option/test-config.yaml Thu Aug  9 17:50:05 2012
@@ -1,0 +1,33 @@
+testinfo:
+    summary: 'Test that a simple bridge works'
+    description: |
+        'Set up a bridge between two endpoints using the "L" option to app_dial and
+        ensure that the call is automatically ended and that sounds play when they are
+        expected to.'
+
+test-modules:
+    add-test-to-search-path: 'True'
+    test-object:
+        config-section: bridge-config
+        typename: 'BridgeTestCase.BridgeTestCase'
+    modules:
+        -
+            typename: 'Tester.Tester'
+
+bridge-config:
+    -
+        originate_channel: 'SIP/no_warning at uut'
+    -
+        originate_channel: 'SIP/caller_warning at uut'
+    -
+        originate_channel: 'SIP/callee_warning at uut'
+    -
+        originate_channel: 'SIP/both_warning at uut'
+
+properties:
+    minversion: '11.0.0'
+    dependencies:
+        - python : 'twisted'
+        - python : 'starpy'
+    tags:
+        - bridge

Propchange: asterisk/team/mmichelson/bridge-tests/tests/bridge/dial_L_option/test-config.yaml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/team/mmichelson/bridge-tests/tests/bridge/dial_L_option/test-config.yaml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/team/mmichelson/bridge-tests/tests/bridge/dial_L_option/test-config.yaml
------------------------------------------------------------------------------
    svn:mime-type = text/plain




More information about the svn-commits mailing list