[Asterisk-code-review] test case: Add option to not end test when iterations are ex... (testsuite[master])
Joshua Colp
asteriskteam at digium.com
Wed Apr 27 13:28:02 CDT 2016
Joshua Colp has uploaded a new change for review.
https://gerrit.asterisk.org/2714
Change subject: test_case: Add option to not end test when iterations are exhausted.
......................................................................
test_case: Add option to not end test when iterations are exhausted.
The test case module can be ended through a few mechanisms. One of
these is when all iterations are exhausted. This is problematic for
the manager redirect tests as they perform actions after the
test would normally be ended.
This change adds an option which causes the test to not be
ended when all iterations have been exhausted. It is up to
alternative ways to trigger the termination of the test.
The manager redirect dual tests have been updated to use this
option and they are ended when all expected events occur instead.
ASTERISK-25967 #close
Change-Id: Ia0a73ae5868432b102cdcde5aa54364299415a14
---
M lib/python/asterisk/test_case.py
M sample-yaml/simpletestcase-config.yaml.sample
M tests/manager/redirect/dual/app/test-config.yaml
M tests/manager/redirect/dual/bridge/different/test-config.yaml
M tests/manager/redirect/dual/bridge/same/test-config.yaml
5 files changed, 15 insertions(+), 3 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/testsuite refs/changes/14/2714/1
diff --git a/lib/python/asterisk/test_case.py b/lib/python/asterisk/test_case.py
index ded6ab6..9fc07cc 100644
--- a/lib/python/asterisk/test_case.py
+++ b/lib/python/asterisk/test_case.py
@@ -737,6 +737,7 @@
self._ignore_originate_failures = False
self._spawn_after_hangup = False
self._end_test_delay = 0
+ self._stop_on_end = True
if test_config is None or 'test-iterations' not in test_config:
# No special test configuration defined, use defaults
@@ -759,6 +760,7 @@
if 'spawn-after-hangup' in test_config:
self._spawn_after_hangup = test_config['spawn-after-hangup']
self._end_test_delay = test_config.get('end-test-delay') or 0
+ self._stop_on_end = test_config.get('stop-on-end', True)
self.create_asterisk(count=1)
@@ -871,14 +873,16 @@
def __start_new_call(self, ami):
"""Kick off the next new call, or, if we've run out of calls to make,
- stop the test
+ stop the test if configured to do so
"""
if self._current_run < len(self._test_runs):
self.__originate_call(ami, self._test_runs[self._current_run])
else:
- LOGGER.info("All calls executed, stopping")
- reactor.callLater(self._end_test_delay, self.stop_reactor)
+ LOGGER.info("All calls executed")
+ if self._stop_on_end:
+ LOGGER.info("Stopping")
+ reactor.callLater(self._end_test_delay, self.stop_reactor)
def __event_cb(self, ami, event):
"""UserEvent callback handler.
diff --git a/sample-yaml/simpletestcase-config.yaml.sample b/sample-yaml/simpletestcase-config.yaml.sample
index dd74131..f3f1737 100644
--- a/sample-yaml/simpletestcase-config.yaml.sample
+++ b/sample-yaml/simpletestcase-config.yaml.sample
@@ -23,6 +23,11 @@
# the previous iteration's channel has hung up.
spawn-after-hangup: True
+ # Set this option to false if you don't want the test to be stopped when
+ # all iterations have completed. It will be up to alternative logic to
+ # stop the test.
+ stop-on-end: True
+
# The test iterations block define a sequence of sets of scenarios to run
# sequentially
test-iterations:
diff --git a/tests/manager/redirect/dual/app/test-config.yaml b/tests/manager/redirect/dual/app/test-config.yaml
index dec0933..0a72f59 100644
--- a/tests/manager/redirect/dual/app/test-config.yaml
+++ b/tests/manager/redirect/dual/app/test-config.yaml
@@ -28,6 +28,7 @@
# expect three user events - the first will kick off the second originate
# and the second/third one will be raised during redirect
expected_events: 4
+ stop-on-end: False
test-iterations:
-
channel: 'Local/real_one at default'
diff --git a/tests/manager/redirect/dual/bridge/different/test-config.yaml b/tests/manager/redirect/dual/bridge/different/test-config.yaml
index 7765fac..0adac2f 100644
--- a/tests/manager/redirect/dual/bridge/different/test-config.yaml
+++ b/tests/manager/redirect/dual/bridge/different/test-config.yaml
@@ -29,6 +29,7 @@
# expect four user events - the first initiates the second call, the second
# and third events are raised during redirect, and the fourth ends the test
expected_events: 4
+ stop-on-end: False
test-iterations:
-
channel: 'Local/alice0 at default'
diff --git a/tests/manager/redirect/dual/bridge/same/test-config.yaml b/tests/manager/redirect/dual/bridge/same/test-config.yaml
index 9d4a56e..5f4d246 100644
--- a/tests/manager/redirect/dual/bridge/same/test-config.yaml
+++ b/tests/manager/redirect/dual/bridge/same/test-config.yaml
@@ -29,6 +29,7 @@
# expect three user events - the first two are raised during redirect and
# the last event ends the test
expected_events: 3
+ stop-on-end: False
test-iterations:
-
channel: 'Local/alice at default'
--
To view, visit https://gerrit.asterisk.org/2714
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia0a73ae5868432b102cdcde5aa54364299415a14
Gerrit-PatchSet: 1
Gerrit-Project: testsuite
Gerrit-Branch: master
Gerrit-Owner: Joshua Colp <jcolp at digium.com>
More information about the asterisk-code-review
mailing list