[Asterisk-code-review] message_send_ami: Refactor to use Destination parameter (testsuite[19])
George Joseph
asteriskteam at digium.com
Fri Oct 1 10:05:40 CDT 2021
George Joseph has uploaded this change for review. ( https://gerrit.asterisk.org/c/testsuite/+/16581 )
Change subject: message_send_ami: Refactor to use Destination parameter
......................................................................
message_send_ami: Refactor to use Destination parameter
ASTERISK-29677
Change-Id: I2f386f80e5cfaf9ea6af5234823928bc216116ca
---
M tests/channels/pjsip/message/message_send_ami/configs/ast1/pjsip.conf
D tests/channels/pjsip/message/message_send_ami/run-test
M tests/channels/pjsip/message/message_send_ami/sipp/message_recv.xml
M tests/channels/pjsip/message/message_send_ami/test-config.yaml
4 files changed, 55 insertions(+), 86 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/testsuite refs/changes/81/16581/1
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
index d040aa9..ef56e19 100644
--- a/tests/channels/pjsip/message/message_send_ami/configs/ast1/pjsip.conf
+++ b/tests/channels/pjsip/message/message_send_ami/configs/ast1/pjsip.conf
@@ -7,7 +7,7 @@
[user1]
type=aor
-contact=sip:user1 at 127.0.0.1:5062
+contact=sip:user1 at 127.0.0.1:5061
max_contacts=1
[user1]
diff --git a/tests/channels/pjsip/message/message_send_ami/run-test b/tests/channels/pjsip/message/message_send_ami/run-test
deleted file mode 100755
index afdaeb5..0000000
--- a/tests/channels/pjsip/message/message_send_ami/run-test
+++ /dev/null
@@ -1,81 +0,0 @@
-#!/usr/bin/env python
-# vim: sw=3 et:
-'''
-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 os
-import logging
-
-from twisted.internet import reactor
-
-sys.path.append("lib/python")
-
-from asterisk.sipp import SIPpScenario
-from asterisk.test_case import TestCase
-
-"""
-The TestCase class will initialize the python logger - creating a
-logger here will log under the '__main__' namespace
-"""
-logger = logging.getLogger(__name__)
-
-TEST_DIR = os.path.dirname(os.path.realpath(__file__))
-
-class AMIActionMessageSend(TestCase):
- """
- Test handling of AMI MessageSend action sending SIP MESSAGE
- """
- def __init__(self):
- super(AMIActionMessageSend, self).__init__()
- self.create_asterisk()
- sipp_scenario = { 'scenario':'message_recv.xml', '-p':'5062' }
- self.scenario = SIPpScenario(TEST_DIR, sipp_scenario)
-
- def run(self):
- super(AMIActionMessageSend, self).run()
- self.create_ami_factory()
-
- def ami_connect(self, ami):
- """
- This method is called by the StarPY manager class when AMI connects to Asterisk
-
- Keyword Arguments:
- ami - The StarPY manager object that connected
- """
- def __check_result(result):
- self.passed = result.passed
- self.stop_reactor()
-
- # There is a race between starting SIPp and sending the SIP MESSAGE
- # being sent by MessageSend. Fortunately, we don't care because SIP
- # will retransmit the MESSAGE so SIPp can catch it on the next go
- # round.
- logger.debug("Starting SIP scenario")
- deferred = self.scenario.run()
- deferred.addCallback(__check_result)
-
- logger.debug("Sending AMI action MessageSend")
- ami_action = { "Action":"MessageSend", "To":"pjsip:user1", "From":"sip:user", "Body":"Watson, come here." }
- ami.sendDeferred(ami_action).addCallback(ami.errorUnlessResponse)
-
-def main():
- """
- Main entry point for the test.
- """
-
- test = AMIActionMessageSend()
- reactor.run()
-
- if not test.passed:
- return 1
-
- return 0
-
-if __name__ == "__main__":
- sys.exit(main() or 0)
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
index e485947..b1fa7a3 100644
--- a/tests/channels/pjsip/message/message_send_ami/sipp/message_recv.xml
+++ b/tests/channels/pjsip/message/message_send_ami/sipp/message_recv.xml
@@ -1,10 +1,19 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
-<!DOCTYPE scenario SYSTEM "sipp.dtd">
+<!DOCTYPE scenario SYSTEM "../../../../../../contrib/sipp/sipp.dtd">
<scenario name="MESSAGE receive from AMI">
- <recv request="MESSAGE" crlf="true" />
+ <recv request="MESSAGE" crlf="true">
+ <action>
+ <ereg search_in="msg" regexp="^MESSAGE\s+sip:user1 at 127.0.0.1:5061\s+SIP/2[.]0"
+ check_it="true" assign_to="junk1"/>
+ <ereg search_in="hdr" header="From:" regexp="sip:user0"
+ check_it="true" assign_to="junk2"/>
+ <ereg search_in="hdr" header="To:" regexp="sip:ralph at somewhere.com"
+ check_it="true" assign_to="junk3"/>
+ </action>
+ </recv>
- <send>
+ <send>
<![CDATA[
SIP/2.0 202 Accepted
[last_Via:]
@@ -16,5 +25,7 @@
Content-Length: 0
]]>
- </send>
+ </send>
+
+ <Reference variables="junk1,junk2,junk3"/>
</scenario>
diff --git a/tests/channels/pjsip/message/message_send_ami/test-config.yaml b/tests/channels/pjsip/message/message_send_ami/test-config.yaml
index d5547a7..61218ee 100644
--- a/tests/channels/pjsip/message/message_send_ami/test-config.yaml
+++ b/tests/channels/pjsip/message/message_send_ami/test-config.yaml
@@ -12,3 +12,42 @@
tags:
- pjsip
+test-modules:
+ test-object:
+ config-section: test-object-config
+ typename: 'sipp.SIPpTestCase'
+ modules:
+ -
+ config-section: 'ami-config'
+ typename: 'pluggable_modules.EventActionModule'
+
+test-object-config:
+ reactor-timeout: 15
+ connect-ami: True
+ test-iterations:
+ -
+ scenarios:
+ - { 'key-args': {'scenario': 'message_recv.xml', '-i': '127.0.0.1', '-p': '5061'} }
+
+ami-config:
+ -
+ ami-start:
+ ami-actions:
+ action:
+ Action: 'MessageSend'
+ ActionID: '12345'
+ Destination: 'pjsip:user1'
+ From: 'sip:user0'
+ To: 'sip:ralph at somewhere.com'
+ Body: 'Watson, come here.'
+ -
+ ami-events:
+ conditions:
+ match:
+ Event: 'TestEvent'
+ requirements:
+ match:
+ MdataDestination: 'user1'
+ MdataFrom: 'sip:user0'
+ MsgTo: 'sip:ralph at somewhere.com'
+ count: 1
--
To view, visit https://gerrit.asterisk.org/c/testsuite/+/16581
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: testsuite
Gerrit-Branch: 19
Gerrit-Change-Id: I2f386f80e5cfaf9ea6af5234823928bc216116ca
Gerrit-Change-Number: 16581
Gerrit-PatchSet: 1
Gerrit-Owner: George Joseph <gjoseph at digium.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20211001/e0204bb0/attachment-0001.html>
More information about the asterisk-code-review
mailing list