[Asterisk-code-review] Testsuite: Allow CDR test to specify CDR directory (testsuite[master])

Jonathan Rose asteriskteam at digium.com
Thu Oct 22 14:40:54 CDT 2015


Jonathan Rose has uploaded a new change for review.

  https://gerrit.asterisk.org/1483

Change subject: Testsuite: Allow CDR test to specify CDR directory
......................................................................

Testsuite: Allow CDR test to specify CDR directory

On one of our internal test builds, cdr_csv is unavailable but we
still want to perform a CDR record check using the same parameters as
what we would expect from cdr_csv. Fortunately, cdr_custom can be used
to write a CDR log identical to what cdr_csv writes. However, since the
test class for CDR matching was written with cdr_csv in mind, we can't
tell it to use the cdr-custom folder. This patch will allow the test
yaml that defines the CDR match to specify which folder the CDR file
resides in.

Change-Id: I8148499a447a27129ca6620effcfc3bf7b40a0d4
---
M lib/python/asterisk/bridge_test_case.py
M lib/python/asterisk/cdr.py
2 files changed, 13 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/testsuite refs/changes/83/1483/1

diff --git a/lib/python/asterisk/bridge_test_case.py b/lib/python/asterisk/bridge_test_case.py
index e9ae244..39b526d 100644
--- a/lib/python/asterisk/bridge_test_case.py
+++ b/lib/python/asterisk/bridge_test_case.py
@@ -92,7 +92,14 @@
 
         if 'asterisk-instances' in test_config:
             self.instances = test_config['asterisk-instances']
-        self.create_asterisk(self.instances, "%s/configs/bridge" % os.getcwd())
+
+        if test_config.get('use_pjsip') is True:
+            self.create_asterisk(self.instances,
+                                 "%s/configs/bridge_pjsip" % os.getcwd())
+        else:
+            self.create_asterisk(self.instances,
+                                 "%s/configs/bridge" % os.getcwd())
+
         LOGGER.info("Bridge test initialized")
 
     def run(self):
diff --git a/lib/python/asterisk/cdr.py b/lib/python/asterisk/cdr.py
index 6380ed0..cc5226b 100644
--- a/lib/python/asterisk/cdr.py
+++ b/lib/python/asterisk/cdr.py
@@ -32,8 +32,11 @@
 
         # Build our expected CDR records
         self.cdr_records = {}
+        self.file_locations = {}
         for record in module_config:
             file_name = record['file']
+            cdr_dir = record.get('cdr-dir', 'cdr-csv')
+            self.file_locations[file_name] = cdr_dir
             ast_id = record.get('id') or 0
             if ast_id not in self.cdr_records:
                 self.cdr_records[ast_id] = {}
@@ -79,7 +82,8 @@
                 records = self.cdr_records[ast_id][file_name]
                 cdr_expect = AsteriskCSVCDR(records=records)
                 cdr_file = AsteriskCSVCDR(filename=ast_instance.get_path(
-                    "astlogdir", "cdr-csv", "%s.csv" % file_name))
+                    "astlogdir", self.file_locations[file_name],
+                    "%s.csv" % file_name))
                 if cdr_expect.match(cdr_file):
                     LOGGER.debug("%s.csv: CDR results met expectations" %
                                  file_name)

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8148499a447a27129ca6620effcfc3bf7b40a0d4
Gerrit-PatchSet: 1
Gerrit-Project: testsuite
Gerrit-Branch: master
Gerrit-Owner: Jonathan Rose <jrose at digium.com>



More information about the asterisk-code-review mailing list