[Asterisk-code-review] testsuite: Add min/max version lists to test-object and modu... (testsuite[master])

Richard Mudgett asteriskteam at digium.com
Thu Sep 28 18:57:11 CDT 2017


Richard Mudgett has uploaded this change for review. ( https://gerrit.asterisk.org/6638


Change subject: testsuite: Add min/max version lists to test-object and modules.
......................................................................

testsuite: Add min/max version lists to test-object and modules.

Make testsuite accept the minversion/maxversion syntax for "test-object"
and "modules".  Before it only accepted a single version string.  Now it
will accept a single version string or a list of version strings.

test-modules:
    test-object:
        -
            maxversion: ['13.18.0', '14.7.0', '15.1.0']
            config-section: test-object-config-v12
            typename: 'sipp.SIPpTestCase'
        -
            minversion: ['13.18.0', '14.7.0', '15.1.0']
            config-section: test-object-config-v13.18.0
            typename: 'sipp.SIPpTestCase'
    modules:
        -
            maxversion: ['13.18.0', '14.7.0', '15.1.0']
            config-section: 'ami-config-v12'
            typename: 'ami.AMIEventModule'
        -
            minversion: ['13.18.0', '14.7.0', '15.1.0']
            config-section: 'ami-config-v13.18.0'
            typename: 'ami.AMIEventModule'

Also fixed a bug in the "properties: maxversion" handling of version
lists.  We were cutting off running the test only if the Asterisk version
was greater than or equal to all listed versions.  It is now handled
similarly to minversion.

Change-Id: Ibd896104af60bdab720e14e3b5bd03aafc8f2167
---
M lib/python/asterisk/test_config.py
M lib/python/asterisk/test_runner.py
2 files changed, 42 insertions(+), 9 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/testsuite refs/changes/38/6638/1

diff --git a/lib/python/asterisk/test_config.py b/lib/python/asterisk/test_config.py
index b44ffb9..7775a62 100644
--- a/lib/python/asterisk/test_config.py
+++ b/lib/python/asterisk/test_config.py
@@ -484,11 +484,17 @@
             min_candidates = self.minversion
         self.minversion_check = all([ast_version >= ver
                                      for ver in min_candidates])
+
         # Max version is a bit different: generally, it is a hard cut-off
-        # (as what the test covers has been removed). We should always be less
-        # than any provided max version.
+        # (as what the test covers has been removed).  If we have a maximum
+        # version for our branch; use that.  Otherwise, compare against all
+        # listed maximum versions.
+        max_candidates = [ver for ver in self.maxversion
+                          if ver.major == ast_version.major]
+        if not len(max_candidates):
+            max_candidates = self.maxversion
         self.maxversion_check = all([ast_version < ver
-                                     for ver in self.maxversion])
+                                     for ver in max_candidates])
 
         if not self.minversion_check or not self.maxversion_check:
             self.can_run = False
diff --git a/lib/python/asterisk/test_runner.py b/lib/python/asterisk/test_runner.py
index a097d02..a31c8ca 100755
--- a/lib/python/asterisk/test_runner.py
+++ b/lib/python/asterisk/test_runner.py
@@ -145,13 +145,40 @@
     version, True otherwise
     """
 
-    modminversion = module_spec.get('minversion')
-    modmaxversion = module_spec.get('maxversion')
-    if (modminversion is not None and
-            AsteriskVersion(ast_version) < AsteriskVersion(modminversion)):
+    running_version = AsteriskVersion(ast_version)
+
+    minversion = module_spec.get("minversion", [])
+    if not isinstance(minversion, list):
+        minversion = [minversion]
+    min_versions = [AsteriskVersion(ver) for ver in minversion]
+
+    # If we have a minimum version for our branch; use that.  Otherwise,
+    # compare against all listed minimum versions.
+    min_candidates = [ver for ver in min_versions
+                      if ver.major == running_version.major]
+    if not len(min_candidates):
+        min_candidates = min_versions
+    min_version_check = all([running_version >= ver for ver in min_candidates])
+
+    if not min_version_check:
         return False
-    if (modmaxversion is not None and
-            AsteriskVersion(ast_version) >= AsteriskVersion(modmaxversion)):
+
+    maxversion = module_spec.get("maxversion", [])
+    if not isinstance(maxversion, list):
+        maxversion = [maxversion]
+    max_versions = [AsteriskVersion(ver) for ver in maxversion]
+
+    # Max version is a bit different: generally, it is a hard cut-off
+    # (as what the test covers has been removed).  If we have a maximum
+    # version for our branch; use that.  Otherwise, compare against all
+    # listed maximum versions.
+    max_candidates = [ver for ver in max_versions
+                      if ver.major == running_version.major]
+    if not len(max_candidates):
+        max_candidates = max_versions
+    max_version_check = all([running_version < ver for ver in max_candidates])
+
+    if not max_version_check:
         return False
 
     return True

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

Gerrit-Project: testsuite
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibd896104af60bdab720e14e3b5bd03aafc8f2167
Gerrit-Change-Number: 6638
Gerrit-PatchSet: 1
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20170928/a9ddf56c/attachment-0001.html>


More information about the asterisk-code-review mailing list