[Asterisk-code-review] testsuite: Add test for cdr cvs file (...testsuite[master])

Rodrigo Ramirez Norambuena asteriskteam at digium.com
Mon May 6 21:31:47 CDT 2019


Rodrigo Ramirez Norambuena has uploaded this change for review. ( https://gerrit.asterisk.org/c/testsuite/+/11359


Change subject: testsuite: Add test for cdr cvs file
......................................................................

testsuite: Add test for cdr cvs file

>From Asterisk 1.8 are include three new fields for CDR:
 - peeraccount
 - userfield
 - sequence

This patch include a test to check the correct behaviour of logs these
files when is set newcdrcolumn into cdr.conf file.

ASTERISK-24976

Change-Id: Iba0b7aff5be841eaf0f4665e5d7adc0a63540ce6
---
M lib/python/asterisk/cdr.py
A tests/cdr/cdr_newcdrcolumns_yes/configs/ast1/extensions.conf
A tests/cdr/cdr_newcdrcolumns_yes/test-config.yaml
A tests/cdr/configs/newcdrcolumns/ast1/cdr.conf
M tests/cdr/tests.yaml
5 files changed, 98 insertions(+), 3 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/testsuite refs/changes/59/11359/1

diff --git a/lib/python/asterisk/cdr.py b/lib/python/asterisk/cdr.py
index c5d62db..bf584ca 100644
--- a/lib/python/asterisk/cdr.py
+++ b/lib/python/asterisk/cdr.py
@@ -99,14 +99,16 @@
     fields = [
         'accountcode', 'source', 'destination', 'dcontext', 'callerid',
         'channel', 'dchannel', 'lastapp', 'lastarg', 'start', 'answer', 'end',
-        'duration', 'billsec', 'disposition', 'amaflags', 'uniqueid', 'userfield']
+        'duration', 'billsec', 'disposition', 'amaflags', 'uniqueid',
+        'userfield', 'peeraccount', 'linkedid', 'sequence']
 
     def __init__(
             self, accountcode=None, source=None, destination=None,
             dcontext=None, callerid=None, channel=None, dchannel=None,
             lastapp=None, lastarg=None, start=None, answer=None, end=None,
             duration=None, billsec=None, disposition=None, amaflags=None,
-            uniqueid=None, userfield=None):
+            uniqueid=None, userfield=None, peeraccount=None, linkedid=None,
+            sequence=None):
         """Construct an Asterisk CSV CDR.
 
         The arguments list definition must be in the same order that the
@@ -122,7 +124,8 @@
             dchannel=dchannel, lastapp=lastapp, lastarg=lastarg, start=start,
             answer=answer, end=end, duration=duration, billsec=billsec,
             disposition=disposition, amaflags=amaflags, uniqueid=uniqueid,
-            userfield=userfield)
+            userfield=userfield, peeraccount=peeraccount, linkedid=linkedid,
+            sequence=sequence)
 
 
 class AsteriskCSVCDR(astcsv.AsteriskCSV):
diff --git a/tests/cdr/cdr_newcdrcolumns_yes/configs/ast1/extensions.conf b/tests/cdr/cdr_newcdrcolumns_yes/configs/ast1/extensions.conf
new file mode 100644
index 0000000..4fb76cb
--- /dev/null
+++ b/tests/cdr/cdr_newcdrcolumns_yes/configs/ast1/extensions.conf
@@ -0,0 +1,24 @@
+[general]
+writeprotect=no
+clearglobalvars=no
+
+[globals]
+
+[default]
+
+exten => alice,1,NoOp()
+ same => n,Set(CHANNEL(accountcode)=alice_acct)
+ same => n,Set(CHANNEL(peeraccount)=alice_peer)
+ same => n,Dial(Local/bob at default)
+ same => n,Hangup()
+
+; Note: The accountcodes must be set on Local/bob at default;2 before answering
+; the call because of a propagation race between the answer signal and setting
+; the account codes.  The Local/bob at default;1 accountcode may or may not get
+; across the bridge between Local/alice at default;2 and Local/bob at default;1.
+;
+exten => bob,1,NoOp()
+ same => n,Set(CHANNEL(accountcode)=bob_acct)
+ same => n,Set(CHANNEL(peeraccount)=bob_peer)
+ same => n,Answer()
+ same => n,Hangup()
diff --git a/tests/cdr/cdr_newcdrcolumns_yes/test-config.yaml b/tests/cdr/cdr_newcdrcolumns_yes/test-config.yaml
new file mode 100644
index 0000000..35e69e1
--- /dev/null
+++ b/tests/cdr/cdr_newcdrcolumns_yes/test-config.yaml
@@ -0,0 +1,56 @@
+testinfo:
+    summary: 'Test the newcdrcolumns=yes cdr.conf option'
+    description: |
+        'Do a simple call and check for a CDR record in csv file.
+         The call is dialed between two local channels.
+         Should be add the new fields into CDR record file for
+          - peeraccount
+          - sequence
+          - linkedid'
+
+    issues:
+        - jira: 'ASTERISK-24976'
+
+test-modules:
+    test-object:
+        config-section: test-object-config
+        typename: 'test_case.SimpleTestCase'
+    modules:
+        -
+            config-section: 'cdr-config-12'
+            typename: 'cdr.CDRModule'
+
+test-object-config:
+    config-path: 'tests/cdr/configs/newcdrcolumns'
+    spawn-after-hangup: True
+    ignore-originate-failures: True
+    end-test-delay: 2
+    test-iterations:
+        -
+            channel: 'Local/alice at default'
+            application: 'Echo'
+            async: True
+            account: 'True'
+
+cdr-config-12:
+    -
+        file: 'alice_acct'
+        lines:
+            -
+                sequence: '1'
+                peeraccount: 'bob_peer'
+                linkedid: '.{10}.0'
+
+
+properties:
+    dependencies:
+        - python : 'twisted'
+        - python : 'starpy'
+        - asterisk : 'cdr_csv'
+    tags:
+        - newcdrcolumns
+        - peeraccount
+        - sequence
+        - linkedid
+        - CDR
+        - chan_local
diff --git a/tests/cdr/configs/newcdrcolumns/ast1/cdr.conf b/tests/cdr/configs/newcdrcolumns/ast1/cdr.conf
new file mode 100644
index 0000000..9581d36
--- /dev/null
+++ b/tests/cdr/configs/newcdrcolumns/ast1/cdr.conf
@@ -0,0 +1,11 @@
+[general]
+enable=yes
+debug=yes
+unanswered=yes
+
+[csv]
+usegmtime=yes      ; log date/time in GMT.  Default is "no"
+loguniqueid=yes    ; log uniqueid.  Default is "no"
+loguserfield=yes   ; log user field.  Default is "no"
+newcdrcolumns=yes  ; Enable logging of post-1.8 CDR columns (peeraccount, linkedid, sequence).
+                   ; Default is "no".
diff --git a/tests/cdr/tests.yaml b/tests/cdr/tests.yaml
index 10ac044..17f6fca 100644
--- a/tests/cdr/tests.yaml
+++ b/tests/cdr/tests.yaml
@@ -7,6 +7,7 @@
     - test: 'cdr_bridge_multi'
     - test: 'console_dial_sip_transfer'
     - test: 'cdr_unanswered_yes'
+    - test: 'cdr_newcdrcolumns_yes'
     - test: 'app_queue'
     - test: 'originate-cdr-disposition'
     - test: 'app_dial_G_flag'

-- 
To view, visit https://gerrit.asterisk.org/c/testsuite/+/11359
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: testsuite
Gerrit-Branch: master
Gerrit-Change-Id: Iba0b7aff5be841eaf0f4665e5d7adc0a63540ce6
Gerrit-Change-Number: 11359
Gerrit-PatchSet: 1
Gerrit-Owner: Rodrigo Ramirez Norambuena <a at rodrigoramirez.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20190506/27aebf15/attachment-0001.html>


More information about the asterisk-code-review mailing list