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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Sep 12 12:30:04 CDT 2013


Author: jrose
Date: Thu Sep 12 12:29:57 2013
New Revision: 4168

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=4168
Log:
testsuite: Update bridge/parkcall and bridge/parkcall_bridgefeatures for res_parking

(issue ASTERISK-22328)
Reported by: Matt Jordan
Review: https://reviewboard.asterisk.org/r/2814/

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

Modified: asterisk/trunk/tests/bridge/parkcall/Executioner.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/bridge/parkcall/Executioner.py?view=diff&rev=4168&r1=4167&r2=4168
==============================================================================
--- asterisk/trunk/tests/bridge/parkcall/Executioner.py (original)
+++ asterisk/trunk/tests/bridge/parkcall/Executioner.py Thu Sep 12 12:29:57 2013
@@ -13,7 +13,10 @@
 
 sys.path.append("lib/python")
 
+from version import AsteriskVersion
+
 LOGGER = logging.getLogger(__name__)
+
 
 class Executioner(object):
     def __init__(self, module_config, test_object):
@@ -22,11 +25,18 @@
         test_object.register_ami_observer(self.ami_connect)
         self.test_object = test_object
 
+        running_version = AsteriskVersion()
+
         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.calls.append({'parker': 'alice', 'parkee': 'bob'})
+        self.calls.append({'parker': 'bob', 'parkee': 'alice'})
+
+        # Parking events for this test vary with Asterisk 12 and
+        # up from prior versions.
+        if (running_version < AsteriskVersion("12.0.0")):
+            self.asterisk12Events = False
+        else:
+            self.asterisk12Events = True
 
         self.parking_events_received = 0
 
@@ -41,11 +51,14 @@
         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. There are no zombies in
+        # Asterisk 12 mode, so we hang up on the first hangup.
+        if not self.asterisk12Events and self.hangups_processed == 1 \
+                or self.asterisk12Events and self.hangups_processed == 0:
+            ami.hangup(self.parked_channel)
 
-    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):
@@ -54,26 +67,51 @@
         this_parker = this_expectation['parker']
         this_parkee = this_expectation['parkee']
 
-        this_result_parker = event.get('from')
-        this_result_parkee = event.get('channel')
+        if self.asterisk12Events:
+            parker_field = 'parkerdialstring'
+            parkee_field = 'parkeechannel'
+        else:
+            parker_field = 'from'
+            parkee_field = 'channel'
+
+        this_result_parker = event.get(parker_field)
+        this_result_parkee = event.get(parkee_field)
+
         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))
+        if this_result_parker is None:
+            LOGGER.error("Phase %d: event %s - missing parker identifying "
+                         "field '%s'" % (self.parking_events_received, event,
+                                         parker_field))
             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))
+        if this_result_parkee is None:
+            LOGGER.error("Phase %d: event %s - missing parkee identifying "
+                         "field '%s'" % (self.parking_events_received, event,
+                                         parkee_field))
             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))
+        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
 
-        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))
+        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))

Modified: 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=diff&rev=4168&r1=4167&r2=4168
==============================================================================
--- asterisk/trunk/tests/bridge/parkcall/configs/ast1/extensions.conf (original)
+++ asterisk/trunk/tests/bridge/parkcall/configs/ast1/extensions.conf Thu Sep 12 12:29:57 2013
@@ -5,11 +5,3 @@
 
 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

Added: asterisk/trunk/tests/bridge/parkcall/configs/ast1/res_parking.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/bridge/parkcall/configs/ast1/res_parking.conf?view=auto&rev=4168
==============================================================================
    (empty)

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

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

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

Modified: asterisk/trunk/tests/bridge/parkcall/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/bridge/parkcall/test-config.yaml?view=diff&rev=4168&r1=4167&r2=4168
==============================================================================
--- asterisk/trunk/tests/bridge/parkcall/test-config.yaml (original)
+++ asterisk/trunk/tests/bridge/parkcall/test-config.yaml Thu Sep 12 12:29:57 2013
@@ -16,7 +16,14 @@
         typename: 'BridgeTestCase.BridgeTestCase'
     modules:
         -
