[svn-commits] kharwell: testsuite/asterisk/trunk r6164 - in /asterisk/trunk: lib/python/ast...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Jan 2 14:11:26 CST 2015


Author: kharwell
Date: Fri Jan  2 14:11:13 2015
New Revision: 6164

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=6164
Log:
Dual channel redirect tests

Wrote three tests:

1) Redirect two channels that are in the Echo application, verify that they are both redirected to the appropriate dialplan location, make sure no surrogate channels are hanging around.

2) Redirect two channels that are bridged, verify that both channels are redirected to the same dialplan location, the bridge they were in gets destroyed, and neither channel is hung up by the process.

3) Redirect two channels that are in two different bridges, verify that both channels are redirected to the same dialplan location, the bridges they were in get destroyed, and neither channel is hung up by the process.

Also, added an option to the event action pluggable module instance that when set will not trigger the action until the count has been met on the event.

ASTERISK-24536
Reported by: Niklas Larsson
Review: https://reviewboard.asterisk.org/r/4283/

Added:
    asterisk/trunk/tests/manager/redirect/dual/
    asterisk/trunk/tests/manager/redirect/dual/app/
    asterisk/trunk/tests/manager/redirect/dual/app/configs/
    asterisk/trunk/tests/manager/redirect/dual/app/configs/ast1/
    asterisk/trunk/tests/manager/redirect/dual/app/configs/ast1/extensions.conf   (with props)
    asterisk/trunk/tests/manager/redirect/dual/app/test-config.yaml   (with props)
    asterisk/trunk/tests/manager/redirect/dual/bridge/
    asterisk/trunk/tests/manager/redirect/dual/bridge/different/
    asterisk/trunk/tests/manager/redirect/dual/bridge/different/configs/
    asterisk/trunk/tests/manager/redirect/dual/bridge/different/configs/ast1/
    asterisk/trunk/tests/manager/redirect/dual/bridge/different/configs/ast1/extensions.conf   (with props)
    asterisk/trunk/tests/manager/redirect/dual/bridge/different/test-config.yaml   (with props)
    asterisk/trunk/tests/manager/redirect/dual/bridge/same/
    asterisk/trunk/tests/manager/redirect/dual/bridge/same/configs/
    asterisk/trunk/tests/manager/redirect/dual/bridge/same/configs/ast1/
    asterisk/trunk/tests/manager/redirect/dual/bridge/same/configs/ast1/extensions.conf   (with props)
    asterisk/trunk/tests/manager/redirect/dual/bridge/same/test-config.yaml   (with props)
    asterisk/trunk/tests/manager/redirect/dual/bridge/tests.yaml   (with props)
    asterisk/trunk/tests/manager/redirect/dual/tests.yaml   (with props)
Modified:
    asterisk/trunk/lib/python/asterisk/ami.py
    asterisk/trunk/tests/manager/redirect/tests.yaml

Modified: asterisk/trunk/lib/python/asterisk/ami.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/ami.py?view=diff&rev=6164&r1=6163&r2=6164
==============================================================================
--- asterisk/trunk/lib/python/asterisk/ami.py (original)
+++ asterisk/trunk/lib/python/asterisk/ami.py Fri Jan  2 14:11:13 2015
@@ -667,19 +667,27 @@
 class AMIPluggableEventInstance(AMIHeaderMatchInstance):
     """Subclass of AMIEventInstance that works with the pluggable event action
     module.
+
+    Events can be set to 'trigger-on-count' meaning (when set to True) the
+    trigger callback will not be called until the min count is reached. For
+    event/actions this means actions won't be executed until an event reaches
+    its specified count.
     """
 
     def __init__(self, test_object, triggered_callback, config, data):
         """Setup the AMI event observer"""
         self.triggered_callback = triggered_callback
 	self.data = data
+        self.trigger_on_count = config.get('trigger-on-count', False)
         super(AMIPluggableEventInstance, self).__init__(config, test_object)
 
     def event_callback(self, ami, event):
         """Callback called when an event is received from AMI"""
 	super(AMIPluggableEventInstance, self).event_callback(ami, event)
-        if self.passed:
+        if self.passed and (not self.trigger_on_count or
+                            self.count['event'] == self.count['min']):
             self.triggered_callback(self.data, ami, event)
