[Asterisk-code-review] res_ari_channels/res_pjsip: Added test for exposed protocol_id (testsuite[master])

Moritz Fain asteriskteam at digium.com
Thu Apr 28 07:20:12 CDT 2022


Moritz Fain has uploaded this change for review. ( https://gerrit.asterisk.org/c/testsuite/+/18418 )


Change subject: res_ari_channels/res_pjsip: Added test for exposed protocol_id
......................................................................

res_ari_channels/res_pjsip: Added test for exposed protocol_id

This test checks whether the protocol_id is successfully exposed
and filled with a PJSIP style Call-ID.

ASTERISK-30027
Reported by: Moritz Fain

Change-Id: Ibc8a103b9e54d709aa39472fa2d77a969c1685ac
---
M addons/Makefile
A tests/rest_api/channels/originate_to_pjsip_endpoint/channel_originate.py
A tests/rest_api/channels/originate_to_pjsip_endpoint/configs/ast1/extensions.conf
A tests/rest_api/channels/originate_to_pjsip_endpoint/configs/ast1/pjsip.conf
A tests/rest_api/channels/originate_to_pjsip_endpoint/pjsip.conf
A tests/rest_api/channels/originate_to_pjsip_endpoint/test-config.yaml
M tests/rest_api/channels/tests.yaml
7 files changed, 175 insertions(+), 3 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/testsuite refs/changes/18/18418/1

diff --git a/addons/Makefile b/addons/Makefile
index 2496d27..d4ea379 100644
--- a/addons/Makefile
+++ b/addons/Makefile
@@ -31,10 +31,10 @@
 update:
 	@if [ -d starpy ]; then \
 		cd starpy; \
-		if [ `git config --get remote.origin.url` = git://github.com/asterisk-org/starpy.git ]; then \
-			git remote set-url origin git://github.com/asterisk/starpy.git git://github.com/asterisk-org/starpy.git; \
+		if [ `git config --get remote.origin.url` = https://github.com/asterisk/starpy ]; then \
+			git remote set-url origin https://github.com/asterisk/starpy; \
 		fi; \
 		git pull; \
 	else \
-		git clone git://github.com/asterisk/starpy.git; \
+		git clone https://github.com/asterisk/starpy; \
 	fi
diff --git a/tests/rest_api/channels/originate_to_pjsip_endpoint/channel_originate.py b/tests/rest_api/channels/originate_to_pjsip_endpoint/channel_originate.py
new file mode 100644
index 0000000..241b2b2
--- /dev/null
+++ b/tests/rest_api/channels/originate_to_pjsip_endpoint/channel_originate.py
@@ -0,0 +1,40 @@
+'''
+Copyright (C) 2013, Digium, Inc.
+Joshua Colp <jcolp at digium.com>
+
+This program is free software, distributed under the terms of
+the GNU General Public License Version 2.
+'''
+
+import logging
+
+LOGGER = logging.getLogger(__name__)
+
+CHANNELS = 0
+
+
+def on_kickoff_start(ari, event, test_object):
+    LOGGER.debug("on_kickoff_start(%r)" % event)
+    for x in xrange(15):
+        ari.post('channels',
+                 endpoint='PJSIP/1000 at endpoint1',
+                 app='testsuite',
+                 appArgs='blast')
+    ari.delete('channels', event['channel']['id'])
+    return True
+
+
+def on_blast_start(ari, event, test_object):
+    LOGGER.debug("on_blast_start(%r)" % event)
+    return True
+
+
+def on_channel_destroyed(ari, event, test_object):
+    global CHANNELS
+    LOGGER.debug("on_channel_destroyed: %s" % str(event.get('channel')))
+    CHANNELS += 1
+    if CHANNELS == 15:
+        LOGGER.info("All channels destroyed")
+        test_object.set_passed(True)
+        test_object.stop_reactor()
+    return True
diff --git a/tests/rest_api/channels/originate_to_pjsip_endpoint/configs/ast1/extensions.conf b/tests/rest_api/channels/originate_to_pjsip_endpoint/configs/ast1/extensions.conf
new file mode 100644
index 0000000..68e0987
--- /dev/null
+++ b/tests/rest_api/channels/originate_to_pjsip_endpoint/configs/ast1/extensions.conf
@@ -0,0 +1,13 @@
+[default]
+
+exten => s,1,NoOp()
+	same => n,Answer()
+	same => n,Stasis(testsuite)
+	same => n,Hangup()
+
+
+[default2]
+
+exten => 1000,1,NoOp()
+	same => n,Answer()
+	same => n,Hangup()
diff --git a/tests/rest_api/channels/originate_to_pjsip_endpoint/configs/ast1/pjsip.conf b/tests/rest_api/channels/originate_to_pjsip_endpoint/configs/ast1/pjsip.conf
new file mode 100644
index 0000000..f748994
--- /dev/null
+++ b/tests/rest_api/channels/originate_to_pjsip_endpoint/configs/ast1/pjsip.conf
@@ -0,0 +1,40 @@
+[global]
+debug=yes
+
+
+[transport1]
+type=transport
+protocol=udp
+bind=127.0.0.1:5060
+
+[endpoint1]
+type=endpoint
+context=default
+transport=transport1
+allow=!all,ulaw
+media_address=127.0.0.1
+direct_media=no
+aors=endpoint1_aor
+
+[endpoint1_aor]
+type=aor
+contact=sip:127.0.0.2:5060
+
+
+[transport2]
+type=transport
+protocol=udp
+bind=127.0.0.2:5060
+
+[endpoint2]
+type=endpoint
+context=default2
+transport=transport2
+allow=!all,ulaw
+media_address=127.0.0.2
+direct_media=no
+
+[endpoint2_identity]
+type=identify
+endpoint=endpoint2
+match=127.0.0.1
diff --git a/tests/rest_api/channels/originate_to_pjsip_endpoint/pjsip.conf b/tests/rest_api/channels/originate_to_pjsip_endpoint/pjsip.conf
new file mode 100644
index 0000000..f35f723
--- /dev/null
+++ b/tests/rest_api/channels/originate_to_pjsip_endpoint/pjsip.conf
@@ -0,0 +1,16 @@
+[global]
+debug=yes
+
+[transport-template](!)
+type=transport
+bind=127.0.0.1
+
+[transport-udp](transport-template)
+protocol=udp
+
+[endpoint-template](!)
+type=endpoint
+context=default
+allow=!all,ulaw
+
+[anonymous](endpoint-template)
diff --git a/tests/rest_api/channels/originate_to_pjsip_endpoint/test-config.yaml b/tests/rest_api/channels/originate_to_pjsip_endpoint/test-config.yaml
new file mode 100644
index 0000000..e689470
--- /dev/null
+++ b/tests/rest_api/channels/originate_to_pjsip_endpoint/test-config.yaml
@@ -0,0 +1,62 @@
+testinfo:
+    summary: Test originating calls to a Stasis application with PJSIP endpoint using ARI.
+    description: |
+        Originate a specific number of calls using ARI and verify they have a protocol_id set from PJSIP.
+
+test-modules:
+    add-test-to-search-path: True
+    test-object:
+        typename: ari.AriOriginateTestObject
+        config-section: test-config
+    modules:
+        -
+            config-section: ari-config
+            typename: ari.WebSocketEventModule
+
+test-config:
+    stop-on-end: False
+
+ari-config:
+    apps: testsuite
+    events:
+        -   conditions:
+                match:
+                    type: StasisStart
+                    application: testsuite
+                    args: []
+            count: 1
+            callback:
+                module: channel_originate
+                method: on_kickoff_start
+        -   conditions:
+                match:
+                    type: StasisStart
+                    application: testsuite
+                    args: ['blast']
+                    channel:
+                        protocol_id: '^.{8}-.{4}-.{4}-.{4}-.{12}$'
+            count: 15
+            callback:
+                module: channel_originate
+                method: on_blast_start
+        -   conditions:
+                match:
+                    type: ChannelDestroyed
+                    application: testsuite
+            count: 15
+            callback:
+                module: channel_originate
+                method: on_channel_destroyed
+
+properties:
+    dependencies:
+        - python : autobahn.websocket
+        - python : requests
+        - python : twisted
+        - python : starpy
+        - asterisk : res_ari_channels
+        - asterisk : chan_pjsip
+        - asterisk : res_pjsip
+    tags:
+        - ARI
+        - PJSIP
diff --git a/tests/rest_api/channels/tests.yaml b/tests/rest_api/channels/tests.yaml
index b585099..9f2b4fd 100644
--- a/tests/rest_api/channels/tests.yaml
+++ b/tests/rest_api/channels/tests.yaml
@@ -4,6 +4,7 @@
     - test: 'originate_with_id'
     - test: 'originate_with_linkedid'
     - test: 'originate_then_continue'
+    - test: 'originate_to_pjsip_endpoint'
     - test: 'snoop_whisper'
     - test: 'snoop_spy'
     - test: 'snoop_id'

-- 
To view, visit https://gerrit.asterisk.org/c/testsuite/+/18418
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: testsuite
Gerrit-Branch: master
Gerrit-Change-Id: Ibc8a103b9e54d709aa39472fa2d77a969c1685ac
Gerrit-Change-Number: 18418
Gerrit-PatchSet: 1
Gerrit-Owner: Moritz Fain <moritz at fain.io>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20220428/7ed24c7a/attachment-0001.html>


More information about the asterisk-code-review mailing list