<p>Friendly Automation <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/testsuite/+/11460">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Benjamin Keith Ford: Looks good to me, but someone else must approve
Joshua Colp: Looks good to me, approved
Friendly Automation: Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">voicemail/polling: use TestCase object to stop reactor, and set passed<br><br>The voicemail polling tests were calling reactor.stop directly. While this<br>stopped the test it did not clean up, and stop other processes like Asterisk.<br>Also some tests would still be marked as "passing" even when they failed.<br><br>This patch makes it so the offending tests now use the parent TestCase object's<br>stop_reactor call when ending the test. This ensures everything gets properly<br>cleaned up. TestCase itself has a passed flag that it tracks. This patch also<br>modifies the tests to use that flag instead of overriding it. This made it so<br>tests now fail appropriately.<br><br>Change-Id: Ide866b4ba75d2f99d7613e27dd94c65c767745d7<br>---<br>M tests/apps/voicemail/polling/poll_multiple_mailboxes/configs/ast1/pjsip.conf<br>M tests/apps/voicemail/polling/poll_multiple_mailboxes/run-test<br>M tests/apps/voicemail/polling/poll_no_subs/run-test<br>M tests/apps/voicemail/polling/poll_same_mailbox/configs/ast1/pjsip.conf<br>M tests/apps/voicemail/polling/poll_same_mailbox/run-test<br>M tests/apps/voicemail/polling/poll_single_mailbox/configs/ast1/pjsip.conf<br>M tests/apps/voicemail/polling/poll_single_mailbox/run-test<br>M tests/apps/voicemail/polling/poll_sub_unsub/configs/ast1/pjsip.conf<br>M tests/apps/voicemail/polling/poll_sub_unsub/run-test<br>M tests/channels/pjsip/subscriptions/mwi/missing_aor/configs/ast1/pjsip.conf<br>10 files changed, 30 insertions(+), 23 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/tests/apps/voicemail/polling/poll_multiple_mailboxes/configs/ast1/pjsip.conf b/tests/apps/voicemail/polling/poll_multiple_mailboxes/configs/ast1/pjsip.conf</span><br><span>index 3bffe84..36bba18 100644</span><br><span>--- a/tests/apps/voicemail/polling/poll_multiple_mailboxes/configs/ast1/pjsip.conf</span><br><span>+++ b/tests/apps/voicemail/polling/poll_multiple_mailboxes/configs/ast1/pjsip.conf</span><br><span>@@ -1,3 +1,7 @@</span><br><span style="color: hsl(120, 100%, 40%);">+[global]</span><br><span style="color: hsl(120, 100%, 40%);">+type=global</span><br><span style="color: hsl(120, 100%, 40%);">+debug=yes</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> [dummy-transport]</span><br><span> type=transport</span><br><span> bind=0.0.0.0</span><br><span>diff --git a/tests/apps/voicemail/polling/poll_multiple_mailboxes/run-test b/tests/apps/voicemail/polling/poll_multiple_mailboxes/run-test</span><br><span>index 7900d87..9ec8b86 100755</span><br><span>--- a/tests/apps/voicemail/polling/poll_multiple_mailboxes/run-test</span><br><span>+++ b/tests/apps/voicemail/polling/poll_multiple_mailboxes/run-test</span><br><span>@@ -20,13 +20,12 @@</span><br><span> class PollingTest(TestCase):</span><br><span> def __init__(self):</span><br><span> TestCase.__init__(self)</span><br><span style="color: hsl(0, 100%, 40%);">- self.passed = False</span><br><span> self.flags = 0</span><br><span> self.create_asterisk()</span><br><span> </span><br><span> def stop_test(self, passed=False):</span><br><span style="color: hsl(0, 100%, 40%);">- self.passed = passed</span><br><span style="color: hsl(0, 100%, 40%);">- reactor.stop()</span><br><span style="color: hsl(120, 100%, 40%);">+ self.set_passed(passed)</span><br><span style="color: hsl(120, 100%, 40%);">+ self.stop_reactor()</span><br><span> </span><br><span> def handle_message_waiting(self, ami, event):</span><br><span> </span><br><span>diff --git a/tests/apps/voicemail/polling/poll_no_subs/run-test b/tests/apps/voicemail/polling/poll_no_subs/run-test</span><br><span>index 6aeb8ba..5bb9fe1 100755</span><br><span>--- a/tests/apps/voicemail/polling/poll_no_subs/run-test</span><br><span>+++ b/tests/apps/voicemail/polling/poll_no_subs/run-test</span><br><span>@@ -20,16 +20,11 @@</span><br><span> class PollingTest(TestCase):</span><br><span> def __init__(self):</span><br><span> TestCase.__init__(self)</span><br><span style="color: hsl(0, 100%, 40%);">- self.passed = False</span><br><span> self.create_asterisk()</span><br><span> </span><br><span> def stop_test(self, passed=False):</span><br><span style="color: hsl(0, 100%, 40%);">- self.passed = passed</span><br><span style="color: hsl(0, 100%, 40%);">- # Sometimes the reactor has already stopped, we only care if the test passed</span><br><span style="color: hsl(0, 100%, 40%);">- try:</span><br><span style="color: hsl(0, 100%, 40%);">- reactor.stop()</span><br><span style="color: hsl(0, 100%, 40%);">- except Exception as e:</span><br><span style="color: hsl(0, 100%, 40%);">- LOGGER.info("Error while stopping reactor: '{0}'".format(e))</span><br><span style="color: hsl(120, 100%, 40%);">+ self.set_passed(passed)</span><br><span style="color: hsl(120, 100%, 40%);">+ self.stop_reactor()</span><br><span> </span><br><span> def handle_message_waiting(self, ami, event):</span><br><span> LOGGER.error("Got a MessageWaiting event we weren't expecting!")</span><br><span>diff --git a/tests/apps/voicemail/polling/poll_same_mailbox/configs/ast1/pjsip.conf b/tests/apps/voicemail/polling/poll_same_mailbox/configs/ast1/pjsip.conf</span><br><span>index 4c7b3e1..4f1b649 100644</span><br><span>--- a/tests/apps/voicemail/polling/poll_same_mailbox/configs/ast1/pjsip.conf</span><br><span>+++ b/tests/apps/voicemail/polling/poll_same_mailbox/configs/ast1/pjsip.conf</span><br><span>@@ -1,3 +1,7 @@</span><br><span style="color: hsl(120, 100%, 40%);">+[global]</span><br><span style="color: hsl(120, 100%, 40%);">+type=global</span><br><span style="color: hsl(120, 100%, 40%);">+debug=yes</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> [dummy-transport]</span><br><span> type=transport</span><br><span> bind=0.0.0.0</span><br><span>diff --git a/tests/apps/voicemail/polling/poll_same_mailbox/run-test b/tests/apps/voicemail/polling/poll_same_mailbox/run-test</span><br><span>index 9aff5ec..cabf515 100755</span><br><span>--- a/tests/apps/voicemail/polling/poll_same_mailbox/run-test</span><br><span>+++ b/tests/apps/voicemail/polling/poll_same_mailbox/run-test</span><br><span>@@ -20,13 +20,12 @@</span><br><span> class PollingTest(TestCase):</span><br><span> def __init__(self):</span><br><span> TestCase.__init__(self)</span><br><span style="color: hsl(0, 100%, 40%);">- self.passed = False</span><br><span> self.counter = 0</span><br><span> self.create_asterisk()</span><br><span> </span><br><span> def stop_test(self, passed=False):</span><br><span style="color: hsl(0, 100%, 40%);">- self.passed = passed</span><br><span style="color: hsl(0, 100%, 40%);">- reactor.stop()</span><br><span style="color: hsl(120, 100%, 40%);">+ self.set_passed(passed)</span><br><span style="color: hsl(120, 100%, 40%);">+ self.stop_reactor()</span><br><span> </span><br><span> def handle_message_waiting(self, ami, event):</span><br><span> </span><br><span>diff --git a/tests/apps/voicemail/polling/poll_single_mailbox/configs/ast1/pjsip.conf b/tests/apps/voicemail/polling/poll_single_mailbox/configs/ast1/pjsip.conf</span><br><span>index dce5f75..a3aa219 100644</span><br><span>--- a/tests/apps/voicemail/polling/poll_single_mailbox/configs/ast1/pjsip.conf</span><br><span>+++ b/tests/apps/voicemail/polling/poll_single_mailbox/configs/ast1/pjsip.conf</span><br><span>@@ -1,3 +1,7 @@</span><br><span style="color: hsl(120, 100%, 40%);">+[global]</span><br><span style="color: hsl(120, 100%, 40%);">+type=global</span><br><span style="color: hsl(120, 100%, 40%);">+debug=yes</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> [dummy-transport]</span><br><span> type=transport</span><br><span> bind=0.0.0.0</span><br><span>diff --git a/tests/apps/voicemail/polling/poll_single_mailbox/run-test b/tests/apps/voicemail/polling/poll_single_mailbox/run-test</span><br><span>index 649a7f1..7b3d62c 100755</span><br><span>--- a/tests/apps/voicemail/polling/poll_single_mailbox/run-test</span><br><span>+++ b/tests/apps/voicemail/polling/poll_single_mailbox/run-test</span><br><span>@@ -20,13 +20,12 @@</span><br><span> class PollingTest(TestCase):</span><br><span> def __init__(self):</span><br><span> TestCase.__init__(self)</span><br><span style="color: hsl(0, 100%, 40%);">- self.passed = False</span><br><span> self.test_phase = 1</span><br><span> self.create_asterisk()</span><br><span> </span><br><span> def stop_test(self, passed=False):</span><br><span style="color: hsl(0, 100%, 40%);">- self.passed = passed</span><br><span style="color: hsl(0, 100%, 40%);">- reactor.stop()</span><br><span style="color: hsl(120, 100%, 40%);">+ self.set_passed(passed)</span><br><span style="color: hsl(120, 100%, 40%);">+ self.stop_reactor()</span><br><span> </span><br><span> def handle_message_waiting(self, ami, event):</span><br><span> </span><br><span>diff --git a/tests/apps/voicemail/polling/poll_sub_unsub/configs/ast1/pjsip.conf b/tests/apps/voicemail/polling/poll_sub_unsub/configs/ast1/pjsip.conf</span><br><span>index 091bdab..f0edf1e 100644</span><br><span>--- a/tests/apps/voicemail/polling/poll_sub_unsub/configs/ast1/pjsip.conf</span><br><span>+++ b/tests/apps/voicemail/polling/poll_sub_unsub/configs/ast1/pjsip.conf</span><br><span>@@ -1,3 +1,7 @@</span><br><span style="color: hsl(120, 100%, 40%);">+[global]</span><br><span style="color: hsl(120, 100%, 40%);">+type=global</span><br><span style="color: hsl(120, 100%, 40%);">+debug=yes</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> [dummy-transport]</span><br><span> type=transport</span><br><span> bind=0.0.0.0</span><br><span>diff --git a/tests/apps/voicemail/polling/poll_sub_unsub/run-test b/tests/apps/voicemail/polling/poll_sub_unsub/run-test</span><br><span>index 56666b7..60345d4 100755</span><br><span>--- a/tests/apps/voicemail/polling/poll_sub_unsub/run-test</span><br><span>+++ b/tests/apps/voicemail/polling/poll_sub_unsub/run-test</span><br><span>@@ -21,7 +21,6 @@</span><br><span> class PollingTest(TestCase):</span><br><span> def __init__(self):</span><br><span> TestCase.__init__(self)</span><br><span style="color: hsl(0, 100%, 40%);">- self.passed = False</span><br><span> self.test_phase = 1</span><br><span> self._registered_done = False</span><br><span> self._unregistered_done = False</span><br><span>@@ -34,12 +33,8 @@</span><br><span> self.create_asterisk()</span><br><span> </span><br><span> def stop_test(self, passed=False):</span><br><span style="color: hsl(0, 100%, 40%);">- self.passed = passed</span><br><span style="color: hsl(0, 100%, 40%);">- # Sometimes the reactor has already stopped, we only care if the test passed</span><br><span style="color: hsl(0, 100%, 40%);">- try:</span><br><span style="color: hsl(0, 100%, 40%);">- reactor.stop()</span><br><span style="color: hsl(0, 100%, 40%);">- except Exception as e:</span><br><span style="color: hsl(0, 100%, 40%);">- LOGGER.info("Error while stopping reactor: '{0}'".format(e))</span><br><span style="color: hsl(120, 100%, 40%);">+ self.set_passed(passed)</span><br><span style="color: hsl(120, 100%, 40%);">+ self.stop_reactor()</span><br><span> </span><br><span> def handle_message_waiting(self, ami, event):</span><br><span> </span><br><span>diff --git a/tests/channels/pjsip/subscriptions/mwi/missing_aor/configs/ast1/pjsip.conf b/tests/channels/pjsip/subscriptions/mwi/missing_aor/configs/ast1/pjsip.conf</span><br><span>index 0afb5a4..6110741 100644</span><br><span>--- a/tests/channels/pjsip/subscriptions/mwi/missing_aor/configs/ast1/pjsip.conf</span><br><span>+++ b/tests/channels/pjsip/subscriptions/mwi/missing_aor/configs/ast1/pjsip.conf</span><br><span>@@ -1,3 +1,7 @@</span><br><span style="color: hsl(120, 100%, 40%);">+[global]</span><br><span style="color: hsl(120, 100%, 40%);">+type=global</span><br><span style="color: hsl(120, 100%, 40%);">+debug=yes</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> [local]</span><br><span> type=transport</span><br><span> protocol=udp</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/testsuite/+/11460">change 11460</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/+/11460"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: testsuite </div>
<div style="display:none"> Gerrit-Branch: 13 </div>
<div style="display:none"> Gerrit-Change-Id: Ide866b4ba75d2f99d7613e27dd94c65c767745d7 </div>
<div style="display:none"> Gerrit-Change-Number: 11460 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Benjamin Keith Ford <bford@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>