From 3639c5fee28fccab2d4dcad2e08c3177fced680e Mon Sep 17 00:00:00 2001 From: "bodong.yang" Date: Tue, 3 Dec 2024 02:06:58 +0000 Subject: [PATCH] test_retry_task_map: minor update for faster test --- tests/test_otaclient_common/test_retry_task_map.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/test_otaclient_common/test_retry_task_map.py b/tests/test_otaclient_common/test_retry_task_map.py index c9c1aa24d..ca65e2304 100644 --- a/tests/test_otaclient_common/test_retry_task_map.py +++ b/tests/test_otaclient_common/test_retry_task_map.py @@ -32,6 +32,8 @@ MAX_CONCURRENT = 128 MAX_WAIT_BEFORE_SUCCESS = 10 THREAD_INIT_MSG = "thread init message" +BACKOFF_FACTOR = 0.001 # for faster test +BACKOFF_MAX = 0.1 class _RetryTaskMapTestErr(Exception): @@ -47,7 +49,7 @@ def _thread_initializer(msg: str) -> None: class TestRetryTaskMap: @pytest.fixture(autouse=True) - def setup(self): + def setup(self) -> None: self._start_time = time.time() self._success_wait_dict = { idx: random.randint(0, MAX_WAIT_BEFORE_SUCCESS) @@ -83,6 +85,8 @@ def _exit_on_exceed_max_count(): watchdog_func=_exit_on_exceed_max_count, initializer=_thread_initializer, initargs=(THREAD_INIT_MSG,), + backoff_factor=BACKOFF_FACTOR, + backoff_max=BACKOFF_MAX, ) as executor: with pytest.raises(retry_task_map.TasksEnsureFailed): for _fut in executor.ensure_tasks( @@ -99,6 +103,8 @@ def test_retry_exceed_retry_limit(self): max_total_retry=MAX_TOTAL_RETRY, initializer=_thread_initializer, initargs=(THREAD_INIT_MSG,), + backoff_factor=BACKOFF_FACTOR, + backoff_max=BACKOFF_MAX, ) as executor: with pytest.raises(retry_task_map.TasksEnsureFailed): for _fut in executor.ensure_tasks( @@ -115,6 +121,8 @@ def test_retry_finally_succeeded(self): max_concurrent=MAX_CONCURRENT, initializer=_thread_initializer, initargs=(THREAD_INIT_MSG,), + backoff_factor=BACKOFF_FACTOR, + backoff_max=BACKOFF_MAX, ) as executor: for _fut in executor.ensure_tasks( self.workload_failed_and_then_succeed, range(TASKS_COUNT) @@ -130,6 +138,8 @@ def test_succeeded_in_one_try(self): max_concurrent=MAX_CONCURRENT, initializer=_thread_initializer, initargs=(THREAD_INIT_MSG,), + backoff_factor=BACKOFF_FACTOR, + backoff_max=BACKOFF_MAX, ) as executor: for _fut in executor.ensure_tasks( self.workload_succeed, range(TASKS_COUNT)