[asterisk-commits] jrose: testsuite/asterisk/trunk r3609 - in /asterisk/trunk/tests/bridge: ./ p...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jan 18 11:40:13 CST 2013


Author: jrose
Date: Fri Jan 18 11:40:09 2013
New Revision: 3609

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=3609
Log:
Testsuite - Bridging: Add a bridge test for call parking DTMF feature

This test uses the bridging test module. Put simply, it starts a call from
Alice to Bob, and then either Alice or Bob uses the call parking feature to
park the call. The test covers feature detection as well as whether or not
parked call events are received over AMI as expected for each scenario.
Features are set both via Dial options and through the BRIDGE_FEATURES channel
variable in different test phases.

review: https://reviewboard.asterisk.org/r/2273/

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

Added: asterisk/trunk/tests/bridge/parkcall/Executioner.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/bridge/parkcall/Executioner.py?view=auto&rev=3609
==============================================================================
--- asterisk/trunk/tests/bridge/parkcall/Executioner.py (added)
+++ asterisk/trunk/tests/bridge/parkcall/Executioner.py Fri Jan 18 11:40:09 2013
@@ -1,0 +1,79 @@
+#!/usr/bin/env python
+'''
+Copyright (C) 2013, 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 logging
+import re
+
+sys.path.append("lib/python")
+
+LOGGER = logging.getLogger(__name__)
+
+class Executioner(object):
+    def __init__(self, module_config, test_object):
+        self.ami = None
+        self.parked_channel = None
+        test_object.register_ami_observer(self.ami_connect)
+        self.test_object = test_object
+
+        self.calls = []
+        self.calls.append({'parker' : 'alice', 'parkee' : 'bob'})
+        self.calls.append({'parker' : 'bob', 'parkee' : 'alice'})
+        self.calls.append({'parker' : 'alice', 'parkee' : 'bob'})
+        self.calls.append({'parker' : 'bob', 'parkee' : 'alice'})
+
+        self.parking_events_received = 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.check_hangup)
+        self.ami.registerEvent('ParkedCall', self.check_park)
+
+
+    def check_hangup(self, ami, event):
+        # We only hangup when we know that both the channel that initiated park and our zombie channel are gone.
+        if (self.hangups_processed == 1):
+            ami.hangup(self.parked_channel)
+        self.hangups_processed += 1
+
+    def check_park(self, ami, event):
+        self.parking_events_received += 1
+        this_expectation = self.calls.pop(0)
+        this_parker = this_expectation['parker']
+        this_parkee = this_expectation['parkee']
+
+        this_result_parker = event.get('from')
+        this_result_parkee = event.get('channel')
+        self.parked_channel = this_result_parkee
+
+        self.hangups_processed = 0
+
+        # Make sure the park event matches expectations. If not, we autofail.
+        if this_result_parker == None or this_result_parkee == None:
+            LOGGER.error("Phase %d: event %s - missing either 'from' or 'channel' fields." % (self.parking_events_received, event))
+            self.test_object.set_passed(False)
+            return
+
+        if not (re.match( (".*/%s-.*" % this_parker), this_result_parker)):
+            LOGGER.error("Phase %d: The expected parker (%s) did not match the parker received in the park event (%s)." % (self.parking_events_received, this_parker, this_result_parker))
+            self.test_object.set_passed(False)
+            return
+
+        if not (re.match( (".*/%s-.*" % this_parkee), this_result_parkee)):
+            LOGGER.error("Phase %d: The expected parkee (%s) did not match the parkee received from the park event (%s)." % (self.parking_events_received, this_parkee, this_result_parkee))
+            self.test_object.set_passed(False)
+            return
+
+        LOGGER.info ("Phase %d: Parker and Parkee for this phase arrived as expected.  The parkee (%s) will be hungup." % (self.parking_events_received, this_result_parkee))

Propchange: asterisk/trunk/tests/bridge/parkcall/Executioner.py
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/bridge/parkcall/Executioner.py
------------------------------------------------------------------------------
    svn:executable = *

Propchange: asterisk/trunk/tests/bridge/parkcall/Executioner.py
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Rev URL"

Propchange: asterisk/trunk/tests/bridge/parkcall/Executioner.py
------------------------------------------------------------------------------
    svn:mime-type = text/x-python

Added: asterisk/trunk/tests/bridge/parkcall/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/bridge/parkcall/configs/ast1/extensions.conf?view=auto&rev=3609
==============================================================================
--- asterisk/trunk/tests/bridge/parkcall/configs/ast1/extensions.conf (added)
+++ asterisk/trunk/tests/bridge/parkcall/configs/ast1/extensions.conf Fri Jan 18 11:40:09 2013
@@ -1,0 +1,15 @@
+[default]
+
+exten => alice_parkcall,1,Dial(SIP/test_call at bob,,Kh)
+same => n,Hangup
+
+exten => bob_parkcall,1,Dial(SIP/test_call at bob,,kH)
+same => n,Hangup
+
+exten => alice_parkcall2,1,Set(BRIDGE_FEATURES=K)
+same => n,Dial(SIP/test_call at bob,,h)
+same => n,Hangup
+
+exten => bob_parkcall2,1,Set(BRIDGE_FEATURES=k)
+same => n,Dial(SIP/test_call at bob,,H)
+same => n,Hangup

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

Propchange: asterisk/trunk/tests/bridge/parkcall/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Rev URL"

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

Added: asterisk/trunk/tests/bridge/parkcall/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/bridge/parkcall/test-config.yaml?view=auto&rev=3609
==============================================================================
--- asterisk/trunk/tests/bridge/parkcall/test-config.yaml (added)
+++ asterisk/trunk/tests/bridge/parkcall/test-config.yaml Fri Jan 18 11:40:09 2013
@@ -1,0 +1,124 @@
+testinfo:
+    summary: 'Test the call parking feature'
+    description: |
+        'Set up a bridge between two endpoints and check that the DTMF call parking
+        feature is detected properly. This test checks that the feature is detected
+        with normal BridgeTestCase feature detection and it also makes sure that
+        parking events are received on the expected channels. CEL log checks are
+        omitted in this test due to unpredictable hangup order for the parking channel
+        and the zombie of the channel that gets parked. This behavior makes CEL logs
+        have variability in both order and properties.'
+
+test-modules:
+    add-test-to-search-path: 'True'
+    test-object:
+        config-section: bridge-config
+        typename: 'BridgeTestCase.BridgeTestCase'
+    modules:
+        -
+            config-section: 'cdr-config'
+            typename: 'cdr.CDRModule'
+
+        -
+            typename: 'Executioner.Executioner'
+
+bridge-config:
+    -
+        originate_channel: 'SIP/alice_parkcall at uut'
+        features:
+            -
+                who: 'bob'
+                what: 'parkcall'
+                success: 'false'
+            -
+                who: 'alice'
+                what: 'parkcall'
+                success: 'true'
+
+    -
+        originate_channel: 'SIP/bob_parkcall at uut'
+        features:
+            -
+                who: 'alice'
+                what: 'parkcall'
+                success: 'false'
+            -
+                who: 'bob'
+                what: 'parkcall'
+                success: 'true'
+
+    -
+        originate_channel: 'SIP/alice_parkcall2 at uut'
+        features:
+            -
+                who: 'bob'
+                what: 'parkcall'
+                success: 'false'
+            -
+                who: 'alice'
+                what: 'parkcall'
+                success: 'true'
+
+    -
+        originate_channel: 'SIP/bob_parkcall2 at uut'
+        features:
+            -
+                who: 'alice'
+                what: 'parkcall'
+                success: 'false'
+            -
+                who: 'bob'
+                what: 'parkcall'
+                success: 'true'
+cdr-config:
+    -
+        file: 'Master'
+        lines:
+            -
+                source: '1234'
+                destination: 'alice_parkcall'
+                dcontext: 'default'
+                callerid: '"Alice" <1234>'
+                channel: '.*/alice-.*'
+                dchannel: '.*/bob-.*'
+                lastapp: 'Dial'
+                disposition: 'ANSWERED'
+                amaflags: 'DOCUMENTATION'
+            -
+                source: '1234'
+                destination: 'bob_parkcall'
+                dcontext: 'default'
+                callerid: '"Alice" <1234>'
+                channel: '.*/alice-.*'
+                dchannel: '.*/bob-.*'
+                lastapp: 'Dial'
+                disposition: 'ANSWERED'
+                amaflags: 'DOCUMENTATION'
+            -
+                source: '1234'
+                destination: 'alice_parkcall2'
+                dcontext: 'default'
+                callerid: '"Alice" <1234>'
+                channel: '.*/alice-.*'
+                dchannel: '.*/bob-.*'
+                lastapp: 'Dial'
+                disposition: 'ANSWERED'
+                amaflags: 'DOCUMENTATION'
+            -
+                source: '1234'
+                destination: 'bob_parkcall2'
+                dcontext: 'default'
+                callerid: '"Alice" <1234>'
+                channel: '.*/alice-.*'
+                dchannel: '.*/bob-.*'
+                lastapp: 'Dial'
+                disposition: 'ANSWERED'
+                amaflags: 'DOCUMENTATION'
+
+properties:
+    minversion: '12.0.0'
+    dependencies:
+        - python : 'twisted'
+        - python : 'starpy'
+    tags:
+        - bridge

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

Propchange: asterisk/trunk/tests/bridge/parkcall/test-config.yaml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Rev URL"

Propchange: asterisk/trunk/tests/bridge/parkcall/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=3609&r1=3608&r2=3609
==============================================================================
--- asterisk/trunk/tests/bridge/tests.yaml (original)
+++ asterisk/trunk/tests/bridge/tests.yaml Fri Jan 18 11:40:09 2013
@@ -5,5 +5,6 @@
     - test: 'blindxfer'
     - test: 'automon'
     - test: 'automixmon'
+    - test: 'parkcall'
     - test: 'dial_LS_options'
     - test: 'connected_line_update'




More information about the asterisk-commits mailing list