[svn-commits] mjordan: testsuite/asterisk/trunk r6442 - in /asterisk/trunk/tests/apps/confb...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Sun Feb 15 11:46:14 CST 2015
Author: mjordan
Date: Sun Feb 15 11:46:12 2015
New Revision: 6442
URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=6442
Log:
tests/apps/confbridge/confbridge_recording: Handle race conditions in recording
When recording a conference, there is a race condition between the MixMonitor
on the recording channel being finished before/after the conference finishes.
This can cause the test to fail during the sound checking portion.
This patch does the following:
(1) It makes it so that the end of the conference logic (wihch triggers the
sound detection) is fired either from the MixMonitor end logic or the
hangup of the channel in the ConfBridge. In both cases, the logic checks
to see if the other condition already occurred, and only triggers the
sound checking logic if the other one did occur.
(2) The sound checking logic is now a bit more careful about not firing twice,
as that can cause the test logic itself to execute more times than it
should.
Modified:
asterisk/trunk/tests/apps/confbridge/confbridge_recording/configs/ast1/extensions.conf
asterisk/trunk/tests/apps/confbridge/confbridge_recording/run-test
Modified: asterisk/trunk/tests/apps/confbridge/confbridge_recording/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/apps/confbridge/confbridge_recording/configs/ast1/extensions.conf?view=diff&rev=6442&r1=6441&r2=6442
==============================================================================
--- asterisk/trunk/tests/apps/confbridge/confbridge_recording/configs/ast1/extensions.conf (original)
+++ asterisk/trunk/tests/apps/confbridge/confbridge_recording/configs/ast1/extensions.conf Sun Feb 15 11:46:12 2015
@@ -26,17 +26,17 @@
[confbridge]
-exten => record-default,1,NoOp()
+exten => record_default,1,NoOp()
same => n,Set(CONFBRIDGE(bridge,template)=default_bridge)
same => n,Set(CONFBRIDGE(bridge,record_conference)=yes)
same => n,ConfBridge(1)
same => n,Hangup()
-exten => record-conf,1,NoOp()
+exten => record_conf,1,NoOp()
same => n,ConfBridge(1,bridge_record_file,default_user)
same => n,Hangup()
-exten => record-func,1,NoOp()
+exten => record_func,1,NoOp()
same => n,Set(CONFBRIDGE(bridge,template)=default_bridge)
same => n,Set(CONFBRIDGE(bridge,record_conference)=yes)
same => n,Set(CONFBRIDGE(bridge,record_file)=${RECORD_FILE})
Modified: asterisk/trunk/tests/apps/confbridge/confbridge_recording/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/apps/confbridge/confbridge_recording/run-test?view=diff&rev=6442&r1=6441&r2=6442
==============================================================================
--- asterisk/trunk/tests/apps/confbridge/confbridge_recording/run-test (original)
+++ asterisk/trunk/tests/apps/confbridge/confbridge_recording/run-test Sun Feb 15 11:46:12 2015
@@ -55,6 +55,9 @@
return
logger.debug("Detected variable MIXMONITOR_FILENAME: %s" % event['file'])
self.test_case.set_recording_file("%s.wav" % event['file'])
+ if self.test_case.expected_events['channelhungup']:
+ self.test_case.confbridge_ended()
+
def handle_confbridge_join_event(self, ami, event):
""" ConfBridgeJoin event handler """
@@ -160,11 +163,11 @@
# A dictionary is used to set the parameters for each test.
# This includes the channel to create, and, if applicable, the
# recording file to set for the ConfBridge.
- self._tests = [{'channel':'local/record-default at confbridge',
+ self._tests = [{'channel':'local/record_default at confbridge',
'file': ''},
- {'channel': 'local/record-conf at confbridge',
+ {'channel': 'local/record_conf at confbridge',
'file': ''},
- {'channel': 'local/record-func at confbridge',
+ {'channel': 'local/record_func at confbridge',
'file': 'confbridge_recording_func.wav'},]
self._test_results = []
self._current_test = 0
@@ -181,6 +184,8 @@
self.expected_events['recordingfilename'] = False
self.expected_events['confbridgeleave'] = False
self.expected_events['confbridgeend'] = False
+ self.expected_events['channelhungup'] = False
+ self.expected_events['talkdetectiontriggered'] = False
def confbridge_ended(self):
""" Called when the confbridge channels have hung up. This
@@ -188,6 +193,10 @@
if we've recorded anything, and if we received all expected
events from the test states.
"""
+
+ if self.expected_events['talkdetectiontriggered']:
+ return
+ self.expected_events['talkdetectiontriggered'] = True
# Check that we got all the expected events
failed_events = [e for e, v in self.expected_events.items() if not v]
@@ -201,11 +210,13 @@
self._test_results.append(True)
# Check the recorded file
- logger.debug("Performing talk detection on file %s " % self._record_file[:len(self._record_file) - 4])
- self.ami[0].originate(channel = "Local/detect_audio at talkdetect",
- context = 'talkdetect', exten='playback', priority='1',
- variable = {'TESTAUDIO': '"%s"' % (self._record_file[:len(self._record_file) - 4])}
- ).addErrback(self.handle_originate_failure)
+ logger.info("Performing talk detection on file %s " % self._record_file[:len(self._record_file) - 4])
+ self.ami[0].originate(channel="Local/detect_audio at talkdetect",
+ context='talkdetect',
+ exten='playback',
+ priority='1',
+ variable={'TESTAUDIO': '"%s"' % (self._record_file[:len(self._record_file) - 4])}
+ ).addErrback(self.handle_originate_failure)
def set_recording_file(self, filename):
""" Called by the test states when the recorded file is known """
@@ -245,9 +256,9 @@
variable = {}
if self._tests[self._current_test]['file']:
variable["RECORD_FILE"] = self._tests[self._current_test]['file']
- ami.originate(channel = channel,
- context = 'caller', exten='wait', priority='1',
- variable = variable
+ ami.originate(channel=channel,
+ context='caller', exten='wait', priority='1',
+ variable=variable
).addErrback(self.handle_originate_failure)
def new_exten_event_handler(self, ami, event):
@@ -284,7 +295,9 @@
if event['channel'] != self._confbridge_channel:
return
logger.debug("Hangup detected of ConfBridge channel %s" % self._confbridge_channel)
- self.confbridge_ended()
+ self.expected_events['channelhungup'] = True
+ if self.expected_events['recordingfilename']:
+ self.confbridge_ended()
def new_channel_handler(self, ami, event):
""" Record all new non-Bridge channels. This lets us later determine
@@ -305,6 +318,9 @@
return
if 'status' not in event or 'message' not in event:
return
+ if self._current_test > len(self._tests):
+ return
+
logger.debug("Received status %s: %s" % (event['status'], event['message']))
# Note that we only want to override the test results if it Failed
if event['status'] == 'fail':
More information about the svn-commits
mailing list