[asterisk-commits] bridges: Ensure correct device state when on-hold and redire... (testsuite[master])
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Sep 25 05:26:27 CDT 2015
Joshua Colp has submitted this change and it was merged.
Change subject: bridges: Ensure correct device state when on-hold and redirected.
......................................................................
bridges: Ensure correct device state when on-hold and redirected.
This test redirects an on-hold channel out of a bridge into an Echo
extension. We then ensure that the DEVICE_STATE() function for that
channel's corresponding device shows that the channel now appears to be
"in use".
ASTERISK-25410
Change-Id: If27c743388d91529709fa68d9b497026a82e4add
---
A tests/bridge/hold_redirect/configs/ast1/extensions.conf
A tests/bridge/hold_redirect/configs/ast1/pjsip.conf
A tests/bridge/hold_redirect/devstate_check.py
A tests/bridge/hold_redirect/sipp/alice.xml
A tests/bridge/hold_redirect/sipp/bob.xml
A tests/bridge/hold_redirect/test-config.yaml
M tests/bridge/tests.yaml
7 files changed, 325 insertions(+), 0 deletions(-)
Approvals:
Matt Jordan: Looks good to me, but someone else must approve
Joshua Colp: Looks good to me, approved; Verified
diff --git a/tests/bridge/hold_redirect/configs/ast1/extensions.conf b/tests/bridge/hold_redirect/configs/ast1/extensions.conf
new file mode 100644
index 0000000..b60732f
--- /dev/null
+++ b/tests/bridge/hold_redirect/configs/ast1/extensions.conf
@@ -0,0 +1,10 @@
+[default]
+
+exten => bob,1,NoOp()
+same => n,Dial(PJSIP/bob)
+same => n,Hangup()
+
+exten => echo,1,NoOp()
+same => n,UserEvent(Echoing)
+same => n,Echo()
+saem => n,Hangup()
diff --git a/tests/bridge/hold_redirect/configs/ast1/pjsip.conf b/tests/bridge/hold_redirect/configs/ast1/pjsip.conf
new file mode 100644
index 0000000..1ef605d
--- /dev/null
+++ b/tests/bridge/hold_redirect/configs/ast1/pjsip.conf
@@ -0,0 +1,21 @@
+[local-transport]
+type = transport
+bind = 127.0.0.1
+protocol = udp
+
+[alice]
+type = endpoint
+context = default
+allow = ulaw,alaw,g722
+direct_media = no
+
+[bob]
+type = endpoint
+context = default
+allow = ulaw,alaw,g722
+direct_media = no
+aors = bob
+
+[bob]
+type=aor
+contact = sip:127.0.0.1:5062
diff --git a/tests/bridge/hold_redirect/devstate_check.py b/tests/bridge/hold_redirect/devstate_check.py
new file mode 100644
index 0000000..b07dc51
--- /dev/null
+++ b/tests/bridge/hold_redirect/devstate_check.py
@@ -0,0 +1,48 @@
+#!/usr/bin/env python
+
+import logging
+LOGGER = logging.getLogger('test_runner')
+
+class DevStateCheck(object):
+ def __init__(self, config, test_object):
+ self.test_object = test_object
+ self.test_object.register_ami_observer(self.ami_connected)
+
+ def ami_connected(self, ami):
+ ami.registerEvent('DeviceStateChange', self.devstate_changed)
+ ami.registerEvent('UserEvent', self.user_event)
+
+ def devstate_changed(self, ami, event):
+ '''When we see that Bob has been put on hold, we need to redirect Bob to
+ the "echo" extension
+ '''
+ if (event.get('device') == 'PJSIP/bob' and
+ event.get('state') == 'ONHOLD'):
+ LOGGER.info("PJSIP/bob is on hold")
+ message = {
+ 'action': 'redirect',
+ 'channel': 'PJSIP/bob-00000001',
+ 'context': 'default',
+ 'exten': 'echo',
+ 'priority': '1',
+ }
+
+ ami.sendMessage(message)
+
+ def user_event(self, ami, event):
+ '''When we have confirmation that Bob has been redirected, we need to
+ ensure that Bob's device state is now INUSE. No matter if the test
+ passes or fails, we also need to hang up Bob and Alice.
+ '''
+ def __getvar_cb(result):
+ if result == 'INUSE':
+ self.test_object.set_passed(True)
+ else:
+ LOGGER.error("PJSIP/bob device state is {0}".format(result))
+ self.test_object.set_passed(False)
+
+ ami.hangup('/.*/')
+
+ LOGGER.info("Received UserEvent")
+ ami.getVar(channel=None, variable="DEVICE_STATE(PJSIP/bob)"
+ ).addCallbacks(__getvar_cb)
diff --git a/tests/bridge/hold_redirect/sipp/alice.xml b/tests/bridge/hold_redirect/sipp/alice.xml
new file mode 100644
index 0000000..bd04b14
--- /dev/null
+++ b/tests/bridge/hold_redirect/sipp/alice.xml
@@ -0,0 +1,133 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "alice.dtd">
+
+<scenario name="alice">
+ <send retrans="500">
+ <![CDATA[
+
+ INVITE sip:bob@[remote_ip]:[remote_port] SIP/2.0
+ Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+ From: alice <sip:alice@[local_ip]:[local_port]>;tag=[pid]aliceTag00[call_number]
+ To: sut <sip:bob@[remote_ip]:[remote_port]>
+ Call-ID: [call_id]
+ CSeq: 1 INVITE
+ Contact: <sip:alice@[local_ip]:[local_port];transport=[transport]>
+ Max-Forwards: 70
+ Subject: Performance Test
+ Content-Type: application/sdp
+ Content-Length: [len]
+
+ v=0
+ o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip]
+ s=-
+ c=IN IP[media_ip_type] [media_ip]
+ t=0 0
+ m=audio [media_port] RTP/AVP 0
+ a=rtpmap:0 PCMU/8000
+
+ ]]>
+ </send>
+
+ <recv response="100"
+ optional="true">
+ </recv>
+
+ <recv response="181"
+ optional="true">
+ </recv>
+
+ <recv response="180" optional="true">
+ </recv>
+
+ <recv response="183" optional="true">
+ </recv>
+
+ <recv response="200" rtd="true">
+ </recv>
+
+ <send>
+ <![CDATA[
+
+ ACK sip:bob@[remote_ip]:[remote_port] SIP/2.0
+ Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+ From: alice <sip:alice@[local_ip]:[local_port]>;tag=[pid]aliceTag00[call_number]
+ To: sut <sip:bob@[remote_ip]:[remote_port]>[peer_tag_param]
+ Call-ID: [call_id]
+ CSeq: 1 ACK
+ Contact: sip:alice@[local_ip]:[local_port]
+ Max-Forwards: 70
+ Subject: Performance Test
+ Content-Length: 0
+
+ ]]>
+ </send>
+
+ <pause />
+
+ <send retrans="500">
+ <![CDATA[
+
+ INVITE sip:bob@[remote_ip]:[remote_port] SIP/2.0
+ Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+ From: alice <sip:alice@[local_ip]:[local_port]>;tag=[pid]aliceTag00[call_number]
+ To: sut <sip:bob@[remote_ip]:[remote_port]>[peer_tag_param]
+ Call-ID: [call_id]
+ CSeq: 2 INVITE
+ Contact: <sip:alice@[local_ip]:[local_port];transport=[transport]>
+ Max-Forwards: 70
+ Subject: Performance Test
+ Content-Type: application/sdp
+ Content-Length: [len]
+
+ v=0
+ o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip]
+ s=-
+ c=IN IP[media_ip_type] [media_ip]
+ t=0 0
+ m=audio [media_port] RTP/AVP 0
+ a=rtpmap:0 PCMU/8000
+ a=sendonly
+
+ ]]>
+ </send>
+
+ <recv response="200" rtd="true">
+ </recv>
+
+ <send>
+ <![CDATA[
+
+ ACK sip:bob@[remote_ip]:[remote_port] SIP/2.0
+ Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+ From: alice <sip:alice@[local_ip]:[local_port]>;tag=[pid]aliceTag00[call_number]
+ To: sut <sip:bob@[remote_ip]:[remote_port]>[peer_tag_param]
+ Call-ID: [call_id]
+ CSeq: 2 ACK
+ Contact: sip:alice@[local_ip]:[local_port]
+ Max-Forwards: 70
+ Subject: Performance Test
+ Content-Length: 0
+
+ ]]>
+ </send>
+
+ <recv request="BYE">
+ </recv>
+
+ <send>
+ <![CDATA[
+
+ SIP/2.0 200 OK
+ [last_Via:]
+ [last_From:]
+ [last_To:]
+ [last_Call-ID:]
+ [last_CSeq:]
+ Contact: <sip:[local_ip]:[local_port];transport=[transport]>
+ Content-Length: 0
+
+ ]]>
+ </send>
+
+</scenario>
+
diff --git a/tests/bridge/hold_redirect/sipp/bob.xml b/tests/bridge/hold_redirect/sipp/bob.xml
new file mode 100644
index 0000000..31542ef
--- /dev/null
+++ b/tests/bridge/hold_redirect/sipp/bob.xml
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<scenario name="bob">
+ <recv request="INVITE" crlf="true">
+ </recv>
+ <send>
+ <![CDATA[
+
+ SIP/2.0 180 Ringing
+ [last_Via:]
+ [last_From:]
+ [last_To:];tag=[pid]SIPpTag01[call_number]
+ [last_Call-ID:]
+ [last_CSeq:]
+ Contact: <sip:[local_ip]:[local_port];transport=[transport]>
+ Content-Length: 0
+
+ ]]>
+ </send>
+
+ <send retrans="500">
+ <![CDATA[
+
+ SIP/2.0 200 OK
+ [last_Via:]
+ [last_From:]
+ [last_To:];tag=[pid]SIPpTag01[call_number]
+ [last_Call-ID:]
+ [last_CSeq:]
+ Contact: <sip:[local_ip]:[local_port];transport=[transport]>
+ Content-Type: application/sdp
+ Content-Length: [len]
+
+ v=0
+ o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip]
+ s=-
+ c=IN IP[media_ip_type] [media_ip]
+ t=0 0
+ m=audio [media_port] RTP/AVP 0
+ a=rtpmap:0 PCMU/8000
+
+ ]]>
+ </send>
+
+ <recv request="ACK"
+ optional="true"
+ rtd="true"
+ crlf="true">
+ </recv>
+
+ <recv request="BYE">
+ </recv>
+
+ <send>
+ <![CDATA[
+
+ SIP/2.0 200 OK
+ [last_Via:]
+ [last_From:]
+ [last_To:]
+ [last_Call-ID:]
+ [last_CSeq:]
+ Contact: <sip:[local_ip]:[local_port];transport=[transport]>
+ Content-Length: 0
+
+ ]]>
+ </send>
+
+</scenario>
+
diff --git a/tests/bridge/hold_redirect/test-config.yaml b/tests/bridge/hold_redirect/test-config.yaml
new file mode 100644
index 0000000..ab77b2b
--- /dev/null
+++ b/tests/bridge/hold_redirect/test-config.yaml
@@ -0,0 +1,41 @@
+testinfo:
+ summary: 'Ensure that a channel on hold does not remain on hold when moved out of a bridge'
+ description: |
+ "The test performs the following:
+ 1) Alice places a call to Bob
+ 2) Alice places Bob on hold
+ 3) We ensure that Bob's device state is ONHOLD.
+ 4) We use an AMI redirect to move Bob to an Echo application.
+ 5) We ensure that Bob's device state is INUSE."
+
+test-modules:
+ add-test-to-search-path: True
+ test-object:
+ config-section: 'sipp-config'
+ typename: 'sipp.SIPpTestCase'
+ modules:
+ -
+ typename: 'devstate_check.DevStateCheck'
+ -
+ config-section: 'hangup-config'
+ typename: 'pluggable_modules.HangupMonitor'
+
+hangup-config:
+ ids: '0'
+
+sipp-config:
+ test-iterations:
+ -
+ scenarios:
+ - { 'key-args': {'scenario': 'alice.xml', '-p': '5061', '-d': '5000' } }
+ - { 'key-args': {'scenario': 'bob.xml', '-p': '5062' } }
+
+properties:
+ minversion: '13.6.0'
+ dependencies:
+ - python: 'twisted'
+ - python: 'starpy'
+ - asterisk: 'res_pjsip'
+ tags:
+ - bridge
+ - pjsip
diff --git a/tests/bridge/tests.yaml b/tests/bridge/tests.yaml
index 1557301..c5e7090 100644
--- a/tests/bridge/tests.yaml
+++ b/tests/bridge/tests.yaml
@@ -24,3 +24,4 @@
- test: 'atxfer_threeway_nominal'
- test: 'atxfer_retries'
- test: 'feature_timeout_hangup'
+ - test: 'hold_redirect'
--
To view, visit https://gerrit.asterisk.org/1306
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: If27c743388d91529709fa68d9b497026a82e4add
Gerrit-PatchSet: 1
Gerrit-Project: testsuite
Gerrit-Branch: master
Gerrit-Owner: Mark Michelson <mmichelson at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Matt Jordan <mjordan at digium.com>
More information about the asterisk-commits
mailing list