[Asterisk-code-review] voicemail/polling: use TestCase object to stop reactor, and set passed (...testsuite[master])
Kevin Harwell
asteriskteam at digium.com
Wed Jun 12 16:06:08 CDT 2019
Kevin Harwell has uploaded this change for review. ( https://gerrit.asterisk.org/c/testsuite/+/11458
Change subject: voicemail/polling: use TestCase object to stop reactor, and set passed
......................................................................
voicemail/polling: use TestCase object to stop reactor, and set passed
The voicemail polling tests were calling reactor.stop directly. While this
stopped the test it did not clean up, and stop other processes like Asterisk.
Also some tests would still be marked as "passing" even when they failed.
This patch makes it so the offending tests now use the parent TestCase object's
stop_reactor call when ending the test. This ensures everything gets properly
cleaned up. TestCase itself has a passed flag that it tracks. This patch also
modifies the tests to use that flag instead of overriding it. This made it so
tests now fail appropriately.
Change-Id: Ide866b4ba75d2f99d7613e27dd94c65c767745d7
---
M tests/apps/voicemail/polling/poll_multiple_mailboxes/configs/ast1/pjsip.conf
M tests/apps/voicemail/polling/poll_multiple_mailboxes/run-test
M tests/apps/voicemail/polling/poll_no_subs/run-test
M tests/apps/voicemail/polling/poll_same_mailbox/configs/ast1/pjsip.conf
M tests/apps/voicemail/polling/poll_same_mailbox/run-test
M tests/apps/voicemail/polling/poll_single_mailbox/configs/ast1/pjsip.conf
M tests/apps/voicemail/polling/poll_single_mailbox/run-test
M tests/apps/voicemail/polling/poll_sub_unsub/configs/ast1/pjsip.conf
M tests/apps/voicemail/polling/poll_sub_unsub/run-test
M tests/channels/pjsip/subscriptions/mwi/missing_aor/configs/ast1/pjsip.conf
10 files changed, 30 insertions(+), 23 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/testsuite refs/changes/58/11458/1
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
index 3bffe84..36bba18 100644
--- a/tests/apps/voicemail/polling/poll_multiple_mailboxes/configs/ast1/pjsip.conf
+++ b/tests/apps/voicemail/polling/poll_multiple_mailboxes/configs/ast1/pjsip.conf
@@ -1,3 +1,7 @@
+[global]
+type=global
+debug=yes
+
[dummy-transport]
type=transport
bind=0.0.0.0
diff --git a/tests/apps/voicemail/polling/poll_multiple_mailboxes/run-test b/tests/apps/voicemail/polling/poll_multiple_mailboxes/run-test
index 7900d87..9ec8b86 100755
--- a/tests/apps/voicemail/polling/poll_multiple_mailboxes/run-test
+++ b/tests/apps/voicemail/polling/poll_multiple_mailboxes/run-test
@@ -20,13 +20,12 @@
class PollingTest(TestCase):
def __init__(self):
TestCase.__init__(self)
- self.passed = False
self.flags = 0
self.create_asterisk()
def stop_test(self, passed=False):
- self.passed = passed
- reactor.stop()
+ self.set_passed(passed)
+ self.stop_reactor()
def handle_message_waiting(self, ami, event):
diff --git a/tests/apps/voicemail/polling/poll_no_subs/run-test b/tests/apps/voicemail/polling/poll_no_subs/run-test
index 6aeb8ba..5bb9fe1 100755
--- a/tests/apps/voicemail/polling/poll_no_subs/run-test
+++ b/tests/apps/voicemail/polling/poll_no_subs/run-test
@@ -20,16 +20,11 @@
class PollingTest(TestCase):
def __init__(self):
TestCase.__init__(self)
- self.passed = False
self.create_asterisk()
def stop_test(self, passed=False):
- self.passed = passed
- # Sometimes the reactor has already stopped, we only care if the test passed
- try:
- reactor.stop()
- except Exception as e:
- LOGGER.info("Error while stopping reactor: '{0}'".format(e))
+ self.set_passed(passed)
+ self.stop_reactor()
def handle_message_waiting(self, ami, event):
LOGGER.error("Got a MessageWaiting event we weren't expecting!")
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
index 4c7b3e1..4f1b649 100644
--- a/tests/apps/voicemail/polling/poll_same_mailbox/configs/ast1/pjsip.conf
+++ b/tests/apps/voicemail/polling/poll_same_mailbox/configs/ast1/pjsip.conf
@@ -1,3 +1,7 @@
+[global]
+type=global
+debug=yes
+
[dummy-transport]
type=transport
bind=0.0.0.0
diff --git a/tests/apps/voicemail/polling/poll_same_mailbox/run-test b/tests/apps/voicemail/polling/poll_same_mailbox/run-test
index 9aff5ec..cabf515 100755
--- a/tests/apps/voicemail/polling/poll_same_mailbox/run-test
+++ b/tests/apps/voicemail/polling/poll_same_mailbox/run-test
@@ -20,13 +20,12 @@
class PollingTest(TestCase):
def __init__(self):
TestCase.__init__(self)
- self.passed = False
self.counter = 0
self.create_asterisk()
def stop_test(self, passed=False):
- self.passed = passed
- reactor.stop()
+ self.set_passed(passed)
+ self.stop_reactor()
def handle_message_waiting(self, ami, event):
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
index dce5f75..a3aa219 100644
--- a/tests/apps/voicemail/polling/poll_single_mailbox/configs/ast1/pjsip.conf
+++ b/tests/apps/voicemail/polling/poll_single_mailbox/configs/ast1/pjsip.conf
@@ -1,3 +1,7 @@
+[global]
+type=global
+debug=yes
+
[dummy-transport]
type=transport
bind=0.0.0.0
diff --git a/tests/apps/voicemail/polling/poll_single_mailbox/run-test b/tests/apps/voicemail/polling/poll_single_mailbox/run-test
index 649a7f1..7b3d62c 100755
--- a/tests/apps/voicemail/polling/poll_single_mailbox/run-test
+++ b/tests/apps/voicemail/polling/poll_single_mailbox/run-test
@@ -20,13 +20,12 @@
class PollingTest(TestCase):
def __init__(self):
TestCase.__init__(self)
- self.passed = False
self.test_phase = 1
self.create_asterisk()
def stop_test(self, passed=False):
- self.passed = passed
- reactor.stop()
+ self.set_passed(passed)
+ self.stop_reactor()
def handle_message_waiting(self, ami, event):
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
index 091bdab..f0edf1e 100644
--- a/tests/apps/voicemail/polling/poll_sub_unsub/configs/ast1/pjsip.conf
+++ b/tests/apps/voicemail/polling/poll_sub_unsub/configs/ast1/pjsip.conf
@@ -1,3 +1,7 @@
+[global]
+type=global
+debug=yes
+
[dummy-transport]
type=transport
bind=0.0.0.0
diff --git a/tests/apps/voicemail/polling/poll_sub_unsub/run-test b/tests/apps/voicemail/polling/poll_sub_unsub/run-test
index 56666b7..60345d4 100755
--- a/tests/apps/voicemail/polling/poll_sub_unsub/run-test
+++ b/tests/apps/voicemail/polling/poll_sub_unsub/run-test
@@ -21,7 +21,6 @@
class PollingTest(TestCase):
def __init__(self):
TestCase.__init__(self)
- self.passed = False
self.test_phase = 1
self._registered_done = False
self._unregistered_done = False
@@ -34,12 +33,8 @@
self.create_asterisk()
def stop_test(self, passed=False):
- self.passed = passed
- # Sometimes the reactor has already stopped, we only care if the test passed
- try:
- reactor.stop()
- except Exception as e:
- LOGGER.info("Error while stopping reactor: '{0}'".format(e))
+ self.set_passed(passed)
+ self.stop_reactor()
def handle_message_waiting(self, ami, event):
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
index 0afb5a4..6110741 100644
--- a/tests/channels/pjsip/subscriptions/mwi/missing_aor/configs/ast1/pjsip.conf
+++ b/tests/channels/pjsip/subscriptions/mwi/missing_aor/configs/ast1/pjsip.conf
@@ -1,3 +1,7 @@
+[global]
+type=global
+debug=yes
+
[local]
type=transport
protocol=udp
--
To view, visit https://gerrit.asterisk.org/c/testsuite/+/11458
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: testsuite
Gerrit-Branch: master
Gerrit-Change-Id: Ide866b4ba75d2f99d7613e27dd94c65c767745d7
Gerrit-Change-Number: 11458
Gerrit-PatchSet: 1
Gerrit-Owner: Kevin Harwell <kharwell at digium.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20190612/b2b4abc6/attachment-0001.html>
More information about the asterisk-code-review
mailing list