[Asterisk-code-review] manager/mixmonitor: test AMI events (testsuite[16])

Sébastien Duthil asteriskteam at digium.com
Thu Feb 18 17:18:37 CST 2021


Sébastien Duthil has uploaded this change for review. ( https://gerrit.asterisk.org/c/testsuite/+/15502 )


Change subject: manager/mixmonitor: test AMI events
......................................................................

manager/mixmonitor: test AMI events

ASTERISK-29244

Change-Id: I5f0a20517c7d1d5707a6ed03ceedad5fb8c72b4d
---
M tests/manager/mixmonitor/configs/ast1/extensions.conf
D tests/manager/mixmonitor/start_mix.py
M tests/manager/mixmonitor/test-config.yaml
3 files changed, 103 insertions(+), 45 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/testsuite refs/changes/02/15502/1

diff --git a/tests/manager/mixmonitor/configs/ast1/extensions.conf b/tests/manager/mixmonitor/configs/ast1/extensions.conf
index 0874417..a48ab70 100644
--- a/tests/manager/mixmonitor/configs/ast1/extensions.conf
+++ b/tests/manager/mixmonitor/configs/ast1/extensions.conf
@@ -1,6 +1,13 @@
 [default]
-exten => s,1,Answer()
-    same => n,Playback(tt-monkeys)
+exten => talk,1,Answer()
+    same => n,UserEvent(test-manager-monitor,Action: start)
+    same => n,SayDigits(1)
+    same => n,UserEvent(test-manager-monitor,Action: mute)
+    same => n,SayDigits(2)
+    same => n,UserEvent(test-manager-monitor,Action: unmute)
+    same => n,SayDigits(3)
+    same => n,UserEvent(test-manager-monitor,Action: stop)
+    same => n,Wait(5)
     same => n,Hangup()
 
 exten => echo,1,Answer()
diff --git a/tests/manager/mixmonitor/start_mix.py b/tests/manager/mixmonitor/start_mix.py
deleted file mode 100644
index 55b22f0..0000000
--- a/tests/manager/mixmonitor/start_mix.py
+++ /dev/null
@@ -1,29 +0,0 @@
-"""
-Copyright (C) 2014, Digium, Inc.
-Tyler Cambron <tcambron at digium.com>
-
-This program is free software, distributed under the terms of
-the GNU General Public License Version 2.
-"""
-
-import logging
-
-LOGGER = logging.getLogger(__name__)
-
-
-def record(ami, event):
-    """
-    When the event specified in the test-config is triggered, the variable
-    'channel' is set to the channelid of the channel where the event occurs.
-    'channel' is then used to create the MixMonitor command message that is
-    sent to asterisk to begin the recording of the playback.
-    """
-    channel = event.get('destchannel')
-    if not channel:
-        channel = event.get('channel')
-    if not channel:
-        return False
-    message = {'Action': 'MixMonitor', 'Channel': '%s' % channel,
-               'File': 'theRecording.wav', 'options': 'r'}
-    ami.sendMessage(message)
-    return True
diff --git a/tests/manager/mixmonitor/test-config.yaml b/tests/manager/mixmonitor/test-config.yaml
index 65c94e1..7a91b8d 100644
--- a/tests/manager/mixmonitor/test-config.yaml
+++ b/tests/manager/mixmonitor/test-config.yaml
@@ -13,35 +13,82 @@
             config-section: test-object-config
             typename: 'test_case.TestCaseModule'
         modules:
-          - config-section: ami-config-12
-            typename: 'ami.AMIEventModule'
           - config-section: start-call
             typename: 'pluggable_modules.Originator'
-
+          - config-section: ami-actions
+            typename: 'pluggable_modules.EventActionModule'
           - config-section: sound-file-analyzer
             typename: 'pluggable_modules.SoundChecker'
+          - config-section: expected-ami-events
+            typename: 'ami.AMIEventModule'
 
 test-object-config:
     asterisk-instances: 1
     connect-ami: true
 
 start-call:
-    channel: 'Local/s at default'
+    channel: 'Local/talk at default'
     context: 'default'
     exten: 'echo'
     priority: 1
     trigger: 'ami_connect'
     async: True
 
-ami-config-12:
+ami-actions:
     -
-        type: 'callback'
-        conditions:
-            match:
-                Event: 'DialEnd'
-                DestChannel: 'Local/s at default-.*'
-        callbackModule: 'start_mix'
-        callbackMethod: 'record'
+        ami-events:
+            conditions:
+                match:
+                    Event: 'UserEvent'
+                    UserEvent: 'test-manager-monitor'
+                    Action: 'start'
+            count: 1
+        ami-actions:
+            action:
+                Action: 'MixMonitor'
+                Channel: '{channel}'
+                File: 'theRecording.wav'
+                Options: 'r'
+    -
+        ami-events:
+            conditions:
+                match:
+                    Event: 'UserEvent'
+                    UserEvent: 'test-manager-monitor'
+                    Action: 'mute'
+            count: 1
+        ami-actions:
+            action:
+                Action: 'MixMonitorMute'
+                Channel: '{channel}'
+                Direction: 'both'
+                State: '1'
+    -
+        ami-events:
+            conditions:
+                match:
+                    Event: 'UserEvent'
+                    UserEvent: 'test-manager-monitor'
+                    Action: 'unmute'
+            count: 1
+        ami-actions:
+            action:
+                Action: 'MixMonitorMute'
+                Channel: '{channel}'
+                Direction: 'both'
+                State: '0'
+    -
+        ami-events:
+            conditions:
+                match:
+                    Event: 'UserEvent'
+                    UserEvent: 'test-manager-monitor'
+                    Action: 'stop'
+            count: 1
+        ami-actions:
+            action:
+                Action: 'StopMixMonitor'
+                Channel: '{channel}'
 
 sound-file-analyzer:
     auto-stop: True
@@ -59,14 +106,47 @@
                     actions:
                         -
                             type: 'size_check'
-                            size: 258000
-                            tolerance: 5000
+                            size: 40400
+                            tolerance: 2000
                         -
                             type: 'energy_check'
                             channel: 'Local/audio at soundtest'
                             context: 'default'
                             exten: 's'
                             priority: '1'
+expected-ami-events:
+    -
+        type: 'headermatch'
+        conditions:
+            match:
+                Event: 'MixMonitorStart'
+                Channel: 'Local/talk at default-.*'
+        count: '1'
+    -
+        type: 'headermatch'
+        conditions:
+            match:
+                Event: 'MixMonitorMute'
+                Channel: 'Local/talk at default-.*'
+                Direction: 'both'
+                State: '1'
+        count: '1'
+    -
+        type: 'headermatch'
+        conditions:
+            match:
+                Event: 'MixMonitorMute'
+                Channel: 'Local/talk at default-.*'
+                Direction: 'both'
+                State: '0'
+        count: '1'
+    -
+        type: 'headermatch'
+        conditions:
+            match:
+                Event: 'MixMonitorStop'
+                Channel: 'Local/talk at default-.*'
+        count: '1'
 
 properties:
     dependencies:

-- 
To view, visit https://gerrit.asterisk.org/c/testsuite/+/15502
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: testsuite
Gerrit-Branch: 16
Gerrit-Change-Id: I5f0a20517c7d1d5707a6ed03ceedad5fb8c72b4d
Gerrit-Change-Number: 15502
Gerrit-PatchSet: 1
Gerrit-Owner: Sébastien Duthil <sduthil at wazo.community>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20210218/48e73d23/attachment-0001.html>


More information about the asterisk-code-review mailing list