[svn-commits] dlee: branch dlee/ari-tests r3830 - in /asterisk/team/dlee/ari-tests: lib/pyt...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Thu Jun 6 16:54:32 CDT 2013
Author: dlee
Date: Thu Jun 6 16:54:31 2013
New Revision: 3830
URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=3830
Log:
Initial work
Added:
asterisk/team/dlee/ari-tests/lib/python/asterisk/ari.py (with props)
asterisk/team/dlee/ari-tests/tests/rest_api/
asterisk/team/dlee/ari-tests/tests/rest_api/continue/
asterisk/team/dlee/ari-tests/tests/rest_api/continue/configs/
asterisk/team/dlee/ari-tests/tests/rest_api/continue/configs/ast1/
asterisk/team/dlee/ari-tests/tests/rest_api/continue/configs/ast1/extensions.conf (with props)
asterisk/team/dlee/ari-tests/tests/rest_api/continue/configs/ast1/http.conf (with props)
asterisk/team/dlee/ari-tests/tests/rest_api/continue/configs/ast1/stasis_http.conf (with props)
asterisk/team/dlee/ari-tests/tests/rest_api/continue/rest_continue.py (with props)
asterisk/team/dlee/ari-tests/tests/rest_api/continue/test-config.yaml (with props)
asterisk/team/dlee/ari-tests/tests/rest_api/tests.yaml (with props)
Modified:
asterisk/team/dlee/ari-tests/tests/tests.yaml
Added: asterisk/team/dlee/ari-tests/lib/python/asterisk/ari.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/dlee/ari-tests/lib/python/asterisk/ari.py?view=auto&rev=3830
==============================================================================
--- asterisk/team/dlee/ari-tests/lib/python/asterisk/ari.py (added)
+++ asterisk/team/dlee/ari-tests/lib/python/asterisk/ari.py Thu Jun 6 16:54:31 2013
@@ -1,0 +1,72 @@
+'''
+Copyright (C) 2013, Digium, Inc.
+David M. Lee, II <dlee at digium.com>
+
+This program is free software, distributed under the terms of
+the GNU General Public License Version 2.
+'''
+
+import logging
+import time
+import urllib
+import websocket
+
+logger = logging.getLogger(__name__)
+
+class Range(object):
+ def __init__(self, min = 0, max = float("inf")):
+ self.min = min
+ self.max = max
+
+ def contains(self, v):
+ return self.min <= v <= self.max
+
+def decode_range(v):
+ if isinstance(v, int):
+ return Range(v, v)
+ elif count[0] == '<':
+ # Need at most this many events
+ self.count_min = 0
+ self.count_max = int(count[1:])
+ elif count[0] == '>':
+ # Need at least this many events
+ self.count_min = int(count[1:])
+ self.count_max = float("inf")
+ else:
+ # Need exactly this many events
+ self.count_min = int(count)
+ self.count_max = int(count)
+
+class EventMatcher(object):
+ def __init__(self, instance_config, test_object):
+ self.instance_config = instance_config
+ self.test_object = test_object
+
+class WebSocketEventModule(object):
+ def __init__(self, module_config, test_object):
+ self.test_object = test_object
+
+ self.events = [
+ EventMatcher(e, test_object) for e in module_config['events']]
+
+ apps = module_config['apps']
+ if isinstance(apps, list):
+ apps = ','.join(apps)
+ path = "ws://127.0.0.1:8088/ws"
+ params = urllib.urlencode({'app': apps})
+ url = "%s?%s" % (path, params)
+
+ tries = 1
+ while True:
+ try:
+ self.ws = websocket.create_connection(
+ url, header=["Sec-WebSocket-Protocol: stasis"])
+ except:
+ if tries > 10:
+ logger.error("WebSocket connection failed.")
+ break
+ # Wait a bit and try again
+ logger.info("WebSocket connection failed. Retrying...")
+ tries += 1
+ time.sleep(1)
+
Propchange: asterisk/team/dlee/ari-tests/lib/python/asterisk/ari.py
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/team/dlee/ari-tests/lib/python/asterisk/ari.py
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/team/dlee/ari-tests/lib/python/asterisk/ari.py
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/team/dlee/ari-tests/tests/rest_api/continue/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/dlee/ari-tests/tests/rest_api/continue/configs/ast1/extensions.conf?view=auto&rev=3830
==============================================================================
--- asterisk/team/dlee/ari-tests/tests/rest_api/continue/configs/ast1/extensions.conf (added)
+++ asterisk/team/dlee/ari-tests/tests/rest_api/continue/configs/ast1/extensions.conf Thu Jun 6 16:54:31 2013
@@ -1,0 +1,7 @@
+[default]
+
+exten => s,1,NoOp()
+ same => n,Answer()
+# same => n,Stasis(continue-test)
+ same => n,UserEvent(TestResult,Result: pass,Status: successfully broke out of Stasis)
+ same => n,Hangup()
Propchange: asterisk/team/dlee/ari-tests/tests/rest_api/continue/configs/ast1/extensions.conf
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/team/dlee/ari-tests/tests/rest_api/continue/configs/ast1/extensions.conf
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/team/dlee/ari-tests/tests/rest_api/continue/configs/ast1/extensions.conf
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/team/dlee/ari-tests/tests/rest_api/continue/configs/ast1/http.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/dlee/ari-tests/tests/rest_api/continue/configs/ast1/http.conf?view=auto&rev=3830
==============================================================================
--- asterisk/team/dlee/ari-tests/tests/rest_api/continue/configs/ast1/http.conf (added)
+++ asterisk/team/dlee/ari-tests/tests/rest_api/continue/configs/ast1/http.conf Thu Jun 6 16:54:31 2013
@@ -1,0 +1,3 @@
+[general]
+enabled=yes
+bindaddr=127.0.0.1
Propchange: asterisk/team/dlee/ari-tests/tests/rest_api/continue/configs/ast1/http.conf
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/team/dlee/ari-tests/tests/rest_api/continue/configs/ast1/http.conf
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/team/dlee/ari-tests/tests/rest_api/continue/configs/ast1/http.conf
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/team/dlee/ari-tests/tests/rest_api/continue/configs/ast1/stasis_http.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/dlee/ari-tests/tests/rest_api/continue/configs/ast1/stasis_http.conf?view=auto&rev=3830
==============================================================================
--- asterisk/team/dlee/ari-tests/tests/rest_api/continue/configs/ast1/stasis_http.conf (added)
+++ asterisk/team/dlee/ari-tests/tests/rest_api/continue/configs/ast1/stasis_http.conf Thu Jun 6 16:54:31 2013
@@ -1,0 +1,2 @@
+[general]
+enabled = yes
Propchange: asterisk/team/dlee/ari-tests/tests/rest_api/continue/configs/ast1/stasis_http.conf
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/team/dlee/ari-tests/tests/rest_api/continue/configs/ast1/stasis_http.conf
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/team/dlee/ari-tests/tests/rest_api/continue/configs/ast1/stasis_http.conf
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/team/dlee/ari-tests/tests/rest_api/continue/rest_continue.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/dlee/ari-tests/tests/rest_api/continue/rest_continue.py?view=auto&rev=3830
==============================================================================
--- asterisk/team/dlee/ari-tests/tests/rest_api/continue/rest_continue.py (added)
+++ asterisk/team/dlee/ari-tests/tests/rest_api/continue/rest_continue.py Thu Jun 6 16:54:31 2013
@@ -1,0 +1,23 @@
+'''
+Copyright (C) 2013, Digium, Inc.
+David M. Lee, II <dlee 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__)
+
+id = None
+
+def on_start(ari, event):
+ global id
+ id = event['channel']['uniqueid']
+ ari.resource('channels', id, 'continue').post
+ return True
+
+def on_end(ari, event):
+ global id
+ return id == event['channel']['uniqueid']
Propchange: asterisk/team/dlee/ari-tests/tests/rest_api/continue/rest_continue.py
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/team/dlee/ari-tests/tests/rest_api/continue/rest_continue.py
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/team/dlee/ari-tests/tests/rest_api/continue/rest_continue.py
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/team/dlee/ari-tests/tests/rest_api/continue/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/dlee/ari-tests/tests/rest_api/continue/test-config.yaml?view=auto&rev=3830
==============================================================================
--- asterisk/team/dlee/ari-tests/tests/rest_api/continue/test-config.yaml (added)
+++ asterisk/team/dlee/ari-tests/tests/rest_api/continue/test-config.yaml Thu Jun 6 16:54:31 2013
@@ -1,0 +1,66 @@
+testinfo:
+ summary: Test continuing on from the RESTful API back to the dialplan
+ description: |
+ This test simply waits for a call via the WebSocket, then hits the
+ continue controller to send it back to the dialplan.
+
+test-modules:
+ add-test-to-search-path: True
+ test-object:
+ config-section: test-object-config
+ typename: SimpleTestCase.SimpleTestCase
+ modules:
+ - config-section: ari-config
+ typename: ari.WebSocketEventModule
+ - config-section: ami-config
+ typename: ami.AMIEventModule
+
+test-object-config:
+ spawn-after-hangup: True
+ test-iterations:
+ - channel: Local/s at default
+ application: Echo
+
+ari-config:
+ apps: continue-test
+ events:
+ - match:
+ application: continue-test
+ stasis_start:
+ args: []
+ count: 1
+ callback:
+ module: rest_continue
+ method: on_start
+ - match:
+ application: continue-test
+ stasis_end:
+ count: 1
+ callback:
+ module: rest_continue
+ method: on_end
+
+ami-config:
+ - type: headermatch
+ conditions:
+ match:
+ Event: UserEvent
+ requirements:
+ match:
+ Result: pass
+ count: 1
+
+properties:
+ minversion: '12.0.0'
+ dependencies:
+ - python : websocket
+ - python : requests
+ - python : twisted
+ - python : starpy
+ - asterisk : res_stasis_http_channels
+ - asterisk : app_userevent
+ - asterisk : app_echo
+ tags:
+ - ARI
+
+
Propchange: asterisk/team/dlee/ari-tests/tests/rest_api/continue/test-config.yaml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/team/dlee/ari-tests/tests/rest_api/continue/test-config.yaml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/team/dlee/ari-tests/tests/rest_api/continue/test-config.yaml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/team/dlee/ari-tests/tests/rest_api/tests.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/dlee/ari-tests/tests/rest_api/tests.yaml?view=auto&rev=3830
==============================================================================
--- asterisk/team/dlee/ari-tests/tests/rest_api/tests.yaml (added)
+++ asterisk/team/dlee/ari-tests/tests/rest_api/tests.yaml Thu Jun 6 16:54:31 2013
@@ -1,0 +1,3 @@
+# Enter tests here in the order they should be considered for execution:
+tests:
+ - test: 'continue'
Propchange: asterisk/team/dlee/ari-tests/tests/rest_api/tests.yaml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/team/dlee/ari-tests/tests/rest_api/tests.yaml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/team/dlee/ari-tests/tests/rest_api/tests.yaml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: asterisk/team/dlee/ari-tests/tests/tests.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/dlee/ari-tests/tests/tests.yaml?view=diff&rev=3830&r1=3829&r2=3830
==============================================================================
--- asterisk/team/dlee/ari-tests/tests/tests.yaml (original)
+++ asterisk/team/dlee/ari-tests/tests/tests.yaml Thu Jun 6 16:54:31 2013
@@ -27,3 +27,4 @@
- dir: 'redirecting'
- test: 'cause_answered_elsewhere'
- dir: 'bridge'
+ - dir: 'rest_api'
More information about the svn-commits
mailing list