Fix flaky cron trigger test

Checking for equality of times is flaky because if the
samplig happens around the boundady of a second, then
it can cause an off by 1 error. The test is modified
to tolerate these errors.

Change-Id: Ib341b0ae4bff6f74c412f62678a5a663a99b0b0b
This commit is contained in:
Andras Kovi 2018-07-30 14:03:09 +02:00
parent b01d6c6642
commit 66f6c90f66
1 changed files with 7 additions and 8 deletions

View File

@ -175,10 +175,9 @@ class ProcessCronTriggerTest(base.EngineTestCase):
None
)
self.assertEqual(
first_time,
cron_trigger.next_execution_time
)
interval = (cron_trigger.next_execution_time - first_time)
self.assertLessEqual(interval.total_seconds(), 3.0)
periodic.process_cron_triggers_v2(None, None)
@ -193,10 +192,10 @@ class ProcessCronTriggerTest(base.EngineTestCase):
cron_trigger_db = db_api.get_cron_trigger(trigger_name)
self.assertIsNotNone(cron_trigger_db)
self.assertEqual(
next_time,
cron_trigger_db.next_execution_time
)
interval = (cron_trigger_db.next_execution_time - next_time)
self.assertLessEqual(interval.total_seconds(), 3.0)
def test_validate_cron_trigger_input_first_time(self):
cfg.CONF.set_default('auth_enable', False, group='pecan')