diff options
author | cerevra <[email protected]> | 2022-02-10 16:45:58 +0300 |
---|---|---|
committer | Daniil Cherednik <[email protected]> | 2022-02-10 16:45:58 +0300 |
commit | bf41dd01f6c920583e9faae7cd55ed25e547e052 (patch) | |
tree | ec7c8c285ffa648a5c5efeff453787a15ab811ac /library/cpp/tvmauth/client/ut/exponential_backoff_ut.cpp | |
parent | e2c3e3004f7cd68441cefcfa4aaccd3d8051c846 (diff) |
Restoring authorship annotation for <[email protected]>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/tvmauth/client/ut/exponential_backoff_ut.cpp')
-rw-r--r-- | library/cpp/tvmauth/client/ut/exponential_backoff_ut.cpp | 86 |
1 files changed, 43 insertions, 43 deletions
diff --git a/library/cpp/tvmauth/client/ut/exponential_backoff_ut.cpp b/library/cpp/tvmauth/client/ut/exponential_backoff_ut.cpp index 3dcbe6ad495..11e735f8369 100644 --- a/library/cpp/tvmauth/client/ut/exponential_backoff_ut.cpp +++ b/library/cpp/tvmauth/client/ut/exponential_backoff_ut.cpp @@ -1,44 +1,44 @@ -#include <library/cpp/tvmauth/client/misc/exponential_backoff.h> - +#include <library/cpp/tvmauth/client/misc/exponential_backoff.h> + #include <library/cpp/testing/unittest/registar.h> - -#include <thread> - -using namespace NTvmAuth; - -Y_UNIT_TEST_SUITE(PasspUtilsExpBackoff) { - Y_UNIT_TEST(common) { - TExponentialBackoff b({TDuration::Seconds(1), TDuration::Seconds(60), 2, 0.01}); - - UNIT_ASSERT_VALUES_EQUAL(TDuration::Seconds(1), b.GetCurrentValue()); - - TDuration dur = b.GetCurrentValue(); - for (size_t idx = 0; idx < 6; ++idx) { - TDuration newValue = b.Increase(); - UNIT_ASSERT_LT(dur, newValue); - dur = newValue; - } - - UNIT_ASSERT_LT(TDuration::Seconds(60) - TDuration::Seconds(3), dur); - UNIT_ASSERT_LT(dur, TDuration::Seconds(60) + TDuration::Seconds(3)); - } - - Y_UNIT_TEST(sleep) { - TExponentialBackoff b({TDuration::Seconds(60), TDuration::Seconds(600), 2, 0.01}); - - const TInstant start = TInstant::Now(); - - TAutoEvent started; - std::thread t([&b, &started]() { - started.Signal(); - b.Sleep(); - }); - - started.WaitT(TDuration::Seconds(30)); - b.Interrupt(); - t.join(); - TDuration dur = TInstant::Now() - start; - - UNIT_ASSERT_LT(dur, TDuration::Seconds(60)); - } -} + +#include <thread> + +using namespace NTvmAuth; + +Y_UNIT_TEST_SUITE(PasspUtilsExpBackoff) { + Y_UNIT_TEST(common) { + TExponentialBackoff b({TDuration::Seconds(1), TDuration::Seconds(60), 2, 0.01}); + + UNIT_ASSERT_VALUES_EQUAL(TDuration::Seconds(1), b.GetCurrentValue()); + + TDuration dur = b.GetCurrentValue(); + for (size_t idx = 0; idx < 6; ++idx) { + TDuration newValue = b.Increase(); + UNIT_ASSERT_LT(dur, newValue); + dur = newValue; + } + + UNIT_ASSERT_LT(TDuration::Seconds(60) - TDuration::Seconds(3), dur); + UNIT_ASSERT_LT(dur, TDuration::Seconds(60) + TDuration::Seconds(3)); + } + + Y_UNIT_TEST(sleep) { + TExponentialBackoff b({TDuration::Seconds(60), TDuration::Seconds(600), 2, 0.01}); + + const TInstant start = TInstant::Now(); + + TAutoEvent started; + std::thread t([&b, &started]() { + started.Signal(); + b.Sleep(); + }); + + started.WaitT(TDuration::Seconds(30)); + b.Interrupt(); + t.join(); + TDuration dur = TInstant::Now() - start; + + UNIT_ASSERT_LT(dur, TDuration::Seconds(60)); + } +} |