[asterisk-commits] mjordan: testsuite/asterisk/trunk r3357 - in /asterisk/trunk/tests: ./ funcs/...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Jul 23 16:34:12 CDT 2012
Author: mjordan
Date: Mon Jul 23 16:34:05 2012
New Revision: 3357
URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=3357
Log:
Add func_jitterbuffer tests
This adds tests for func_jitterbuffer in a new folder, 'funcs'.
Other function related tests can be moved to this location in
a separate commit.
Review: https://reviewboard.asterisk.org/r/2021/
Added:
asterisk/trunk/tests/funcs/
asterisk/trunk/tests/funcs/func_jitterbuffer/
asterisk/trunk/tests/funcs/func_jitterbuffer/configs/
asterisk/trunk/tests/funcs/func_jitterbuffer/configs/ast1/
asterisk/trunk/tests/funcs/func_jitterbuffer/configs/ast1/extensions.conf (with props)
asterisk/trunk/tests/funcs/func_jitterbuffer/configs/ast1/sip.conf (with props)
asterisk/trunk/tests/funcs/func_jitterbuffer/run-test (with props)
asterisk/trunk/tests/funcs/func_jitterbuffer/talking.ulaw (with props)
asterisk/trunk/tests/funcs/func_jitterbuffer/test-config.yaml (with props)
asterisk/trunk/tests/funcs/func_presencestate/
- copied from r3296, asterisk/trunk/tests/func_presencestate/
asterisk/trunk/tests/funcs/func_srv/
- copied from r3296, asterisk/trunk/tests/func_srv/
asterisk/trunk/tests/funcs/tests.yaml (with props)
Modified:
asterisk/trunk/tests/tests.yaml
Added: asterisk/trunk/tests/funcs/func_jitterbuffer/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/funcs/func_jitterbuffer/configs/ast1/extensions.conf?view=auto&rev=3357
==============================================================================
--- asterisk/trunk/tests/funcs/func_jitterbuffer/configs/ast1/extensions.conf (added)
+++ asterisk/trunk/tests/funcs/func_jitterbuffer/configs/ast1/extensions.conf Mon Jul 23 16:34:05 2012
@@ -1,0 +1,70 @@
+[global]
+
+CURRENT_JB_TYPE=none
+CURRENT_RECORDED_FILE=none
+CURRENT_MAX_SIZE=none
+CURRENT_RESYNC_THRESHOLD=none
+CURRENT_TARGET_EXTRA=none
+CURRENT_TEST_TYPE=none
+
+[sippeer]
+
+exten => s,1,NoOp()
+ same => n,GoSubIf($[${CURRENT_TEST_TYPE}=default_jb]?default_jb:)
+ same => n,GoSubIf($[${CURRENT_TEST_TYPE}=all_params_jb]?all_params_jb:)
+ same => n,Record(func_jitterbuffer_%d.wav,,,k)
+ same => n,Verbose(1, ${RECORDED_FILE})
+ same => n,Hangup()
+
+; Subroutines used to set the Jitter Buffer on the outbound SIP channel
+ same => n(default_jb),NoOp()
+ same => n,Set(JITTERBUFFER(${CURRENT_JB_TYPE})=default))
+ same => n,Return()
+
+ same => n(all_params_jb),NoOp()
+ same => n,Set(JITTERBUFFER(${CURRENT_JB_TYPE})=${CURRENT_MAX_SIZE},${CURRENT_RESYNC_THRESHOLD},${CURRENT_TARGET_EXTRA},${CURRENT_FRAME_TYPE})
+ same => n,Return()
+
+exten => h,1,NoOp()
+ same => n,Set(GLOBAL(CURRENT_RECORDED_FILE)=${RECORDED_FILE})
+ same => n,UserEvent(TestResult, result: pass)
+
+[default]
+
+; Local channel destinations to stream input to the receiving side
+exten => stream_file,1,NoOp()
+ same => n,Answer()
+ same => n,Playback(${TALK_AUDIO})
+ same => n,Wait(2)
+ same => n,Hangup()
+
+; Extensions that set up the jitter buffers and dial the SIP channel
+exten => default,1,NoOp()
+ same => n,Set(GLOBAL(CURRENT_TEST_TYPE)=default_jb)
+ same => n,Set(GLOBAL(CURRENT_JB_TYPE)=${JB_TYPE})
+ same => n,Dial(SIP/ast1)
+ same => n,Hangup()
+
+exten => all_param,1,NoOp()
+ same => n,Set(GLOBAL(CURRENT_TEST_TYPE)=all_params_jb)
+ same => n,Set(GLOBAL(CURRENT_MAX_SIZE)=${MAX_SIZE})
+ same => n,Set(GLOBAL(CURRENT_RESYNC_THRESHOLD)=${RESYNC_THRESHOLD})
+ same => n,Set(GLOBAL(CURRENT_TARGET_EXTRA)=${TARGET_EXTRA})
+ same => n,Set(GLOBAL(CURRENT_JB_TYPE)=${JB_TYPE})
+ same => n,Dial(SIP/ast1)
+ same => n,Hangup()
+
+; Talk detect verification for the recorded file
+exten => detect_audio,1,Answer()
+ same => n,Set(TALK_DETECTED=0) ; initialize TALK_DETECT var
+ same => n,BackgroundDetect(${CURRENT_RECORDED_FILE},1,20,,20000)
+ same => n,GoToIf($[${TALK_DETECTED}=0]?talkdetectfail:talkdetectpass)
+ same => n(talkdetectfail),NoOp()
+ same => n,UserEvent(TalkDetect, result: fail)
+ same => n,Hangup()
+ same => n(talkdetectpass),NoOp()
+ same => n,UserEvent(TalkDetect, result: pass)
+ same => n,Hangup()
+
+exten => play_recording,1,Answer()
+ same => n,PlayBack(${CURRENT_RECORDED_FILE})
Propchange: asterisk/trunk/tests/funcs/func_jitterbuffer/configs/ast1/extensions.conf
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/funcs/func_jitterbuffer/configs/ast1/extensions.conf
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/funcs/func_jitterbuffer/configs/ast1/extensions.conf
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/funcs/func_jitterbuffer/configs/ast1/sip.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/funcs/func_jitterbuffer/configs/ast1/sip.conf?view=auto&rev=3357
==============================================================================
--- asterisk/trunk/tests/funcs/func_jitterbuffer/configs/ast1/sip.conf (added)
+++ asterisk/trunk/tests/funcs/func_jitterbuffer/configs/ast1/sip.conf Mon Jul 23 16:34:05 2012
@@ -1,0 +1,7 @@
+[general]
+
+[ast1]
+context=sippeer
+type=peer
+host=127.0.0.1
+port=5060
Propchange: asterisk/trunk/tests/funcs/func_jitterbuffer/configs/ast1/sip.conf
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/funcs/func_jitterbuffer/configs/ast1/sip.conf
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/funcs/func_jitterbuffer/configs/ast1/sip.conf
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/funcs/func_jitterbuffer/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/funcs/func_jitterbuffer/run-test?view=auto&rev=3357
==============================================================================
--- asterisk/trunk/tests/funcs/func_jitterbuffer/run-test (added)
+++ asterisk/trunk/tests/funcs/func_jitterbuffer/run-test Mon Jul 23 16:34:05 2012
@@ -1,0 +1,157 @@
+#!/usr/bin/env python
+# vim: sw=3 et:
+'''
+Copyright (C) 2012, 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 sys
+import os
+import logging
+
+from twisted.internet import reactor
+
+sys.path.append("lib/python")
+
+from asterisk.TestCase import TestCase
+
+LOGGER = logging.getLogger(__name__)
+
+class JitterBufferTest(TestCase):
+ """ Execute tests against func_jitterbuffer
+ """
+
+ DEFAULT_MAX_SIZE = '200'
+ DEFAULT_TARGET_EXTRA = '40'
+ DEFAULT_RESYNC_THRESHOLD = '1000'
+
+ def __init__(self):
+ super(JitterBufferTest, self).__init__()
+ self.talk_audio = os.path.join(os.getcwd(), "tests/funcs/func_jitterbuffer/talking")
+
+ # Build the tests. We check different combinations of jitter buffer
+ # types (fixed/adaptive) as well as varying parameters (resync,
+ # target_extra, etc.).
+ self._tests = []
+ for jb_type in ['adaptive', 'fixed']:
+ # Test JITTERBUFFER(type)=default
+ self._tests.append({'originate' : {'channel': 'Local/default at default',
+ 'exten': 'stream_file',
+ 'context': 'default',
+ 'variable': {'JB_TYPE' : '%s,TALK_AUDIO=%s' %
+ (jb_type, self.talk_audio)},},
+ 'maxsize': JitterBufferTest.DEFAULT_MAX_SIZE,
+ 'impl': jb_type,
+ 'resyncthreshold': JitterBufferTest.DEFAULT_RESYNC_THRESHOLD,
+ 'targetextra': JitterBufferTest.DEFAULT_TARGET_EXTRA})
+ for values in [{'maxsize': '1000', 'targetextra': '10', 'resyncthreshold': '2000'},
+ {'maxsize': '2000', 'targetextra': '50', 'resyncthreshold': '500'}]:
+ # Test a variety of values
+ self._tests.append({'originate' : {'channel': 'Local/all_param at default',
+ 'exten': 'stream_file',
+ 'context': 'default',
+ 'variable': {'JB_TYPE' : '%s,TALK_AUDIO=%s,MAX_SIZE=%s,TARGET_EXTRA=%s,RESYNC_THRESHOLD=%s' %
+ (jb_type, self.talk_audio, values['maxsize'], values['targetextra'], values['resyncthreshold'])},},
+ 'maxsize': values['maxsize'],
+ 'impl': jb_type,
+ 'resyncthreshold': values['resyncthreshold'],
+ 'targetextra': values['targetextra']})
+
+ self._test_counter = 0
+ self._jitterbuffers_detected = 0
+
+ self.create_asterisk()
+
+
+ def run(self):
+ super(JitterBufferTest, self).run()
+ self.create_ami_factory()
+
+
+ def run_test(self, ami):
+ """ Run the next scheduled test """
+
+ test = self._tests[self._test_counter]
+ originate = test['originate']
+ LOGGER.info("Originating %s to %s@%s" %
+ (originate['channel'], originate['exten'], originate['context']))
+ ami.originate(channel=originate['channel'],
+ context=originate['context'],
+ exten=originate['exten'],
+ priority='1',
+ variable=originate['variable']).addErrback(
+ self.handleOriginateFailure)
+
+
+ def ami_connect(self, ami):
+ ami.registerEvent('Newexten', self._newexten_event_handler)
+ ami.registerEvent('UserEvent', self._userevent_handler)
+ self.run_test(ami)
+
+
+ def _launch_talk_detect(self, ami):
+ """ When a voice jitter buffer was used, launch talk detect to make
+ sure the recorded file still has some voice in it """
+
+ ami.originate(channel='Local/detect_audio at default',
+ context='default',
+ exten='play_recording',
+ priority='1').addErrback(
+ self.handleOriginateFailure)
+
+
+ def _userevent_handler(self, ami, event):
+ if 'TestResult' in event['userevent']:
+ LOGGER.debug('Received TestResult event')
+ self._launch_talk_detect(ami)
+ return
+ elif 'TalkDetect' in event['userevent']:
+ LOGGER.debug('Received TalkDetect with result %s' % event['result'])
+ if (event['result'] == 'fail'):
+ LOGGER.error('Received talk detect failure, failing test')
+ self.stop_reactor()
+ return
+ else:
+ return
+
+ self._test_counter += 1
+ if (self._test_counter < len(self._tests)):
+ self.reset_timeout()
+ self.run_test(ami)
+ else:
+ # If we made it through all the tests, then we received all of
+ # the expected test events. Set passed to true and stop the test.
+ LOGGER.info('All tests run; stopping reactor')
+ if (self._jitterbuffers_detected != len(self._tests)):
+ LOGGER.warning('Only %d jitter buffers were applied to ' \
+ 'channels; expected %d' %
+ (self._jitterbuffers_detected, len(self._tests)))
+ self.passed = False
+ else:
+ self.passed = True
+ self.stop_reactor()
+
+ def _newexten_event_handler(self, ami, event):
+ if event['context'] != 'sippeer':
+ return
+ if event['extension'] != 's':
+ return
+ if 'JITTERBUFFER' in event['appdata']:
+ self._jitterbuffers_detected += 1
+ LOGGER.debug('Detected JITTERBUFFER %d' % (self._jitterbuffers_detected))
+
+
+def main():
+ test = JitterBufferTest()
+ reactor.run()
+
+ if not test.passed:
+ return 1
+
+ return 0
+
+if __name__ == "__main__":
+ sys.exit(main() or 0)
Propchange: asterisk/trunk/tests/funcs/func_jitterbuffer/run-test
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/funcs/func_jitterbuffer/run-test
------------------------------------------------------------------------------
svn:executable = *
Propchange: asterisk/trunk/tests/funcs/func_jitterbuffer/run-test
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/funcs/func_jitterbuffer/run-test
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/funcs/func_jitterbuffer/talking.ulaw
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/funcs/func_jitterbuffer/talking.ulaw?view=auto&rev=3357
==============================================================================
Binary file - no diff available.
Propchange: asterisk/trunk/tests/funcs/func_jitterbuffer/talking.ulaw
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: asterisk/trunk/tests/funcs/func_jitterbuffer/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/funcs/func_jitterbuffer/test-config.yaml?view=auto&rev=3357
==============================================================================
--- asterisk/trunk/tests/funcs/func_jitterbuffer/test-config.yaml (added)
+++ asterisk/trunk/tests/funcs/func_jitterbuffer/test-config.yaml Mon Jul 23 16:34:05 2012
@@ -1,0 +1,19 @@
+testinfo:
+ summary: 'Test func_jitterbuffer'
+ description: |
+ 'This test exercises the JITTERBUFFER dialplan function.
+ This includes tests for
+ * Fixed and adaptive jitter buffers
+ * Using the default values versus configured values
+ Each test verifies that the jitter buffer was created,
+ and that content streamed through the jitter buffer is
+ handled appropriately using app_talkdetect'
+
+properties:
+ minversion: '10.7.0'
+ buildoption: 'TEST_FRAMEWORK'
+ dependencies:
+ - python : 'twisted'
+ - python : 'starpy'
+ - asterisk: 'app_talkdetect'
+ - asterisk: 'func_jitterbuffer'
Propchange: asterisk/trunk/tests/funcs/func_jitterbuffer/test-config.yaml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/funcs/func_jitterbuffer/test-config.yaml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/funcs/func_jitterbuffer/test-config.yaml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/funcs/tests.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/funcs/tests.yaml?view=auto&rev=3357
==============================================================================
--- asterisk/trunk/tests/funcs/tests.yaml (added)
+++ asterisk/trunk/tests/funcs/tests.yaml Mon Jul 23 16:34:05 2012
@@ -1,0 +1,3 @@
+# Enter tests here in the order they should be considered for execution:
+tests:
+ - test: 'func_jitterbuffer'
Propchange: asterisk/trunk/tests/funcs/tests.yaml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/funcs/tests.yaml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/funcs/tests.yaml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: asterisk/trunk/tests/tests.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/tests.yaml?view=diff&rev=3357&r1=3356&r2=3357
==============================================================================
--- asterisk/trunk/tests/tests.yaml (original)
+++ asterisk/trunk/tests/tests.yaml Mon Jul 23 16:34:05 2012
@@ -29,6 +29,7 @@
- test: 'predial'
- dir: 'fax'
- dir: 'apps'
+ - dir: 'funcs'
- dir: 'connected_line'
- dir: 'redirecting'
- test: 'func_presencestate'
More information about the asterisk-commits
mailing list