[asterisk-commits] mjordan: testsuite/asterisk/trunk r5085 - in /asterisk/trunk: lib/python/aste...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri May 30 07:48:44 CDT 2014
Author: mjordan
Date: Fri May 30 07:48:40 2014
New Revision: 5085
URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=5085
Log:
tests/funcs/func_talkdetect: Add a test for the TALK_DETECT function
This adds a test for func_talkdetect. The test consists of four iterations. In
each iteration, the same set of sounds are passed through a Local channel.
TALK_DETECT is placed on one half of the local channel, while playbacks are
initiated via ARI on the other half. Based on the various parameters passed to
TALK_DETECT, a different number of events should be received over AMI/ARI. The
iterations are:
- An iteration that sets TALK_DETECT with its default settings. A single pair
of events is expected to be received.
- An iteration that sets TALK_DETECT with a short silence threshold and a
different talk threshold. Two pairs of events are expected to be received.
- An iteration that sets TALK_DETECT with a very short silence threshold.
Three pairs of events are expected to be received.
- An iteration that removes TALK_DETECT. No events should be received.
The test verifies that a total of 6 event pairs are received (over both
AMI/ARI), and that in the 'end' events, a duration that is non-zero is present.
Review: https://reviewboard.asterisk.org/r/3564/
ASTERISK-23786
Reported by: Matt Jordan
Added:
asterisk/trunk/tests/funcs/func_talkdetect/
asterisk/trunk/tests/funcs/func_talkdetect/configs/
asterisk/trunk/tests/funcs/func_talkdetect/configs/ast1/
asterisk/trunk/tests/funcs/func_talkdetect/configs/ast1/extensions.conf (with props)
asterisk/trunk/tests/funcs/func_talkdetect/talk_detect.py (with props)
asterisk/trunk/tests/funcs/func_talkdetect/test-config.yaml (with props)
Modified:
asterisk/trunk/lib/python/asterisk/ari.py
asterisk/trunk/tests/funcs/tests.yaml
Modified: asterisk/trunk/lib/python/asterisk/ari.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/ari.py?view=diff&rev=5085&r1=5084&r2=5085
==============================================================================
--- asterisk/trunk/lib/python/asterisk/ari.py (original)
+++ asterisk/trunk/lib/python/asterisk/ari.py Fri May 30 07:48:40 2014
@@ -682,7 +682,7 @@
return True
elif isinstance(pattern, str) or isinstance(pattern, unicode):
# Pattern strings are considered to be regexes
- return re.match(pattern, message) is not None
+ return re.match(pattern, str(message)) is not None
elif isinstance(pattern, int):
# Integers are literal matches
return pattern == message
Added: asterisk/trunk/tests/funcs/func_talkdetect/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/funcs/func_talkdetect/configs/ast1/extensions.conf?view=auto&rev=5085
==============================================================================
--- asterisk/trunk/tests/funcs/func_talkdetect/configs/ast1/extensions.conf (added)
+++ asterisk/trunk/tests/funcs/func_talkdetect/configs/ast1/extensions.conf Fri May 30 07:48:40 2014
@@ -1,0 +1,77 @@
+
+[default]
+
+exten => talk_detect_normal,1,NoOp()
+ same => n,Set(TALK_DETECT(set)=)
+ same => n,Return()
+
+exten => talk_detect_short,1,NoOp()
+ same => n,Set(TALK_DETECT(set)=1500,128)
+ same => n,Return()
+
+exten => talk_detect_micro,1,NoOp()
+ same => n,Set(TALK_DETECT(set)=500)
+ same => n,Return()
+
+exten => talk_detect_remove,1,NoOp()
+ same => n,Set(TALK_DETECT(remove)=)
+ same => n,Return()
+
+; The actual start of the test. This will loop through the
+; various test iterations - when all are done, it will hangup
+; the channel.
+exten => test,1,NoOp()
+ same => n,Set(TEST_COUNTER=1)
+ same => n(start-test),NoOp()
+ same => n,GotoIf($[${TEST_COUNTER} = 1]?test-one)
+ same => n,GotoIf($[${TEST_COUNTER} = 2]?test-two)
+ same => n,GotoIf($[${TEST_COUNTER} = 3]?test-three)
+ same => n,GotoIf($[${TEST_COUNTER} = 4]?test-four)
+ same => n,Hangup()
+
+ ; Test setting TALK_DETECT with default settings, playing
+ ; back utterances that should result in a single talking
+ ; started/stopped, then removing TALK_DETECT
+ same => n(test-one),NoOp()
+ same => n,GoSub(default,talk_detect_normal,1)
+ same => n,Stasis(testsuite,playback)
+ same => n,GoSub(default,talk_detect_remove,1)
+ same => n,Goto(next-test)
+
+ ; Test setting TALK_DETECT with a shorter silence treshold
+ ; and a smaller talking threshold. This should result in
+ ; two pairs of events.
+ same => n(test-two),NoOp()
+ same => n,GoSub(default,talk_detect_short,1)
+ same => n,Stasis(testsuite,playback)
+ same => n,Goto(next-test)
+
+ ; Test setting TALK_DETECT with modified settings from the
+ ; previous iteration. This sets a tiny silence treshold.
+ ; This should result in three pairs of events.
+ same => n(test-three),NoOp()
+ same => n,GoSub(default,talk_detect_micro,1)
+ same => n,Stasis(testsuite,playback)
+ same => n,Goto(next-test)
+
+ ; Test removing TALK_DETECT and playing back the sounds.
+ ; We should get no events from this - the attached AMI/ARI
+ ; listeners will fail the test if we get additional events
+ ; at this point.
+ same => n(test-four),NoOp()
+ same => n,GoSub(default,talk_detect_remove,1)
+ same => n,Stasis(testsuite,playback)
+ same => n,Goto(next-test)
+
+ same => n(next-test),NoOp()
+ same => n,Set(TEST_COUNTER=${INC(TEST_COUNTER)})
+ same => n,Goto(start-test)
+
+; The channels are originated into the ARI application. The
+; ARI application itself will release one end of the Local channel
+; into the test after subscribing to it; both ARI/AMI listen for
+; the events.
+exten => stasis_app,1,NoOp()
+ same => n,Answer()
+ same => n,Stasis(testsuite,subscribe)
+ same => n,Hangup()
Propchange: asterisk/trunk/tests/funcs/func_talkdetect/configs/ast1/extensions.conf
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/funcs/func_talkdetect/configs/ast1/extensions.conf
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/funcs/func_talkdetect/configs/ast1/extensions.conf
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/funcs/func_talkdetect/talk_detect.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/funcs/func_talkdetect/talk_detect.py?view=auto&rev=5085
==============================================================================
--- asterisk/trunk/tests/funcs/func_talkdetect/talk_detect.py (added)
+++ asterisk/trunk/tests/funcs/func_talkdetect/talk_detect.py Fri May 30 07:48:40 2014
@@ -1,0 +1,113 @@
+"""Test drivers for the func_talkdetect test
+
+Copyright (C) 2014, Digium, Inc.
+Matt Jordan <mjordan at digium.com>
+
+This program is free software, distributed under the terms of
+the GNU General Public License Version 2.
+"""
+
+import logging
+import json
+
+LOGGER = logging.getLogger(__name__)
+
+PLAYBACK_CHAN = None
+TEST_CHAN = None
+FINAL_PLAYBACK = None
+
+def check_playback(ari, event, test_object):
+ """Handler for the PlaybackFinished event
+
+ When the last sound file has played back, release the testing channel back
+ into the dialplan to continue the test.
+
+ Keyword Arguments:
+ ari Our ARI client
+ event The StasisStart event for the application
+ test_object The test object for this test
+ """
+
+ if event['playback']['id'] == FINAL_PLAYBACK:
+ ari.post("channels", TEST_CHAN, "continue")
+
+ return True
+
+def on_start(ari, event, test_object):
+ """Gather our Local channel halves, set up subscriptions, and start testing
+
+ This is the entry point for the Stasis application that the Local channel
+ is originated into. Both halves enter - the ;1 is released into the
+ dialplan to run the tests, while the ;2 is used to play audio back. The
+ audio is considered on the 'read' side of the ;1 channel, and drives each
+ individual test (see do_playback).
+
+ Keyword Arguments:
+ ari Our ARI client
+ event The StasisStart event for the application
+ test_object The test object for this test
+ """
+ global PLAYBACK_CHAN
+ global TEST_CHAN
+
+ args = event.get('args')
+
+ channel_name = event["channel"]["name"]
+ channel_id = event["channel"]["id"]
+ if ";1" in channel_name:
+ TEST_CHAN = channel_id
+
+ ari.post("applications", "testsuite", "subscription",
+ eventSource="channel:%s" % channel_id)
+ else:
+ PLAYBACK_CHAN = channel_id
+
+ if TEST_CHAN and PLAYBACK_CHAN:
+ ari.post("channels", TEST_CHAN, "continue",
+ context="default",
+ extension="test",
+ priority=1)
+
+ return True
+
+def do_playback(ari, event, test_object):
+ """Playback a sequence of sounds to trigger talk detect events
+
+ Entry point for a Stasis application that plays back
+ "Sunday, 830 AM" with some pauses interspersed to test
+ the TALK_DETECT function.
+
+ Keyword Arguments:
+ ari Our ARI client
+ event The StasisStart event for the application
+ test_object The test object for this test
+ """
+ global FINAL_PLAYBACK
+
+ test_object.reset_timeout()
+
+ if not PLAYBACK_CHAN:
+ LOGGER.error("No playback channel for Stasis playback app")
+ test_object.set_passed(False)
+ return False
+
+ ari.post("channels", PLAYBACK_CHAN, "play",
+ media="sound:digits/day-0")
+ ari.post("channels", PLAYBACK_CHAN, "play",
+ media="sound:silence/1")
+ ari.post("channels", PLAYBACK_CHAN, "play",
+ media="sound:digits/8")
+ ari.post("channels", PLAYBACK_CHAN, "play",
+ media="sound:digits/30")
+ ari.post("channels", PLAYBACK_CHAN, "play",
+ media="sound:silence/2")
+ ari.post("channels", PLAYBACK_CHAN, "play",
+ media="sound:digits/a-m")
+ playback = ari.post("channels", PLAYBACK_CHAN, "play",
+ media="sound:silence/3")
+ json_response = json.loads(playback.content)
+ FINAL_PLAYBACK = json_response.get('id')
+
+ return True
+
+
Propchange: asterisk/trunk/tests/funcs/func_talkdetect/talk_detect.py
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/funcs/func_talkdetect/talk_detect.py
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/funcs/func_talkdetect/talk_detect.py
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/funcs/func_talkdetect/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/funcs/func_talkdetect/test-config.yaml?view=auto&rev=5085
==============================================================================
--- asterisk/trunk/tests/funcs/func_talkdetect/test-config.yaml (added)
+++ asterisk/trunk/tests/funcs/func_talkdetect/test-config.yaml Fri May 30 07:48:40 2014
@@ -1,0 +1,125 @@
+testinfo:
+ summary: Test TALK_DETECT function emitting AMI/ARI events
+ description: |
+ "This verifies the TALK_DETECT function. It does this by
+ taking a Local channel, setting the TALK_DETECT function
+ on one half of the channel, and streaming audio through
+ on the other half of the channel.
+
+ When the test starts, both Local channel halves are placed
+ into a Stasis application. A subscription is made to the
+ ;1 channel, which is released into the dialplan.
+
+ The dialplan manages each iteration of the test; when
+ the ;1 channel has the appropriate TALK_DETECT settings
+ enabled on it, it enters into another Stasis application.
+ This Stasis application causes media to be played on the
+ ;2 channel.
+
+ The test consists of 4 iterations:
+ - An iteration that tests the base settings for TALK_DETECT.
+ A single pair of events is expected.
+ - An iteration that tests a shorter silence threshold and
+ a different talking threshold. Two pairs of events
+ are expected.
+ - An iteration that tests a very short silence threshold.
+ Three pairs of events are expected.
+ - An iteration that removes TALK_DETECT and plays back the
+ media. No events are expected."
+
+test-modules:
+ add-test-to-search-path: True
+ test-object:
+ config-section: test-object-config
+ typename: ari.AriTestObject
+ modules:
+ -
+ config-section: ari-config
+ typename: ari.WebSocketEventModule
+ -
+ config-section: ami-config
+ typename: 'ami.AMIEventModule'
+
+
+test-object-config:
+ test-iterations:
+ -
+ channel: 'Local/stasis_app at default'
+ context: 'default'
+ exten: 'stasis_app'
+ priority: '1'
+ async: True
+
+ari-config:
+ events:
+ - conditions:
+ match:
+ type: StasisStart
+ application: testsuite
+ args: ['subscribe']
+ count: 2
+ callback:
+ module: talk_detect
+ method: on_start
+ - conditions:
+ match:
+ type: StasisStart
+ application: testsuite
+ args: ['playback']
+ count: 4
+ callback:
+ module: talk_detect
+ method: do_playback
+ - conditions:
+ match:
+ type: PlaybackFinished
+ callback:
+ module: talk_detect
+ method: check_playback
+ - conditions:
+ match:
+ type: ChannelTalkingStarted
+ count: 6
+ - conditions:
+ match:
+ type: ChannelTalkingFinished
+ duration: '[1-9](\d+)?'
+ count: 6
+
+ami-config:
+ -
+ type: 'headermatch'
+ conditions:
+ match:
+ Event: 'ChannelTalkingStart'
+ requirements:
+ match:
+ Channel: 'Local/stasis_app at default-00000000;1'
+ count: '6'
+ -
+ type: 'headermatch'
+ conditions:
+ match:
+ Event: 'ChannelTalkingStop'
+ requirements:
+ match:
+ Channel: 'Local/stasis_app at default-00000000;1'
+ Duration: '[1-9](\d+)?'
+ count: '6'
+
+properties:
+ minversion: '12.4.0'
+ dependencies:
+ - python : autobahn.websocket
+ - python : requests
+ - python : twisted
+ - python : starpy
+ - asterisk : res_ari_channels
+ - asterisk : res_ari_playbacks
+ - asterisk : func_talkdetect
+ - asterisk : app_stasis
+ - asterisk : res_stasis
+ tags:
+ - ARI
+
+
Propchange: asterisk/trunk/tests/funcs/func_talkdetect/test-config.yaml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/funcs/func_talkdetect/test-config.yaml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/funcs/func_talkdetect/test-config.yaml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: asterisk/trunk/tests/funcs/tests.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/funcs/tests.yaml?view=diff&rev=5085&r1=5084&r2=5085
==============================================================================
--- asterisk/trunk/tests/funcs/tests.yaml (original)
+++ asterisk/trunk/tests/funcs/tests.yaml Fri May 30 07:48:40 2014
@@ -4,3 +4,4 @@
- test: 'func_srv'
- test: 'func_presencestate'
- test: 'func_global'
+ - test: 'func_talkdetect'
More information about the asterisk-commits
mailing list