+            minversion: '11.0.0'
+            maxversion: '12.0.0'
             config-section: 'cdr-config'
+            typename: 'cdr.CDRModule'
+
+        -
+            minversion: '12.0.0'
+            config-section: 'cdr-config-12plus'
             typename: 'cdr.CDRModule'
 
         -
@@ -48,29 +55,6 @@
                 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'
@@ -95,9 +79,32 @@
                 lastapp: 'Dial'
                 disposition: 'ANSWERED'
                 amaflags: 'DOCUMENTATION'
+
+cdr-config-12plus:
+    -
+        file: 'Master'
+        lines:
             -
                 source: '1234'
-                destination: 'alice_parkcall2'
+                destination: 'alice_parkcall'
+                dcontext: 'default'
+                callerid: '"Alice" <1234>'
+                channel: '.*/alice-.*'
+                dchannel: '.*/bob-.*'
+                lastapp: 'Dial'
+                disposition: 'ANSWERED'
+                amaflags: 'DOCUMENTATION'
+            -
+                source: '4321'
+                dcontext: 'default'
+                callerid: '"Bob" <4321>'
+                channel: '.*/bob-.*'
+                dchannel: ''
+                disposition: 'ANSWERED'
+                amaflags: 'DOCUMENTATION'
+            -
+                source: '1234'
+                destination: 'bob_parkcall'
                 dcontext: 'default'
                 callerid: '"Alice" <1234>'
                 channel: '.*/alice-.*'
@@ -107,17 +114,17 @@
                 amaflags: 'DOCUMENTATION'
             -
                 source: '1234'
-                destination: 'bob_parkcall2'
+                destination: 'bob_parkcall'
                 dcontext: 'default'
                 callerid: '"Alice" <1234>'
                 channel: '.*/alice-.*'
-                dchannel: '.*/bob-.*'
+                dchannel: ''
                 lastapp: 'Dial'
                 disposition: 'ANSWERED'
                 amaflags: 'DOCUMENTATION'
 
 properties:
-    minversion: '12.0.0'
+    minversion: '11.0.0'
     dependencies:
         - buildoption: 'TEST_FRAMEWORK'
         - python : 'twisted'

Added: asterisk/trunk/tests/bridge/parkcall_bridgefeatures/Executioner.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/bridge/parkcall_bridgefeatures/Executioner.py?view=auto&rev=4168
==============================================================================
--- asterisk/trunk/tests/bridge/parkcall_bridgefeatures/Executioner.py (added)
+++ asterisk/trunk/tests/bridge/parkcall_bridgefeatures/Executioner.py Thu Sep 12 12:29:57 2013
@@ -1,0 +1,117 @@
+#!/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")
+
+from version import AsteriskVersion
+
+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
+
+        running_version = AsteriskVersion()
+
+        self.calls = []
+        self.calls.append({'parker': 'alice', 'parkee': 'bob'})
+        self.calls.append({'parker': 'bob', 'parkee': 'alice'})
+
+        # Parking events for this test vary with Asterisk 12 and
+        # up from prior versions.
+        if (running_version < AsteriskVersion("12.0.0")):
+            self.asterisk12Events = False
+        else:
+            self.asterisk12Events = True
+
+        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. There are no zombies in
+        # Asterisk 12 mode, so we hang up on the first hangup.
+        if not self.asterisk12Events and self.hangups_processed == 1 \
+                or self.asterisk12Events and self.hangups_processed == 0:
+            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']
+
+        if self.asterisk12Events:
+            parker_field = 'parkerdialstring'
+            parkee_field = 'parkeechannel'
+        else:
+            parker_field = 'from'
+            parkee_field = 'channel'
+
+        this_result_parker = event.get(parker_field)
+        this_result_parkee = event.get(parkee_field)
+
+        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 is None:
+            LOGGER.error("Phase %d: event %s - missing parker identifying "
+                         "field '%s'" % (self.parking_events_received, event,
+                                         parker_field))
+            self.test_object.set_passed(False)
+            return
+
+        if this_result_parkee is None:
+            LOGGER.error("Phase %d: event %s - missing parkee identifying "
+                         "field '%s'" % (self.parking_events_received, event,
+                                         parkee_field))
+            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_bridgefeatures/Executioner.py
------------------------------------------------------------------------------
    svn:eol-style = native

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

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

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

