[asterisk-commits] apps/playback: Add a remote uri test for Playback of remote ... (testsuite[master])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Mar 23 13:17:52 CDT 2016


Anonymous Coward #1000019 has submitted this change and it was merged.

Change subject: apps/playback: Add a remote_uri test for Playback of remote media files
......................................................................


apps/playback: Add a remote_uri test for Playback of remote media files

This patch adds a test that covers the Playback application playing back
media from a remote web server. The test covers playing back a single file
as well as chained file playback.

In order to support this, a new pluggable module, http_static_server, has been
added that creates a very small HTTP server that hosts static content from a
configured location. One of our normal test sounds, talking.wav, has been
copied to contrib/sounds, which can be used for multiple tests.

ASTERISK-25654

Change-Id: I606d700efded1afd2b25f97fba1808dc7a14c8ea
---
A contrib/sounds/README.txt
A contrib/sounds/talking.wav
A lib/python/asterisk/http_static_server.py
A sample-yaml/http-static-server-config.yaml.sample
A tests/apps/playback/remote_uri/configs/ast1/extensions.conf
A tests/apps/playback/remote_uri/test-config.yaml
M tests/apps/playback/tests.yaml
7 files changed, 116 insertions(+), 0 deletions(-)

Approvals:
  Anonymous Coward #1000019: Verified
  Joshua Colp: Looks good to me, approved
  George Joseph: Looks good to me, but someone else must approve



diff --git a/contrib/sounds/README.txt b/contrib/sounds/README.txt
new file mode 100644
index 0000000..15d052c
--- /dev/null
+++ b/contrib/sounds/README.txt
@@ -0,0 +1,3 @@
+# This folder contains sounds that are used by some tests.
+# These sounds are hosted here to reduce duplicate across
+# the test suite.
\ No newline at end of file
diff --git a/contrib/sounds/talking.wav b/contrib/sounds/talking.wav
new file mode 100644
index 0000000..6304af0
--- /dev/null
+++ b/contrib/sounds/talking.wav
Binary files differ
diff --git a/lib/python/asterisk/http_static_server.py b/lib/python/asterisk/http_static_server.py
new file mode 100644
index 0000000..8b545e7
--- /dev/null
+++ b/lib/python/asterisk/http_static_server.py
@@ -0,0 +1,29 @@
+#!/usr/bin/env python
+"""Pluggable module for running an HTTP server that hosts static content
+
+Copyright (C) 2016, 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 os
+
+from twisted.internet import reactor
+from twisted.web import static, server
+
+class HTTPStaticServer(object):
+    """A pluggable module that creates an HTTP server hosting static content
+    """
+
+    def __init__(self, module_config, test_object):
+        """Constructor
+
+        Keyword Arguments:
+        module_config The pluggable module's configuration
+        test_object   The one and only test object
+        """
+        root = static.File(os.path.join(os.getcwd(),
+                                        module_config['root-directory']))
+        reactor.listenTCP(module_config.get('port', 8090), server.Site(root))
diff --git a/sample-yaml/http-static-server-config.yaml.sample b/sample-yaml/http-static-server-config.yaml.sample
new file mode 100644
index 0000000..1def0e0
--- /dev/null
+++ b/sample-yaml/http-static-server-config.yaml.sample
@@ -0,0 +1,12 @@
+# Configuration sample for the static contentHTTP server pluggable module.
+# This is useful for those tests that need to interact with content hosted
+# on a remote web server.
+
+http-server-config
+
+    # The port to listen on. Default is 8090
+    port: 8088
+
+    # Relative (to the root of the Test Suite) path to the directory
+    # holding the static resources to host
+    root-directory: 'contrib/sounds'
diff --git a/tests/apps/playback/remote_uri/configs/ast1/extensions.conf b/tests/apps/playback/remote_uri/configs/ast1/extensions.conf
new file mode 100644
index 0000000..1c6c9d0
--- /dev/null
+++ b/tests/apps/playback/remote_uri/configs/ast1/extensions.conf
@@ -0,0 +1,8 @@
+[default]
+
+exten => test,1,NoOp()
+	same => n,Playback(http://localhost:8090/talking.wav)
+	same => n,ExecIf($[${PLAYBACKSTATUS}=SUCCESS]?UserEvent(Test1,result:pass)
+	same => n,Playback(http://localhost:8090/talking.wav&http://localhost:8090/talking.wav)
+	same => n,ExecIf($[${PLAYBACKSTATUS}=SUCCESS]?UserEvent(Test2,result:pass)
+	same => n,Hangup()
diff --git a/tests/apps/playback/remote_uri/test-config.yaml b/tests/apps/playback/remote_uri/test-config.yaml
new file mode 100644
index 0000000..8dfd202
--- /dev/null
+++ b/tests/apps/playback/remote_uri/test-config.yaml
@@ -0,0 +1,63 @@
+testinfo:
+    summary: 'Test Playback of a remote media resource'
+    description: |
+      'This tests Playback of a media resource from a remote HTTP server.
+       It includes both a single media resource playback, as well as when
+       multiple resources are chained.'
+
+test-modules:
+    test-object:
+        config-section: test-object-config
+        typename: 'test_case.SimpleTestCase'
+    modules:
+        -
+            config-section: ami-config
+            typename: 'ami.AMIEventModule'
+        -
+            config-section: http-server
+            typename: 'http_static_server.HTTPStaticServer'
+
+test-object-config:
+    spawn-after-hangup: True
+    expected_events: 0
+    reactor-timeout: 45
+    test-iterations:
+        -
+            channel: 'Local/test at default'
+            application: 'Echo'
+
+http-server:
+    port: 8090
+    root-directory: 'contrib/sounds'
+
+ami-config:
+    -
+        type: 'headermatch'
+        conditions:
+            match:
+                Event: 'UserEvent'
+        requirements:
+            match:
+                Result: 'pass'
+        count: '2'
+    -
+        type: 'headermatch'
+        conditions:
+            match:
+                Event: 'TestEvent'
+                State: 'PLAYBACK'
+                Message: 'http://localhost:8090/talking.wav'
+        count: '3'
+
+properties:
+    minversion: '14.0.0'
+    tags:
+      - playback
+      - apps
+    dependencies:
+        - python : 'twisted'
+        - python : 'starpy'
+        - buildoption: 'TEST_FRAMEWORK'
+        - asterisk : 'app_userevent'
+        - asterisk : 'app_playback'
+        - asterisk : 'res_http_media_cache'
diff --git a/tests/apps/playback/tests.yaml b/tests/apps/playback/tests.yaml
index 024d15d..80abae9 100644
--- a/tests/apps/playback/tests.yaml
+++ b/tests/apps/playback/tests.yaml
@@ -6,3 +6,4 @@
     - test: 'remote_restart'
     - test: 'remote_reverse'
     - test: 'remote_stop'
+    - test: 'remote_uri'

-- 
To view, visit https://gerrit.asterisk.org/2316
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I606d700efded1afd2b25f97fba1808dc7a14c8ea
Gerrit-PatchSet: 3
Gerrit-Project: testsuite
Gerrit-Branch: master
Gerrit-Owner: Matt Jordan <mjordan at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: George Joseph <george.joseph at fairview5.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>



More information about the asterisk-commits mailing list