Skip to content

Commit

Permalink
app_signal: Add tests for Signal and WaitForSignal
Browse files Browse the repository at this point in the history
Adds tests for the Signal and WaitForSignal
applications to ensure proper functionality.

ASTERISK-29810

Change-Id: I314a7f704def5ecf2e4eac008aebfdc3077d08cd
  • Loading branch information
InterLinked1 authored and Friendly Automation committed Jan 31, 2023
1 parent 381c701 commit c36b6e0
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/apps/signal/configs/ast1/extensions.conf
@@ -0,0 +1,32 @@

[default]
exten => s,1,Answer()
same => n,Signal(nothing)
same => n,GotoIf($["${SIGNALSTATUS}"!="FAILURE"]?fail,1)
same => n,Dial(Local/s@spawn-hangup,5)
same => n,GotoIf($["${DIALSTATUS}"="TIMEOUT"]?fail,1)
same => n,Originate(Local/1@spawn,app,Wait,5,,4)
same => n,Wait(1.${RAND(5,9)})
same => n,Signal(testsig1,payload1)
same => n,GotoIf($["${SIGNALSTATUS}"!="SUCCESS"]?fail,1)
same => n,Originate(Local/2@spawn,app,Wait,5,,4)
same => n,Originate(Local/2@spawn,app,Wait,5,,4)
same => n,Wait(1.${RAND(5,9)})
same => n,Signal(testsig2,payload2)
same => n,Hangup()

[spawn-hangup]
exten => s,1,WaitForSignal(mysignal,2)
same => n,Hangup()

[spawn]
exten => _[12],1,Answer()
same => n,WaitForSignal(testsig${EXTEN})
same => n,UserEvent(SignalSuccess,Result: ${IF($["${WAITFORSIGNALSTATUS}"="SIGNALED"]?Pass:Failure)})
same => n,ExecIf($["${WAITFORSIGNALPAYLOAD}"!="payload${EXTEN}"]?UserEvent(SignalSuccess,Result:Failure))
same => n,Hangup()

[nothing]
exten => 0,1,Answer()
same => n,Wait(10)
same => n,Hangup()
61 changes: 61 additions & 0 deletions tests/apps/signal/test-config.yaml
@@ -0,0 +1,61 @@
testinfo:
summary: 'Ensure that app_signal functions correctly.'
description: |
'This tests the Signal and WaitForSignal applications to make sure
that signaling works correctly. This includes sending signals when
there are listeners as well as when there aren't any listeners, as
well as sending optional payloads.'
test-modules:
test-object:
config-section: test-object-config
typename: 'test_case.TestCaseModule'
modules:
-
config-section: caller-originator
typename: 'pluggable_modules.Originator'
-
config-section: hangup-monitor
typename: 'pluggable_modules.HangupMonitor'
-
config-section: ami-config
typename: 'pluggable_modules.EventActionModule'

test-object-config:
connect-ami: True

caller-originator:
channel: 'Local/s@default'
context: 'nothing'
exten: '0'
priority: '1'
trigger: 'ami_connect'

hangup-monitor:
ids: '0'

ami-config:
-
ami-events:
conditions:
match:
Event: 'UserEvent'
UserEvent: 'SignalSuccess'
requirements:
match:
Result: 'Pass'
count: 3
stop_test:

properties:
tags:
- dial
- apps
dependencies:
- python: 'twisted'
- python: 'starpy'
- asterisk: 'app_dial'
- asterisk: 'app_userevent'
- asterisk: 'app_originate'
- asterisk: 'app_signal'
- asterisk: 'pbx_config'
1 change: 1 addition & 0 deletions tests/apps/tests.yaml
Expand Up @@ -29,3 +29,4 @@ tests:
- test: 'sf'
- test: 'read'
- test: 'if'
- test: 'signal'

0 comments on commit c36b6e0

Please sign in to comment.