Skip to content

Commit e304e4b

Browse files
committed
cc dist_lock: make SetNotEnabled test pass quicker
commit_hash:cbd993fefc68ba8f8d2f619500e86960afb1a693
1 parent 9b3b567 commit e304e4b

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

core/src/dist_lock/dist_lock_test.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,10 @@ UTEST_MT(LockedWorker, SetNotEnabled, 3) {
206206

207207
EXPECT_TRUE(work.WaitForLocked(false, utest::kMaxTestWaitTime));
208208
work.SetWorkLoopOn(true);
209-
EXPECT_FALSE(work.WaitForLocked(true, utest::kMaxTestWaitTime));
209+
// Expect the disabled worker to not reacquire the lock.
210+
// In case of a bug in DistLockedWorker, kAttemptTimeout will be enough to "probably" discover the bug.
211+
// In case of no bug, the test will not become flaky due to a smaller timeout.
212+
EXPECT_FALSE(work.WaitForLocked(true, kAttemptTimeout));
210213

211214
locked_worker.Stop();
212215
}

core/utest/include/userver/utest/utest.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ namespace utest {
2828

2929
/// The maximum time a typical test is allowed to execute. If exceeded, a
3030
/// deadlock is assumed. This time must not be too low to avoid flaky tests.
31+
///
32+
/// Use this timeout for awaiting something that is expected to complete.
33+
/// Use appropriate shorter timeouts for awaiting something that is not expected to ever complete.
3134
inline constexpr std::chrono::seconds kMaxTestWaitTime(20);
3235

3336
} // namespace utest

0 commit comments

Comments
 (0)