diff --git a/src/agent/task_manager/tests/task_manager_test.cpp b/src/agent/task_manager/tests/task_manager_test.cpp index d4889fd595..95c260f040 100644 --- a/src/agent/task_manager/tests/task_manager_test.cpp +++ b/src/agent/task_manager/tests/task_manager_test.cpp @@ -24,7 +24,7 @@ class TaskManagerTest : public ::testing::Test TEST_F(TaskManagerTest, StartAndStop) { - taskManager.Start(2); + taskManager.Start(4); taskManager.Stop(); } @@ -37,13 +37,18 @@ TEST_F(TaskManagerTest, EnqueueFunctionTask) }; taskManager.EnqueueTask(task); + bool taskManagerStarted = false; { std::unique_lock lock(mtx); cv.wait(lock, [&]() { - taskManager.Start(2); + if (!taskManagerStarted) + { + taskManagerStarted = true; + taskManager.Start(4); + } return taskExecuted.load(); }); } @@ -64,13 +69,18 @@ TEST_F(TaskManagerTest, EnqueueCoroutineTask) }; taskManager.EnqueueTask(coroutineTask()); + bool taskManagerStarted = false; { std::unique_lock lock(mtx); cv.wait(lock, [&]() { - taskManager.Start(2); + if (!taskManagerStarted) + { + taskManagerStarted = true; + taskManager.Start(4); + } return taskExecuted.load(); }); } @@ -92,13 +102,18 @@ TEST_F(TaskManagerTest, EnqueueFunctionTaskIncrementsCounter) }; taskManager.EnqueueTask(task); + bool taskManagerStarted = false; { std::unique_lock lock(mtx); cv.wait(lock, [&]() { - taskManager.Start(2); + if (!taskManagerStarted) + { + taskManagerStarted = true; + taskManager.Start(4); + } return taskExecuted.load(); }); }