[Asterisk-code-review] Add global pluggable modules. (testsuite[master])

Anonymous Coward asteriskteam at digium.com
Sun Jan 31 10:13:32 CST 2016


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

Change subject: Add global pluggable modules.
......................................................................


Add global pluggable modules.

This gives the test runner the ability to load pluggable modules from
the global test-config.yaml in addition to the test-specific
test-config.yaml.

The reason for this is that there are certain pluggable modules that
have the following attributes:
1) They have configuration that is specific to the environment, rather
than to the test itself
2) They cause an overall change in behavior to how a test runs, but the
test itself does not need to be aware of this change.
3) They should be applied to loaded during a large number of tests.

The only pluggable module that fits these criteria at the moment is the
pluggable module that converts a test with static configuration files
into a realtime test. By putting this pluggable module in the global
test-config.yaml file, it allows for tests being run to automatically be
converted into realtime tests without the need for altering any of the
tests themselves.

If a global pluggable module is configured, it will be loaded for all
tests that are run. It is likely, therefore, that test runs that use
global pluggable modules will also specify a certain tag. This allows
for test runs where they can allow tests to opt into the run.

Change-Id: Ieec1b1cfa48cadab108c4ab65122ce36ab697e4e
---
M lib/python/asterisk/test_case.py
M lib/python/asterisk/test_runner.py
M test-config.yaml
M tests/channels/pjsip/configuration/happy_config/test-config.yaml
4 files changed, 62 insertions(+), 2 deletions(-)

Approvals:
  Anonymous Coward #1000019: Verified
  Joshua Colp: Looks good to me, approved



diff --git a/lib/python/asterisk/test_case.py b/lib/python/asterisk/test_case.py
index ea24e0c..8b103ec 100644
--- a/lib/python/asterisk/test_case.py
+++ b/lib/python/asterisk/test_case.py
@@ -228,7 +228,8 @@
         count  The number of Asterisk instances to create, if no remote
                Asterisk instances have been specified
         """
-        if self.global_config.config:
+        if (self.global_config.config and
+            'asterisk-instances' in self.global_config.config):
             asterisks = self.global_config.config.get('asterisk-instances')
         else:
             asterisks = [{'num': i + 1, 'host': '127.0.0.%d' % (i + 1)}
diff --git a/lib/python/asterisk/test_runner.py b/lib/python/asterisk/test_runner.py
index 640ccd3..e940fb9 100755
--- a/lib/python/asterisk/test_runner.py
+++ b/lib/python/asterisk/test_runner.py
@@ -319,6 +319,9 @@
     # Load other modules that may be specified
     load_test_modules(test_config, test_object, ast_version)
 
+    # Load global modules as well
+    load_test_modules(test_object.global_config.config, test_object, ast_version)
+
     # Kick off the twisted reactor
     reactor.run()
 
diff --git a/test-config.yaml b/test-config.yaml
index eb34483..d926fde 100644
--- a/test-config.yaml
+++ b/test-config.yaml
@@ -143,3 +143,59 @@
         # branch not based on Asterisk trunk.
         forced-version: 1.8.0.0
 
+# This section demonstrates how to integrate automatic realtime testing into
+# the testsuite. If realtime-config is specified, then Asterisk will replace known
+# configuration file data with realtime equivalents when running tests.
+#
+# The tests assume that the realtime engine being used by Asterisk is ODBC since that
+# is the only realtime backend that has core support.
+#
+# It is strongly recommended that a test-run that uses realtime configuration also
+# specifies a tag so that tests can opt into being run in realtime mode.
+config-realtime:
+    test-modules:
+        modules:
+            -
+                typename: realtime_converter.RealtimeConverter
+                config-section: realtime-config
+
+    realtime-config:
+        # The DBMS being used for the test. This is passed as a URL type to
+        # sqlalchemy. For information on what types of technology can be specified
+        # here, see http://docs.sqlalchemy.org/en/latest/core/engines.html#database-urls
+        #
+        # Default: postgresql
+        engine: 'postgresql'
+        # User that should access the database. This is used both by sqlalchemy when
+        # populating the database and by Asterisk when reading configuration from the
+        # database
+        #
+        # Default: asterisk
+        username: 'asterisk'
+        # Password that corresponds to the user accessing the database. This is used
+        # both by sqlalchemy when populating the database and by Asterisk when reading
+        # configuration from the database
+        #
+        # Default: asterisk
+        password: 'asterisk'
+        # Hostname or IP address where the database can be reached. This is used by
+        # sqlalchemy when populating the database.
+        #
+        # Default: localhost
+        host: 'localhost'
+        # Port where the database can be reached. This is used by sqlalchemy when
+        # populating the database.
+        #
+        # Default: 5432
+        port: '5432'
+        # The name of the database where the configuration tables can be found. This is
+        # used by sqlalchemy when populating the database.
+        #
+        # Default: asterisk
+        db: 'asterisk'
+        # The name of the ODBC DSN for Asterisk to use when connecting to the database. This
+        # DSN references an odbc.ini file that tells the database, host, and port for Asterisk
+        # to use when connecting to the database.
+        #
+        # Default: asterisk
+        dsn: 'asterisk'
diff --git a/tests/channels/pjsip/configuration/happy_config/test-config.yaml b/tests/channels/pjsip/configuration/happy_config/test-config.yaml
index 4386a72..3da6287 100644
--- a/tests/channels/pjsip/configuration/happy_config/test-config.yaml
+++ b/tests/channels/pjsip/configuration/happy_config/test-config.yaml
@@ -39,4 +39,4 @@
     test-scenarios:
         -
             cli_command: 'module show like res_pjsip.so'
-            output_query: 'res_pjsip\.so[^\n]+\n[1-9][0-9]*\smodules\sloaded'
\ No newline at end of file
+            output_query: 'res_pjsip\.so[^\n]+\n[1-9][0-9]*\smodules\sloaded'

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ieec1b1cfa48cadab108c4ab65122ce36ab697e4e
Gerrit-PatchSet: 8
Gerrit-Project: testsuite
Gerrit-Branch: master
Gerrit-Owner: Mark Michelson <mmichelson at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Ashley Sanders <asanders at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-Reviewer: Mark Michelson <mmichelson at digium.com>
Gerrit-Reviewer: Matt Jordan <mjordan at digium.com>



More information about the asterisk-code-review mailing list