@@ -60,7 +60,7 @@ struct TTestEnv {
6060 return data;
6161 };
6262
63- void SendPut (ui32 step, const TString& data, NKikimrProto::EReplyStatus expectedStatus ) {
63+ NKikimrProto::EReplyStatus SendPut (ui32 step, const TString& data) {
6464 const TLogoBlobID id (1 , 1 , step, 0 , data.size (), 0 );
6565 Cerr << " SEND TEvPut with key " << id.ToString () << Endl;
6666 const TActorId sender = Env.Runtime ->AllocateEdgeActor (GroupInfo->GetActorId (*RunningNodes.begin ()).NodeId (), __FILE__, __LINE__);
@@ -69,8 +69,12 @@ struct TTestEnv {
6969 SendToBSProxy (sender, GroupInfo->GroupID , ev.release ());
7070 });
7171 auto res = Env.WaitForEdgeActorEvent <TEvBlobStorage::TEvPutResult>(sender, false );
72- UNIT_ASSERT_VALUES_EQUAL (res->Get ()->Status , expectedStatus);
7372 Cerr << " TEvPutResult: " << res->Get ()->ToString () << Endl;
73+ return res->Get ()->Status ;
74+ };
75+
76+ void SendPut (ui32 step, const TString& data, NKikimrProto::EReplyStatus expectedStatus) {
77+ UNIT_ASSERT_VALUES_EQUAL (SendPut (step, data), expectedStatus);
7478 };
7579
7680 auto SendGet (ui32 step, ui32 dataSize, bool mustRestoreFirst=false ) {
@@ -114,7 +118,6 @@ struct TTestEnv {
114118 const TActorId sender = Env.Runtime ->AllocateEdgeActor (GroupInfo->GetActorId (*RunningNodes.begin ()).NodeId (), __FILE__, __LINE__);
115119 TVector<ui32> partsRes;
116120
117- Cerr << " Get request for vdisk " << position << Endl;
118121 auto queueId = GetQueue (vDiskId);
119122 Env.Runtime ->WrapInActorContext (sender, [&] {
120123 Env.Runtime ->Send (new IEventHandle (queueId, sender, ev.release ()));
@@ -244,13 +247,6 @@ struct TStopOneNodeTest {
244247 Env->Sim (TDuration::Seconds (10 ));
245248 Cerr << " Finish compaction 2" << Endl;
246249
247- Cerr << " Start compaction 3" << Endl;
248- for (ui32 pos = 0 ; pos < Env->Settings .NodeCount ; ++pos) {
249- Env->CompactVDisk (Env.GroupInfo ->GetActorId (pos));
250- }
251- Env->Sim (TDuration::Seconds (10 ));
252- Cerr << " Finish compaction 3" << Endl;
253-
254250 Env.CheckPartsLocations (MakeLogoBlobId (step, data.size ()));
255251 UNIT_ASSERT_VALUES_EQUAL (Env.SendGet (step, data.size ())->Get ()->Responses [0 ].Buffer .ConvertToString (), data);
256252 }
@@ -264,21 +260,23 @@ struct TRandomTest {
264260 void RunTest () {
265261 TVector<TString> data (Reserve (NumIters));
266262
263+ TVector<ui32> successfulSteps;
264+
267265 for (ui32 step = 0 ; step < NumIters; ++step) {
268- Cerr << step << Endl;
266+ Cerr << " Step = " << step << Endl;
269267 data.push_back (GenData (16 + random () % 4096 ));
270- auto blobId = MakeLogoBlobId (step, data.back ().size ());
271- auto locations = Env.GetExpectedPartsLocations (blobId);
268+
269+ if (Env.SendPut (step, data.back ()) == NKikimrProto::OK) {
270+ successfulSteps.push_back (step);
271+ }
272272
273273 if (random () % 10 == 1 && Env.RunningNodes .size () + 2 > Env->Settings .NodeCount ) {
274- ui32 nodeId = random () % Env->Settings .NodeCount ;
275- Cerr << " Stop node " << nodeId << Endl;
276- Env.StopNode (nodeId );
274+ ui32 pos = random () % Env->Settings .NodeCount ;
275+ Cerr << " Stop node " << pos << Endl;
276+ Env.StopNode (pos );
277277 Env->Sim (TDuration::Seconds (10 ));
278278 }
279279
280- Env.SendPut (step, data.back (), NKikimrProto::OK);
281-
282280 if (random () % 10 == 1 ) {
283281 for (ui32 pos = 0 ; pos < Env->Settings .NodeCount ; ++pos) {
284282 if (!Env.RunningNodes .contains (pos)) {
@@ -293,6 +291,7 @@ struct TRandomTest {
293291 if (random () % 50 == 1 ) {
294292 ui32 pos = random () % Env->Settings .NodeCount ;
295293 if (Env.RunningNodes .contains (pos)) {
294+ Cerr << " Compact vdisk " << pos << Endl;
296295 Env->CompactVDisk (Env.GroupInfo ->GetActorId (pos));
297296 Env->Sim (TDuration::Seconds (10 ));
298297 }
@@ -302,6 +301,7 @@ struct TRandomTest {
302301 if (random () % 100 == 1 ) {
303302 ui32 pos = random () % Env->Settings .NodeCount ;
304303 if (Env.RunningNodes .contains (pos)) {
304+ Cerr << " Wipe node " << pos << Endl;
305305 auto baseConfig = Env->FetchBaseConfig ();
306306 const auto & somePDisk = baseConfig.GetPDisk (pos);
307307 const auto & someVSlot = baseConfig.GetVSlot (pos);
@@ -311,14 +311,29 @@ struct TRandomTest {
311311 }
312312 }
313313
314+ UNIT_ASSERT (successfulSteps.size () > NumIters / 2 );
315+
316+ Cerr << " Starting nodes" << Endl;
314317 for (ui32 pos = 0 ; pos < Env->Settings .NodeCount ; ++pos) {
315318 Env.StartNode (pos);
316319 }
320+ Env->Sim (TDuration::Seconds (10 ));
321+
322+ Cerr << " Start compaction 1" << Endl;
323+ for (ui32 pos = 0 ; pos < Env->Settings .NodeCount ; ++pos) {
324+ Env->CompactVDisk (Env.GroupInfo ->GetActorId (pos));
325+ }
326+ Env->Sim (TDuration::Seconds (60 ));
327+
328+ Cerr << " Start compaction 2" << Endl;
329+ for (ui32 pos = 0 ; pos < Env->Settings .NodeCount ; ++pos) {
330+ Env->CompactVDisk (Env.GroupInfo ->GetActorId (pos));
331+ }
332+ Env->Sim (TDuration::Seconds (60 ));
317333
318- Env->Sim (TDuration::Seconds (300 ));
319334 Cerr << " Start checking" << Endl;
320- for (ui32 step = 0 ; step < NumIters; ++step ) {
321- Cerr << step << Endl;
335+ for (ui32 step: successfulSteps ) {
336+ Cerr << " step = " << step << Endl;
322337 Env.CheckPartsLocations (MakeLogoBlobId (step, data[step].size ()));
323338 UNIT_ASSERT_VALUES_EQUAL (Env.SendGet (step, data[step].size ())->Get ()->Responses [0 ].Buffer .ConvertToString (), data[step]);
324339 }
@@ -336,7 +351,7 @@ Y_UNIT_TEST_SUITE(VDiskBalancing) {
336351 TStopOneNodeTest{TTestEnv (9 , TBlobStorageGroupType::ErasureMirror3dc), GenData (100 )}.RunTest ();
337352 }
338353 Y_UNIT_TEST (TestStopOneNode_Block42_HugeBlob) {
339- TStopOneNodeTest{TTestEnv (8 , TBlobStorageGroupType::Erasure4Plus2Block), GenData (521_KB)}.RunTest ();
354+ TStopOneNodeTest{TTestEnv (8 , TBlobStorageGroupType::Erasure4Plus2Block), GenData (521_KB * 6 )}.RunTest ();
340355 }
341356 Y_UNIT_TEST (TestStopOneNode_Mirror3dc_HugeBlob) {
342357 TStopOneNodeTest{TTestEnv (9 , TBlobStorageGroupType::ErasureMirror3dc), GenData (521_KB)}.RunTest ();
0 commit comments