[asterisk-commits] dvossel: testsuite/asterisk/trunk r546 - in /asterisk/trunk/tests: ./ chanspy...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Jul 21 17:58:22 CDT 2010
Author: dvossel
Date: Wed Jul 21 17:58:18 2010
New Revision: 546
URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=546
Log:
adds test for chanspy with barge option
Added:
asterisk/trunk/tests/chanspy/chanspy_barge/
asterisk/trunk/tests/chanspy/chanspy_barge/configs/
asterisk/trunk/tests/chanspy/chanspy_barge/configs/extensions.conf (with props)
asterisk/trunk/tests/chanspy/chanspy_barge/configs/manager.conf (with props)
asterisk/trunk/tests/chanspy/chanspy_barge/configs/sip.conf (with props)
asterisk/trunk/tests/chanspy/chanspy_barge/run-test (with props)
asterisk/trunk/tests/chanspy/chanspy_barge/sounds/
asterisk/trunk/tests/chanspy/chanspy_barge/sounds/talking.wav (with props)
asterisk/trunk/tests/chanspy/chanspy_barge/test-config.yaml (with props)
Modified:
asterisk/trunk/tests/tests.yaml
Added: asterisk/trunk/tests/chanspy/chanspy_barge/configs/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/chanspy/chanspy_barge/configs/extensions.conf?view=auto&rev=546
==============================================================================
--- asterisk/trunk/tests/chanspy/chanspy_barge/configs/extensions.conf (added)
+++ asterisk/trunk/tests/chanspy/chanspy_barge/configs/extensions.conf Wed Jul 21 17:58:18 2010
@@ -1,0 +1,24 @@
+[general]
+
+[globals]
+
+[test]
+exten => play_exten,1,Answer()
+exten => play_exten,n,MixMonitor(${TESTAUDIO1}.wav)
+exten => play_exten,n,Wait(3)
+exten => play_exten,n,StopMixMonitor()
+exten => play_exten,n,Hangup()
+
+exten => chanspytest,1,ChanSpy(SIP,qB)
+
+exten => detect_audio,1,Answer()
+exten => detect_audio,n,Set(TALK_DETECTED=0) ; initialize TALK_DETECT var
+exten => detect_audio,n,BackgroundDetect(${TALK_AUDIO},1,20,,20000)
+exten => detect_audio,n,GoToIf($[${TALK_DETECTED}=0]?talkdetectfail:talkdetectpass)
+exten => detect_audio,n(talkdetectfail),Hangup()
+
+;PASSED!
+exten => detect_audio,n(talkdetectpass),AGI(agi://127.0.0.1:4573)
+
+exten => play_recording,1,Answer()
+exten => play_recording,n,PlayBack(${TESTAUDIO1})
Propchange: asterisk/trunk/tests/chanspy/chanspy_barge/configs/extensions.conf
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/chanspy/chanspy_barge/configs/extensions.conf
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/chanspy/chanspy_barge/configs/extensions.conf
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/chanspy/chanspy_barge/configs/manager.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/chanspy/chanspy_barge/configs/manager.conf?view=auto&rev=546
==============================================================================
--- asterisk/trunk/tests/chanspy/chanspy_barge/configs/manager.conf (added)
+++ asterisk/trunk/tests/chanspy/chanspy_barge/configs/manager.conf Wed Jul 21 17:58:18 2010
@@ -1,0 +1,10 @@
+[general]
+enabled = yes
+port = 5038
+bindaddr = 127.0.0.1
+
+[user]
+secret = mysecret
+read = system,call,log,verbose,agent,user,config,dtmf,reporting,cdr,dialplan
+write = system,call,agent,user,config,command,reporting,originate
+
Propchange: asterisk/trunk/tests/chanspy/chanspy_barge/configs/manager.conf
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/chanspy/chanspy_barge/configs/manager.conf
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/chanspy/chanspy_barge/configs/manager.conf
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/chanspy/chanspy_barge/configs/sip.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/chanspy/chanspy_barge/configs/sip.conf?view=auto&rev=546
==============================================================================
--- asterisk/trunk/tests/chanspy/chanspy_barge/configs/sip.conf (added)
+++ asterisk/trunk/tests/chanspy/chanspy_barge/configs/sip.conf Wed Jul 21 17:58:18 2010
@@ -1,0 +1,29 @@
+[general]
+canreinvite=no
+
+[end_a]
+context=test
+type=friend
+host=127.0.0.1
+port=5065
+insecure=invite
+disallow=all
+allow=ulaw
+
+[end_b]
+context=test
+type=friend
+host=127.0.0.1
+port=5066
+insecure=invite
+disallow=all
+allow=ulaw
+
+[end_c]
+context=test
+type=friend
+host=127.0.0.1
+port=5067
+insecure=invite
+disallow=all
+allow=ulaw
Propchange: asterisk/trunk/tests/chanspy/chanspy_barge/configs/sip.conf
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/chanspy/chanspy_barge/configs/sip.conf
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/chanspy/chanspy_barge/configs/sip.conf
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/chanspy/chanspy_barge/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/chanspy/chanspy_barge/run-test?view=auto&rev=546
==============================================================================
--- asterisk/trunk/tests/chanspy/chanspy_barge/run-test (added)
+++ asterisk/trunk/tests/chanspy/chanspy_barge/run-test Wed Jul 21 17:58:18 2010
@@ -1,0 +1,177 @@
+#!/usr/bin/env python
+'''
+Copyright (C) 2010, Digium, Inc.
+David Vossel <dvossel 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 signal
+import subprocess
+from optparse import OptionParser
+from twisted.application import service, internet
+from twisted.internet import reactor, defer
+from starpy import manager
+from starpy import fastagi
+
+sys.path.append("lib/python")
+from asterisk.asterisk import Asterisk
+from asterisk.version import AsteriskVersion
+
+class ChanSpyBarge:
+ def __init__(self, argv):
+ self.last_step = ""
+ self.passed = False
+ self.numSpyEvents = 0
+ self.expectedSpyEvents = 3
+ self.talkDetected = 0
+ self.test_to = 25
+
+ # get version info
+ parser = OptionParser()
+ parser.add_option("-v", "--version", dest="ast_version",
+ help="Asterisk version string")
+ (options, args) = parser.parse_args(argv)
+ self.ast_version = AsteriskVersion(options.ast_version)
+
+ reactor.callWhenRunning(self.run)
+ self.agi = fastagi.FastAGIFactory(self.reportPassed)
+ reactor.listenTCP(4573, self.agi, self.test_to, '127.0.0.1')
+
+ print self.ast_version
+ self.asterisk = Asterisk(base="/tmp/asterisk-testsuite/chanspy/chanspy_barge")
+ self.asterisk.install_config("tests/chanspy/chanspy_barge/configs/extensions.conf")
+ self.asterisk.install_config("tests/chanspy/chanspy_barge/configs/sip.conf")
+ self.asterisk.install_config("tests/chanspy/chanspy_barge/configs/manager.conf")
+ self.talkingaudio = os.path.join(os.getcwd(), "tests/chanspy/chanspy_barge/sounds/talking")
+ self.audiofile1 = os.path.join(os.getcwd(), "tests/chanspy/chanspy_barge/testaudio1")
+
+ def reportPassed(self, agi):
+ print "GOT PASS RESULTS!!!\n"
+ sequence = fastagi.InSequence()
+ sequence.append(agi.execute, "HangUp")
+ sequence.append(agi.finish)
+ self.passed = True
+ reactor.callLater(1, self.readResult)
+ return sequence()
+
+ def readResult(self):
+ self.logLastStep("Reading results")
+ self.asterisk.cli_exec("core show locks") # get lock output in case of deadlock before tearing down.
+ self.asterisk.cli_exec("core show channels")# if channels are still up for some reason, we want to know that as well
+
+ if self.ast_version < AsteriskVersion("1.6.1"):
+ self.asterisk.cli_exec("core show globals") # The global variables here hold failure conditions
+ else:
+ self.asterisk.cli_exec("dialplan show globals") # The global variables here hold failure conditions
+
+ if self.passed == True:
+ print 'SIP ChanSpy test PASSED!'
+ else:
+ print 'SIP ChanSpy Test FAILED'
+
+ self.stopProcesses()
+
+ if reactor.running:
+ print "Stopping Reactor ..."
+ reactor.stop()
+
+ def chanspyEvent(self, ami, event):
+ self.numSpyEvents += 1
+ if event['spyeechannel'].count('end_a') > 0:
+ reactor.callLater(1, self.aHangup)
+ reactor.callLater(3, self.bHangup)
+ print event
+ def amiOnConnect(self, ami):
+ self.logLastStep("Connected to the AMI")
+ self.ami = ami
+ self.ami.registerEvent('ChanSpyStart', self.chanspyEvent)
+ def amiLoginError(self, ami):
+ self.logLastStep("AMI login failed")
+ reactor.callLater(1, self.readResult)
+ def amiLogin(self):
+ self.logLastStep("Logging in to the AMI")
+ self.ami_factory = manager.AMIFactory("user", "mysecret")
+ self.ami_factory.login('127.0.0.1', 5038).addCallbacks(self.amiOnConnect, self.amiLoginError)
+ def aCall(self):
+ self.logLastStep("A Calling into Wait")
+ self.pja.stdin.write("m\n")
+ self.pja.stdin.write("sip:play_exten at 127.0.0.1:5060\n")
+ def bCall(self):
+ self.logLastStep("B Calling into Playback")
+ self.pjb.stdin.write("m\n")
+ self.pjb.stdin.write("sip:play_exten at 127.0.0.1:5060\n")
+ def aHangup(self):
+ self.pja.stdin.write("h\n")
+ def bHangup(self): #calls into chanspy extension and plays audio to A using Barge
+ self.pjb.stdin.write("h\n")
+ reactor.callLater(2, self.verifyAudio)
+
+ def startProcesses(self):
+ self.logLastStep("Starting Processes")
+ self.asterisk.start()
+ playfilearg = "--play-file=%s.wav" % (self.talkingaudio)
+ self.pja = subprocess.Popen(['pjsua', '--local-port=5065', '--auto-answer=200', '--null-audio', '--auto-loop'], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
+ self.pjb = subprocess.Popen(['pjsua', '--local-port=5066', '--auto-answer=200', playfilearg, '--auto-play'], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
+
+ if self.ast_version < AsteriskVersion("1.6.1"):
+ self.asterisk.cli_exec("core set global TESTAUDIO1 " + self.audiofile1)
+ self.asterisk.cli_exec("core set global TALK_AUDIO " + self.talkingaudio)
+ else:
+ self.asterisk.cli_exec("dialplan set global TESTAUDIO1 " + self.audiofile1)
+ self.asterisk.cli_exec("dialplan set global TALK_AUDIO " + self.talkingaudio)
+
+ def stopProcesses(self):
+ self.logLastStep("Stopping Processes")
+ self.asterisk.stop()
+ os.kill(self.pja.pid, signal.SIGKILL)
+ os.kill(self.pjb.pid, signal.SIGKILL)
+
+ def logLastStep(self, step):
+ print step
+ self.lastStep = step
+
+ def callChanSpy(self):
+ self.logLastStep("Placing call to ChanSpy extension.")
+ if self.ast_version < AsteriskVersion("1.6.2"):
+ self.asterisk.cli_exec("originate SIP/end_b extension chanspytest at test")
+ else:
+ self.asterisk.cli_exec("channel originate SIP/end_b extension chanspytest at test")
+
+ def verifyAudio(self):
+ if self.ast_version < AsteriskVersion("1.6.2"):
+ self.asterisk.cli_exec("originate Local/play_recording at test extension detect_audio at test")
+ else:
+ self.asterisk.cli_exec("channel originate Local/play_recording at test extension detect_audio at test")
+
+ def run(self):
+
+ # start up the processes
+ self.startProcesses()
+
+ # call extensions
+ self.amiLogin()
+ reactor.callLater(1, self.callChanSpy)
+ reactor.callLater(2, self.aCall)
+
+ # stop and read results after timeout
+ reactor.callLater(self.test_to, self.readResult)
+
+def main(argv=None):
+ if argv is None:
+ argv = sys.argv
+
+ # Run Test
+ test = ChanSpyBarge(argv)
+ reactor.run()
+ test.stopProcesses()
+ if test.passed != True:
+ return 1
+ return 0
+
+if __name__ == "__main__":
+ sys.exit(main() or 0)
+
Propchange: asterisk/trunk/tests/chanspy/chanspy_barge/run-test
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/chanspy/chanspy_barge/run-test
------------------------------------------------------------------------------
svn:executable = *
Propchange: asterisk/trunk/tests/chanspy/chanspy_barge/run-test
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/chanspy/chanspy_barge/run-test
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/chanspy/chanspy_barge/sounds/talking.wav
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/chanspy/chanspy_barge/sounds/talking.wav?view=auto&rev=546
==============================================================================
Binary file - no diff available.
Propchange: asterisk/trunk/tests/chanspy/chanspy_barge/sounds/talking.wav
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: asterisk/trunk/tests/chanspy/chanspy_barge/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/chanspy/chanspy_barge/test-config.yaml?view=auto&rev=546
==============================================================================
--- asterisk/trunk/tests/chanspy/chanspy_barge/test-config.yaml (added)
+++ asterisk/trunk/tests/chanspy/chanspy_barge/test-config.yaml Wed Jul 21 17:58:18 2010
@@ -1,0 +1,17 @@
+testinfo:
+ summary: 'Test Chanspy with the \"B\" option for barging in on both channels.'
+ description: |
+ 'This test verifies basic functionality of using ChanSpy with the
+ barge option set. MixMonitor is used to record the audio on the
+ spied on channel to verify the barging spy channel audio is received.
+ Also, since the Wait() application is used during barge, this verifies
+ that the default behavior of transmitting silence during ast_safe_sleep remains.
+ Without transmitting silence during wait, the barge audio will not be mixed and
+ this test will fail.'
+
+properties:
+ minversion: '1.6.2'
+ dependencies:
+ - python : 'twisted'
+ - python : 'starpy'
+ - app : 'pjsua'
Propchange: asterisk/trunk/tests/chanspy/chanspy_barge/test-config.yaml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/chanspy/chanspy_barge/test-config.yaml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/chanspy/chanspy_barge/test-config.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=546&r1=545&r2=546
==============================================================================
--- asterisk/trunk/tests/tests.yaml (original)
+++ asterisk/trunk/tests/tests.yaml Wed Jul 21 17:58:18 2010
@@ -27,6 +27,7 @@
- test: 'feature_attended_transfer'
- test: 'mixmonitor'
- test: 'chanspy/chanspy_w_mixmonitor'
+ - test: 'chanspy/chanspy_barge'
- test: 'queues/queue_baseline'
- test: 'queues/position_priority_maxlen'
- test: 'queues/macro_gosub_test'
More information about the asterisk-commits
mailing list