[svn-commits] dvossel: testsuite/asterisk/trunk r505 - in /asterisk/trunk/tests: ./ chanspy...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Jul 19 17:31:51 CDT 2010


Author: dvossel
Date: Mon Jul 19 17:31:47 2010
New Revision: 505

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=505
Log:
addition of chanspy with mixmonitor test

Added:
    asterisk/trunk/tests/chanspy/
    asterisk/trunk/tests/chanspy/chanspy_w_mixmonitor/
    asterisk/trunk/tests/chanspy/chanspy_w_mixmonitor/configs/
    asterisk/trunk/tests/chanspy/chanspy_w_mixmonitor/configs/extensions.conf   (with props)
    asterisk/trunk/tests/chanspy/chanspy_w_mixmonitor/configs/manager.conf   (with props)
    asterisk/trunk/tests/chanspy/chanspy_w_mixmonitor/configs/sip.conf   (with props)
    asterisk/trunk/tests/chanspy/chanspy_w_mixmonitor/run-test   (with props)
    asterisk/trunk/tests/chanspy/chanspy_w_mixmonitor/sounds/
    asterisk/trunk/tests/chanspy/chanspy_w_mixmonitor/sounds/talking.ulaw   (with props)
    asterisk/trunk/tests/chanspy/chanspy_w_mixmonitor/test-config.yaml   (with props)
Modified:
    asterisk/trunk/tests/tests.yaml

