diff options
author | vvvv <[email protected]> | 2025-10-06 11:26:09 +0300 |
---|---|---|
committer | vvvv <[email protected]> | 2025-10-06 11:53:26 +0300 |
commit | 60f45e69a4d7dbc6131208e16c45faf35aa5a985 (patch) | |
tree | 4daa45b52c295a178c7620e4c93921465fcf7950 /yql/essentials/utils/failure_injector/failure_injector_ut.cpp | |
parent | 1bded1a65a7e6e9171418f3e1c691d390125b64e (diff) |
YQL-20086 utils
init
commit_hash:54feccd520ebd0ab23612bc0cb830914dff9d0e8
Diffstat (limited to 'yql/essentials/utils/failure_injector/failure_injector_ut.cpp')
-rw-r--r-- | yql/essentials/utils/failure_injector/failure_injector_ut.cpp | 104 |
1 files changed, 52 insertions, 52 deletions
diff --git a/yql/essentials/utils/failure_injector/failure_injector_ut.cpp b/yql/essentials/utils/failure_injector/failure_injector_ut.cpp index 4d94b5cce7d..75c67e30048 100644 --- a/yql/essentials/utils/failure_injector/failure_injector_ut.cpp +++ b/yql/essentials/utils/failure_injector/failure_injector_ut.cpp @@ -26,62 +26,62 @@ void SetUpLogger() { } Y_UNIT_TEST_SUITE(TFailureInjectorTests) { - Y_UNIT_TEST(BasicFailureTest) { - SetUpLogger(); - std::atomic<bool> called; - called.store(false); - auto behavior = [&called] { OnReach(called); }; - TFailureInjector::Reach("misc_failure", behavior); - UNIT_ASSERT_EQUAL(false, called.load()); - TFailureInjector::Activate(); - TFailureInjector::Set("misc_failure", 0, 1); - TFailureInjector::Reach("misc_failure", behavior); - UNIT_ASSERT_EQUAL(true, called.load()); - } +Y_UNIT_TEST(BasicFailureTest) { + SetUpLogger(); + std::atomic<bool> called; + called.store(false); + auto behavior = [&called] { OnReach(called); }; + TFailureInjector::Reach("misc_failure", behavior); + UNIT_ASSERT_EQUAL(false, called.load()); + TFailureInjector::Activate(); + TFailureInjector::Set("misc_failure", 0, 1); + TFailureInjector::Reach("misc_failure", behavior); + UNIT_ASSERT_EQUAL(true, called.load()); +} - Y_UNIT_TEST(CheckSkipTest) { - SetUpLogger(); - std::atomic<bool> called; - called.store(false); - auto behavior = [&called] { OnReach(called); }; - TFailureInjector::Activate(); - TFailureInjector::Set("misc_failure", 1, 1); +Y_UNIT_TEST(CheckSkipTest) { + SetUpLogger(); + std::atomic<bool> called; + called.store(false); + auto behavior = [&called] { OnReach(called); }; + TFailureInjector::Activate(); + TFailureInjector::Set("misc_failure", 1, 1); - TFailureInjector::Reach("misc_failure", behavior); - UNIT_ASSERT_EQUAL(false, called.load()); - TFailureInjector::Reach("misc_failure", behavior); - UNIT_ASSERT_EQUAL(true, called.load()); - } + TFailureInjector::Reach("misc_failure", behavior); + UNIT_ASSERT_EQUAL(false, called.load()); + TFailureInjector::Reach("misc_failure", behavior); + UNIT_ASSERT_EQUAL(true, called.load()); +} - Y_UNIT_TEST(CheckFailCountTest) { - SetUpLogger(); - int called = 0; - auto behavior = [&called] { ++called; }; - TFailureInjector::Activate(); - TFailureInjector::Set("misc_failure", 1, 2); +Y_UNIT_TEST(CheckFailCountTest) { + SetUpLogger(); + int called = 0; + auto behavior = [&called] { ++called; }; + TFailureInjector::Activate(); + TFailureInjector::Set("misc_failure", 1, 2); - TFailureInjector::Reach("misc_failure", behavior); - UNIT_ASSERT_EQUAL(0, called); - TFailureInjector::Reach("misc_failure", behavior); - UNIT_ASSERT_EQUAL(1, called); - TFailureInjector::Reach("misc_failure", behavior); - UNIT_ASSERT_EQUAL(2, called); - TFailureInjector::Reach("misc_failure", behavior); - UNIT_ASSERT_EQUAL(2, called); - TFailureInjector::Reach("misc_failure", behavior); - UNIT_ASSERT_EQUAL(2, called); - } + TFailureInjector::Reach("misc_failure", behavior); + UNIT_ASSERT_EQUAL(0, called); + TFailureInjector::Reach("misc_failure", behavior); + UNIT_ASSERT_EQUAL(1, called); + TFailureInjector::Reach("misc_failure", behavior); + UNIT_ASSERT_EQUAL(2, called); + TFailureInjector::Reach("misc_failure", behavior); + UNIT_ASSERT_EQUAL(2, called); + TFailureInjector::Reach("misc_failure", behavior); + UNIT_ASSERT_EQUAL(2, called); +} - Y_UNIT_TEST(SlowDownTest) { - SetUpLogger(); - TFailureInjector::Activate(); - TFailureInjector::Set("misc_failure", 0, 1); +Y_UNIT_TEST(SlowDownTest) { + SetUpLogger(); + TFailureInjector::Activate(); + TFailureInjector::Set("misc_failure", 0, 1); - auto start = system_clock::now(); - TFailureInjector::Reach("misc_failure", [] { ::Sleep(TDuration::Seconds(5)); }); - auto finish = system_clock::now(); - auto duration = duration_cast<std::chrono::seconds>(finish - start); - YQL_LOG(DEBUG) << "Duration :" << duration.count(); - UNIT_ASSERT_GE(duration.count(), 5); - } + auto start = system_clock::now(); + TFailureInjector::Reach("misc_failure", [] { ::Sleep(TDuration::Seconds(5)); }); + auto finish = system_clock::now(); + auto duration = duration_cast<std::chrono::seconds>(finish - start); + YQL_LOG(DEBUG) << "Duration :" << duration.count(); + UNIT_ASSERT_GE(duration.count(), 5); } +} // Y_UNIT_TEST_SUITE(TFailureInjectorTests) |