[asterisk-commits] mjordan: branch mjordan/http-cache-stuff-and-things r5783 - in /asterisk/team...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Oct 25 20:32:11 CDT 2014


Author: mjordan
Date: Sat Oct 25 20:32:08 2014
New Revision: 5783

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=5783
Log:
Now push in

Added:
    asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/
    asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/read/
    asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/read/configs/
    asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/read/configs/ast1/
    asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/read/configs/ast1/extensions.conf   (with props)
    asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/read/configs/ast1/http.conf   (with props)
    asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/read/run-test   (with props)
    asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/read/test-config.yaml   (with props)
    asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/tests.yaml   (with props)
    asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/write/
    asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/write/configs/
    asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/write/configs/ast1/
    asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/write/configs/ast1/extensions.conf   (with props)
    asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/write/configs/ast1/http.conf   (with props)
    asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/write/run-test   (with props)
    asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/write/test-config.yaml   (with props)
Modified:
    asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/tests.yaml

Added: asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/read/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/read/configs/ast1/extensions.conf?view=auto&rev=5783
==============================================================================
--- asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/read/configs/ast1/extensions.conf (added)
+++ asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/read/configs/ast1/extensions.conf Sat Oct 25 20:32:08 2014
@@ -1,0 +1,6 @@
+[default]
+
+exten => s,1,NoOp()
+ same => n,Answer()
+ same => n,Set(TEST_RESULT=${CURL(http://localhost:8088/static/test.json)})
+ same => n,Hangup()

Propchange: asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/read/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/read/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/read/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/read/configs/ast1/http.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/read/configs/ast1/http.conf?view=auto&rev=5783
==============================================================================
--- asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/read/configs/ast1/http.conf (added)
+++ asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/read/configs/ast1/http.conf Sat Oct 25 20:32:08 2014
@@ -1,0 +1,6 @@
+[general]
+
+enabled=yes
+bindaddr=127.0.0.1
+bindport=8088
+enablestatic=yes

Propchange: asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/read/configs/ast1/http.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/read/configs/ast1/http.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/read/configs/ast1/http.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/read/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/read/run-test?view=auto&rev=5783
==============================================================================
--- asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/read/run-test (added)
+++ asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/read/run-test Sat Oct 25 20:32:08 2014
@@ -1,0 +1,98 @@
+#!/usr/bin/env python
+# vim: sw=3 et:
+"""Test for CURL write operations
+
+Copyright (C) 2014, Digium, Inc.
+Matt Jordan <mjordan at digium.com>
+
+This program is free software, distributed under the terms of
+the GNU General Public License Version 2.
+"""
+
+import sys
+import logging
+import json
+
+from twisted.internet import reactor
+
+sys.path.append("lib/python")
+from asterisk.test_case import TestCase
+
+LOGGER = logging.getLogger(__name__)
+
+class CURLReadTest(TestCase):
+    """A class that executes a func_curl write test"""
+
+    def __init__(self):
+        super(CURLReadTest, self).__init__()
+        """Constructor
+        """
+        self.create_asterisk(count=1)
+
+    def run(self):
+        """Entry point for the twisted reactor
+        """
+        super(CURLReadTest, self).run()
+
+        test_file = self.ast[0].get_path('astvarlibdir', 'static-http', 'test.json')
+        with open(test_file, 'w') as fp:
+            fp.write(json.dumps({ 'foo': 'bar' }))
+
+        self.create_ami_factory(count=1)
+
+    def ami_connect(self, ami):
+        """AMI connection  callback
+
+        Keyword Arguments:
+        ami  The StarPY manager object that connected
+        """
+
+        def _on_hangup(ami, event):
+            """Handle our channel hangup event.
+            """
+            self.stop_reactor()
+
+        def _on_var_set(ami, event):
+            """Look for the setting of our variable"""
+
+            if event.get('variable') != 'TEST_RESULT':
+                return
+
+            value = event.get('value')
+            if not value:
+                LOGGER.error('Failed to read any value from test.json')
+                self.set_passed(False)
+                return
+
+            json_blob = json.loads(value)
+
+            if json_blob.get('foo') == 'bar':
+                LOGGER.info('Found foo/bar in JSON')
+                self.set_passed(True)
+            else:
+                LOGGER.error('Could not find expected key/value foo/bar in JSON')
+                self.set_passed(False)
+            return
+
+        ami.registerEvent('Hangup', _on_hangup)
+        ami.registerEvent('VarSet', _on_var_set)
+
+        orig_defer = ami.originate(channel='Local/s at default',
+            application='Echo')
+        orig_defer.addErrback(self.handle_originate_failure)
+
+
+def main():
+    """Main entry point for the test.
+    """
+
+    test = CURLReadTest()
+    reactor.run()
+
+    if not test.passed:
+        return 1
+
+    return 0
+
+if __name__ == "__main__":
+    sys.exit(main() or 0)

Propchange: asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/read/run-test
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/read/run-test
------------------------------------------------------------------------------
    svn:executable = *

Propchange: asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/read/run-test
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/read/run-test
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/read/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/read/test-config.yaml?view=auto&rev=5783
==============================================================================
--- asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/read/test-config.yaml (added)
+++ asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/read/test-config.yaml Sat Oct 25 20:32:08 2014
@@ -1,0 +1,17 @@
+testinfo:
+    summary:     'Test for CURL write'
+    description: |
+        This test exercises the CURL function's write capabilities. It
+        creates a small JSON file and hosts it on the Asterisk instance's
+        static HTTP server. It then spawns a channel which uses the CURL
+        function to cURL the hosted JSON file into the Asterisk spool/tmp
+        directory. Finally, it verifies that the retrieved file contains
+        the same information as the hosted file.
+
+properties:
+    minversion: '14.0.0'
+    dependencies:
+        - python: 'twisted'
+        - python: 'starpy'
+        - asterisk: 'func_curl'
+        - asterisk: 'app_echo'

Propchange: asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/read/test-config.yaml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/read/test-config.yaml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/read/test-config.yaml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/tests.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/tests.yaml?view=auto&rev=5783
==============================================================================
--- asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/tests.yaml (added)
+++ asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/tests.yaml Sat Oct 25 20:32:08 2014
@@ -1,0 +1,4 @@
+# Enter tests here in the order they should be considered for execution:
+tests:
+    - test: 'write'
+    - test: 'read'

Propchange: asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/tests.yaml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/tests.yaml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/tests.yaml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/write/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/write/configs/ast1/extensions.conf?view=auto&rev=5783
==============================================================================
--- asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/write/configs/ast1/extensions.conf (added)
+++ asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/write/configs/ast1/extensions.conf Sat Oct 25 20:32:08 2014
@@ -1,0 +1,10 @@
+[globals]
+
+DEST_FILE=
+
+[default]
+
+exten => s,1,NoOp()
+ same => n,Answer()
+ same => n,Set(CURL(http://localhost:8088/static/test.json)=${DEST_FILE})
+ same => n,Hangup()

Propchange: asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/write/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/write/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/write/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/write/configs/ast1/http.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/write/configs/ast1/http.conf?view=auto&rev=5783
==============================================================================
--- asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/write/configs/ast1/http.conf (added)
+++ asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/write/configs/ast1/http.conf Sat Oct 25 20:32:08 2014
@@ -1,0 +1,6 @@
+[general]
+
+enabled=yes
+bindaddr=127.0.0.1
+bindport=8088
+enablestatic=yes

Propchange: asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/write/configs/ast1/http.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/write/configs/ast1/http.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/write/configs/ast1/http.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/write/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/write/run-test?view=auto&rev=5783
==============================================================================
--- asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/write/run-test (added)
+++ asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/write/run-test Sat Oct 25 20:32:08 2014
@@ -1,0 +1,103 @@
+#!/usr/bin/env python
+# vim: sw=3 et:
+"""Test for CURL write operations
+
+Copyright (C) 2014, Digium, Inc.
+Matt Jordan <mjordan at digium.com>
+
+This program is free software, distributed under the terms of
+the GNU General Public License Version 2.
+"""
+
+import sys
+import logging
+import json
+
+from twisted.internet import reactor
+
+sys.path.append("lib/python")
+from asterisk.test_case import TestCase
+
+LOGGER = logging.getLogger(__name__)
+
+class CURLWriteTest(TestCase):
+    """A class that executes a func_curl write test"""
+
+    def __init__(self):
+        super(CURLWriteTest, self).__init__()
+        """Constructor
+        """
+        self.create_asterisk(count=1)
+        self.output_file = None
+
+    def run(self):
+        """Entry point for the twisted reactor
+        """
+        super(CURLWriteTest, self).run()
+
+        test_file = self.ast[0].get_path('astvarlibdir', 'static-http', 'test.json')
+        self.output_file = self.ast[0].get_path('astspooldir', 'tmp', 'test.json')
+        with open(test_file, 'w') as fp:
+            fp.write(json.dumps({ 'foo': 'bar' }))
+
+        self.create_ami_factory(count=1)
+
+    def ami_connect(self, ami):
+        """AMI connection  callback
+
+        Keyword Arguments:
+        ami  The StarPY manager object that connected
+        """
+
+        def _spawn_channel(result):
+            """Spawn the channel that runs the CURL function
+            """
+            orig_defer = ami.originate(channel='Local/s at default',
+                application='Echo')
+            orig_defer.addErrback(self.handle_originate_failure)
+            return result
+
+        var_defer = ami.setVar(channel=None, variable='DEST_FILE',
+            value=self.output_file)
+        var_defer.addCallback(_spawn_channel)
+
+        def _on_hangup(ami, event):
+            """Handle our channel hangup event.
+            """
+            try:
+                self.verify_results()
+            except:
+                LOGGER.error('Failed to verify results')
+            self.stop_reactor()
+
+        ami.registerEvent('Hangup', _on_hangup)
+
+    def verify_results(self):
+        """Verify that the file was retrieved and contains the JSON data"""
+        with open(self.output_file, 'r') as ofp:
+            text = ofp.read()
+            LOGGER.debug('Read %s from output file' % text)
+            json_blob = json.loads(text)
+
+            if json_blob.get('foo') == 'bar':
+                LOGGER.info('Found foo/bar in JSON')
+                self.set_passed(True)
+            else:
+                LOGGER.error('Could not find expected key/value foo/bar in JSON')
+                self.set_passed(False)
+
+
+def main():
+    """Main entry point for the test.
+    """
+
+    test = CURLWriteTest()
+    reactor.run()
+
+    if not test.passed:
+        return 1
+
+    return 0
+
+if __name__ == "__main__":
+    sys.exit(main() or 0)

Propchange: asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/write/run-test
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/write/run-test
------------------------------------------------------------------------------
    svn:executable = *

Propchange: asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/write/run-test
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/write/run-test
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/write/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/write/test-config.yaml?view=auto&rev=5783
==============================================================================
--- asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/write/test-config.yaml (added)
+++ asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/write/test-config.yaml Sat Oct 25 20:32:08 2014
@@ -1,0 +1,17 @@
+testinfo:
+    summary:     'Test for CURL write'
+    description: |
+        This test exercises the CURL function's write capabilities. It
+        creates a small JSON file and hosts it on the Asterisk instance's
+        static HTTP server. It then spawns a channel which uses the CURL
+        function to cURL the hosted JSON file into the Asterisk spool/tmp
+        directory. Finally, it verifies that the retrieved file contains
+        the same information as the hosted file.
+
+properties:
+    minversion: '14.0.0'
+    dependencies:
+        - python: 'twisted'
+        - python: 'starpy'
+        - asterisk: 'func_curl'
+        - asterisk: 'app_echo'

Propchange: asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/write/test-config.yaml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/write/test-config.yaml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/func_curl/write/test-config.yaml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/tests.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/tests.yaml?view=diff&rev=5783&r1=5782&r2=5783
==============================================================================
--- asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/tests.yaml (original)
+++ asterisk/team/mjordan/http-cache-stuff-and-things/tests/funcs/tests.yaml Sat Oct 25 20:32:08 2014
@@ -6,3 +6,4 @@
     - test: 'func_global'
     - test: 'func_talkdetect'
     - test: 'func_push'
+    - dir: 'func_curl'




More information about the asterisk-commits mailing list