[asterisk-commits] rmudgett: testsuite/asterisk/trunk r3234 - in /asterisk/trunk/tests: ./ masqu...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu May 24 16:52:17 CDT 2012
Author: rmudgett
Date: Thu May 24 16:52:11 2012
New Revision: 3234
URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=3234
Log:
Add masquerade super test.
The test creates a chain of local channels that optimize themselves out
when the call is answered. The test counts how many local channels
execute the h exten. The test passes if all local channels execute the h
exten. Once all local channels are gone, the call can be torn down.
(closes issue ASTERISK-19807)
Reported by: Matt Jordan
Tested by: rmudgett
Review: https://reviewboard.asterisk.org/r/1930/
Added:
asterisk/trunk/tests/masquerade/
asterisk/trunk/tests/masquerade/configs/
asterisk/trunk/tests/masquerade/configs/ast1/
asterisk/trunk/tests/masquerade/configs/ast1/extensions.conf (with props)
asterisk/trunk/tests/masquerade/configs/ast1/features.conf (with props)
asterisk/trunk/tests/masquerade/configs/ast1/iax.conf (with props)
asterisk/trunk/tests/masquerade/configs/ast2/
asterisk/trunk/tests/masquerade/configs/ast2/extensions.conf (with props)
asterisk/trunk/tests/masquerade/configs/ast2/iax.conf (with props)
asterisk/trunk/tests/masquerade/run-test (with props)
asterisk/trunk/tests/masquerade/test-config.yaml (with props)
Modified:
asterisk/trunk/tests/tests.yaml
Added: asterisk/trunk/tests/masquerade/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/masquerade/configs/ast1/extensions.conf?view=auto&rev=3234
==============================================================================
--- asterisk/trunk/tests/masquerade/configs/ast1/extensions.conf (added)
+++ asterisk/trunk/tests/masquerade/configs/ast1/extensions.conf Thu May 24 16:52:11 2012
@@ -1,0 +1,34 @@
+[general]
+static=yes
+writeprotect=no
+lastaction=""
+
+[outgoing]
+exten => _9XXX,1,NoOp(Call to park)
+exten => _9XXX,n,Set(FIRST=1)
+exten => _9XXX,n,Goto(optout,${EXTEN},1)
+
+[optout]
+exten => _9XXX,1,NoOp(Local channel chain to park call)
+exten => _9XXX,n,GotoIf($[${EXTEN} = 9000]?done:)
+exten => _9XXX,n,Dial(Local/$[${EXTEN} - 1]@optout)
+exten => _9XXX,n,UserEvent(ast1,status: FAILURE Dial Local continued in dialplan)
+exten => _9XXX,n,Hangup()
+exten => _9XXX,n(done),Dial(IAX2/ast2/${EXTEN},30)
+exten => _9XXX,n,UserEvent(ast1,status: FAILURE Dial IAX continued in dialplan)
+exten => _9XXX,n,Hangup()
+
+exten => h,1,NoOp(Report local channel optimized out)
+exten => h,n,GotoIf($[x${FIRST}x = x1x]?first:)
+exten => h,n,UserEvent(optout,status: REMOVED)
+exten => h,n(first),NoOp()
+
+[parked]
+exten => parkme,1,NoOp(Park the outgoing call)
+exten => parkme,n,Park(,parked,failed,1)
+exten => parkme,n,UserEvent(ast1,status: FAILURE Park continued in dialplan)
+exten => parkme,n,Hangup()
+
+exten => failed,1,NoOp(Parked call failed to be picked up before timeout)
+exten => failed,n,UserEvent(ast1,status: FAILURE Park timeout)
+exten => failed,n,Hangup()
Propchange: asterisk/trunk/tests/masquerade/configs/ast1/extensions.conf
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/masquerade/configs/ast1/extensions.conf
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/masquerade/configs/ast1/extensions.conf
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/masquerade/configs/ast1/features.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/masquerade/configs/ast1/features.conf?view=auto&rev=3234
==============================================================================
--- asterisk/trunk/tests/masquerade/configs/ast1/features.conf (added)
+++ asterisk/trunk/tests/masquerade/configs/ast1/features.conf Thu May 24 16:52:11 2012
@@ -1,0 +1,6 @@
+[general]
+parkext => 700
+parkpos => 701-720
+context => parkedcalls
+parkingtime => 300
+findslot => next ; Continue to the 'next' free parking space.
Propchange: asterisk/trunk/tests/masquerade/configs/ast1/features.conf
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/masquerade/configs/ast1/features.conf
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/masquerade/configs/ast1/features.conf
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/masquerade/configs/ast1/iax.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/masquerade/configs/ast1/iax.conf?view=auto&rev=3234
==============================================================================
--- asterisk/trunk/tests/masquerade/configs/ast1/iax.conf (added)
+++ asterisk/trunk/tests/masquerade/configs/ast1/iax.conf Thu May 24 16:52:11 2012
@@ -1,0 +1,23 @@
+[general]
+bindaddr=127.0.0.1
+jitterbuffer=no
+forcejitterbuffer=no
+
+[ast1]
+type=user
+host=127.0.0.2
+secret=p at ssw0rd
+context=parkedcalls
+deny=0.0.0.0/0.0.0.0
+permit=127.0.0.2/255.255.255.255
+disallow=all
+allow=gsm
+
+[ast2]
+type=peer
+host=127.0.0.2
+context=parkedcalls
+username=ast2
+secret=pa$$word
+disallow=all
+allow=gsm
Propchange: asterisk/trunk/tests/masquerade/configs/ast1/iax.conf
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/masquerade/configs/ast1/iax.conf
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/masquerade/configs/ast1/iax.conf
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/masquerade/configs/ast2/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/masquerade/configs/ast2/extensions.conf?view=auto&rev=3234
==============================================================================
--- asterisk/trunk/tests/masquerade/configs/ast2/extensions.conf (added)
+++ asterisk/trunk/tests/masquerade/configs/ast2/extensions.conf Thu May 24 16:52:11 2012
@@ -1,0 +1,29 @@
+[general]
+static=yes
+writeprotect=no
+
+[incoming]
+exten => 9000,1,NoOp(Wait for parked call to be retrieved)
+exten => 9000,n,Answer()
+exten => 9000,n,WaitExten(330,m)
+exten => 9000,n,UserEvent(ast1,status: FAILURE WaitExten timeout)
+exten => 9000,n,Hangup()
+
+exten => 5432,1,NoOp(Ack parking retrieval)
+exten => 5432,n,SendDTMF(3456)
+exten => 5432,n,UserEvent(ast1,status: SUCCESS)
+exten => 5432,n,Wait(1)
+exten => 5432,n,Hangup()
+
+[getit]
+exten => retrieve,1,NoOp(Parked call retrieved)
+exten => retrieve,n,Answer()
+exten => retrieve,n,SendDTMF(5432)
+exten => retrieve,n,Background(demo-congrats)
+exten => retrieve,n,UserEvent(ast2,status: FAILURE Did not get expected DTMF)
+exten => retrieve,n,Hangup()
+
+exten => 3456,1,NoOp(Parking retrieval voice path open both ways)
+exten => 3456,n,UserEvent(ast2,status: SUCCESS)
+exten => 3456,n,Wait(1)
+exten => 3456,n,Hangup()
Propchange: asterisk/trunk/tests/masquerade/configs/ast2/extensions.conf
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/masquerade/configs/ast2/extensions.conf
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/masquerade/configs/ast2/extensions.conf
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/masquerade/configs/ast2/iax.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/masquerade/configs/ast2/iax.conf?view=auto&rev=3234
==============================================================================
--- asterisk/trunk/tests/masquerade/configs/ast2/iax.conf (added)
+++ asterisk/trunk/tests/masquerade/configs/ast2/iax.conf Thu May 24 16:52:11 2012
@@ -1,0 +1,23 @@
+[general]
+bindaddr=127.0.0.2
+jitterbuffer=no
+forcejitterbuffer=no
+
+[ast1]
+type=peer
+host=127.0.0.1
+context=incoming
+username=ast1
+secret=p at ssw0rd
+disallow=all
+allow=gsm
+
+[ast2]
+type=user
+host=127.0.0.1
+secret=pa$$word
+context=incoming
+deny=0.0.0.0/0.0.0.0
+permit=127.0.0.1/255.255.255.255
+disallow=all
+allow=gsm
Propchange: asterisk/trunk/tests/masquerade/configs/ast2/iax.conf
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/masquerade/configs/ast2/iax.conf
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/masquerade/configs/ast2/iax.conf
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/masquerade/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/masquerade/run-test?view=auto&rev=3234
==============================================================================
--- asterisk/trunk/tests/masquerade/run-test (added)
+++ asterisk/trunk/tests/masquerade/run-test Thu May 24 16:52:11 2012
@@ -1,0 +1,186 @@
+#!/usr/bin/env python
+'''
+Copyright (C) 2012, Digium, Inc.
+Richard Mudgett <rmudgett at digium.com>
+
+This program is free software, distributed under the terms of
+the GNU General Public License Version 2.
+'''
+
+import sys
+import logging
+from twisted.internet import reactor
+
+sys.path.append("lib/python")
+from asterisk.TestCase import TestCase
+
+logger = logging.getLogger(__name__)
+
+
+class MasqueradeTest(TestCase):
+ def __init__(self):
+ TestCase.__init__(self)
+
+ self.ami_count = 0
+ self.test_complete = False
+
+ # Initial call chain parameters.
+ self.chain_length = 300
+ self.expected_space = 701
+
+ # Clear test completion stage flags.
+ self.removed_count = 0
+ self.park_retrieved = False
+ self.got_AMI_ParkedCall = False
+ self.got_AMI_UnParkedCall = False
+ self.ast1_event = False
+ self.ast2_event = False
+
+ # Create two Asterisk instances ...
+ self.create_asterisk(2)
+
+ def check_result(self):
+ if not self.got_AMI_ParkedCall:
+ return
+ if not self.park_retrieved:
+ if self.removed_count == self.chain_length:
+ # Call chain successfully optimized itself.
+ # Time to see if the call audio path is ok.
+ self.park_retrieved = True
+ self.get_parkedcall()
+ return
+ if not self.got_AMI_UnParkedCall:
+ return
+ if not self.ast1_event:
+ return
+ if not self.ast2_event:
+ return
+
+ # Call chain completed successfully.
+ self.passed = True
+ self.stop_reactor()
+
+ # Initiate test call chain.
+ def initiate_call_chain(self):
+ logger.info("Initiating test call for a chain length of " + str(self.chain_length))
+ exten = 9000 + self.chain_length
+ self.ast[0].cli_originate("Local/" + str(exten) + "@outgoing/n extension parkme at parked")
+
+ # Initiate a call to retrieve the parked call.
+ def get_parkedcall(self):
+ logger.info("Fetching parked call at " + str(self.expected_space))
+ self.ast[1].cli_originate("IAX2/ast1/" + str(self.expected_space) + " extension retrieve at getit")
+
+ # Called when got ParkedCall AMI event
+ def evt_parkedcall(self, ami, event):
+ if self.test_complete:
+ return
+ exten = event.get("exten").lower()
+ logger.info("Call parked at exten: " + str(exten))
+ if exten != str(self.expected_space):
+ logger.warning("Call not parked in expected space " + str(self.expected_space))
+ self.stop_reactor()
+ return
+
+ self.got_AMI_ParkedCall = True
+ self.check_result()
+
+ # Called when got UnParkedCall AMI event
+ def evt_unparkedcall(self, ami, event):
+ if self.test_complete:
+ return
+ exten = event.get("exten").lower()
+ logger.info("Parked call retrieved from exten: " + str(exten))
+ if exten != str(self.expected_space):
+ logger.warning("Call not retrieved from expected space " + str(self.expected_space))
+ self.stop_reactor()
+ return
+
+ self.got_AMI_UnParkedCall = True
+ self.check_result()
+
+ # Called when got ParkedCallTimeOut AMI event
+ def evt_parkedcalltimeout(self, ami, event):
+ if self.test_complete:
+ return
+ logger.warning("Call park timeout!")
+ self.stop_reactor()
+
+ # Called when got UserEvent event from either Asterisk instance
+ def evt_userevent(self, ami, event):
+ if self.test_complete:
+ return
+ # We want the AMI UserEvent header but the headers put
+ # in as dictionary keys are lowercased.
+ evt = event.get("userevent")
+ status = event.get("status")
+ logger.info("UserEvent: " + str(evt) + " status: " + str(status))
+
+ if evt == "optout":
+ self.removed_count += 1
+ logger.info("Calls optimized out: " + str(self.removed_count))
+ # Restart the timeout timer after so many local channels optimize out.
+ #if 0 == self.removed_count % 50:
+ # self.reset_timeout()
+ self.reset_timeout()
+ self.check_result()
+ return
+ elif evt == "ast1":
+ if status == "SUCCESS":
+ self.ast1_event = True
+ self.check_result()
+ return
+ elif evt == "ast2":
+ if status == "SUCCESS":
+ self.ast2_event = True
+ self.check_result()
+ return
+ else:
+ logger.info("Unknown UserEvent")
+ return
+ logger.warning("UserEvent: " + str(evt) + " status: " + str(status))
+ self.stop_reactor()
+
+ # This is called for each AMI connection established.
+ def ami_connect(self, ami):
+ # Add AMI event triggers
+ if ami.id == 0:
+ # Ast1 events to handle
+ self.ami[ami.id].registerEvent("ParkedCall", self.evt_parkedcall)
+ self.ami[ami.id].registerEvent("UnParkedCall", self.evt_unparkedcall)
+ self.ami[ami.id].registerEvent("ParkedCallTimeOut", self.evt_parkedcalltimeout)
+ self.ami[ami.id].registerEvent("UserEvent", self.evt_userevent)
+ elif ami.id == 1:
+ # Ast2 events to handle
+ self.ami[ami.id].registerEvent("UserEvent", self.evt_userevent)
+
+ # Initiate test when both AMI connections are established.
+ self.ami_count += 1
+ if self.ami_count == 2:
+ self.initiate_call_chain()
+
+ # This is called when the reactor has started running.
+ def run(self):
+ TestCase.run(self)
+ self.create_ami_factory(2)
+
+ # This is called when we stop the reactor.
+ def stop_reactor(self):
+ self.test_complete = True
+ TestCase.stop_reactor(self)
+
+
+def main():
+ # Run Masquerade local channel chain Test
+ test = MasqueradeTest()
+ reactor.run()
+ if test.passed:
+ logger.info("Test passed")
+ return 0
+ return 1
+
+if __name__ == "__main__":
+ sys.exit(main() or 0)
+
+
+# vim:sw=4:ts=4:expandtab:textwidth=79
Propchange: asterisk/trunk/tests/masquerade/run-test
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/masquerade/run-test
------------------------------------------------------------------------------
svn:executable = *
Propchange: asterisk/trunk/tests/masquerade/run-test
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/masquerade/run-test
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/masquerade/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/masquerade/test-config.yaml?view=auto&rev=3234
==============================================================================
--- asterisk/trunk/tests/masquerade/test-config.yaml (added)
+++ asterisk/trunk/tests/masquerade/test-config.yaml Thu May 24 16:52:11 2012
@@ -1,0 +1,17 @@
+testinfo:
+ summary: 'Test Masquerading'
+ description: |
+ 'Create a long chain of local channels to be optimized out.'
+
+properties:
+ minversion: '1.8'
+ dependencies:
+ - python : 'twisted'
+ - python : 'starpy'
+ testconditions:
+ - name: 'threads'
+ ignoredThreads:
+ - 'autoservice_run'
+ tags:
+ - parking
+ - IAX
Propchange: asterisk/trunk/tests/masquerade/test-config.yaml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/masquerade/test-config.yaml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/masquerade/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=3234&r1=3233&r2=3234
==============================================================================
--- asterisk/trunk/tests/tests.yaml (original)
+++ asterisk/trunk/tests/tests.yaml Thu May 24 16:52:11 2012
@@ -18,6 +18,7 @@
- test: 'one-step-parking'
- test: 'callparking'
- test: 'callparking_retrieval'
+ - test: 'masquerade'
- test: 'mixmonitor'
- test: 'mixmonitor_audiohook_inherit'
- dir: 'chanspy'
More information about the asterisk-commits
mailing list