Added: asterisk/trunk/tests/chanspy/chanspy_w_mixmonitor/configs/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/chanspy/chanspy_w_mixmonitor/configs/extensions.conf?view=auto&rev=505
==============================================================================
--- asterisk/trunk/tests/chanspy/chanspy_w_mixmonitor/configs/extensions.conf (added)
+++ asterisk/trunk/tests/chanspy/chanspy_w_mixmonitor/configs/extensions.conf Mon Jul 19 17:31:47 2010
@@ -1,0 +1,26 @@
+[general]
+
+[globals]
+
+[test]
+exten => play_exten,1,Playback(${TALK_AUDIO})
+exten => play_exten,n,Playback(${TALK_AUDIO})
+exten => play_exten,n,Playback(${TALK_AUDIO})
+exten => play_exten,n,Playback(${TALK_AUDIO})
+
+exten => chanspytest,1,MixMonitor(${TESTAUDIO1}.wav)
+exten => chanspytest,n,ChanSpy(SIP,q)
+exten => chanspytest,n,StopMixMonitor()
+
+
+exten => detect_audio,1,Answer()
+exten => detect_audio,n,Set(TALK_DETECTED=0) ; initialize TALK_DETECT var
+exten => detect_audio,n,BackgroundDetect(${TESTAUDIO1},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_w_mixmonitor/configs/extensions.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/chanspy/chanspy_w_mixmonitor/configs/extensions.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/chanspy/chanspy_w_mixmonitor/configs/extensions.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/chanspy/chanspy_w_mixmonitor/configs/manager.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/chanspy/chanspy_w_mixmonitor/configs/manager.conf?view=auto&rev=505
==============================================================================
--- asterisk/trunk/tests/chanspy/chanspy_w_mixmonitor/configs/manager.conf (added)
+++ asterisk/trunk/tests/chanspy/chanspy_w_mixmonitor/configs/manager.conf Mon Jul 19 17:31:47 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_w_mixmonitor/configs/manager.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/chanspy/chanspy_w_mixmonitor/configs/manager.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/chanspy/chanspy_w_mixmonitor/configs/manager.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/chanspy/chanspy_w_mixmonitor/configs/sip.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/chanspy/chanspy_w_mixmonitor/configs/sip.conf?view=auto&rev=505
==============================================================================
--- asterisk/trunk/tests/chanspy/chanspy_w_mixmonitor/configs/sip.conf (added)
+++ asterisk/trunk/tests/chanspy/chanspy_w_mixmonitor/configs/sip.conf Mon Jul 19 17:31:47 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_w_mixmonitor/configs/sip.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/chanspy/chanspy_w_mixmonitor/configs/sip.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/chanspy/chanspy_w_mixmonitor/configs/sip.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/chanspy/chanspy_w_mixmonitor/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/chanspy/chanspy_w_mixmonitor/run-test?view=auto&rev=505
==============================================================================
--- asterisk/trunk/tests/chanspy/chanspy_w_mixmonitor/run-test (added)
+++ asterisk/trunk/tests/chanspy/chanspy_w_mixmonitor/run-test Mon Jul 19 17:31:47 2010
@@ -1,0 +1,192 @@
+#!/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 ChanSpyMixMonitorTest:
+    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_w_mixmonitor")
+        self.asterisk.install_config("tests/chanspy/chanspy_w_mixmonitor/configs/extensions.conf")
+        self.asterisk.install_config("tests/chanspy/chanspy_w_mixmonitor/configs/sip.conf")
+        self.asterisk.install_config("tests/chanspy/chanspy_w_mixmonitor/configs/manager.conf")
+        self.talkingaudio = os.path.join(os.getcwd(), "tests/chanspy/chanspy_w_mixmonitor/sounds/talking")
+        self.audiofile1 = os.path.join(os.getcwd(), "tests/chanspy/chanspy_w_mixmonitor/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(2, self.bCall)
+        if event['spyeechannel'].count('end_b') > 0:
+            reactor.callLater(1, self.bHangup)
+            reactor.callLater(2, self.cCall)
+        if event['spyeechannel'].count('end_c') > 0:
+            reactor.callLater(2, self.cHangup)
+            reactor.callLater(3, self.hangupChanSpy)
+        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 Playback")
+        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 cCall(self):
+        self.logLastStep("C Calling into Playback")
+        self.pjc.stdin.write("m\n")
+        self.pjc.stdin.write("sip:play_exten at 127.0.0.1:5060\n")
+    def aHangup(self):
+        self.pja.stdin.write("h\n")
+    def bHangup(self):
+        self.pjb.stdin.write("h\n")
+    def cHangup(self):
+        self.pjc.stdin.write("h\n")
+
+    def startProcesses(self):
+        self.logLastStep("Starting Processes")
+        self.asterisk.start()
+        self.pja = subprocess.Popen(['pjsua', '--local-port=5065', '--auto-answer=200', '--null-audio'], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
+        self.pjb = subprocess.Popen(['pjsua', '--local-port=5066', '--auto-answer=200', '--null-audio'], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
+        self.pjc = subprocess.Popen(['pjsua', '--local-port=5067', '--auto-answer=200', '--null-audio'], 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)
+        os.kill(self.pjc.pid, signal.SIGKILL)
+
+    def logLastStep(self, step):
+        print step
+        self.lastStep = step
+
+    def callChanSpy(self):
+        self.logLastStep("Placing call to ChanSpy extension.")
+        self.asterisk.cli_exec("console dial chanspytest at test")
+
+    def hangupChanSpy(self):
+        self.logLastStep("Hangup ChanSpy.")
+        self.asterisk.cli_exec("console hangup")
+        reactor.callLater(2, self.verifyAudio)
+
+    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 = ChanSpyMixMonitorTest(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_w_mixmonitor/run-test
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/chanspy/chanspy_w_mixmonitor/run-test
------------------------------------------------------------------------------
    svn:executable = *

Propchange: asterisk/trunk/tests/chanspy/chanspy_w_mixmonitor/run-test
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/chanspy/chanspy_w_mixmonitor/run-test
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/chanspy/chanspy_w_mixmonitor/sounds/talking.ulaw
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/chanspy/chanspy_w_mixmonitor/sounds/talking.ulaw?view=auto&rev=505
==============================================================================
Binary file - no diff available.

Propchange: asterisk/trunk/tests/chanspy/chanspy_w_mixmonitor/sounds/talking.ulaw
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: asterisk/trunk/tests/chanspy/chanspy_w_mixmonitor/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/chanspy/chanspy_w_mixmonitor/test-config.yaml?view=auto&rev=505
==============================================================================
--- asterisk/trunk/tests/chanspy/chanspy_w_mixmonitor/test-config.yaml (added)
+++ asterisk/trunk/tests/chanspy/chanspy_w_mixmonitor/test-config.yaml Mon Jul 19 17:31:47 2010
@@ -1,0 +1,17 @@
+testinfo:
+    summary:     'Test Chanspy with MixMonitor'
+    description: |
+        'This test verifies basic functionality of using both ChanSpy
+         and MixMonitor on the same channel.  Three pjsua end points call
+		 into Asterisk playing back an audio file.  As each end point
+		 calls and hangs up the ChanSpy channel attaches to a different
+		 channel.  After all three end points have been spied on the 
+		 MixMonitor audio file is analyzed to verify there was audio
+		 recorded.'
+
+properties:
+    minversion: '1.6.2'
+    dependencies:
+        - python : 'twisted'
+        - python : 'starpy'
+        - app : 'pjsua'

Propchange: asterisk/trunk/tests/chanspy/chanspy_w_mixmonitor/test-config.yaml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/chanspy/chanspy_w_mixmonitor/test-config.yaml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/chanspy/chanspy_w_mixmonitor/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=505&r1=504&r2=505
==============================================================================
--- asterisk/trunk/tests/tests.yaml (original)
+++ asterisk/trunk/tests/tests.yaml Mon Jul 19 17:31:47 2010
@@ -25,6 +25,7 @@
     - test: 'sip_one_legged_transfer'
     - test: 'feature_blonde_transfer'
     - test: 'mixmonitor'
+    - test: 'chanspy/chanspy_w_mixmonitor'
     - test: 'queues/queue_baseline'
     - test: 'queues/position_priority_maxlen'
     - test: 'queues/macro_gosub_test'




More information about the svn-commits mailing list