<html>
<body>
<div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
<table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 solid;">
<tr>
<td>
This is an automatically generated e-mail. To reply, visit:
<a href="https://reviewboard.asterisk.org/r/2799/">https://reviewboard.asterisk.org/r/2799/</a>
</td>
</tr>
</table>
<br />
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<p style="margin-top: 0;">On September 5th, 2013, 9:20 p.m. UTC, <b>jrose</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
<thead>
<tr>
<th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
<a href="https://reviewboard.asterisk.org/r/2799/diff/1/?file=45241#file45241line684" style="color: black; font-weight: bold; text-decoration: underline;">/asterisk/trunk/lib/python/asterisk/ami.py</a>
<span style="font-weight: normal;">
(Diff revision 1)
</span>
</th>
</tr>
</thead>
<tbody style="background-color: #e4d9cb; padding: 4px 8px; text-align: center;">
<tr>
<td colspan="4"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">def event_callback(self, ami, event):</pre></td>
</tr>
</tbody>
<tbody>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
<th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">389</font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "> <span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">cel_requirement</span><span class="p">),</span> <span class="n">named_event</span><span class="p">))</span></pre></td>
</tr>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
<th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">390</font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "> <span class="bp">self</span><span class="o">.</span><span class="n">test_object</span><span class="o">.</span><span class="n">set_passed</span><span class="p">(</span><span class="bp">False</span><span class="p">)</span></pre></td>
</tr>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
<th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">391</font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "> <span class="k">elif</span> <span class="n">order_type</span> <span class="o">==</span> <span class="s">'before'</span><span class="p">:</span></pre></td>
</tr>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
<th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">392</font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "> <span class="n">matches</span> <span class="o">=</span> <span class="p">[</span><span class="n">ev</span> <span class="k">for</span> <span class="n">ev</span> <span class="ow">in</span> <span class="n">AMICel</span><span class="o">.</span><span class="n">unmatched_cel_events</span> <span class="k">if</span></pre></td>
</tr>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
<th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">393</font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "> <span class="n">ev</span><span class="o">.</span><span class="n">named_id</span> <span class="o">==</span> <span class="n">named_event</span><span class="p">]</span></pre></td>
</tr>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
<th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">394</font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">matches</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span></pre></td>
</tr>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
<th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">395</font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "> <span class="n">logger</span><span class="o">.</span><span class="n">warning</span><span class="p">(</span><span class="s">'Event </span><span class="si">%s</span><span class="s"> did not occur before </span><span class="si">%s</span><span class="s">; failing'</span> <span class="o">%</span></pre></td>
</tr>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
<th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">396</font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "> <span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">cel_requirement</span><span class="p">),</span> <span class="n">named_event</span><span class="p">))</span></pre></td>
</tr>
</tbody>
</table>
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">More style complaints from flake8:
line continuation should indent up to the last parenthesis, so for example...
logger.warning("Some stuff %d %d %d" %
var1, var2, var3)
instead of
logger.warning(... %
var1, var2, var3
Also a handful of lines longer than 79 characters are present, but again... ehhhhh</pre>
</blockquote>
</blockquote>
<pre style="margin-left: 1em; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Only you know... with parenthesis around the vars because it's a tuple.</pre>
<br />
<p>- jrose</p>
<br />
<p>On August 28th, 2013, 3:34 p.m. UTC, Matt Jordan wrote:</p>
<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" style="background-image: url('https://reviewboard.asterisk.org/static/rb/images/review_request_box_top_bg.png'); background-position: left top; background-repeat: repeat-x; border: 1px black solid;">
<tr>
<td>
<div>Review request for Asterisk Developers.</div>
<div>By Matt Jordan.</div>
<p style="color: grey;"><i>Updated Aug. 28, 2013, 3:34 p.m.</i></p>
<div style="margin-top: 1.5em;">
<b style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Bugs: </b>
<a href="https://issues.asterisk.org/jira/browse/ASTERISK-22323">ASTERISK-22323</a>
</div>
<div style="margin-top: 1.5em;">
<b style="color: #575012; font-size: 10pt;">Repository: </b>
testsuite
</div>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
<tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">This patch does a few things.
1) It updates the simple_bridge test for Asterisk 12, such that it handles the correct AMI events, CDR entries, and CEL events.
2) It adds a tool (and I emphasize it as a tool to aid in development) that will snoop CEL AMI events and dump them out in YAML. I found this to be helpful when producing the expected CEL events for this test; it may help others as well.
3) It updates and simplifies the CEL parsing. More on that below.
-- CEL PARSING --
For a single channel, the CEL events related to that channel should always have a well-defined ordering. That is, for a given test, a channel should always transition through the same states in the same order, e.g.,
CHAN_START
APP_START
BRIDGE_ENTER
BRIDGE_EXIT
APP_END
HANGUP
CHAN_END
CEL gets tricky, however, because in addition to verifying that the events for a single channel occurred in the correct order, we also care whether or not events across channels occurred in the correct order.
For example, take this test, where Alice calls Bob. The events for each channel may look something like this (simplified greatly):
Alice Bob
------- ---------
CHAN_START CHAN_START
APP_START ANSWER
ANSWER BRIDGE_ENTER
BRIDGE_ENTER BRIDGE_EXIT
BRIDGE_EXIT HANGUP
APP_END CHAN_END
HANGUP
CHAN_END
Because Alice and Bob will be executing on separate threads, a total ordering of all events is impossible to verify. The notion that such an ordering was ever possible led to the downfall of the original CEL checking. The existing CEL checking handles this, but requires identifying all events and establishing more relationships than is strictly necessary. In reality, what we want to verify between Alice and Bob is closer to the following:
Alice Bob
------- ---------
CHAN_START
APP_START
CHAN_START (verify that Bob starts after Alice's application start)
ANSWER
ANSWER (verify that Alice answers after Bob answers)
BRIDGE_ENTER BRIDGE_ENTER (verify that Bob enters the bridge after Alice answers)
BRIDGE_EXIT BRIDGE_EXIT
APP_END
CHAN_END CHAN_END
So what we need are just three orderings between the channels:
* Bob's CHAN_START must happen after Alice's APP_START
* Alice's ANSWER must happen after Bob's ANSWER
* Bob's BRIDGE_ENTER must happen after Alice's ANSWER
The CEL event checking now allows for this by letting an event be tagged with an identifier. Any other event can declare that they have a partial ordering with that event, and state that they must happen before or after that event. If they do not happen before or after that event, the test fails. However, unlike the previous implementation, we don't have to declare identifiers for all events, nor define an ordering for all events.</pre>
</td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">
<li>/asterisk/trunk/tests/bridge/simple_bridge/test-config.yaml <span style="color: grey">(4090)</span></li>
<li>/asterisk/trunk/lib/python/asterisk/cel.py <span style="color: grey">(4090)</span></li>
<li>/asterisk/trunk/lib/python/asterisk/ami.py <span style="color: grey">(4090)</span></li>
</ul>
<p><a href="https://reviewboard.asterisk.org/r/2799/diff/" style="margin-left: 3em;">View Diff</a></p>
</td>
</tr>
</table>
</div>
</body>
</html>