diff options
author | azevaykin <azevaykin@yandex-team.com> | 2023-11-16 15:15:33 +0300 |
---|---|---|
committer | azevaykin <azevaykin@yandex-team.com> | 2023-11-16 16:39:00 +0300 |
commit | 358c0fc7925cf5ede4394a784bf8dd74ad964cc1 (patch) | |
tree | 64eed6a400aa79bff224b6c6caa20143a52662ec | |
parent | 3b6c6c4a799c566414ad46638676ac561f09521f (diff) | |
download | ydb-358c0fc7925cf5ede4394a784bf8dd74ad964cc1.tar.gz |
Move WriteRow to helpers.cpp
-rw-r--r-- | ydb/core/tx/schemeshard/ut_backup/ut_backup.cpp | 23 | ||||
-rw-r--r-- | ydb/core/tx/schemeshard/ut_export/ut_export.cpp | 27 | ||||
-rw-r--r-- | ydb/core/tx/schemeshard/ut_helpers/helpers.cpp | 31 | ||||
-rw-r--r-- | ydb/core/tx/schemeshard/ut_helpers/helpers.h | 3 |
4 files changed, 43 insertions, 41 deletions
diff --git a/ydb/core/tx/schemeshard/ut_backup/ut_backup.cpp b/ydb/core/tx/schemeshard/ut_backup/ut_backup.cpp index 1dbdafe230..53bd14fa35 100644 --- a/ydb/core/tx/schemeshard/ut_backup/ut_backup.cpp +++ b/ydb/core/tx/schemeshard/ut_backup/ut_backup.cpp @@ -68,21 +68,6 @@ Y_UNIT_TEST_SUITE(TBackupTests) { return std::make_pair(partsUploaded, objectsPut); } - void WriteRow(TTestBasicRuntime& runtime, ui64 tabletId, const TString& key, const TString& value) { - NKikimrMiniKQL::TResult result; - TString error; - NKikimrProto::EReplyStatus status = LocalMiniKQL(runtime, tabletId, Sprintf(R"( - ( - (let key '( '('key (Utf8 '%s) ) ) ) - (let row '( '('value (Utf8 '%s) ) ) ) - (return (AsList (UpdateRow '__user__Table key row) )) - ) - )", key.c_str(), value.c_str()), result, error); - - UNIT_ASSERT_VALUES_EQUAL_C(status, NKikimrProto::EReplyStatus::OK, error); - UNIT_ASSERT_VALUES_EQUAL(error, ""); - } - Y_UNIT_TEST_WITH_COMPRESSION(ShouldSucceedOnSingleShardTable) { TTestBasicRuntime runtime; @@ -92,7 +77,7 @@ Y_UNIT_TEST_SUITE(TBackupTests) { Columns { Name: "value" Type: "Utf8" } KeyColumnNames: ["key"] )", [](TTestBasicRuntime& runtime) { - WriteRow(runtime, TTestTxConfig::FakeHiveTablets, "a", "valueA"); + WriteRow(runtime, "a", "valueA"); }); } @@ -110,8 +95,8 @@ Y_UNIT_TEST_SUITE(TBackupTests) { } } )", [](TTestBasicRuntime& runtime) { - WriteRow(runtime, TTestTxConfig::FakeHiveTablets + 0, "a", "valueA"); - WriteRow(runtime, TTestTxConfig::FakeHiveTablets + 1, "b", "valueb"); + WriteRow(runtime, "a", "valueA", TTestTxConfig::FakeHiveTablets + 0); + WriteRow(runtime, "b", "valueb", TTestTxConfig::FakeHiveTablets + 1); }); } @@ -127,7 +112,7 @@ Y_UNIT_TEST_SUITE(TBackupTests) { KeyColumnNames: ["key"] )", [](TTestBasicRuntime& runtime) { for (ui32 i = 0; i < 100 * batchSize; ++i) { - WriteRow(runtime, TTestTxConfig::FakeHiveTablets, Sprintf("a%d", i), "valueA"); + WriteRow(runtime, Sprintf("a%d", i), "valueA"); } }, batchSize, minWriteBatchSize); diff --git a/ydb/core/tx/schemeshard/ut_export/ut_export.cpp b/ydb/core/tx/schemeshard/ut_export/ut_export.cpp index c8db1c6081..0c0e396adf 100644 --- a/ydb/core/tx/schemeshard/ut_export/ut_export.cpp +++ b/ydb/core/tx/schemeshard/ut_export/ut_export.cpp @@ -168,21 +168,6 @@ namespace { TestGetExport(runtime, exportId, "/MyRoot", Ydb::StatusIds::NOT_FOUND); } - void WriteRow(TTestActorRuntime& runtime, ui64 tabletId, const TString& key, const TString& value) { - NKikimrMiniKQL::TResult result; - TString error; - NKikimrProto::EReplyStatus status = LocalMiniKQL(runtime, tabletId, Sprintf(R"( - ( - (let key '( '('key (Utf8 '%s) ) ) ) - (let row '( '('value (Utf8 '%s) ) ) ) - (return (AsList (UpdateRow '__user__Table key row) )) - ) - )", key.c_str(), value.c_str()), result, error); - - UNIT_ASSERT_VALUES_EQUAL_C(status, NKikimrProto::EReplyStatus::OK, error); - UNIT_ASSERT_VALUES_EQUAL(error, ""); - } - } // anonymous Y_UNIT_TEST_SUITE(TExportToS3Tests) { @@ -708,8 +693,8 @@ partitioning_settings { )"); env.TestWaitNotification(runtime, txId); - WriteRow(runtime, TTestTxConfig::FakeHiveTablets, "a", "valueA"); - WriteRow(runtime, TTestTxConfig::FakeHiveTablets, "b", "valueB"); + WriteRow(runtime, "a", "valueA"); + WriteRow(runtime, "b", "valueB"); runtime.SetLogPriority(NKikimrServices::S3_WRAPPER, NActors::NLog::PRI_TRACE); runtime.SetLogPriority(NKikimrServices::DATASHARD_BACKUP, NActors::NLog::PRI_TRACE); @@ -849,7 +834,7 @@ partitioning_settings { env.TestWaitNotification(runtime, txId); for (int i = 1; i < 500; ++i) { - WriteRow(runtime, TTestTxConfig::FakeHiveTablets, Sprintf("a%i", i), "value"); + WriteRow(runtime, Sprintf("a%i", i), "value"); } // trigger memtable's compaction @@ -946,7 +931,7 @@ partitioning_settings { )"); env.TestWaitNotification(runtime, txId); - WriteRow(runtime, TTestTxConfig::FakeHiveTablets, "a", "valueA"); + WriteRow(runtime, "a", "valueA"); TPortManager portManager; const ui16 port = portManager.GetPort(); @@ -1298,8 +1283,8 @@ partitioning_settings { )"); env.TestWaitNotification(runtime, txId); - WriteRow(runtime, TTestTxConfig::FakeHiveTablets, "a", "valueA"); - WriteRow(runtime, TTestTxConfig::FakeHiveTablets, "b", "valueB"); + WriteRow(runtime, "a", "valueA"); + WriteRow(runtime, "b", "valueB"); runtime.SetLogPriority(NKikimrServices::DATASHARD_BACKUP, NActors::NLog::PRI_DEBUG); TPortManager portManager; diff --git a/ydb/core/tx/schemeshard/ut_helpers/helpers.cpp b/ydb/core/tx/schemeshard/ut_helpers/helpers.cpp index ed58a9dd40..414ee0d9da 100644 --- a/ydb/core/tx/schemeshard/ut_helpers/helpers.cpp +++ b/ydb/core/tx/schemeshard/ut_helpers/helpers.cpp @@ -2251,6 +2251,36 @@ namespace NSchemeShardUT_Private { NKikimr::NPQ::CmdWrite(&runtime, tabletId, edge, partitionId, "sourceid0", msgSeqNo, data, false, {}, true, cookie, 0); } + void WriteRow(TTestActorRuntime& runtime, const TString& key, const TString& value, ui64 tabletId) { + NKikimrMiniKQL::TResult result; + TString error; + NKikimrProto::EReplyStatus status = LocalMiniKQL(runtime, tabletId, Sprintf(R"( + ( + (let key '( '('key (Utf8 '%s) ) ) ) + (let row '( '('value (Utf8 '%s) ) ) ) + (return (AsList (UpdateRow '__user__Table key row) )) + ) + )", key.c_str(), value.c_str()), result, error); + + UNIT_ASSERT_VALUES_EQUAL_C(status, NKikimrProto::EReplyStatus::OK, error); + UNIT_ASSERT_VALUES_EQUAL(error, ""); + } + + void WriteRowPg(TTestActorRuntime& runtime, const TString& key, ui32 value, ui64 tabletId) { + NKikimrMiniKQL::TResult result; + TString error; + NKikimrProto::EReplyStatus status = LocalMiniKQL(runtime, tabletId, Sprintf(R"( + ( + (let key '( '('key (Utf8 '%s) ) ) ) + (let row '( '('value (PgConst '%u (PgType 'int4)) ) ) ) + (return (AsList (UpdateRow '__user__Table key row) )) + ) + )", key.c_str(), value), result, error); + + UNIT_ASSERT_VALUES_EQUAL_C(status, NKikimrProto::EReplyStatus::OK, error); + UNIT_ASSERT_VALUES_EQUAL(error, ""); + } + void UploadRows(TTestActorRuntime& runtime, const TString& tablePath, int partitionIdx, const TVector<ui32>& keyTags, const TVector<ui32>& valueTags, const TVector<ui32>& recordIds) { auto tableDesc = DescribePath(runtime, tablePath, true, true); @@ -2271,6 +2301,7 @@ namespace NSchemeShardUT_Private { for (ui32 i : recordIds) { auto key = TVector<TCell>{TCell::Make(i)}; auto value = TVector<TCell>{TCell::Make(i)}; + Cerr << value[0].AsBuf().Size() << Endl; auto& row = *ev->Record.AddRows(); row.SetKeyColumns(TSerializedCellVec::Serialize(key)); diff --git a/ydb/core/tx/schemeshard/ut_helpers/helpers.h b/ydb/core/tx/schemeshard/ut_helpers/helpers.h index 9fa053fa64..f63db2c623 100644 --- a/ydb/core/tx/schemeshard/ut_helpers/helpers.h +++ b/ydb/core/tx/schemeshard/ut_helpers/helpers.h @@ -541,7 +541,8 @@ namespace NSchemeShardUT_Private { void SendTEvPeriodicTopicStats(TTestActorRuntime& runtime, ui64 topicId, ui64 generation, ui64 round, ui64 dataSize, ui64 usedReserveSize); void WriteToTopic(TTestActorRuntime& runtime, const TString& path, ui32& msgSeqNo, const TString& message); - + void WriteRow(TTestActorRuntime& runtime, const TString& key, const TString& value, ui64 tabletId = TTestTxConfig::FakeHiveTablets); + void WriteRowPg(TTestActorRuntime& runtime, const TString& key, ui32 value, ui64 tabletId = TTestTxConfig::FakeHiveTablets); void UploadRows(TTestActorRuntime& runtime, const TString& tablePath, int partitionIdx, const TVector<ui32>& keyTags, const TVector<ui32>& valueTags, const TVector<ui32>& recordIds); } //NSchemeShardUT_Private |