Decrease test failure if second changes during run

test_create_with_live_time fails gating constantly. This is due to
the logic in the test which breaks if the second changes between the
two timestamps expires_at and updated_at are created. This change
drops the failure rate to those occasions where we hit that second
change also to minute change.

Closes-Bug: #1505675

Change-Id: I234d80388edd2a659a2374a29179ce23b23bb99a
(cherry picked from commit b413db7652)
This commit is contained in:
Erno Kuvaja 2015-10-13 12:40:06 +00:00
parent 7158d7886c
commit 8902d12659

View File

@ -357,9 +357,11 @@ class TestTasksController(test_utils.BaseTestCase):
task_executor.begin_processing(new_task.task_id)
success_task = self.controller.get(request, new_task.task_id)
# ignore microsecond
task_live_time = (success_task.expires_at.replace(microsecond=0) -
success_task.updated_at.replace(microsecond=0))
# ignore second and microsecond to avoid flaky runs
task_live_time = (success_task.expires_at.replace(second=0,
microsecond=0) -
success_task.updated_at.replace(second=0,
microsecond=0))
task_live_time_hour = (task_live_time.days * 24 +
task_live_time.seconds / 3600)
self.assertEqual(CONF.task.task_time_to_live, task_live_time_hour)