Added: asterisk/trunk/tests/bridge/parkcall_bridgefeatures/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/bridge/parkcall_bridgefeatures/configs/ast1/extensions.conf?view=auto&rev=4168
==============================================================================
--- asterisk/trunk/tests/bridge/parkcall_bridgefeatures/configs/ast1/extensions.conf (added)
+++ asterisk/trunk/tests/bridge/parkcall_bridgefeatures/configs/ast1/extensions.conf Thu Sep 12 12:29:57 2013
@@ -1,0 +1,9 @@
+[default]
+
+exten => alice_parkcall,1,Set(BRIDGE_FEATURES=K)
+same => n,Dial(SIP/test_call at bob,,h)
+same => n,Hangup
+
+exten => bob_parkcall,1,Set(BRIDGE_FEATURES=k)
+same => n,Dial(SIP/test_call at bob,,H)
+same => n,Hangup

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

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

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

Added: asterisk/trunk/tests/bridge/parkcall_bridgefeatures/configs/ast1/res_parking.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/bridge/parkcall_bridgefeatures/configs/ast1/res_parking.conf?view=auto&rev=4168
==============================================================================
    (empty)

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

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

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

Added: asterisk/trunk/tests/bridge/parkcall_bridgefeatures/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/bridge/parkcall_bridgefeatures/test-config.yaml?view=auto&rev=4168
==============================================================================
--- asterisk/trunk/tests/bridge/parkcall_bridgefeatures/test-config.yaml (added)
+++ asterisk/trunk/tests/bridge/parkcall_bridgefeatures/test-config.yaml Thu Sep 12 12:29:57 2013
@@ -1,0 +1,97 @@
+testinfo:
+    summary: 'Test the call parking feature set via BRIDGE_FEATURES'
+    description: |
+        'This is the same as the basic call parking test, only the'
+        'feature is applied by the BRIDGE_FEATURES channel variable'
+        'instead of with application arguments.'
+
+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:
+  test-runs:
+    -
+        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'
+
+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: '4321'
+                dcontext: 'default'
+                callerid: '"Bob" <4321>'
+                channel: '.*/bob-.*'
+                dchannel: ''
+                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: 'bob_parkcall'
+                dcontext: 'default'
+                callerid: '"Alice" <1234>'
+                channel: '.*/alice-.*'
+                dchannel: ''
+                lastapp: 'Dial'
+                disposition: 'ANSWERED'
+                amaflags: 'DOCUMENTATION'
+
+properties:
+    minversion: '12.0.0'
+    dependencies:
+        - buildoption: 'TEST_FRAMEWORK'
+        - python : 'twisted'
+        - python : 'starpy'
+    tags:
+        - bridge

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

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

Propchange: asterisk/trunk/tests/bridge/parkcall_bridgefeatures/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=4168&r1=4167&r2=4168
==============================================================================
--- asterisk/trunk/tests/bridge/tests.yaml (original)
+++ asterisk/trunk/tests/bridge/tests.yaml Thu Sep 12 12:29:57 2013
@@ -9,10 +9,11 @@
     - test: 'automon'
     - test: 'automixmon'
     - test: 'parkcall'
+    - test: 'parkcall_bridgefeatures'
     - dir: 'parkcall_timeout'
     - test: 'parkcall_blindxfer'
     - test: 'dial_LS_options'
     - test: 'connected_line_update'
     - test: 'transfer_capabilities'
     - test: 'transfer_failure'
-    - test: 'bridge_action'
+    - test: 'bridge_action'




More information about the asterisk-commits mailing list