[Asterisk-code-review] pluggable modules: Add a pluggable module that installs Aste... (testsuite[master])

Anonymous Coward asteriskteam at digium.com
Wed May 18 17:41:10 CDT 2016


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

Change subject: pluggable_modules: Add a pluggable module that installs Asterisk config files
......................................................................


pluggable_modules: Add a pluggable module that installs Asterisk config files

Some tests in the Asterisk Test Suite have very specific Asterisk
configuration that makes little sense to be shared across tests. More
common, however, are tests that use the same configuration files. For
example, the ARI tests often use a simply 'extensions.conf' with a
simple dialplan entry. Today, the Test Suite requires that each test
define the same file repeatedly.

This patch adds a pluggable module that will instead install an Asterisk
config file. This allows a test to reference a configuration file stored
someplace in the Test Suite hierarchy, and have that configuration file
be installed after the Asterisk wrapper class has been created but
before Asterisk has been started. This allows for pluggable module based
tests to re-use configuration, reducing the amount of work needed to
write many tests and avoiding needless copying.

Change-Id: I283fbcc8962308ba2046aa3b0ac9c4be61bc267f
---
M lib/python/asterisk/pluggable_modules.py
A sample-yaml/asterisk-config.yaml.sample
2 files changed, 37 insertions(+), 0 deletions(-)

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



diff --git a/lib/python/asterisk/pluggable_modules.py b/lib/python/asterisk/pluggable_modules.py
index 65105e3..785874f 100755
--- a/lib/python/asterisk/pluggable_modules.py
+++ b/lib/python/asterisk/pluggable_modules.py
@@ -639,6 +639,26 @@
         self.event_register(ami)
 
 
+class AsteriskConfigModule(object):
+    """A pluggable module that installs an Asterisk config file.
+
+    Configuration is as follows:
+    config-section:
+        -
+            id: 0
+            src: tests/my-test/my-super-awesome.conf
+            dst: extensions.conf
+    """
+
+    def __init__(self, instance_config, test_object):
+        """Constructor for pluggable modules"""
+        super(AsteriskConfigModule, self).__init__()
+
+        for info in instance_config:
+            asterisk_instance = test_object.ast[info.get('id', 0)]
+            asterisk_instance.install_config(info['src'], info['dst'])
+
+
 class FastAGIModule(object):
     """A class that makes a FastAGI server available to be called via the
     dialplan and allows simple commands to be executed.
diff --git a/sample-yaml/asterisk-config.yaml.sample b/sample-yaml/asterisk-config.yaml.sample
new file mode 100644
index 0000000..7d80876
--- /dev/null
+++ b/sample-yaml/asterisk-config.yaml.sample
@@ -0,0 +1,17 @@
+# Configuration for the pluggable_modules.AsteriskConfigModule pluggable module.
+# This module installs a customer Asterisk config file, allowing config files
+# to be shared across tests.
+
+asterisk-config:
+    # The configuration should consist of a list of files to install into
+    # specific Asterisk instances
+    -
+        # The Asterisk instance to install the file into. If not provided,
+        # will install into Asterisk instance 0
+        id: 0
+
+        # The config file to install
+        src: 'tests/my-cool-test/extensions.conf'
+
+        # The config file it should replace
+        dst: 'extensions.conf'

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I283fbcc8962308ba2046aa3b0ac9c4be61bc267f
Gerrit-PatchSet: 1
Gerrit-Project: testsuite
Gerrit-Branch: master
Gerrit-Owner: Matt Jordan <mjordan at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Mark Michelson <mmichelson at digium.com>



More information about the asterisk-code-review mailing list