[asterisk-commits] kmoore: testsuite/asterisk/trunk r3579 - in /asterisk/trunk/tests/bridge: ./ ...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Dec 18 11:51:02 CST 2012


Author: kmoore
Date: Tue Dec 18 11:50:58 2012
New Revision: 3579

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=3579
Log:
Add tests for L() and S() bridging options

This addtion to the testsuite tests the S() bridging option which hangs
up the call a specified time after the call is answered, and the L()
bridging option which provides the ability to play warnings to one or
both parties in addition to hanging up the call at the desired time
after the answer.

(closes issue SWP-4713)

Added:
    asterisk/trunk/tests/bridge/dial_LS_options/
    asterisk/trunk/tests/bridge/dial_LS_options/Tester.py   (with props)
    asterisk/trunk/tests/bridge/dial_LS_options/configs/
    asterisk/trunk/tests/bridge/dial_LS_options/configs/ast1/
    asterisk/trunk/tests/bridge/dial_LS_options/configs/ast1/extensions.conf   (with props)
    asterisk/trunk/tests/bridge/dial_LS_options/test-config.yaml   (with props)
Modified:
    asterisk/trunk/tests/bridge/tests.yaml

Added: asterisk/trunk/tests/bridge/dial_LS_options/Tester.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/bridge/dial_LS_options/Tester.py?view=auto&rev=3579
==============================================================================
--- asterisk/trunk/tests/bridge/dial_LS_options/Tester.py (added)
+++ asterisk/trunk/tests/bridge/dial_LS_options/Tester.py Tue Dec 18 11:50:58 2012
@@ -1,0 +1,99 @@
+#!/usr/bin/env python
+'''
+Copyright (C) 2012, Digium, Inc.
+Kinsey Moore <kmoore at digium.com>
+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, 'hangup_style': 'HANGUP_TIME'})
+        # Second call is a timed call with a single warning played to the caller
+        self.calls.append({'timeout': 10.0, 'numwarnings': 1, 'hangup_style': 'BRIDGE_TIMELIMIT'})
+        # Third call is a timed call with a single warning played to the callee
+        self.calls.append({'timeout': 10.0, 'numwarnings': 1, 'hangup_style': 'BRIDGE_TIMELIMIT'})
+        # Fourth call is a timed call with a single warning played to both
+        # parties
+        self.calls.append({'timeout': 10.0, 'numwarnings': 2, 'hangup_style': 'BRIDGE_TIMELIMIT'})
+	# Fifth call is a timed call with no warning using the S() option (uses the same mechanism as L with no warning)
+        self.calls.append({'timeout': 4.0, 'numwarnings': 0, 'hangup_style': 'HANGUP_TIME'})
+        self.current_call = self.calls.pop(0)
+        self.num_warnings = 0
+        self.num_hangup_triggers = 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 event.get('state') == 'PLAYBACK' and event.get('message') == 'beep':
+            self.num_warnings += 1
+            return
+
+        if event.get('state') == self.current_call['hangup_style']:
+            self.num_hangup_triggers += 1
+            return
+
+    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)
+
+        if 1 != self.num_hangup_triggers:
+            LOGGER.error("We expected 1 hangup trigger but got %d" %
+                    (self.num_hangup_triggers))
+            self.test_object.set_passed(False)
+
+        # Reset the variables for the next call
+        self.num_hangup_triggers = self.bridge_time = self.end_time = self.num_warnings = 0
+        if len(self.calls) != 0:
+            self.current_call = self.calls.pop(0)

Propchange: asterisk/trunk/tests/bridge/dial_LS_options/Tester.py
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/bridge/dial_LS_options/Tester.py
------------------------------------------------------------------------------
    svn:executable = *

Propchange: asterisk/trunk/tests/bridge/dial_LS_options/Tester.py
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/bridge/dial_LS_options/Tester.py
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/bridge/dial_LS_options/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/bridge/dial_LS_options/configs/ast1/extensions.conf?view=auto&rev=3579
==============================================================================
--- asterisk/trunk/tests/bridge/dial_LS_options/configs/ast1/extensions.conf (added)
+++ asterisk/trunk/tests/bridge/dial_LS_options/configs/ast1/extensions.conf Tue Dec 18 11:50:58 2012
@@ -1,0 +1,25 @@
+[default]
+
+exten => no_warning,1,NoOp()
+same => n,Dial(SIP/test_call at bob,,L(4000))
+same => n,Hangup()
+
+exten => caller_warning,1,NoOp()
+same => n,Set(LIMIT_WARNING_FILE=beep)
+same => n,Dial(SIP/test_call at bob,,L(10000:5000))
+same => n,Hangup()
+
+exten => callee_warning,1,NoOp()
+same => n,Set(LIMIT_WARNING_FILE=beep)
+same => n,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,NoOp()
+same => n,Set(LIMIT_WARNING_FILE=beep)
+same => n,Set(LIMIT_PLAYAUDIO_CALLEE=yes)
+same => n,Dial(SIP/test_call at bob,,L(10000:5000))
+
+exten => no_warning_s,1,NoOp()
+same => n,Dial(SIP/test_call at bob,,S(4))
+same => n,Hangup()

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

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

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

Added: asterisk/trunk/tests/bridge/dial_LS_options/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/bridge/dial_LS_options/test-config.yaml?view=auto&rev=3579
==============================================================================
--- asterisk/trunk/tests/bridge/dial_LS_options/test-config.yaml (added)
+++ asterisk/trunk/tests/bridge/dial_LS_options/test-config.yaml Tue Dec 18 11:50:58 2012
@@ -1,0 +1,35 @@
+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/uut/no_warning'
+    -
+        originate_channel: 'SIP/uut/caller_warning'
+    -
+        originate_channel: 'SIP/uut/callee_warning'
+    -
+        originate_channel: 'SIP/uut/both_warning'
+    -
+        originate_channel: 'SIP/uut/no_warning_s'
+
+properties:
+    minversion: '11.0.0'
+    dependencies:
+        - python : 'twisted'
+        - python : 'starpy'
+    tags:
+        - bridge

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

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

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

Modified: asterisk/trunk/tests/bridge/tests.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/bridge/tests.yaml?view=diff&rev=3579&r1=3578&r2=3579
==============================================================================
--- asterisk/trunk/tests/bridge/tests.yaml (original)
+++ asterisk/trunk/tests/bridge/tests.yaml Tue Dec 18 11:50:58 2012
@@ -5,4 +5,4 @@
     - test: 'blindxfer'
     - test: 'automon'
     - test: 'automixmon'
-    - test: 'dial_L_option'
+    - test: 'dial_LS_options'




More information about the asterisk-commits mailing list