1
1
#include " defs.h"
2
- #include " dsproxy_vdisk_mock_ut.h"
3
2
#include " dsproxy_env_mock_ut.h"
3
+ #include " dsproxy_test_state_ut.h"
4
4
5
5
#include < ydb/core/blobstorage/dsproxy/dsproxy_put_impl.h>
6
+ #include < ydb/core/blobstorage/dsproxy/dsproxy_request_reporting.h>
6
7
#include < ydb/core/blobstorage/vdisk/common/vdisk_events.h>
7
8
8
9
#include < ydb/core/testlib/basics/runtime.h>
9
10
#include < ydb/core/testlib/actor_helpers.h>
10
11
11
12
#include < library/cpp/containers/stack_vector/stack_vec.h>
12
- #include < library/cpp/testing/unittest/registar.h>
13
13
14
14
namespace NKikimr {
15
15
namespace NDSProxyPutTest {
@@ -35,7 +35,7 @@ void TestPutMaxPartCountOnHandoff(TErasureType::EErasureSpecies erasureSpecies)
35
35
TBlobStorageGroupType groupType (erasureSpecies);
36
36
const ui32 domainCount = groupType.BlobSubgroupSize ();;
37
37
38
- TGroupMock group (groupId, erasureSpecies, domainCount, 1 );
38
+ TGroupMock group (groupId, erasureSpecies, 1 , domainCount, 1 );
39
39
TIntrusivePtr<TGroupQueues> groupQueues = group.MakeGroupQueues ();
40
40
41
41
TIntrusivePtr<::NMonitoring::TDynamicCounters> counters (new ::NMonitoring::TDynamicCounters ());
@@ -175,7 +175,7 @@ struct TTestPutAllOk {
175
175
176
176
TTestPutAllOk ()
177
177
: GroupType(ErasureSpecies)
178
- , Group(GroupId, ErasureSpecies, GroupType.BlobSubgroupSize(), 1 )
178
+ , Group(GroupId, ErasureSpecies, 1 , GroupType.BlobSubgroupSize(), 1 )
179
179
, GroupQueues(Group.MakeGroupQueues())
180
180
, BlobIds({TLogoBlobID (743284823 , 10 , 12345 , 0 , DataSize, 0 ), TLogoBlobID (743284823 , 9 , 12346 , 0 , DataSize, 0 )})
181
181
, Data(AlphaData(DataSize))
@@ -386,6 +386,180 @@ Y_UNIT_TEST(TestMirror3dcWith3x3MinLatencyMod) {
386
386
}
387
387
}
388
388
389
+ void TestPutResultWithVDiskResults (TBlobStorageGroupType type, TMap<TVDiskID, NKikimrProto::EReplyStatus> vdiskStatuses, uint expectedVdiskRequests, NKikimrProto::EReplyStatus resultStatus) {
390
+ TTestBasicRuntime runtime (1 , false );
391
+ runtime.SetDispatchTimeout (TDuration::Seconds (1 ));
392
+ runtime.SetLogPriority (NKikimrServices::BS_PROXY_PUT, NLog::PRI_DEBUG);
393
+ SetupRuntime (runtime);
394
+ TDSProxyEnv env;
395
+ env.Configure (runtime, type, 0 , 0 );
396
+ TTestState testState (runtime, type, env.Info );
397
+
398
+ TLogoBlobID blobId (72075186224047637 , 1 , 863 , 1 , 786 , 24576 );
399
+ TStringBuilder dataBuilder;
400
+ for (size_t i = 0 ; i < blobId.BlobSize (); ++i) {
401
+ dataBuilder << ' a' ;
402
+ }
403
+ TBlobTestSet::TBlob blob (blobId, dataBuilder);
404
+
405
+ TGroupMock &groupMock = testState.GetGroupMock ();
406
+ for (const auto & status : vdiskStatuses) {
407
+ groupMock.SetError (status.first , status.second );
408
+ }
409
+
410
+
411
+ TEvBlobStorage::TEvPut::ETactic tactic = TEvBlobStorage::TEvPut::TacticDefault;
412
+ NKikimrBlobStorage::EPutHandleClass handleClass = NKikimrBlobStorage::TabletLog;
413
+
414
+ TEvBlobStorage::TEvPut::TPtr ev = testState.CreatePutRequest (blob, tactic, handleClass);
415
+ auto putActor = env.CreatePutRequestActor (ev);
416
+ runtime.Register (putActor.release ());
417
+
418
+ auto reportActor = std::unique_ptr<IActor>(CreateRequestReportingThrottler (1 ));
419
+ runtime.Register (reportActor.release ());
420
+
421
+ for (ui64 idx = 0 ; idx < expectedVdiskRequests; ++idx) {
422
+ TEvBlobStorage::TEvVPut::TPtr ev = testState.GrabEventPtr <TEvBlobStorage::TEvVPut>();
423
+ TVDiskID vDiskId = VDiskIDFromVDiskID (ev->Get ()->Record .GetVDiskID ());
424
+ NKikimrProto::EReplyStatus status = groupMock.OnVPut (*ev->Get ());
425
+ TEvBlobStorage::TEvVPutResult::TPtr result = testState.CreateEventResultPtr (ev, status, vDiskId);
426
+ runtime.Send (result.Release ());
427
+ }
428
+
429
+ TMap<TLogoBlobID, NKikimrProto::EReplyStatus> expectedStatus {
430
+ {blobId, resultStatus}
431
+ };
432
+ testState.ReceivePutResults (1 , expectedStatus);
433
+ }
434
+
435
+ Y_UNIT_TEST (TestBlock42PutStatusOkWith_0_0_VdiskErrors) {
436
+ TestPutResultWithVDiskResults ({TErasureType::Erasure4Plus2Block}, {}, 6 , NKikimrProto::OK);
437
+ }
438
+
439
+ Y_UNIT_TEST (TestBlock42PutStatusOkWith_1_0_VdiskErrors) {
440
+ TMap<TVDiskID, NKikimrProto::EReplyStatus> vdiskStatuses {
441
+ {TVDiskID (0 , 1 , 0 , 0 , 0 ), NKikimrProto::ERROR},
442
+ };
443
+ TestPutResultWithVDiskResults ({TErasureType::Erasure4Plus2Block}, vdiskStatuses, 7 , NKikimrProto::OK);
444
+ }
445
+
446
+ Y_UNIT_TEST (TestBlock42PutStatusOkWith_1_1_VdiskErrors) {
447
+ TMap<TVDiskID, NKikimrProto::EReplyStatus> vdiskStatuses {
448
+ {TVDiskID (0 , 1 , 0 , 0 , 0 ), NKikimrProto::ERROR},
449
+ {TVDiskID (0 , 1 , 0 , 6 , 0 ), NKikimrProto::ERROR},
450
+ };
451
+ TestPutResultWithVDiskResults ({TErasureType::Erasure4Plus2Block}, vdiskStatuses, 8 , NKikimrProto::OK);
452
+ }
453
+
454
+ Y_UNIT_TEST (TestBlock42PutStatusOkWith_2_0_VdiskErrors) {
455
+ TMap<TVDiskID, NKikimrProto::EReplyStatus> vdiskStatuses {
456
+ {TVDiskID (0 , 1 , 0 , 0 , 0 ), NKikimrProto::ERROR},
457
+ {TVDiskID (0 , 1 , 0 , 1 , 0 ), NKikimrProto::ERROR},
458
+ };
459
+ TestPutResultWithVDiskResults ({TErasureType::Erasure4Plus2Block}, vdiskStatuses, 8 , NKikimrProto::OK);
460
+ }
461
+
462
+ Y_UNIT_TEST (TestBlock42PutStatusErrorWith_2_1_VdiskErrors) {
463
+ TMap<TVDiskID, NKikimrProto::EReplyStatus> vdiskStatuses {
464
+ {TVDiskID (0 , 1 , 0 , 0 , 0 ), NKikimrProto::ERROR},
465
+ {TVDiskID (0 , 1 , 0 , 1 , 0 ), NKikimrProto::ERROR},
466
+ {TVDiskID (0 , 1 , 0 , 6 , 0 ), NKikimrProto::ERROR},
467
+ };
468
+ TestPutResultWithVDiskResults ({TErasureType::Erasure4Plus2Block}, vdiskStatuses, 8 , NKikimrProto::ERROR);
469
+ }
470
+
471
+ Y_UNIT_TEST (TestBlock42PutStatusErrorWith_3_0_VdiskErrors) {
472
+ TMap<TVDiskID, NKikimrProto::EReplyStatus> vdiskStatuses {
473
+ {TVDiskID (0 , 1 , 0 , 0 , 0 ), NKikimrProto::ERROR},
474
+ {TVDiskID (0 , 1 , 0 , 1 , 0 ), NKikimrProto::ERROR},
475
+ {TVDiskID (0 , 1 , 0 , 2 , 0 ), NKikimrProto::ERROR},
476
+ };
477
+ TestPutResultWithVDiskResults ({TErasureType::Erasure4Plus2Block}, vdiskStatuses, 6 , NKikimrProto::ERROR);
478
+ }
479
+
480
+ Y_UNIT_TEST (TestBlock42PutStatusErrorWith_1_2_VdiskErrors) {
481
+ TMap<TVDiskID, NKikimrProto::EReplyStatus> vdiskStatuses {
482
+ {TVDiskID (0 , 1 , 0 , 0 , 0 ), NKikimrProto::ERROR},
483
+ {TVDiskID (0 , 1 , 0 , 6 , 0 ), NKikimrProto::ERROR},
484
+ {TVDiskID (0 , 1 , 0 , 7 , 0 ), NKikimrProto::ERROR},
485
+ };
486
+ TestPutResultWithVDiskResults ({TErasureType::Erasure4Plus2Block}, vdiskStatuses, 8 , NKikimrProto::ERROR);
487
+ }
488
+
489
+ Y_UNIT_TEST (TestMirror3dcPutStatusOkWith_0_0_0_VdiskErrors) {
490
+ TestPutResultWithVDiskResults ({TErasureType::ErasureMirror3dc}, {}, 3 , NKikimrProto::OK);
491
+ }
492
+
493
+ Y_UNIT_TEST (TestMirror3dcPutStatusOkWith_1_0_0_VdiskErrors) {
494
+ TMap<TVDiskID, NKikimrProto::EReplyStatus> vdiskStatuses {
495
+ {TVDiskID (0 , 1 , 0 , 1 , 0 ), NKikimrProto::ERROR},
496
+ };
497
+ TestPutResultWithVDiskResults ({TErasureType::ErasureMirror3dc}, vdiskStatuses, 4 , NKikimrProto::OK);
498
+ }
499
+
500
+ Y_UNIT_TEST (TestMirror3dcPutStatusOkWith_2_0_0_VdiskErrors) {
501
+ TMap<TVDiskID, NKikimrProto::EReplyStatus> vdiskStatuses {
502
+ {TVDiskID (0 , 1 , 0 , 1 , 0 ), NKikimrProto::ERROR},
503
+ {TVDiskID (0 , 1 , 0 , 2 , 0 ), NKikimrProto::ERROR},
504
+ };
505
+ TestPutResultWithVDiskResults ({TErasureType::ErasureMirror3dc}, vdiskStatuses, 5 , NKikimrProto::OK);
506
+ }
507
+
508
+ Y_UNIT_TEST (TestMirror3dcPutStatusOkWith_3_0_0_VdiskErrors) {
509
+ TMap<TVDiskID, NKikimrProto::EReplyStatus> vdiskStatuses {
510
+ {TVDiskID (0 , 1 , 0 , 1 , 0 ), NKikimrProto::ERROR},
511
+ {TVDiskID (0 , 1 , 0 , 2 , 0 ), NKikimrProto::ERROR},
512
+ {TVDiskID (0 , 1 , 0 , 0 , 0 ), NKikimrProto::ERROR},
513
+ };
514
+ TestPutResultWithVDiskResults ({TErasureType::ErasureMirror3dc}, vdiskStatuses, 7 , NKikimrProto::OK);
515
+ }
516
+
517
+ Y_UNIT_TEST (TestMirror3dcPutStatusOkWith_1_1_0_VdiskErrors) {
518
+ TMap<TVDiskID, NKikimrProto::EReplyStatus> vdiskStatuses {
519
+ {TVDiskID (0 , 1 , 0 , 1 , 0 ), NKikimrProto::ERROR},
520
+ {TVDiskID (0 , 1 , 1 , 1 , 0 ), NKikimrProto::ERROR},
521
+ };
522
+ TestPutResultWithVDiskResults ({TErasureType::ErasureMirror3dc}, vdiskStatuses, 5 , NKikimrProto::OK);
523
+ }
524
+
525
+ Y_UNIT_TEST (TestMirror3dcPutStatusOkWith_2_1_0_VdiskErrors) {
526
+ TMap<TVDiskID, NKikimrProto::EReplyStatus> vdiskStatuses {
527
+ {TVDiskID (0 , 1 , 0 , 1 , 0 ), NKikimrProto::ERROR},
528
+ {TVDiskID (0 , 1 , 0 , 2 , 0 ), NKikimrProto::ERROR},
529
+ {TVDiskID (0 , 1 , 1 , 1 , 0 ), NKikimrProto::ERROR},
530
+ };
531
+ TestPutResultWithVDiskResults ({TErasureType::ErasureMirror3dc}, vdiskStatuses, 6 , NKikimrProto::OK);
532
+ }
533
+
534
+ Y_UNIT_TEST (TestMirror3dcPutStatusErrorWith_1_1_1_VdiskErrors) {
535
+ TMap<TVDiskID, NKikimrProto::EReplyStatus> vdiskStatuses {
536
+ {TVDiskID (0 , 1 , 0 , 1 , 0 ), NKikimrProto::ERROR},
537
+ {TVDiskID (0 , 1 , 1 , 1 , 0 ), NKikimrProto::ERROR},
538
+ {TVDiskID (0 , 1 , 2 , 1 , 0 ), NKikimrProto::ERROR},
539
+ };
540
+ TestPutResultWithVDiskResults ({TErasureType::ErasureMirror3dc}, vdiskStatuses, 3 , NKikimrProto::ERROR);
541
+ }
542
+
543
+ Y_UNIT_TEST (TestMirror3dcPutStatusErrorWith_2_2_0_VdiskErrors) {
544
+ TMap<TVDiskID, NKikimrProto::EReplyStatus> vdiskStatuses {
545
+ {TVDiskID (0 , 1 , 0 , 1 , 0 ), NKikimrProto::ERROR},
546
+ {TVDiskID (0 , 1 , 0 , 2 , 0 ), NKikimrProto::ERROR},
547
+ {TVDiskID (0 , 1 , 1 , 1 , 0 ), NKikimrProto::ERROR},
548
+ {TVDiskID (0 , 1 , 1 , 2 , 0 ), NKikimrProto::ERROR},
549
+ };
550
+ TestPutResultWithVDiskResults ({TErasureType::ErasureMirror3dc}, vdiskStatuses, 5 , NKikimrProto::ERROR);
551
+ }
552
+
553
+ Y_UNIT_TEST (TestMirror3dcPutStatusOkWith_3_1_0_VdiskErrors) {
554
+ TMap<TVDiskID, NKikimrProto::EReplyStatus> vdiskStatuses {
555
+ {TVDiskID (0 , 1 , 0 , 0 , 0 ), NKikimrProto::ERROR},
556
+ {TVDiskID (0 , 1 , 0 , 1 , 0 ), NKikimrProto::ERROR},
557
+ {TVDiskID (0 , 1 , 0 , 2 , 0 ), NKikimrProto::ERROR},
558
+ {TVDiskID (0 , 1 , 1 , 1 , 0 ), NKikimrProto::ERROR},
559
+ };
560
+ TestPutResultWithVDiskResults ({TErasureType::ErasureMirror3dc}, vdiskStatuses, 8 , NKikimrProto::OK);
561
+ }
562
+
389
563
} // Y_UNIT_TEST_SUITE TDSProxyPutTest
390
564
} // namespace NDSProxyPutTest
391
565
} // namespace NKikimr
0 commit comments