From ce637fe65e8f42648352398857a8fc21b773a24d Mon Sep 17 00:00:00 2001 From: yibin <13482527984@163.com> Date: Mon, 8 Jul 2024 13:34:32 +0800 Subject: [PATCH] Change sleep time for sanitizer build type of gtest_compute_server (#9194) ref pingcap/tiflash#8285 Signed-off-by: yibin --- dbms/src/Flash/tests/gtest_compute_server.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/dbms/src/Flash/tests/gtest_compute_server.cpp b/dbms/src/Flash/tests/gtest_compute_server.cpp index 6312f27432b..b0988e8b2c9 100644 --- a/dbms/src/Flash/tests/gtest_compute_server.cpp +++ b/dbms/src/Flash/tests/gtest_compute_server.cpp @@ -179,6 +179,12 @@ class ComputeServerRunner : public DB::tests::MPPTaskTestUtils #define WRAP_FOR_SERVER_TEST_END } +#ifdef SANITIZER +#define ADAPTIVE_SLEEP(X, Y) std::this_thread::sleep_for(Y) +#else +#define ADAPTIVE_SLEEP(X, Y) std::this_thread::sleep_for(X) +#endif // SANITIZER + TEST_F(ComputeServerRunner, simpleExchange) try { @@ -995,7 +1001,7 @@ try addOneQuery(i + 10, running_queries, gather_ids); } using namespace std::literals::chrono_literals; - std::this_thread::sleep_for(4s); + ADAPTIVE_SLEEP(4s, 8s); ASSERT_TRUE( TiFlashMetrics::instance() .tiflash_task_scheduler.get(tiflash_task_scheduler_metrics::type_active_queries_count, "") @@ -1007,7 +1013,7 @@ try .Value() == 0); addOneQuery(1, running_queries, gather_ids); - std::this_thread::sleep_for(4s); + ADAPTIVE_SLEEP(4s, 8s); ASSERT_TRUE( TiFlashMetrics::instance() .tiflash_task_scheduler.get(tiflash_task_scheduler_metrics::type_active_queries_count, "") @@ -1030,7 +1036,7 @@ try addOneQuery((i + 1) * 20, running_queries, gather_ids); } using namespace std::literals::chrono_literals; - std::this_thread::sleep_for(4s); + ADAPTIVE_SLEEP(4s, 8s); ASSERT_TRUE( TiFlashMetrics::instance() .tiflash_task_scheduler.get(tiflash_task_scheduler_metrics::type_active_queries_count, "") @@ -1042,7 +1048,7 @@ try .Value() == 0); addOneQuery(30, running_queries, gather_ids); - std::this_thread::sleep_for(4s); + ADAPTIVE_SLEEP(4s, 8s); ASSERT_TRUE( TiFlashMetrics::instance() .tiflash_task_scheduler.get(tiflash_task_scheduler_metrics::type_active_queries_count, "") @@ -1056,7 +1062,7 @@ try /// cancel 1 running query MockComputeServerManager::instance().cancelGather(gather_ids[0]); running_queries[0].join(); - std::this_thread::sleep_for(4s); + ADAPTIVE_SLEEP(4s, 8s); ASSERT_TRUE( TiFlashMetrics::instance() .tiflash_task_scheduler.get(tiflash_task_scheduler_metrics::type_active_queries_count, "") @@ -1113,7 +1119,7 @@ try single_gather_properties.gather_id = 1; addOneGather(running_queries, gather_ids, single_gather_properties); using namespace std::literals::chrono_literals; - std::this_thread::sleep_for(4s); + ADAPTIVE_SLEEP(4s, 8s); /// 6 gathers, but two query ASSERT_TRUE( TiFlashMetrics::instance()