From e69d1a153ef6e164d18f98f7dde15faa1c718e08 Mon Sep 17 00:00:00 2001 From: Gianmatteo Palmieri Date: Mon, 16 Sep 2024 09:59:55 +0200 Subject: [PATCH] fix(tests): flaky thread pool tests Signed-off-by: Gianmatteo Palmieri --- userspace/libsinsp/test/plugins.ut.cpp | 2 +- userspace/libsinsp/test/thread_pool.ut.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/userspace/libsinsp/test/plugins.ut.cpp b/userspace/libsinsp/test/plugins.ut.cpp index f802590942..682ade7437 100644 --- a/userspace/libsinsp/test/plugins.ut.cpp +++ b/userspace/libsinsp/test/plugins.ut.cpp @@ -1092,7 +1092,7 @@ TEST_F(sinsp_with_test_input, plugin_routines) { PPM_O_RDWR, 0); std::this_thread::sleep_for( - std::chrono::nanoseconds(1000)); // wait for a bit to let routine finish + std::chrono::nanoseconds(2000)); // wait for a bit to let routine finish routines_num = tp->routines_num(); ASSERT_EQ(routines_num, 1); diff --git a/userspace/libsinsp/test/thread_pool.ut.cpp b/userspace/libsinsp/test/thread_pool.ut.cpp index 55fc3dd599..164ae99fe4 100644 --- a/userspace/libsinsp/test/thread_pool.ut.cpp +++ b/userspace/libsinsp/test/thread_pool.ut.cpp @@ -48,7 +48,7 @@ TEST_F(sinsp_with_test_input, thread_pool) { std::atomic count = 0; std::atomic routine_exited = false; r = tp->subscribe([&count, &routine_exited] { - if(count >= 1024) { + if(count >= 2048) { routine_exited = true; return false; } @@ -57,12 +57,12 @@ TEST_F(sinsp_with_test_input, thread_pool) { }); ASSERT_EQ(tp->routines_num(), 1); - // the routine above keeps increasing a counter, until the counter reaches 1024 + // the routine above keeps increasing a counter, until the counter reaches 2048 // we wait for the routine to exit, then we check if it has been unsubscribed while(!routine_exited) { - std::this_thread::sleep_for(std::chrono::milliseconds(500)); + std::this_thread::sleep_for(std::chrono::milliseconds(1000)); } - ASSERT_EQ(count, 1024); + ASSERT_EQ(count, 2048); ASSERT_EQ(tp->routines_num(), 0); // all the remaining routines should be unsubscribed when the inspector is closed