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

Jenkins2 asteriskteam at digium.com
Mon Oct 9 09:26:35 CDT 2017


Jenkins2 has submitted this change and it was merged. ( 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(-)

Approvals:
  Joshua Colp: Looks good to me, but someone else must approve
  Kevin Harwell: Looks good to me, approved
  Jenkins2: Approved for Submit



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: merged
Gerrit-Change-Id: Ibd896104af60bdab720e14e3b5bd03aafc8f2167
Gerrit-Change-Number: 6638
Gerrit-PatchSet: 2
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20171009/77c98b62/attachment.html>


More information about the asterisk-code-review mailing list