<p>Friendly Automation <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/testsuite/+/16565">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Kevin Harwell: Looks good to me, but someone else must approve
George Joseph: Looks good to me, approved; Verified
Friendly Automation: Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">message_send_ami: Refactor to use Destination parameter<br><br>ASTERISK-29677<br><br>Change-Id: I2f386f80e5cfaf9ea6af5234823928bc216116ca<br>---<br>M tests/channels/pjsip/message/message_send_ami/configs/ast1/pjsip.conf<br>D tests/channels/pjsip/message/message_send_ami/run-test<br>M tests/channels/pjsip/message/message_send_ami/sipp/message_recv.xml<br>M tests/channels/pjsip/message/message_send_ami/test-config.yaml<br>4 files changed, 55 insertions(+), 86 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/tests/channels/pjsip/message/message_send_ami/configs/ast1/pjsip.conf b/tests/channels/pjsip/message/message_send_ami/configs/ast1/pjsip.conf</span><br><span>index d040aa9..ef56e19 100644</span><br><span>--- a/tests/channels/pjsip/message/message_send_ami/configs/ast1/pjsip.conf</span><br><span>+++ b/tests/channels/pjsip/message/message_send_ami/configs/ast1/pjsip.conf</span><br><span>@@ -7,7 +7,7 @@</span><br><span> </span><br><span> [user1]</span><br><span> type=aor</span><br><span style="color: hsl(0, 100%, 40%);">-contact=sip:user1@127.0.0.1:5062</span><br><span style="color: hsl(120, 100%, 40%);">+contact=sip:user1@127.0.0.1:5061</span><br><span> max_contacts=1</span><br><span> </span><br><span> [user1]</span><br><span>diff --git a/tests/channels/pjsip/message/message_send_ami/run-test b/tests/channels/pjsip/message/message_send_ami/run-test</span><br><span>deleted file mode 100755</span><br><span>index afdaeb5..0000000</span><br><span>--- a/tests/channels/pjsip/message/message_send_ami/run-test</span><br><span>+++ /dev/null</span><br><span>@@ -1,81 +0,0 @@</span><br><span style="color: hsl(0, 100%, 40%);">-#!/usr/bin/env python</span><br><span style="color: hsl(0, 100%, 40%);">-# vim: sw=3 et:</span><br><span style="color: hsl(0, 100%, 40%);">-'''</span><br><span style="color: hsl(0, 100%, 40%);">-Copyright (C) 2012, Digium, Inc.</span><br><span style="color: hsl(0, 100%, 40%);">-Richard Mudgett <rmudgett@digium.com></span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-This program is free software, distributed under the terms of</span><br><span style="color: hsl(0, 100%, 40%);">-the GNU General Public License Version 2.</span><br><span style="color: hsl(0, 100%, 40%);">-'''</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-import sys</span><br><span style="color: hsl(0, 100%, 40%);">-import os</span><br><span style="color: hsl(0, 100%, 40%);">-import logging</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-from twisted.internet import reactor</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-sys.path.append("lib/python")</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-from asterisk.sipp import SIPpScenario</span><br><span style="color: hsl(0, 100%, 40%);">-from asterisk.test_case import TestCase</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-"""</span><br><span style="color: hsl(0, 100%, 40%);">-The TestCase class will initialize the python logger - creating a</span><br><span style="color: hsl(0, 100%, 40%);">-logger here will log under the '__main__' namespace</span><br><span style="color: hsl(0, 100%, 40%);">-"""</span><br><span style="color: hsl(0, 100%, 40%);">-logger = logging.getLogger(__name__)</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-TEST_DIR = os.path.dirname(os.path.realpath(__file__))</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-class AMIActionMessageSend(TestCase):</span><br><span style="color: hsl(0, 100%, 40%);">- """</span><br><span style="color: hsl(0, 100%, 40%);">- Test handling of AMI MessageSend action sending SIP MESSAGE</span><br><span style="color: hsl(0, 100%, 40%);">- """</span><br><span style="color: hsl(0, 100%, 40%);">- def __init__(self):</span><br><span style="color: hsl(0, 100%, 40%);">- super(AMIActionMessageSend, self).__init__()</span><br><span style="color: hsl(0, 100%, 40%);">- self.create_asterisk()</span><br><span style="color: hsl(0, 100%, 40%);">- sipp_scenario = { 'scenario':'message_recv.xml', '-p':'5062' }</span><br><span style="color: hsl(0, 100%, 40%);">- self.scenario = SIPpScenario(TEST_DIR, sipp_scenario)</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- def run(self):</span><br><span style="color: hsl(0, 100%, 40%);">- super(AMIActionMessageSend, self).run()</span><br><span style="color: hsl(0, 100%, 40%);">- self.create_ami_factory()</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- def ami_connect(self, ami):</span><br><span style="color: hsl(0, 100%, 40%);">- """</span><br><span style="color: hsl(0, 100%, 40%);">- This method is called by the StarPY manager class when AMI connects to Asterisk</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- Keyword Arguments:</span><br><span style="color: hsl(0, 100%, 40%);">- ami - The StarPY manager object that connected</span><br><span style="color: hsl(0, 100%, 40%);">- """</span><br><span style="color: hsl(0, 100%, 40%);">- def __check_result(result):</span><br><span style="color: hsl(0, 100%, 40%);">- self.passed = result.passed</span><br><span style="color: hsl(0, 100%, 40%);">- self.stop_reactor()</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- # There is a race between starting SIPp and sending the SIP MESSAGE</span><br><span style="color: hsl(0, 100%, 40%);">- # being sent by MessageSend. Fortunately, we don't care because SIP</span><br><span style="color: hsl(0, 100%, 40%);">- # will retransmit the MESSAGE so SIPp can catch it on the next go</span><br><span style="color: hsl(0, 100%, 40%);">- # round.</span><br><span style="color: hsl(0, 100%, 40%);">- logger.debug("Starting SIP scenario")</span><br><span style="color: hsl(0, 100%, 40%);">- deferred = self.scenario.run()</span><br><span style="color: hsl(0, 100%, 40%);">- deferred.addCallback(__check_result)</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- logger.debug("Sending AMI action MessageSend")</span><br><span style="color: hsl(0, 100%, 40%);">- ami_action = { "Action":"MessageSend", "To":"pjsip:user1", "From":"sip:user", "Body":"Watson, come here." }</span><br><span style="color: hsl(0, 100%, 40%);">- ami.sendDeferred(ami_action).addCallback(ami.errorUnlessResponse)</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-def main():</span><br><span style="color: hsl(0, 100%, 40%);">- """</span><br><span style="color: hsl(0, 100%, 40%);">- Main entry point for the test.</span><br><span style="color: hsl(0, 100%, 40%);">- """</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- test = AMIActionMessageSend()</span><br><span style="color: hsl(0, 100%, 40%);">- reactor.run()</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- if not test.passed:</span><br><span style="color: hsl(0, 100%, 40%);">- return 1</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- return 0</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-if __name__ == "__main__":</span><br><span style="color: hsl(0, 100%, 40%);">- sys.exit(main() or 0)</span><br><span>diff --git a/tests/channels/pjsip/message/message_send_ami/sipp/message_recv.xml b/tests/channels/pjsip/message/message_send_ami/sipp/message_recv.xml</span><br><span>index e485947..b1fa7a3 100644</span><br><span>--- a/tests/channels/pjsip/message/message_send_ami/sipp/message_recv.xml</span><br><span>+++ b/tests/channels/pjsip/message/message_send_ami/sipp/message_recv.xml</span><br><span>@@ -1,10 +1,19 @@</span><br><span> <?xml version="1.0" encoding="ISO-8859-1" ?></span><br><span style="color: hsl(0, 100%, 40%);">-<!DOCTYPE scenario SYSTEM "sipp.dtd"></span><br><span style="color: hsl(120, 100%, 40%);">+<!DOCTYPE scenario SYSTEM "../../../../../../contrib/sipp/sipp.dtd"></span><br><span> </span><br><span> <scenario name="MESSAGE receive from AMI"></span><br><span style="color: hsl(0, 100%, 40%);">- <recv request="MESSAGE" crlf="true" /></span><br><span style="color: hsl(120, 100%, 40%);">+ <recv request="MESSAGE" crlf="true"></span><br><span style="color: hsl(120, 100%, 40%);">+ <action></span><br><span style="color: hsl(120, 100%, 40%);">+ <ereg search_in="msg" regexp="^MESSAGE\s+sip:user1@127.0.0.1:5061\s+SIP/2[.]0"</span><br><span style="color: hsl(120, 100%, 40%);">+ check_it="true" assign_to="junk1"/></span><br><span style="color: hsl(120, 100%, 40%);">+ <ereg search_in="hdr" header="From:" regexp="sip:user0"</span><br><span style="color: hsl(120, 100%, 40%);">+ check_it="true" assign_to="junk2"/></span><br><span style="color: hsl(120, 100%, 40%);">+ <ereg search_in="hdr" header="To:" regexp="sip:ralph@somewhere.com"</span><br><span style="color: hsl(120, 100%, 40%);">+ check_it="true" assign_to="junk3"/></span><br><span style="color: hsl(120, 100%, 40%);">+ </action></span><br><span style="color: hsl(120, 100%, 40%);">+ </recv></span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- <send></span><br><span style="color: hsl(120, 100%, 40%);">+ <send></span><br><span> <![CDATA[</span><br><span> SIP/2.0 202 Accepted</span><br><span> [last_Via:]</span><br><span>@@ -16,5 +25,7 @@</span><br><span> Content-Length: 0</span><br><span> </span><br><span> ]]></span><br><span style="color: hsl(0, 100%, 40%);">- </send></span><br><span style="color: hsl(120, 100%, 40%);">+ </send></span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ <Reference variables="junk1,junk2,junk3"/></span><br><span> </scenario></span><br><span>diff --git a/tests/channels/pjsip/message/message_send_ami/test-config.yaml b/tests/channels/pjsip/message/message_send_ami/test-config.yaml</span><br><span>index d5547a7..61218ee 100644</span><br><span>--- a/tests/channels/pjsip/message/message_send_ami/test-config.yaml</span><br><span>+++ b/tests/channels/pjsip/message/message_send_ami/test-config.yaml</span><br><span>@@ -12,3 +12,42 @@</span><br><span> tags:</span><br><span> - pjsip</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+test-modules:</span><br><span style="color: hsl(120, 100%, 40%);">+ test-object:</span><br><span style="color: hsl(120, 100%, 40%);">+ config-section: test-object-config</span><br><span style="color: hsl(120, 100%, 40%);">+ typename: 'sipp.SIPpTestCase'</span><br><span style="color: hsl(120, 100%, 40%);">+ modules:</span><br><span style="color: hsl(120, 100%, 40%);">+ -</span><br><span style="color: hsl(120, 100%, 40%);">+ config-section: 'ami-config'</span><br><span style="color: hsl(120, 100%, 40%);">+ typename: 'pluggable_modules.EventActionModule'</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+test-object-config:</span><br><span style="color: hsl(120, 100%, 40%);">+ reactor-timeout: 15</span><br><span style="color: hsl(120, 100%, 40%);">+ connect-ami: True</span><br><span style="color: hsl(120, 100%, 40%);">+ test-iterations:</span><br><span style="color: hsl(120, 100%, 40%);">+ -</span><br><span style="color: hsl(120, 100%, 40%);">+ scenarios:</span><br><span style="color: hsl(120, 100%, 40%);">+ - { 'key-args': {'scenario': 'message_recv.xml', '-i': '127.0.0.1', '-p': '5061'} }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ami-config:</span><br><span style="color: hsl(120, 100%, 40%);">+ -</span><br><span style="color: hsl(120, 100%, 40%);">+ ami-start:</span><br><span style="color: hsl(120, 100%, 40%);">+ ami-actions:</span><br><span style="color: hsl(120, 100%, 40%);">+ action:</span><br><span style="color: hsl(120, 100%, 40%);">+ Action: 'MessageSend'</span><br><span style="color: hsl(120, 100%, 40%);">+ ActionID: '12345'</span><br><span style="color: hsl(120, 100%, 40%);">+ Destination: 'pjsip:user1'</span><br><span style="color: hsl(120, 100%, 40%);">+ From: 'sip:user0'</span><br><span style="color: hsl(120, 100%, 40%);">+ To: 'sip:ralph@somewhere.com'</span><br><span style="color: hsl(120, 100%, 40%);">+ Body: 'Watson, come here.'</span><br><span style="color: hsl(120, 100%, 40%);">+ -</span><br><span style="color: hsl(120, 100%, 40%);">+ ami-events:</span><br><span style="color: hsl(120, 100%, 40%);">+ conditions:</span><br><span style="color: hsl(120, 100%, 40%);">+ match:</span><br><span style="color: hsl(120, 100%, 40%);">+ Event: 'TestEvent'</span><br><span style="color: hsl(120, 100%, 40%);">+ requirements:</span><br><span style="color: hsl(120, 100%, 40%);">+ match:</span><br><span style="color: hsl(120, 100%, 40%);">+ MdataDestination: 'user1'</span><br><span style="color: hsl(120, 100%, 40%);">+ MdataFrom: 'sip:user0'</span><br><span style="color: hsl(120, 100%, 40%);">+ MsgTo: 'sip:ralph@somewhere.com'</span><br><span style="color: hsl(120, 100%, 40%);">+ count: 1</span><br><span></span><br></pre><div style="white-space:pre-wrap"></div><p>To view, visit <a href="https://gerrit.asterisk.org/c/testsuite/+/16565">change 16565</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/testsuite/+/16565"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: testsuite </div>
<div style="display:none"> Gerrit-Branch: 16 </div>
<div style="display:none"> Gerrit-Change-Id: I2f386f80e5cfaf9ea6af5234823928bc216116ca </div>
<div style="display:none"> Gerrit-Change-Number: 16565 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>