aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorijon <ijon@yandex-team.com>2023-02-16 10:48:55 +0300
committerijon <ijon@yandex-team.com>2023-02-16 10:48:55 +0300
commit2833f666f68066051c16ce5769ed730127293cdc (patch)
treeeb2ae33a451a47763a9033b56eae91ca2055b694
parent0c383af328f81a22f2d28f7ac626e56506c2bb6c (diff)
downloadydb-2833f666f68066051c16ce5769ed730127293cdc.tar.gz
tx_proxy, tests: remove excess waiting in CheckTableBecome*()
Use TTestActorRuntimeBase::DispatchTimeout manipulation to achieve proper (small) wait times. The reason to this is that timeout value given to CheckTableBecome*() propagates first to Tests:TClient::WaitForTablet*(), then propagates to NActors::TTestActorsRuntimebase::GrabEdgeEvent(). Timeout parameter to GrabEdgeEvent*() is a timeout in a simulated time. Timeout mechanics does not work if time does not get updated during a simulation. And entire time simulation mechanics does not work if TTestActorRuntimeBase is used with UseRealThreads setting set to true (which is the default). And when timeout in a simulated time does not work, the only timeout GrabEdgeEvent*() really obeys is DispatchTimeout which defaults to 60 seconds (or 120 seconds if code runs under some sanitizer). Tests in ydb/core/tx/tx_proxy runs with UseRealThreads set to true, so timeouts in CheckTableBecome*() methods do nothing, and whenever tests wait for something that should never happen (and specify small reasonable timeout value for that) they wait for 60 (or 120) seconds instead. This change cuts run time of the affected tests from 7 minutes to 2.
-rw-r--r--ydb/core/tx/tx_proxy/proxy_ut_helpers.cpp21
1 files changed, 15 insertions, 6 deletions
diff --git a/ydb/core/tx/tx_proxy/proxy_ut_helpers.cpp b/ydb/core/tx/tx_proxy/proxy_ut_helpers.cpp
index 80a768c43a1..f7472c424da 100644
--- a/ydb/core/tx/tx_proxy/proxy_ut_helpers.cpp
+++ b/ydb/core/tx/tx_proxy/proxy_ut_helpers.cpp
@@ -394,18 +394,27 @@ void CheckTableIsOfline(TBaseTestEnv &env, ui64 tablet_id) {
}
void CheckTableBecomeAlive(TBaseTestEnv &env, ui64 tablet_id) {
+ auto prev = env.GetRuntime().SetDispatchTimeout(WaitTimeOut);
UNIT_ASSERT(
env.GetClient().WaitForTabletAlive(&env.GetRuntime(), tablet_id, true, WaitTimeOut));
-
+ env.GetRuntime().SetDispatchTimeout(prev);
}
void CheckTableBecomeOfline(TBaseTestEnv &env, ui64 tablet_id) {
- UNIT_ASSERT(
- env.GetClient().WaitForTabletDown(&env.GetRuntime(), tablet_id, true, WaitTimeOut));
- //ensure that tablet do not wake up
+ {
+ auto prev = env.GetRuntime().SetDispatchTimeout(WaitTimeOut);
+ UNIT_ASSERT(
+ env.GetClient().WaitForTabletDown(&env.GetRuntime(), tablet_id, true, WaitTimeOut));
+ env.GetRuntime().SetDispatchTimeout(prev);
+ }
+ // check that tablet did not wake up
TDuration negativeTimeout = TDuration::Seconds(1);
- UNIT_ASSERT(
- !env.GetClient().WaitForTabletAlive(&env.GetRuntime(), tablet_id, true, negativeTimeout));
+ {
+ auto prev = env.GetRuntime().SetDispatchTimeout(negativeTimeout);
+ UNIT_ASSERT(
+ !env.GetClient().WaitForTabletAlive(&env.GetRuntime(), tablet_id, true, negativeTimeout));
+ env.GetRuntime().SetDispatchTimeout(prev);
+ }
}
void CheckTableRunOnProperTenantNode(TBaseTestEnv &env, const TString &tenant, ui64 tablet_id) {