fix unstable test case for thread pool (#26465)

Signed-off-by: luzhang <luzhang@zilliz.com>
Co-authored-by: luzhang <luzhang@zilliz.com>
This commit is contained in:
zhagnlu 2023-08-18 22:42:20 +08:00 committed by GitHub
parent c073aa0dc3
commit 79ca04b995
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -126,6 +126,7 @@ TEST_F(DiskAnnFileManagerTest, TestThreadPoolBase) {
for (int i = 0; i < 10; ++i) {
futs.push_back(thread_pool->Submit(compute, i));
}
std::this_thread::sleep_for(std::chrono::milliseconds(300));
std::cout << "current thread num" << thread_pool->GetThreadNum()
<< std::endl;
auto thread_num_2 = thread_pool->GetThreadNum();
@ -135,7 +136,7 @@ TEST_F(DiskAnnFileManagerTest, TestThreadPoolBase) {
std::cout << futs[i].get() << std::endl;
}
sleep(5);
std::this_thread::sleep_for(std::chrono::milliseconds(5000));
std::cout << "current thread num" << thread_pool->GetThreadNum()
<< std::endl;
auto thread_num_3 = thread_pool->GetThreadNum();
@ -183,4 +184,4 @@ TEST_F(DiskAnnFileManagerTest, TestThreadPoolException) {
} catch (std::exception& e) {
EXPECT_EQ(std::string(e.what()), "run time error");
}
}
}