|
16 | 16 | #include <ydb/core/mind/tenant_pool.h>
|
17 | 17 | #include <ydb/core/tablet_flat/tablet_flat_executed.h>
|
18 | 18 | #include <ydb/core/tablet/tablet_impl.h>
|
| 19 | +#include <ydb/core/testlib/actors/block_events.h> |
19 | 20 | #include <ydb/core/testlib/basics/appdata.h>
|
20 | 21 | #include <ydb/core/testlib/basics/helpers.h>
|
21 | 22 | #include <ydb/core/testlib/tablet_helpers.h>
|
@@ -6154,13 +6155,14 @@ Y_UNIT_TEST_SUITE(THiveTest) {
|
6154 | 6155 | ActorIdToProto(owner, event->Record.MutableOwnerActor());
|
6155 | 6156 | }
|
6156 | 6157 | TActorId senderB = runtime.AllocateEdgeActor(nodeIndex);
|
| 6158 | + Ctest << "Send UnlockTablet\n"; |
6157 | 6159 | runtime.SendToPipe(hiveTablet, senderB, event.Release(), nodeIndex, GetPipeConfigWithRetries());
|
6158 | 6160 |
|
6159 | 6161 | TAutoPtr<IEventHandle> handle;
|
6160 | 6162 | auto result = runtime.GrabEdgeEventRethrow<TEvHive::TEvUnlockTabletExecutionResult>(handle);
|
6161 | 6163 | UNIT_ASSERT(result);
|
6162 | 6164 | UNIT_ASSERT_VALUES_EQUAL(result->Record.GetTabletID(), tabletId);
|
6163 |
| - UNIT_ASSERT_VALUES_EQUAL(result->Record.GetStatus(), expectedStatus); |
| 6165 | + UNIT_ASSERT_C(result->Record.GetStatus() == expectedStatus, "Expected status " << expectedStatus << ", got reply " << result->Record.ShortDebugString()); |
6164 | 6166 | }
|
6165 | 6167 |
|
6166 | 6168 | Y_UNIT_TEST(TestLockTabletExecutionBadUnlock) {
|
@@ -6237,6 +6239,44 @@ Y_UNIT_TEST_SUITE(THiveTest) {
|
6237 | 6239 | VerifyLockTabletExecutionLost(runtime, tabletId, owner);
|
6238 | 6240 | }
|
6239 | 6241 |
|
| 6242 | + Y_UNIT_TEST(TestLockTabletExecutionLocalGone) { |
| 6243 | + TTestBasicRuntime runtime(3, false); |
| 6244 | + Setup(runtime, false); |
| 6245 | + CreateLocal(runtime, 0); // only the 1st node has local running |
| 6246 | + const ui64 hiveTablet = MakeDefaultHiveID(); |
| 6247 | + const ui64 testerTablet = MakeTabletID(false, 1); |
| 6248 | + const TActorId hiveActor = CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::Hive), &CreateDefaultHive); |
| 6249 | + const TActorId senderA = runtime.AllocateEdgeActor(0); |
| 6250 | + runtime.EnableScheduleForActor(hiveActor); |
| 6251 | + |
| 6252 | + TTabletTypes::EType tabletType = TTabletTypes::Dummy; |
| 6253 | + THolder<TEvHive::TEvCreateTablet> ev(new TEvHive::TEvCreateTablet(testerTablet, 0, tabletType, BINDED_CHANNELS)); |
| 6254 | + ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, true); |
| 6255 | + MakeSureTabletIsUp(runtime, tabletId, 0); |
| 6256 | + |
| 6257 | + TActorId owner = runtime.AllocateEdgeActor(1); |
| 6258 | + SendLockTabletExecution(runtime, hiveTablet, tabletId, 1, NKikimrProto::OK, owner, 100500); |
| 6259 | + MakeSureTabletIsDown(runtime, tabletId, 0); |
| 6260 | + |
| 6261 | + // Block events related to node disconnect |
| 6262 | + // TEvents::TEvUndelivered - actor system does not guarantee that this event will be sent |
| 6263 | + // TEvLocal::TEvStatus - we cannot expect that the disconnecting node will always be able to send this |
| 6264 | + // TEvInterconnect::TEvNodeDisconnected - we will send this one, but follow it up with NodeConnected |
| 6265 | + // This is simulating a case when a new host is using the old node id and that new host does not run Local |
| 6266 | + TBlockEvents<TEvents::TEvUndelivered> blockUndleivered(runtime, [](auto&& ev) { return ev->Get()->SourceType == TEvLocal::EvPing; }); |
| 6267 | + TBlockEvents<TEvLocal::TEvStatus> blockStatus(runtime, [](auto&& ev) { return ev->Get()->Record.GetStatus() != NKikimrProto::OK; }); |
| 6268 | + SendKillLocal(runtime, 0); |
| 6269 | + runtime.SendToPipe(hiveTablet, senderA, new TEvInterconnect::TEvNodeDisconnected(runtime.GetNodeId(0)), 0, GetPipeConfigWithRetries()); |
| 6270 | + CreateLocal(runtime, 2); |
| 6271 | + runtime.Register(CreateTabletKiller(hiveTablet)); |
| 6272 | + runtime.SendToPipe(hiveTablet, senderA, new TEvInterconnect::TEvNodeConnected(runtime.GetNodeId(0)), 0, GetPipeConfigWithRetries()); |
| 6273 | + |
| 6274 | + // Unlocking with the same owner should succeed and boot the tablet |
| 6275 | + SendUnlockTabletExecution(runtime, hiveTablet, tabletId, 1, NKikimrProto::OK, owner); |
| 6276 | + WaitForTabletIsUp(runtime, tabletId, 0); |
| 6277 | + |
| 6278 | + } |
| 6279 | + |
6240 | 6280 | Y_UNIT_TEST(TestExternalBoot) {
|
6241 | 6281 | TTestBasicRuntime runtime(1, false);
|
6242 | 6282 | Setup(runtime, true);
|
|
0 commit comments