Skip to content

Commit 3e8e8b3

Browse files
author
Tyler Goodlet
committed
Add a dialplan timeout test
Verify that when a session is parked but not handled within the timeout period (in this case 3 seconds as set in our CI dialplan) it is cancelled by FS. In the contrary case verify that a simple `session.answer()` within the timeout results in a successful SIPp `uac` client scenario. Resolves #47
1 parent a2cf88b commit 3e8e8b3

File tree

2 files changed

+50
-2
lines changed

2 files changed

+50
-2
lines changed

conf/ci-minimal/dialplan/switchydp.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<!-- A context for relinquishing control of all calls to switchio, the inbound ESL client -->
33
<context name="switchio">
4-
<!-- Park call and transfer control to esl -->
54
<extension name="switchiopark">
65
<condition field="destination_number" expression="^(.*)$">
7-
<action application="set" data="park_timeout=3:DESTINATION_OUT_OF_ORDER"/>
6+
<!-- Park call and transfer control to switchio over ESL -->
7+
<action application="set" data="park_timeout=3:NETWORK_OUT_OF_ORDER"/>
88
<action application="park"/>
99
</condition>
1010
</extension>

tests/test_coroutines.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,51 @@ async def timeout_on_hangup(self, sess):
8888
assert task.done()
8989
with pytest.raises(asyncio.TimeoutError):
9090
task.result()
91+
92+
93+
@pytest.mark.parametrize('sleep', [2, 5])
94+
def test_simplest_flow(fssock, scenario, client, ael, sleep):
95+
"""Verify that a coroutine can satisfy SIPp's simplest call flow.
96+
97+
Additionally, verify that when calls are not answered and left in the park
98+
state they time out and are rejected after 3 seconds (according to the CI
99+
dialplan).
100+
"""
101+
class MyApp:
102+
@coroutine(
103+
"CHANNEL_PARK",
104+
subscribe=('PLAYBACK_STOP', 'PLAYBACK_START')
105+
)
106+
async def answer_play_hangup(self, sess):
107+
await asyncio.sleep(sleep)
108+
await sess.answer()
109+
# non-blocking
110+
sess.playback(
111+
'en/us/callie/ivr/8000/ivr-founder_of_freesource.wav')
112+
await sess.recv("PLAYBACK_START")
113+
await sess.recv("CHANNEL_HANGUP")
114+
# XXX: seems the playback isn't stopping on its own? - the
115+
# hangup does it though...
116+
# sess.breakmedia()
117+
await sess.recv("PLAYBACK_STOP")
118+
await sess.recv("CHANNEL_HANGUP_COMPLETE")
119+
120+
client.connect()
121+
client.listener = ael
122+
# assigning a listener overrides it's call lookup var so restore it
123+
client.listener.call_tracking_header = 'variable_call_uuid'
124+
assert 'default' == client.load_app(MyApp, on_value="default")
125+
126+
uac = scenario.prepare()[1]
127+
uac.proxyaddr = None
128+
uac.destaddr = fssock
129+
uac.pause_duration = 6000
130+
131+
# make the call
132+
if sleep > 3:
133+
# XML dialplan's `park_timeout` should reject the call
134+
with pytest.raises(RuntimeError):
135+
uac()
136+
else:
137+
# call should be hung up by this UAC
138+
uac()

0 commit comments

Comments
 (0)