+
 
 class AMIPluggableEventModule(object):
     """Generates AMIEventInstance instances that match events for the pluggable

Added: asterisk/trunk/tests/manager/redirect/dual/app/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/manager/redirect/dual/app/configs/ast1/extensions.conf?view=auto&rev=6164
==============================================================================
--- asterisk/trunk/tests/manager/redirect/dual/app/configs/ast1/extensions.conf (added)
+++ asterisk/trunk/tests/manager/redirect/dual/app/configs/ast1/extensions.conf Fri Jan  2 14:11:13 2015
@@ -1,0 +1,14 @@
+[default]
+
+exten => one,1,Answer()
+      same => n,UserEvent(Next)
+      same => n,Echo()
+      same => n,Hangup()
+
+exten => two,1,Answer()
+      same => n,Echo()
+      same => n,Hangup()
+
+exten => redirect,1,Answer()
+      same => n,UserEvent(Redirected)
+      same => n,Echo() ; simple test case takes care of hangups

Propchange: asterisk/trunk/tests/manager/redirect/dual/app/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/manager/redirect/dual/app/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Rev URL

Propchange: asterisk/trunk/tests/manager/redirect/dual/app/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/manager/redirect/dual/app/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/manager/redirect/dual/app/test-config.yaml?view=auto&rev=6164
==============================================================================
--- asterisk/trunk/tests/manager/redirect/dual/app/test-config.yaml (added)
+++ asterisk/trunk/tests/manager/redirect/dual/app/test-config.yaml Fri Jan  2 14:11:13 2015
@@ -1,0 +1,89 @@
+testinfo:
+    summary: 'Redirect two channels that are in a dialplan application'
+    description: |
+        Redirect two channels that are in the Echo application, verify that
+        they are both redirected to the appropriate dialplan location, and
+        make sure no surrogate channels are hanging around.
+
+properties:
+    minversion: '13.2.0'
+    dependencies:
+        - python : 'twisted'
+        - python : 'starpy'
+        - asterisk: 'app_echo'
+        - asterisk: 'app_userevent'
+    tags:
+        - manager
+
+test-modules:
+    test-object:
+        config-section: test-config
+        typename: 'test_case.SimpleTestCase'
+    modules:
+        -
+            config-section: event-action-config
+            typename: 'pluggable_modules.EventActionModule'
+
+test-config:
+    # expect three user events - the first will kick off the second originate
+    # and the second/third one will be raised during redirect
+    expected_events: 3
+    test-iterations:
+        -
+            channel: 'Local/one at default'
+            application: 'Echo'
+        -
+            channel: 'Local/two at default'
+            application: 'Echo'
+
+event-action-config:
+    -
+        ami-events:
+            # once we receive two DialEnd events (both in the 'up' state)
+            # assume the channels are ready to be redirected
+            conditions:
+                match:
+                    Event: 'DialEnd'
+                    DestChannel: 'Local/.*1'
+            requirements:
+                match:
+                   DestChannelState: '6' # Up
+            count: '2'
+            trigger-on-count: True
+        ami-actions:
+            # redirect the channels to the "redirect" extension
+            action:
+                Action: 'Redirect'
+                Channel: 'Local/one at default-00000000;1'
+                Context: 'default'
+                Exten: 'redirect'
+                Priority: '1'
+                Extrachannel: 'Local/two at default-00000001;1'
+                Extracontext: 'default'
+                Extraexten: 'redirect'
+                Extrapriority: '1'
+    -
+        ami-events:
+            # check to make sure that the two user event are received (raised
+            # from the extension the channels got redirected to)
+            conditions:
+                match:
+                    Event: 'UserEvent'
+                    Channel: 'Local/.*1$'
+                requirements:
+                    UserEvent: 'Redirected'
+            count: '2'
+            trigger-on-count: True
+        ami-actions:
+            # the channels have been redirected at this point so check the
+            # current channel status
+            action:
+                Action: 'Status'
+    -
+        ami-events:
+            # make sure there are no surrogate channels around
+            conditions:
+                match:
+                    Event: 'Status'
+                    Channel: 'Surrogate/Local/.*'
+            count: '0'

Propchange: asterisk/trunk/tests/manager/redirect/dual/app/test-config.yaml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/manager/redirect/dual/app/test-config.yaml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Rev URL

Propchange: asterisk/trunk/tests/manager/redirect/dual/app/test-config.yaml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/manager/redirect/dual/bridge/different/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/manager/redirect/dual/bridge/different/configs/ast1/extensions.conf?view=auto&rev=6164
==============================================================================
--- asterisk/trunk/tests/manager/redirect/dual/bridge/different/configs/ast1/extensions.conf (added)
+++ asterisk/trunk/tests/manager/redirect/dual/bridge/different/configs/ast1/extensions.conf Fri Jan  2 14:11:13 2015
@@ -1,0 +1,24 @@
+[default]
+
+exten => alice0,1,Answer()
+      same => n,UserEvent(Next)
+      same => n,Echo()
+
+exten => call-bob0,1,Dial(Local/bob0 at default,,Tt)
+      same => n,Hangup()
+
+exten => bob0,1,Answer()
+      same => n,Echo()
+
+exten => alice1,1,Answer()
+      same => n,Echo()
+
+exten => call-bob1,1,Dial(Local/bob1 at default,,Tt)
+      same => n,Hangup()
+
+exten => bob1,1,Answer()
+      same => n,Echo()
+
+exten => redirect,1,Answer()
+      same => n,UserEvent(Redirected)
+      same => n,Echo() ; simple test case takes care of hangups

Propchange: asterisk/trunk/tests/manager/redirect/dual/bridge/different/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/manager/redirect/dual/bridge/different/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Rev URL

Propchange: asterisk/trunk/tests/manager/redirect/dual/bridge/different/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/manager/redirect/dual/bridge/different/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/manager/redirect/dual/bridge/different/test-config.yaml?view=auto&rev=6164
==============================================================================
--- asterisk/trunk/tests/manager/redirect/dual/bridge/different/test-config.yaml (added)
+++ asterisk/trunk/tests/manager/redirect/dual/bridge/different/test-config.yaml Fri Jan  2 14:11:13 2015
@@ -1,0 +1,113 @@
+testinfo:
+    summary: 'Redirect two channels that are in two different bridges'
+    description: |
+        Redirect two channels that are in two different bridges, verify that
+        both channels are redirected to the same dialplan location, the bridges
+        they were in get destroyed, and neither channel is hung up by the process.
+
+properties:
+    minversion: '13.2.0'
+    dependencies:
+        - python : 'twisted'
+        - python : 'starpy'
+        - asterisk: 'app_dial'
+        - asterisk: 'app_echo'
+        - asterisk: 'app_userevent'
+    tags:
+        - manager
+
+test-modules:
+    test-object:
+        config-section: test-config
+        typename: 'test_case.SimpleTestCase'
+    modules:
+        -
+            config-section: event-action-config
+            typename: 'pluggable_modules.EventActionModule'
+
+test-config:
+    # expect four user events - the first initiates the second call, the second
+    # and third events are raised during redirect, and the fourth ends the test
+    expected_events: 4
+    test-iterations:
+        -
+            channel: 'Local/alice0 at default'
+            context: 'default'
+            exten: 'call-bob0'
+            priority: '1'
+        -
+            channel: 'Local/alice1 at default'
+            context: 'default'
+            exten: 'call-bob1'
+            priority: '1'
+
+event-action-config:
+    -
+        ami-events:
+            # once we receive two DialEnd events (both in the 'up' state)
+            # assume the channels are in their respective bridges and ready
+            # to be redirected
+            conditions:
+                match:
+                    Event: 'DialEnd'
+                    DestChannel: 'Local/bob.*1'
+            requirements:
+                match:
+                   DestChannelState: '6' # Up
+            count: '2'
+            trigger-on-count: True
+
+        ami-actions:
+            # redirect the channels to the "redirect" extension
+            action:
+                Action: 'Redirect'
+                Channel: 'Local/alice0 at default-00000000;1'
+                Context: 'default'
+                Exten: 'redirect'
+                Priority: '1'
+                Extrachannel: 'Local/alice1 at default-00000002;1'
+                Extracontext: 'default'
+                Extraexten: 'redirect'
+                Extrapriority: '1'
+    -
+        ami-events:
+            # verify that the bridges gets destroyed
+            conditions:
+                match:
+                    Event: 'BridgeDestroy'
+                    BridgeNumChannels: '0'
+            count: '2'
+    -
+        ami-events:
+            # check to make sure that the user events are received (raised from
+            # the extension the channels got redirected to) for both alices
+            conditions:
+                match:
+                    Event: 'UserEvent'
+                    Channel: 'Local/alice.*1$'
+                requirements:
+                    UserEvent: 'Redirected'
+            count: '2'
+            trigger-on-count: True
+
+        ami-actions:
+            # once we receive two redirected events check alices's status
+            action:
+                Action: 'Status'
+
+    -
+        ami-events:
+            # make sure the alices are still up
+            conditions:
+                match:
+                    Event: 'Status'
+                    Channel: 'Local/alice.*1$'
+            count: '2'
+            trigger-on-count: True
+
+        ami-actions:
+            # notify the simple test case to stop
+            action:
+                Action: 'UserEvent'
+                UserEvent: 'Done'
+

Propchange: asterisk/trunk/tests/manager/redirect/dual/bridge/different/test-config.yaml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/manager/redirect/dual/bridge/different/test-config.yaml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Rev URL

Propchange: asterisk/trunk/tests/manager/redirect/dual/bridge/different/test-config.yaml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/manager/redirect/dual/bridge/same/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/manager/redirect/dual/bridge/same/configs/ast1/extensions.conf?view=auto&rev=6164
==============================================================================
--- asterisk/trunk/tests/manager/redirect/dual/bridge/same/configs/ast1/extensions.conf (added)
+++ asterisk/trunk/tests/manager/redirect/dual/bridge/same/configs/ast1/extensions.conf Fri Jan  2 14:11:13 2015
@@ -1,0 +1,14 @@
+[default]
+
+exten => alice,1,Answer()
+      same => n,Echo()
+
+exten => call-bob,1,Dial(Local/bob at default,,Tt)
+      same => n,Hangup()
+
+exten => bob,1,Answer()
+      same => n,Echo()
+
+exten => redirect,1,Answer()
+      same => n,UserEvent(Redirected)
+      same => n,Echo() ; simple test case takes care of hangups

Propchange: asterisk/trunk/tests/manager/redirect/dual/bridge/same/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/manager/redirect/dual/bridge/same/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Rev URL

Propchange: asterisk/trunk/tests/manager/redirect/dual/bridge/same/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/manager/redirect/dual/bridge/same/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/manager/redirect/dual/bridge/same/test-config.yaml?view=auto&rev=6164
==============================================================================
--- asterisk/trunk/tests/manager/redirect/dual/bridge/same/test-config.yaml (added)
+++ asterisk/trunk/tests/manager/redirect/dual/bridge/same/test-config.yaml Fri Jan  2 14:11:13 2015
@@ -1,0 +1,114 @@
+testinfo:
+    summary: 'Redirect two channels that are in a bridge together'
+    description: |
+        Redirect two channels that are bridged, verify that both channels are
+        redirected to the same dialplan location, the bridge they were
+        in gets destroyed, and neither channel is hung up by the process.
+
+properties:
+    minversion: '13.2.0'
+    dependencies:
+        - python : 'twisted'
+        - python : 'starpy'
+        - asterisk: 'app_dial'
+        - asterisk: 'app_echo'
+        - asterisk: 'app_userevent'
+    tags:
+        - manager
+
+test-modules:
+    test-object:
+        config-section: test-config
+        typename: 'test_case.SimpleTestCase'
+    modules:
+        -
+            config-section: event-action-config
+            typename: 'pluggable_modules.EventActionModule'
+
+test-config:
+    # expect three user events - the first two are raised during redirect and
+    # the last event ends the test
+    expected_events: 3
+    test-iterations:
+        -
+            channel: 'Local/alice at default'
+            context: 'default'
+            exten: 'call-bob'
+            priority: '1'
+
+event-action-config:
+    -
+        ami-events:
+            # verify that alice and bob get bridged
+            conditions:
+                match:
+                    Event: 'BridgeEnter'
+                    Channel: 'Local/.*1$'
+            count: '2'
+    -
+        ami-events:
+            # wait for bob to enter the echo application before redirecting
+            # (note - this is the condition that triggers the redirect)
+            conditions:
+                match:
+                    Event: 'DialEnd'
+                    DestChannel: 'Local/bob.*1'
+            requirements:
+                match:
+                   DestChannelState: '6' # Up
+            count: '1'
+
+        ami-actions:
+            # redirect alice/bob to the "redirect" extension
+            action:
+                Action: 'Redirect'
+                Channel: 'Local/alice at default-00000000;1'
+                Context: 'default'
+                Exten: 'redirect'
+                Priority: '1'
+                Extrachannel: 'Local/bob at default-00000001;1'
+                Extracontext: 'default'
+                Extraexten: 'redirect'
+                Extrapriority: '1'
+    -
+        ami-events:
+            # verify that the bridge gets destroyed
+            conditions:
+                match:
+                    Event: 'BridgeDestroy'
+                    BridgeNumChannels: '0'
+            count: '1'
+    -
+        ami-events:
+            # check to make sure that the user event is received (raised
+            # from the extension the channel got redirected) for both
+            # alice and bob
+            conditions:
+                match:
+                    Event: 'UserEvent'
+                    Channel: 'Local/.*1$'
+                requirements:
+                    UserEvent: 'Redirected'
+            count: '2'
+            trigger-on-count: True
+
+        ami-actions:
+            # once we receive two redirected events check alice/bob's status
+            action:
+                Action: 'Status'
+
+    -
+        ami-events:
+            # make sure the alice/bob are still up
+            conditions:
+                match:
+                    Event: 'Status'
+                    Channel: 'Local/.*1$'
+            count: '2'
+            trigger-on-count: True
+
+        ami-actions:
+            # notify the simple test case to stop
+            action:
+                Action: 'UserEvent'
+                UserEvent: 'Done'

Propchange: asterisk/trunk/tests/manager/redirect/dual/bridge/same/test-config.yaml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/manager/redirect/dual/bridge/same/test-config.yaml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Rev URL

Propchange: asterisk/trunk/tests/manager/redirect/dual/bridge/same/test-config.yaml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/manager/redirect/dual/bridge/tests.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/manager/redirect/dual/bridge/tests.yaml?view=auto&rev=6164
==============================================================================
--- asterisk/trunk/tests/manager/redirect/dual/bridge/tests.yaml (added)
+++ asterisk/trunk/tests/manager/redirect/dual/bridge/tests.yaml Fri Jan  2 14:11:13 2015
@@ -1,0 +1,4 @@
+# Enter tests here in the order they should be considered for execution:
+tests:
+    - test: 'same'
+    - test: 'different'

Propchange: asterisk/trunk/tests/manager/redirect/dual/bridge/tests.yaml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/manager/redirect/dual/bridge/tests.yaml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Rev URL

Propchange: asterisk/trunk/tests/manager/redirect/dual/bridge/tests.yaml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/manager/redirect/dual/tests.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/manager/redirect/dual/tests.yaml?view=auto&rev=6164
==============================================================================
--- asterisk/trunk/tests/manager/redirect/dual/tests.yaml (added)
+++ asterisk/trunk/tests/manager/redirect/dual/tests.yaml Fri Jan  2 14:11:13 2015
@@ -1,0 +1,4 @@
+# Enter tests here in the order they should be considered for execution:
+tests:
+    - test: 'app'
+    - dir: 'bridge'

Propchange: asterisk/trunk/tests/manager/redirect/dual/tests.yaml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/manager/redirect/dual/tests.yaml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Rev URL

Propchange: asterisk/trunk/tests/manager/redirect/dual/tests.yaml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: asterisk/trunk/tests/manager/redirect/tests.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/manager/redirect/tests.yaml?view=diff&rev=6164&r1=6163&r2=6164
==============================================================================
--- asterisk/trunk/tests/manager/redirect/tests.yaml (original)
+++ asterisk/trunk/tests/manager/redirect/tests.yaml Fri Jan  2 14:11:13 2015
@@ -1,3 +1,4 @@
 # Enter tests here in the order they should be considered for execution:
 tests:
     - dir:  'single'
+    - dir:  'dual'




More information about the svn-commits mailing list