|
1 | 1 | #include <ydb/core/tx/datashard/ut_common/datashard_ut_common.h> |
2 | 2 | #include <ydb/core/tablet_flat/shared_sausagecache.h> |
3 | 3 | #include <ydb/core/tablet_flat/test/libs/table/test_make.h> |
| 4 | +#include <ydb/core/testlib/actors/block_events.h> |
4 | 5 |
|
5 | 6 | namespace NKikimr { |
6 | 7 |
|
@@ -441,28 +442,16 @@ Y_UNIT_TEST_SUITE(DataShardStats) { |
441 | 442 | const auto shard1 = GetTableShards(server, sender, "/Root/table-1").at(0); |
442 | 443 |
|
443 | 444 | UpsertRows(server, sender); |
444 | | - |
445 | | - bool captured = false; |
446 | | - auto observer = runtime.AddObserver<NSharedCache::TEvResult>([&](NSharedCache::TEvResult::TPtr& event) { |
447 | | - Cerr << "Captured NSharedCache::TEvResult from " << runtime.FindActorName(event->Sender) << " to " << runtime.FindActorName(event->GetRecipientRewrite()) << Endl; |
448 | | - if (runtime.FindActorName(event->GetRecipientRewrite()) == "DATASHARD_STATS_BUILDER") { |
449 | | - auto& message = *event->Get(); |
450 | | - event.Reset(static_cast<TEventHandle<NSharedCache::TEvResult> *>( |
451 | | - new IEventHandle(event->Recipient, event->Sender, |
452 | | - new NSharedCache::TEvResult(message.Origin, message.Cookie, NKikimrProto::NODATA)))); |
453 | | - captured = true; |
454 | | - } |
| 445 | + |
| 446 | + TBlockEvents<NSharedCache::TEvResult> block(runtime, [&](NSharedCache::TEvResult::TPtr& event) { |
| 447 | + return runtime.FindActorName(event->GetRecipientRewrite()) == "DATASHARD_STATS_BUILDER"; |
455 | 448 | }); |
456 | 449 |
|
457 | 450 | CompactTable(runtime, shard1, tableId1, false); |
458 | 451 |
|
459 | | - for (int i = 0; i < 5 && !captured; ++i) { |
460 | | - TDispatchOptions options; |
461 | | - options.CustomFinalCondition = [&]() { return captured; }; |
462 | | - runtime.DispatchEvents(options, TDuration::Seconds(5)); |
463 | | - } |
464 | | - UNIT_ASSERT(captured); |
465 | | - observer.Remove(); |
| 452 | + runtime.WaitFor("blocked read", [&]{ return block.size(); }); |
| 453 | + |
| 454 | + block.Stop().Unblock(); |
466 | 455 |
|
467 | 456 | { |
468 | 457 | Cerr << "Waiting stats.." << Endl; |
|
0 commit comments