|
| 1 | +#include <ydb/core/blobstorage/ut_blobstorage/ut_helpers.h> |
1 | 2 | #include <ydb/core/blobstorage/ut_blobstorage/lib/env.h>
|
2 | 3 | #include <ydb/core/blobstorage/vdisk/common/vdisk_private_events.h>
|
| 4 | +#include <util/random/random.h> |
3 | 5 |
|
4 | 6 | Y_UNIT_TEST_SUITE(BlobStorageSync) {
|
| 7 | + |
| 8 | + void TestCutting(TBlobStorageGroupType groupType) { |
| 9 | + const ui32 groupSize = groupType.BlobSubgroupSize(); |
| 10 | + |
| 11 | + // for (ui32 mask = 0; mask < (1 << groupSize); ++mask) { // TIMEOUT |
| 12 | + { |
| 13 | + ui32 mask = RandomNumber(1ull << groupSize); |
| 14 | + for (bool compressChunks : { true, false }) { |
| 15 | + TEnvironmentSetup env{{ |
| 16 | + .NodeCount = groupSize, |
| 17 | + .Erasure = groupType, |
| 18 | + }}; |
| 19 | + |
| 20 | + env.CreateBoxAndPool(1, 1); |
| 21 | + std::vector<ui32> groups = env.GetGroups(); |
| 22 | + UNIT_ASSERT_VALUES_EQUAL(groups.size(), 1); |
| 23 | + ui32 groupId = groups[0]; |
| 24 | + |
| 25 | + const ui64 tabletId = 5000; |
| 26 | + const ui32 channel = 10; |
| 27 | + ui32 gen = 1; |
| 28 | + ui32 step = 1; |
| 29 | + ui64 cookie = 1; |
| 30 | + |
| 31 | + ui64 totalSize = 0; |
| 32 | + |
| 33 | + std::vector<TControlWrapper> cutLocalSyncLogControls; |
| 34 | + std::vector<TControlWrapper> compressChunksControls; |
| 35 | + std::vector<TActorId> edges; |
| 36 | + |
| 37 | + for (ui32 nodeId = 1; nodeId <= groupSize; ++nodeId) { |
| 38 | + cutLocalSyncLogControls.emplace_back(0, 0, 1); |
| 39 | + compressChunksControls.emplace_back(1, 0, 1); |
| 40 | + TAppData* appData = env.Runtime->GetNode(nodeId)->AppData.get(); |
| 41 | + appData->Icb->RegisterSharedControl(cutLocalSyncLogControls.back(), "VDiskControls.EnableLocalSyncLogDataCutting"); |
| 42 | + appData->Icb->RegisterSharedControl(compressChunksControls.back(), "VDiskControls.EnableSyncLogChunkCompressionHDD"); |
| 43 | + edges.push_back(env.Runtime->AllocateEdgeActor(nodeId)); |
| 44 | + } |
| 45 | + |
| 46 | + for (ui32 i = 0; i < groupSize; ++i) { |
| 47 | + env.Runtime->WrapInActorContext(edges[i], [&] { |
| 48 | + SendToBSProxy(edges[i], groupId, new TEvBlobStorage::TEvStatus(TInstant::Max())); |
| 49 | + }); |
| 50 | + auto res = env.WaitForEdgeActorEvent<TEvBlobStorage::TEvStatusResult>(edges[i], false); |
| 51 | + UNIT_ASSERT_VALUES_EQUAL(res->Get()->Status, NKikimrProto::OK); |
| 52 | + } |
| 53 | + |
| 54 | + auto writeBlob = [&](ui32 nodeId, ui32 blobSize) { |
| 55 | + TLogoBlobID blobId(tabletId, gen, step, channel, blobSize, ++cookie); |
| 56 | + totalSize += blobSize; |
| 57 | + TString data = MakeData(blobSize); |
| 58 | + |
| 59 | + const TActorId& sender = edges[nodeId - 1]; |
| 60 | + env.Runtime->WrapInActorContext(sender, [&] () { |
| 61 | + SendToBSProxy(sender, groupId, new TEvBlobStorage::TEvPut(blobId, std::move(data), TInstant::Max())); |
| 62 | + }); |
| 63 | + }; |
| 64 | + |
| 65 | + env.Runtime->FilterFunction = [&](ui32/* nodeId*/, std::unique_ptr<IEventHandle>& ev) { |
| 66 | + switch(ev->Type) { |
| 67 | + case TEvBlobStorage::TEvPutResult::EventType: |
| 68 | + UNIT_ASSERT_VALUES_EQUAL(ev->Get<TEvBlobStorage::TEvPutResult>()->Status, NKikimrProto::OK); |
| 69 | + return false; |
| 70 | + default: |
| 71 | + return true; |
| 72 | + } |
| 73 | + }; |
| 74 | + |
| 75 | + while (totalSize < 16_MB) { |
| 76 | + writeBlob(GenerateRandom(1, groupSize + 1), GenerateRandom(1, 1_MB)); |
| 77 | + } |
| 78 | + env.Sim(TDuration::Minutes(5)); |
| 79 | + |
| 80 | + for (ui32 i = 0; i < groupSize; ++i) { |
| 81 | + cutLocalSyncLogControls[i] = !!(mask & (1 << i)); |
| 82 | + compressChunksControls[i] = compressChunks; |
| 83 | + } |
| 84 | + |
| 85 | + while (totalSize < 32_MB) { |
| 86 | + writeBlob(GenerateRandom(1, groupSize + 1), GenerateRandom(1, 1_MB)); |
| 87 | + } |
| 88 | + |
| 89 | + env.Sim(TDuration::Minutes(5)); |
| 90 | + } |
| 91 | + } |
| 92 | + } |
| 93 | + |
| 94 | + Y_UNIT_TEST(TestSyncLogCuttingMirror3dc) { |
| 95 | + TestCutting(TBlobStorageGroupType::ErasureMirror3dc); |
| 96 | + } |
| 97 | + |
| 98 | + Y_UNIT_TEST(TestSyncLogCuttingMirror3of4) { |
| 99 | + TestCutting(TBlobStorageGroupType::ErasureMirror3of4); |
| 100 | + } |
| 101 | + |
| 102 | + Y_UNIT_TEST(TestSyncLogCuttingBlock4Plus2) { |
| 103 | + TestCutting(TBlobStorageGroupType::Erasure4Plus2Block); |
| 104 | + } |
| 105 | + |
5 | 106 | Y_UNIT_TEST(SyncWhenDiskGetsDown) {
|
6 | 107 | return; // re-enable when protocol issue is resolved
|
7 | 108 |
|
|
0 commit comments