[asterisk-commits] realtime: Improve test compatibility. (testsuite[master])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jul 28 10:22:22 CDT 2016


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

Change subject: realtime: Improve test compatibility.
......................................................................


realtime: Improve test compatibility.

When configuring SIP URIs in the pjsip.conf file it is
necessary to escape the semicolon so the parser does not
treat it as a comment. This change allows this to work in
the astconfigparser implementation.

A secondary bug where some data was lost if a configuration
option included a "=" in its value was also fixed.

Semi-colons are now also encoded according to how the
res_config_odbc module expects. Without this encoding they
were treated as a separator option values.

A bug where sections would be considered equal despite
being different has also been fixed.

Configuration file tests for PJSIP have also been marked
as being for configuration and a new option to runtests.py
has been added to skip a subset of tests based on tags.

Change-Id: Ibff2af1c0c4bce28b94360aecec5996f363b4ae8
---
M lib/python/asterisk/astconfigparser.py
M lib/python/asterisk/realtime_converter.py
M lib/python/asterisk/test_config.py
M runtests.py
M tests/channels/pjsip/configuration/duplicate_sections/test-config.yaml
M tests/channels/pjsip/configuration/happy_config/test-config.yaml
6 files changed, 30 insertions(+), 12 deletions(-)

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



diff --git a/lib/python/asterisk/astconfigparser.py b/lib/python/asterisk/astconfigparser.py
index 778b17f..46f4fb4 100644
--- a/lib/python/asterisk/astconfigparser.py
+++ b/lib/python/asterisk/astconfigparser.py
@@ -51,6 +51,12 @@
         """
         return cmp(self.id, other.id)
 
+    def __eq__(self, other):
+        """
+        Use self.id as means of determining equality
+        """
+        return self.id == other.id
+
     def get(self, key, from_self=True, from_templates=True,
             from_defaults=True):
         """
@@ -191,9 +197,14 @@
         # otherwise it was an embedded comment so combine
         return ''.join([part[0].strip(), ' ', line]).rstrip(), False
 
-    # check for eol comment
-    return line.partition(COMMENT)[0].strip(), False
+    # find the first occurence of a comment that is not escaped
+    match = re.match(r'.*?([^\\];)', line)
 
+    if match:
+         # the end of where the real string is is where the comment starts
+         line = line[0:(match.end()-1)]
+
+    return line.replace("\\", "").strip(), False
 
 def try_include(line):
     """
@@ -231,7 +242,7 @@
 
 def try_option(line):
     """Parses the line as an option, returning the key/value pair."""
-    data = re.split('=>?', line)
+    data = re.split('=>?', line, 1)
     # should split in two (key/val), but either way use first two elements
     return data[0].rstrip(), data[1].lstrip()
 
diff --git a/lib/python/asterisk/realtime_converter.py b/lib/python/asterisk/realtime_converter.py
index 8aec232..4688f61 100644
--- a/lib/python/asterisk/realtime_converter.py
+++ b/lib/python/asterisk/realtime_converter.py
@@ -155,7 +155,7 @@
                 vals = {'id': title}
                 for key in section.keys():
                     if key != 'type':
-                        vals[key] = section.get(key)[0]
+                        vals[key] = section.get(key)[0].replace(";", "^3B")
 
                 conn.execute(table.insert().values(**vals))
 
diff --git a/lib/python/asterisk/test_config.py b/lib/python/asterisk/test_config.py
index eb0a03d..b44ffb9 100644
--- a/lib/python/asterisk/test_config.py
+++ b/lib/python/asterisk/test_config.py
@@ -503,7 +503,7 @@
                 self.can_run = False
         return self.can_run
 
-    def check_tags(self, requested_tags):
+    def check_tags(self, requested_tags, skip_tags):
         """Check whether or not a test should execute based on its tags
 
         Keyword arguments:
@@ -516,13 +516,15 @@
         if not self.config:
             return False
 
-        # If no tags are requested, this test's tags don't matter
-        if not requested_tags:
-            return self.can_run
+        if requested_tags:
+            intersection = set(requested_tags).intersection(set(self.tags))
+            if len(intersection) == 0:
+                self.can_run = False
 
-        intersection = set(requested_tags).intersection(set(self.tags))
-        if len(intersection) == 0:
-            self.can_run = False
+        if skip_tags:
+            intersection = set(skip_tags).intersection(set(self.tags))
+            if len(intersection) != 0:
+                self.can_run = False
 
         # all tags matched successfully
         return self.can_run
diff --git a/runtests.py b/runtests.py
index 5b0b651..7d324cf 100755
--- a/runtests.py
+++ b/runtests.py
@@ -437,7 +437,7 @@
     def __check_can_run(self, ast_version):
         """Check tags and dependencies in the test config."""
         if self.test_config.check_deps(ast_version) and \
-                self.test_config.check_tags(self.options.tags):
+                self.test_config.check_tags(self.options.tags, self.options.skip_tags):
             self.can_run = True
 
     def __parse_run_output(self, output):
@@ -754,6 +754,9 @@
     parser.add_option("-g", "--tag", action="append",
                       dest="tags",
                       help="Specify one or more tags to select a subset of tests.")
+    parser.add_option("-G", "--skip-tag", action="append",
+                      dest="skip_tags",
+                      help="Specify one or more tags to ignore a subset of tests.")
     parser.add_option("-k", "--keep-core", action="store_true",
                       dest="keep_core", default=False,
                       help="Archive the 'core' file if Asterisk crashes.")
diff --git a/tests/channels/pjsip/configuration/duplicate_sections/test-config.yaml b/tests/channels/pjsip/configuration/duplicate_sections/test-config.yaml
index 87dd9ae..cc1cc21 100644
--- a/tests/channels/pjsip/configuration/duplicate_sections/test-config.yaml
+++ b/tests/channels/pjsip/configuration/duplicate_sections/test-config.yaml
@@ -28,6 +28,7 @@
             version: 'v3.0'
     tags:
         - pjsip
+        - realtime-incompatible
     issues:
         - jira: 'ASTERISK-24996'
 
diff --git a/tests/channels/pjsip/configuration/happy_config/test-config.yaml b/tests/channels/pjsip/configuration/happy_config/test-config.yaml
index 3da6287..ce504a5 100644
--- a/tests/channels/pjsip/configuration/happy_config/test-config.yaml
+++ b/tests/channels/pjsip/configuration/happy_config/test-config.yaml
@@ -17,6 +17,7 @@
             version: 'v3.0'
     tags:
         - pjsip
+        - realtime-incompatible
     issues:
         - jira: 'ASTERISK-24996'
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ibff2af1c0c4bce28b94360aecec5996f363b4ae8
Gerrit-PatchSet: 4
Gerrit-Project: testsuite
Gerrit-Branch: master
Gerrit-Owner: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-Reviewer: Mark Michelson <mmichelson at digium.com>



More information about the asterisk-commits mailing list