Skip to content

Commit

Permalink
Add a dialplan timeout test
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Tyler Goodlet committed Dec 6, 2017
1 parent 36b50dc commit b5f9820
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 2 deletions.
4 changes: 2 additions & 2 deletions conf/ci-minimal/dialplan/switchydp.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- A context for relinquishing control of all calls to switchio, the inbound ESL client -->
<context name="switchio">
<!-- Park call and transfer control to esl -->
<extension name="switchiopark">
<condition field="destination_number" expression="^(.*)$">
<action application="set" data="park_timeout=3:DESTINATION_OUT_OF_ORDER"/>
<!-- Park call and transfer control to switchio over ESL -->
<action application="set" data="park_timeout=3:NETWORK_OUT_OF_ORDER"/>
<action application="park"/>
</condition>
</extension>
Expand Down
48 changes: 48 additions & 0 deletions tests/test_coroutines.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,51 @@ async def timeout_on_hangup(self, sess):
assert task.done()
with pytest.raises(asyncio.TimeoutError):
task.result()


@pytest.mark.parametrize('sleep', [2, 5])
def test_simplest_flow(fssock, scenario, client, ael, sleep):
"""Verify that a coroutine can satisfy SIPp's simplest call flow.
Additionally, verify that when calls are not answered and left in the park
state they time out and are rejected after 3 seconds (according to the CI
dialplan).
"""
class MyApp:
@coroutine(
"CHANNEL_PARK",
subscribe=('PLAYBACK_STOP', 'PLAYBACK_START')
)
async def answer_play_hangup(self, sess):
await asyncio.sleep(sleep)
await sess.answer()
# non-blocking
sess.playback(
'en/us/callie/ivr/8000/ivr-founder_of_freesource.wav')
await sess.recv("PLAYBACK_START")
await sess.recv("CHANNEL_HANGUP")
# XXX: seems the playback isn't stopping on its own? - the
# hangup does it though...
# sess.breakmedia()
await sess.recv("PLAYBACK_STOP")
await sess.recv("CHANNEL_HANGUP_COMPLETE")

client.connect()
client.listener = ael
# assigning a listener overrides it's call lookup var so restore it
client.listener.call_tracking_header = 'variable_call_uuid'
assert 'default' == client.load_app(MyApp, on_value="default")

uac = scenario.prepare()[1]
uac.proxyaddr = None
uac.destaddr = fssock
uac.pause_duration = 6000

# make the call
if sleep > 3:
# XML dialplan's `park_timeout` should reject the call
with pytest.raises(RuntimeError):
uac()
else:
# call should be hung up by this UAC
uac()

0 comments on commit b5f9820

Please sign in to comment.