<p>Rodrigo Ramirez Norambuena has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/testsuite/+/11359">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">testsuite: Add test for cdr cvs file<br><br>From Asterisk 1.8 are include three new fields for CDR:<br> - peeraccount<br> - userfield<br> - sequence<br><br>This patch include a test to check the correct behaviour of logs these<br>files when is set newcdrcolumn into cdr.conf file.<br><br>ASTERISK-24976<br><br>Change-Id: Iba0b7aff5be841eaf0f4665e5d7adc0a63540ce6<br>---<br>M lib/python/asterisk/cdr.py<br>A tests/cdr/cdr_newcdrcolumns_yes/configs/ast1/extensions.conf<br>A tests/cdr/cdr_newcdrcolumns_yes/test-config.yaml<br>A tests/cdr/configs/newcdrcolumns/ast1/cdr.conf<br>M tests/cdr/tests.yaml<br>5 files changed, 98 insertions(+), 3 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/testsuite refs/changes/59/11359/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/lib/python/asterisk/cdr.py b/lib/python/asterisk/cdr.py</span><br><span>index c5d62db..bf584ca 100644</span><br><span>--- a/lib/python/asterisk/cdr.py</span><br><span>+++ b/lib/python/asterisk/cdr.py</span><br><span>@@ -99,14 +99,16 @@</span><br><span> fields = [</span><br><span> 'accountcode', 'source', 'destination', 'dcontext', 'callerid',</span><br><span> 'channel', 'dchannel', 'lastapp', 'lastarg', 'start', 'answer', 'end',</span><br><span style="color: hsl(0, 100%, 40%);">- 'duration', 'billsec', 'disposition', 'amaflags', 'uniqueid', 'userfield']</span><br><span style="color: hsl(120, 100%, 40%);">+ 'duration', 'billsec', 'disposition', 'amaflags', 'uniqueid',</span><br><span style="color: hsl(120, 100%, 40%);">+ 'userfield', 'peeraccount', 'linkedid', 'sequence']</span><br><span> </span><br><span> def __init__(</span><br><span> self, accountcode=None, source=None, destination=None,</span><br><span> dcontext=None, callerid=None, channel=None, dchannel=None,</span><br><span> lastapp=None, lastarg=None, start=None, answer=None, end=None,</span><br><span> duration=None, billsec=None, disposition=None, amaflags=None,</span><br><span style="color: hsl(0, 100%, 40%);">- uniqueid=None, userfield=None):</span><br><span style="color: hsl(120, 100%, 40%);">+ uniqueid=None, userfield=None, peeraccount=None, linkedid=None,</span><br><span style="color: hsl(120, 100%, 40%);">+ sequence=None):</span><br><span> """Construct an Asterisk CSV CDR.</span><br><span> </span><br><span> The arguments list definition must be in the same order that the</span><br><span>@@ -122,7 +124,8 @@</span><br><span> dchannel=dchannel, lastapp=lastapp, lastarg=lastarg, start=start,</span><br><span> answer=answer, end=end, duration=duration, billsec=billsec,</span><br><span> disposition=disposition, amaflags=amaflags, uniqueid=uniqueid,</span><br><span style="color: hsl(0, 100%, 40%);">- userfield=userfield)</span><br><span style="color: hsl(120, 100%, 40%);">+ userfield=userfield, peeraccount=peeraccount, linkedid=linkedid,</span><br><span style="color: hsl(120, 100%, 40%);">+ sequence=sequence)</span><br><span> </span><br><span> </span><br><span> class AsteriskCSVCDR(astcsv.AsteriskCSV):</span><br><span>diff --git a/tests/cdr/cdr_newcdrcolumns_yes/configs/ast1/extensions.conf b/tests/cdr/cdr_newcdrcolumns_yes/configs/ast1/extensions.conf</span><br><span>new file mode 100644</span><br><span>index 0000000..4fb76cb</span><br><span>--- /dev/null</span><br><span>+++ b/tests/cdr/cdr_newcdrcolumns_yes/configs/ast1/extensions.conf</span><br><span>@@ -0,0 +1,24 @@</span><br><span style="color: hsl(120, 100%, 40%);">+[general]</span><br><span style="color: hsl(120, 100%, 40%);">+writeprotect=no</span><br><span style="color: hsl(120, 100%, 40%);">+clearglobalvars=no</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+[globals]</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+[default]</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+exten => alice,1,NoOp()</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,Set(CHANNEL(accountcode)=alice_acct)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,Set(CHANNEL(peeraccount)=alice_peer)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,Dial(Local/bob@default)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,Hangup()</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+; Note: The accountcodes must be set on Local/bob@default;2 before answering</span><br><span style="color: hsl(120, 100%, 40%);">+; the call because of a propagation race between the answer signal and setting</span><br><span style="color: hsl(120, 100%, 40%);">+; the account codes. The Local/bob@default;1 accountcode may or may not get</span><br><span style="color: hsl(120, 100%, 40%);">+; across the bridge between Local/alice@default;2 and Local/bob@default;1.</span><br><span style="color: hsl(120, 100%, 40%);">+;</span><br><span style="color: hsl(120, 100%, 40%);">+exten => bob,1,NoOp()</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,Set(CHANNEL(accountcode)=bob_acct)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,Set(CHANNEL(peeraccount)=bob_peer)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,Answer()</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,Hangup()</span><br><span>diff --git a/tests/cdr/cdr_newcdrcolumns_yes/test-config.yaml b/tests/cdr/cdr_newcdrcolumns_yes/test-config.yaml</span><br><span>new file mode 100644</span><br><span>index 0000000..35e69e1</span><br><span>--- /dev/null</span><br><span>+++ b/tests/cdr/cdr_newcdrcolumns_yes/test-config.yaml</span><br><span>@@ -0,0 +1,56 @@</span><br><span style="color: hsl(120, 100%, 40%);">+testinfo:</span><br><span style="color: hsl(120, 100%, 40%);">+ summary: 'Test the newcdrcolumns=yes cdr.conf option'</span><br><span style="color: hsl(120, 100%, 40%);">+ description: |</span><br><span style="color: hsl(120, 100%, 40%);">+ 'Do a simple call and check for a CDR record in csv file.</span><br><span style="color: hsl(120, 100%, 40%);">+ The call is dialed between two local channels.</span><br><span style="color: hsl(120, 100%, 40%);">+ Should be add the new fields into CDR record file for</span><br><span style="color: hsl(120, 100%, 40%);">+ - peeraccount</span><br><span style="color: hsl(120, 100%, 40%);">+ - sequence</span><br><span style="color: hsl(120, 100%, 40%);">+ - linkedid'</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ issues:</span><br><span style="color: hsl(120, 100%, 40%);">+ - jira: 'ASTERISK-24976'</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+test-modules:</span><br><span style="color: hsl(120, 100%, 40%);">+ test-object:</span><br><span style="color: hsl(120, 100%, 40%);">+ config-section: test-object-config</span><br><span style="color: hsl(120, 100%, 40%);">+ typename: 'test_case.SimpleTestCase'</span><br><span style="color: hsl(120, 100%, 40%);">+ modules:</span><br><span style="color: hsl(120, 100%, 40%);">+ -</span><br><span style="color: hsl(120, 100%, 40%);">+ config-section: 'cdr-config-12'</span><br><span style="color: hsl(120, 100%, 40%);">+ typename: 'cdr.CDRModule'</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+test-object-config:</span><br><span style="color: hsl(120, 100%, 40%);">+ config-path: 'tests/cdr/configs/newcdrcolumns'</span><br><span style="color: hsl(120, 100%, 40%);">+ spawn-after-hangup: True</span><br><span style="color: hsl(120, 100%, 40%);">+ ignore-originate-failures: True</span><br><span style="color: hsl(120, 100%, 40%);">+ end-test-delay: 2</span><br><span style="color: hsl(120, 100%, 40%);">+ test-iterations:</span><br><span style="color: hsl(120, 100%, 40%);">+ -</span><br><span style="color: hsl(120, 100%, 40%);">+ channel: 'Local/alice@default'</span><br><span style="color: hsl(120, 100%, 40%);">+ application: 'Echo'</span><br><span style="color: hsl(120, 100%, 40%);">+ async: True</span><br><span style="color: hsl(120, 100%, 40%);">+ account: 'True'</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+cdr-config-12:</span><br><span style="color: hsl(120, 100%, 40%);">+ -</span><br><span style="color: hsl(120, 100%, 40%);">+ file: 'alice_acct'</span><br><span style="color: hsl(120, 100%, 40%);">+ lines:</span><br><span style="color: hsl(120, 100%, 40%);">+ -</span><br><span style="color: hsl(120, 100%, 40%);">+ sequence: '1'</span><br><span style="color: hsl(120, 100%, 40%);">+ peeraccount: 'bob_peer'</span><br><span style="color: hsl(120, 100%, 40%);">+ linkedid: '.{10}.0'</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+properties:</span><br><span style="color: hsl(120, 100%, 40%);">+ dependencies:</span><br><span style="color: hsl(120, 100%, 40%);">+ - python : 'twisted'</span><br><span style="color: hsl(120, 100%, 40%);">+ - python : 'starpy'</span><br><span style="color: hsl(120, 100%, 40%);">+ - asterisk : 'cdr_csv'</span><br><span style="color: hsl(120, 100%, 40%);">+ tags:</span><br><span style="color: hsl(120, 100%, 40%);">+ - newcdrcolumns</span><br><span style="color: hsl(120, 100%, 40%);">+ - peeraccount</span><br><span style="color: hsl(120, 100%, 40%);">+ - sequence</span><br><span style="color: hsl(120, 100%, 40%);">+ - linkedid</span><br><span style="color: hsl(120, 100%, 40%);">+ - CDR</span><br><span style="color: hsl(120, 100%, 40%);">+ - chan_local</span><br><span>diff --git a/tests/cdr/configs/newcdrcolumns/ast1/cdr.conf b/tests/cdr/configs/newcdrcolumns/ast1/cdr.conf</span><br><span>new file mode 100644</span><br><span>index 0000000..9581d36</span><br><span>--- /dev/null</span><br><span>+++ b/tests/cdr/configs/newcdrcolumns/ast1/cdr.conf</span><br><span>@@ -0,0 +1,11 @@</span><br><span style="color: hsl(120, 100%, 40%);">+[general]</span><br><span style="color: hsl(120, 100%, 40%);">+enable=yes</span><br><span style="color: hsl(120, 100%, 40%);">+debug=yes</span><br><span style="color: hsl(120, 100%, 40%);">+unanswered=yes</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+[csv]</span><br><span style="color: hsl(120, 100%, 40%);">+usegmtime=yes ; log date/time in GMT. Default is "no"</span><br><span style="color: hsl(120, 100%, 40%);">+loguniqueid=yes ; log uniqueid. Default is "no"</span><br><span style="color: hsl(120, 100%, 40%);">+loguserfield=yes ; log user field. Default is "no"</span><br><span style="color: hsl(120, 100%, 40%);">+newcdrcolumns=yes ; Enable logging of post-1.8 CDR columns (peeraccount, linkedid, sequence).</span><br><span style="color: hsl(120, 100%, 40%);">+ ; Default is "no".</span><br><span>diff --git a/tests/cdr/tests.yaml b/tests/cdr/tests.yaml</span><br><span>index 10ac044..17f6fca 100644</span><br><span>--- a/tests/cdr/tests.yaml</span><br><span>+++ b/tests/cdr/tests.yaml</span><br><span>@@ -7,6 +7,7 @@</span><br><span> - test: 'cdr_bridge_multi'</span><br><span> - test: 'console_dial_sip_transfer'</span><br><span> - test: 'cdr_unanswered_yes'</span><br><span style="color: hsl(120, 100%, 40%);">+ - test: 'cdr_newcdrcolumns_yes'</span><br><span> - test: 'app_queue'</span><br><span> - test: 'originate-cdr-disposition'</span><br><span> - test: 'app_dial_G_flag'</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/testsuite/+/11359">change 11359</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/testsuite/+/11359"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: testsuite </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Iba0b7aff5be841eaf0f4665e5d7adc0a63540ce6 </div>
<div style="display:none"> Gerrit-Change-Number: 11359 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Rodrigo Ramirez Norambuena <a@rodrigoramirez.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>