Skip to content

Commit d42149a

Browse files
authored
test overload with WritePortionsOnInsert (#16963)
1 parent 34a1855 commit d42149a

File tree

1 file changed

+28
-25
lines changed

1 file changed

+28
-25
lines changed

ydb/core/tx/columnshard/ut_rw/ut_columnshard_read_write.cpp

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <ydb/core/tx/columnshard/hooks/testing/controller.h>
1111
#include <ydb/core/tx/columnshard/operations/write_data.h>
1212
#include <ydb/core/tx/columnshard/test_helper/columnshard_ut_common.h>
13+
#include <ydb/core/tx/columnshard/test_helper/test_combinator.h>
1314
#include <ydb/core/tx/columnshard/test_helper/controllers.h>
1415
#include <ydb/core/tx/columnshard/test_helper/shard_reader.h>
1516
#include <ydb/core/tx/columnshard/test_helper/shard_writer.h>
@@ -434,11 +435,12 @@ void TestWrite(const TestTableDescription& table) {
434435
UNIT_ASSERT(ok);
435436
}
436437

437-
void TestWriteOverload(const TestTableDescription& table) {
438+
void TestWriteOverload(const TestTableDescription& table, bool WritePortionsOnInsert) {
438439
TTestBasicRuntime runtime;
439440
TTester::Setup(runtime);
441+
runtime.GetAppData().FeatureFlags.SetEnableWritePortionsOnInsert(WritePortionsOnInsert);
440442
auto csDefaultControllerGuard = NKikimr::NYDBTest::TControllers::RegisterCSControllerGuard<TDefaultTestsController>();
441-
443+
csDefaultControllerGuard->SetOverrideBlobSplitSettings(std::nullopt);
442444
TActorId sender = runtime.AllocateEdgeActor();
443445
CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet0, TTabletTypes::ColumnShard), &CreateColumnShard);
444446

@@ -462,26 +464,31 @@ void TestWriteOverload(const TestTableDescription& table) {
462464
TDeque<TAutoPtr<IEventHandle>> capturedWrites;
463465

464466
auto captureEvents = [&](TTestActorRuntimeBase&, TAutoPtr<IEventHandle>& ev) {
465-
if (auto* msg = TryGetPrivateEvent<NColumnShard::TEvPrivate::TEvWriteBlobsResult>(ev)) {
466-
Cerr << "CATCH TEvWrite, status " << msg->GetPutResult().GetPutStatus() << Endl;
467-
if (toCatch && msg->GetPutResult().GetPutStatus() != NKikimrProto::UNKNOWN) {
468-
capturedWrites.push_back(ev.Release());
467+
if (toCatch) {
468+
TAutoPtr<IEventHandle> eventToCapture;
469+
if (WritePortionsOnInsert) {
470+
if (auto* msg = TryGetPrivateEvent<NColumnShard::NPrivateEvents::NWrite::TEvWritePortionResult>(ev)) {
471+
Cerr << "CATCH TEvWritePortionResult, status " << msg->GetWriteStatus() << Endl;
472+
if (msg->GetWriteStatus() != NKikimrProto::EReplyStatus::UNKNOWN) {
473+
eventToCapture = ev.Release();
474+
}
475+
}
476+
} else {
477+
if (auto* msg = TryGetPrivateEvent<NColumnShard::TEvPrivate::TEvWriteBlobsResult>(ev)) {
478+
Cerr << "CATCH TEvWrite, status " << msg->GetPutResult().GetPutStatus() << Endl;
479+
if (msg->GetPutResult().GetPutStatus() != NKikimrProto::UNKNOWN) {
480+
eventToCapture = ev.Release();
481+
}
482+
}
483+
}
484+
if (eventToCapture) {
469485
--toCatch;
486+
capturedWrites.push_back(std::move(eventToCapture));
470487
return true;
471-
} else {
472-
return false;
473488
}
474489
}
475490
return false;
476491
};
477-
478-
auto resendOneCaptured = [&]() {
479-
UNIT_ASSERT(capturedWrites.size());
480-
Cerr << "RESEND TEvWrite" << Endl;
481-
runtime.Send(capturedWrites.front().Release());
482-
capturedWrites.pop_front();
483-
};
484-
485492
runtime.SetEventFilter(captureEvents);
486493

487494
const ui32 toSend = toCatch + 1;
@@ -492,7 +499,8 @@ void TestWriteOverload(const TestTableDescription& table) {
492499
UNIT_ASSERT_VALUES_EQUAL(WaitWriteResult(runtime, TTestTxConfig::TxTablet0), (ui32)NKikimrDataEvents::TEvWriteResult::STATUS_OVERLOADED);
493500

494501
while (capturedWrites.size()) {
495-
resendOneCaptured();
502+
runtime.Send(capturedWrites.front().Release());
503+
capturedWrites.pop_front();
496504
UNIT_ASSERT_VALUES_EQUAL(WaitWriteResult(runtime, TTestTxConfig::TxTablet0), (ui32)NKikimrDataEvents::TEvWriteResult::STATUS_COMPLETED);
497505
}
498506

@@ -1665,15 +1673,10 @@ Y_UNIT_TEST_SUITE(TColumnShardTestReadWrite) {
16651673
TestWrite(table);
16661674
}
16671675

1668-
Y_UNIT_TEST(WriteOverload) {
1676+
Y_UNIT_TEST_QUATRO(WriteOverload, InStore, WithWritePortionsOnInsert) {
16691677
TestTableDescription table;
1670-
TestWriteOverload(table);
1671-
}
1672-
1673-
Y_UNIT_TEST(WriteStandaloneOverload) {
1674-
TestTableDescription table;
1675-
table.InStore = false;
1676-
TestWriteOverload(table);
1678+
table.InStore = InStore;
1679+
TestWriteOverload(table, WithWritePortionsOnInsert);
16771680
}
16781681

16791682
Y_UNIT_TEST(WriteReadDuplicate) {

0 commit comments

Comments
 (0)