summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAngus Salkeld <asalkeld@redhat.com>2012-08-15 17:29:00 +1000
committerAngus Salkeld <asalkeld@redhat.com>2012-08-20 20:32:23 +1000
commit31495c3a9d31920cea8f98fef23b10958d38e6a5 (patch)
tree021b02e4f66549c63bf6a76377ee8d9b0de11150 /tests
parenta6c4b02c206120a5815f08ad7112cb68c3e9c3e5 (diff)
downloadoslo-31495c3a9d31920cea8f98fef23b10958d38e6a5.tar.gz
oslo-31495c3a9d31920cea8f98fef23b10958d38e6a5.tar.xz
oslo-31495c3a9d31920cea8f98fef23b10958d38e6a5.zip
Add threadgroup to manage timers and greenthreads.
Part of blueprint service-infrastructure Change-Id: I40593b6ad13d99d9e63c8c04154a0dac5aced02e Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/test_service.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/tests/unit/test_service.py b/tests/unit/test_service.py
index 7e2aa3c..91e9155 100644
--- a/tests/unit/test_service.py
+++ b/tests/unit/test_service.py
@@ -50,6 +50,16 @@ class ServiceManagerTestCase(utils.BaseTestCase):
self.assertEqual(serv.test_method(), 'service')
+class ServiceWithTimer(service.Service):
+ def start(self):
+ super(ServiceWithTimer, self).start()
+ self.timer_fired = 0
+ self.tg.add_timer(1, self.timer_expired)
+
+ def timer_expired(self):
+ self.timer_fired = self.timer_fired + 1
+
+
class ServiceLauncherTest(utils.BaseTestCase):
"""
Originally from nova/tests/integrated/test_multiprocess_api.py
@@ -69,7 +79,7 @@ class ServiceLauncherTest(utils.BaseTestCase):
status = 0
try:
launcher = service.ProcessLauncher()
- serv = ExtendedService('test', None)
+ serv = ServiceWithTimer('test', None)
launcher.launch_service(serv, workers=self.workers)
launcher.wait()
except SystemExit as exc: