Fix logic error in periodic task wait code.
I was calculating the time to wait for the next run of a periodic task incorrectly. Resolves bug 1098819. Change-Id: Ida60b69014aa06229111e58024e35268262f18fb
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
|
|
||||||
import fixtures
|
import fixtures
|
||||||
|
import time
|
||||||
|
|
||||||
from nova import manager
|
from nova import manager
|
||||||
from nova import test
|
from nova import test
|
||||||
@@ -76,6 +77,19 @@ class Manager(test.TestCase):
|
|||||||
idle = m.periodic_tasks(None)
|
idle = m.periodic_tasks(None)
|
||||||
self.assertAlmostEqual(60, idle, 1)
|
self.assertAlmostEqual(60, idle, 1)
|
||||||
|
|
||||||
|
def test_periodic_tasks_idle_calculation(self):
|
||||||
|
class Manager(manager.Manager):
|
||||||
|
@manager.periodic_task(spacing=10)
|
||||||
|
def bar(self):
|
||||||
|
return 'bar'
|
||||||
|
|
||||||
|
m = Manager()
|
||||||
|
m.periodic_tasks(None)
|
||||||
|
time.sleep(0.1)
|
||||||
|
idle = m.periodic_tasks(None)
|
||||||
|
self.assertTrue(idle > 9.7)
|
||||||
|
self.assertTrue(idle < 9.9)
|
||||||
|
|
||||||
def test_periodic_tasks_disabled(self):
|
def test_periodic_tasks_disabled(self):
|
||||||
class Manager(manager.Manager):
|
class Manager(manager.Manager):
|
||||||
@manager.periodic_task(spacing=-1)
|
@manager.periodic_task(spacing=-1)
|
||||||
|
|||||||
Reference in New Issue
Block a user