From b5c0a975825fd6babb81ff26987f5db1ffb1f51a Mon Sep 17 00:00:00 2001 From: Ghanshyam Maan Date: Thu, 19 Feb 2026 19:06:07 +0000 Subject: [PATCH] Fix the flasky test test_submit_second_while_delaying_first This test failied a few times and most recent faaailure is - https://review.opendev.org/c/openstack/nova/+/975586 (PS8 run) Traceback (most recent call last): File "/home/zuul/src/opendev.org/openstack/nova/nova/tests/unit/test_utils.py", line 2185, in test_submit_second_while_delaying_first self.assertGreater(task2_runtime, 2.0) File "/usr/lib/python3.12/unittest/case.py", line 1269, in assertGreater self.fail(self._formatMessage(msg, standardMsg)) File "/usr/lib/python3.12/unittest/case.py", line 715, in fail raise self.failureException(msg) AssertionError: 1.997275639999998 not greater than 2.0 From error, it seems we are capturing the start time after we submit the task to executor who will count the task submit time little ahead of test captured the task start time. let's capture the task start time before task is submitted so that we can caompare the time in more correct way. Change-Id: I5a9845813b614c58e0f5a66e07f8a8c732f38eb3 Signed-off-by: Ghanshyam Maan --- nova/tests/unit/test_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nova/tests/unit/test_utils.py b/nova/tests/unit/test_utils.py index 6d3f70e136..aeebc4a926 100644 --- a/nova/tests/unit/test_utils.py +++ b/nova/tests/unit/test_utils.py @@ -2154,8 +2154,8 @@ class StaticallyDelayingCancellableTaskExecutorWrapperTest(test.NoDBTestCase): 2, utils._get_default_executor()) self.addCleanup(executor.shutdown, wait=True) - future1 = executor.submit_with_delay(task1) task1_start = time.monotonic() + future1 = executor.submit_with_delay(task1) # wait a bit so the wrapper is picking it up and waiting for its # deadline time.sleep(1) @@ -2163,8 +2163,8 @@ class StaticallyDelayingCancellableTaskExecutorWrapperTest(test.NoDBTestCase): self.assertFalse(task1_started.is_set()) # now submit the second task, it will be queued - future2 = executor.submit_with_delay(task2) task2_start = time.monotonic() + future2 = executor.submit_with_delay(task2) self.assertFalse(executor._queue.empty()) self.assertFalse(task1_started.is_set())