diff options
author | kirisha-k <kirisha-k@yandex-team.com> | 2023-05-10 12:43:56 +0300 |
---|---|---|
committer | kirisha-k <kirisha-k@yandex-team.com> | 2023-05-10 12:43:56 +0300 |
commit | cc5864c4a61e0fb13950c8ad0c2067874cddcc2f (patch) | |
tree | 32f62cd136d64d606c3e0a6f81775499db19e537 | |
parent | be715415026f79c27aa5574943b003a3f606a106 (diff) | |
download | ydb-cc5864c4a61e0fb13950c8ad0c2067874cddcc2f.tar.gz |
move some tx helpers to testlib
Mv some tx helpers to testlib
-rw-r--r-- | ydb/core/testlib/CMakeLists.darwin-x86_64.txt | 1 | ||||
-rw-r--r-- | ydb/core/testlib/CMakeLists.linux-aarch64.txt | 1 | ||||
-rw-r--r-- | ydb/core/testlib/CMakeLists.linux-x86_64.txt | 1 | ||||
-rw-r--r-- | ydb/core/testlib/CMakeLists.windows-x86_64.txt | 1 | ||||
-rw-r--r-- | ydb/core/testlib/tx_helpers.cpp | 52 | ||||
-rw-r--r-- | ydb/core/testlib/tx_helpers.h | 12 | ||||
-rw-r--r-- | ydb/core/tx/schemeshard/ut_helpers/helpers.cpp | 41 | ||||
-rw-r--r-- | ydb/core/tx/schemeshard/ut_helpers/helpers.h | 3 |
8 files changed, 69 insertions, 43 deletions
diff --git a/ydb/core/testlib/CMakeLists.darwin-x86_64.txt b/ydb/core/testlib/CMakeLists.darwin-x86_64.txt index b5ca30b917c..485e4984e46 100644 --- a/ydb/core/testlib/CMakeLists.darwin-x86_64.txt +++ b/ydb/core/testlib/CMakeLists.darwin-x86_64.txt @@ -108,4 +108,5 @@ target_sources(ydb-core-testlib PRIVATE ${CMAKE_SOURCE_DIR}/ydb/core/testlib/tablet_helpers.cpp ${CMAKE_SOURCE_DIR}/ydb/core/testlib/tenant_runtime.cpp ${CMAKE_SOURCE_DIR}/ydb/core/testlib/test_client.cpp + ${CMAKE_SOURCE_DIR}/ydb/core/testlib/tx_helpers.cpp ) diff --git a/ydb/core/testlib/CMakeLists.linux-aarch64.txt b/ydb/core/testlib/CMakeLists.linux-aarch64.txt index 87c8de49023..1d8990c7e80 100644 --- a/ydb/core/testlib/CMakeLists.linux-aarch64.txt +++ b/ydb/core/testlib/CMakeLists.linux-aarch64.txt @@ -109,4 +109,5 @@ target_sources(ydb-core-testlib PRIVATE ${CMAKE_SOURCE_DIR}/ydb/core/testlib/tablet_helpers.cpp ${CMAKE_SOURCE_DIR}/ydb/core/testlib/tenant_runtime.cpp ${CMAKE_SOURCE_DIR}/ydb/core/testlib/test_client.cpp + ${CMAKE_SOURCE_DIR}/ydb/core/testlib/tx_helpers.cpp ) diff --git a/ydb/core/testlib/CMakeLists.linux-x86_64.txt b/ydb/core/testlib/CMakeLists.linux-x86_64.txt index 87c8de49023..1d8990c7e80 100644 --- a/ydb/core/testlib/CMakeLists.linux-x86_64.txt +++ b/ydb/core/testlib/CMakeLists.linux-x86_64.txt @@ -109,4 +109,5 @@ target_sources(ydb-core-testlib PRIVATE ${CMAKE_SOURCE_DIR}/ydb/core/testlib/tablet_helpers.cpp ${CMAKE_SOURCE_DIR}/ydb/core/testlib/tenant_runtime.cpp ${CMAKE_SOURCE_DIR}/ydb/core/testlib/test_client.cpp + ${CMAKE_SOURCE_DIR}/ydb/core/testlib/tx_helpers.cpp ) diff --git a/ydb/core/testlib/CMakeLists.windows-x86_64.txt b/ydb/core/testlib/CMakeLists.windows-x86_64.txt index b5ca30b917c..485e4984e46 100644 --- a/ydb/core/testlib/CMakeLists.windows-x86_64.txt +++ b/ydb/core/testlib/CMakeLists.windows-x86_64.txt @@ -108,4 +108,5 @@ target_sources(ydb-core-testlib PRIVATE ${CMAKE_SOURCE_DIR}/ydb/core/testlib/tablet_helpers.cpp ${CMAKE_SOURCE_DIR}/ydb/core/testlib/tenant_runtime.cpp ${CMAKE_SOURCE_DIR}/ydb/core/testlib/test_client.cpp + ${CMAKE_SOURCE_DIR}/ydb/core/testlib/tx_helpers.cpp ) diff --git a/ydb/core/testlib/tx_helpers.cpp b/ydb/core/testlib/tx_helpers.cpp new file mode 100644 index 00000000000..9dd4864318a --- /dev/null +++ b/ydb/core/testlib/tx_helpers.cpp @@ -0,0 +1,52 @@ +#include "tx_helpers.h" + +#include <google/protobuf/text_format.h> + +#include <library/cpp/testing/unittest/registar.h> + +#include <ydb/core/base/tablet.h> +#include <ydb/core/testlib/tablet_helpers.h> + +namespace NKikimr { + +NKikimrProto::EReplyStatus LocalSchemeTx(TTestActorRuntime& runtime, ui64 tabletId, const TString& schemeChangesStr, bool dryRun, + NTabletFlatScheme::TSchemeChanges& scheme, TString& err) { + TActorId sender = runtime.AllocateEdgeActor(); + + auto evTx = new TEvTablet::TEvLocalSchemeTx; + evTx->Record.SetDryRun(dryRun); + auto schemeChanges = evTx->Record.MutableSchemeChanges(); + bool parseResult = ::google::protobuf::TextFormat::ParseFromString(schemeChangesStr, schemeChanges); + UNIT_ASSERT_C(parseResult, "protobuf parsing failed"); + + ForwardToTablet(runtime, tabletId, sender, evTx); + + TAutoPtr<IEventHandle> handle; + auto event = runtime.GrabEdgeEvent<TEvTablet::TEvLocalSchemeTxResponse>(handle); + UNIT_ASSERT(event); + + err = event->Record.GetErrorReason(); + scheme.CopyFrom(event->Record.GetFullScheme()); + + // emulate enum behavior from proto3 + return static_cast<NKikimrProto::EReplyStatus>(event->Record.GetStatus()); +} + +ui64 GetExecutorCacheSize(TTestActorRuntime& runtime, ui64 tabletId) { + NTabletFlatScheme::TSchemeChanges scheme; + TString err; + NKikimrProto::EReplyStatus status = LocalSchemeTx(runtime, tabletId, "", true, scheme, err); + UNIT_ASSERT_VALUES_EQUAL(status, NKikimrProto::EReplyStatus::OK); + //Cdbg << scheme << "\n"; + // looking for "Delta { DeltaType: UpdateExecutorInfo ExecutorCacheSize: 33554432 }" + for (ui32 i = 0; i < scheme.DeltaSize(); ++i) { + const auto& d = scheme.GetDelta(i); + if (d.GetDeltaType() == NTabletFlatScheme::TAlterRecord::UpdateExecutorInfo) { + return d.GetExecutorCacheSize(); + } + } + UNIT_ASSERT_C(false, "UpdateExecutorInfo delta record not found"); + return -1; +} + +} // namespace NKikimr diff --git a/ydb/core/testlib/tx_helpers.h b/ydb/core/testlib/tx_helpers.h new file mode 100644 index 00000000000..f3f4145a4ac --- /dev/null +++ b/ydb/core/testlib/tx_helpers.h @@ -0,0 +1,12 @@ +#pragma once + +#include <ydb/core/protos/scheme_log.pb.h> +#include <ydb/core/testlib/actors/test_runtime.h> + +namespace NKikimr { + +NKikimrProto::EReplyStatus LocalSchemeTx(TTestActorRuntime& runtime, ui64 tabletId, const TString& schemeChangesStr, bool dryRun, NTabletFlatScheme::TSchemeChanges& scheme, TString& err); + +ui64 GetExecutorCacheSize(TTestActorRuntime& runtime, ui64 tabletId); + +} // namespace NKikimr diff --git a/ydb/core/tx/schemeshard/ut_helpers/helpers.cpp b/ydb/core/tx/schemeshard/ut_helpers/helpers.cpp index 9f66ddeff93..78538b16141 100644 --- a/ydb/core/tx/schemeshard/ut_helpers/helpers.cpp +++ b/ydb/core/tx/schemeshard/ut_helpers/helpers.cpp @@ -1263,29 +1263,6 @@ namespace NSchemeShardUT_Private { return result.GetValue().GetStruct(0).GetOptional().HasOptional(); } - NKikimrProto::EReplyStatus LocalSchemeTx(TTestActorRuntime& runtime, ui64 tabletId, const TString& schemeChangesStr, bool dryRun, - NTabletFlatScheme::TSchemeChanges& scheme, TString& err) { - TActorId sender = runtime.AllocateEdgeActor(); - - auto evTx = new TEvTablet::TEvLocalSchemeTx; - evTx->Record.SetDryRun(dryRun); - auto schemeChanges = evTx->Record.MutableSchemeChanges(); - bool parseResult = ::google::protobuf::TextFormat::ParseFromString(schemeChangesStr, schemeChanges); - UNIT_ASSERT_C(parseResult, "protobuf parsing failed"); - - ForwardToTablet(runtime, tabletId, sender, evTx); - - TAutoPtr<IEventHandle> handle; - auto event = runtime.GrabEdgeEvent<TEvTablet::TEvLocalSchemeTxResponse>(handle); - UNIT_ASSERT(event); - - err = event->Record.GetErrorReason(); - scheme.CopyFrom(event->Record.GetFullScheme()); - - // emulate enum behavior from proto3 - return static_cast<NKikimrProto::EReplyStatus>(event->Record.GetStatus()); - } - ui64 GetDatashardState(TTestActorRuntime& runtime, ui64 tabletId) { NKikimrMiniKQL::TResult result; TString err; @@ -1346,24 +1323,6 @@ namespace NSchemeShardUT_Private { return GetDatashardSysTableValue(runtime, tabletId, 20); } - ui64 GetExecutorCacheSize(TTestActorRuntime& runtime, ui64 tabletId) { - NTabletFlatScheme::TSchemeChanges scheme; - TString err; - NKikimrProto::EReplyStatus status = LocalSchemeTx(runtime, tabletId, "", true, scheme, err); - UNIT_ASSERT_VALUES_EQUAL(status, NKikimrProto::EReplyStatus::OK); - //Cdbg << scheme << "\n"; - // looking for "Delta { DeltaType: UpdateExecutorInfo ExecutorCacheSize: 33554432 }" - for (ui32 i = 0; i < scheme.DeltaSize(); ++i) { - const auto& d = scheme.GetDelta(i); - if (d.GetDeltaType() == NTabletFlatScheme::TAlterRecord::UpdateExecutorInfo) { - return d.GetExecutorCacheSize(); - } - } - UNIT_ASSERT_C(false, "UpdateExecutorInfo delta record not found"); - return -1; - } - - bool GetFastLogPolicy(TTestActorRuntime& runtime, ui64 tabletId) { NTabletFlatScheme::TSchemeChanges scheme; TString err; diff --git a/ydb/core/tx/schemeshard/ut_helpers/helpers.h b/ydb/core/tx/schemeshard/ut_helpers/helpers.h index ed822ab77b8..57bdfb7e003 100644 --- a/ydb/core/tx/schemeshard/ut_helpers/helpers.h +++ b/ydb/core/tx/schemeshard/ut_helpers/helpers.h @@ -8,6 +8,7 @@ #include <ydb/core/engine/mkql_engine_flat.h> #include <ydb/core/persqueue/ut/common/pq_ut_common.h> #include <ydb/core/protos/tx_datashard.pb.h> +#include <ydb/core/testlib/tx_helpers.h> #include <ydb/core/testlib/minikql_compile.h> #include <ydb/core/tx/datashard/datashard.h> #include <ydb/core/tx/scheme_cache/scheme_cache.h> @@ -61,7 +62,6 @@ namespace NSchemeShardUT_Private { ////////// tablet NKikimrProto::EReplyStatus LocalMiniKQL(TTestActorRuntime& runtime, ui64 tabletId, const TString& query, NKikimrMiniKQL::TResult& result, TString& err); NKikimrMiniKQL::TResult LocalMiniKQL(TTestActorRuntime& runtime, ui64 tabletId, const TString& query); - NKikimrProto::EReplyStatus LocalSchemeTx(TTestActorRuntime& runtime, ui64 tabletId, const TString& schemeChangesStr, bool dryRun, NTabletFlatScheme::TSchemeChanges& scheme, TString& err); bool CheckLocalRowExists(TTestActorRuntime& runtime, ui64 tabletId, const TString& tableName, const TString& keyColumn, ui64 keyValue); @@ -401,7 +401,6 @@ namespace NSchemeShardUT_Private { ui64 GetTxReadSizeLimit(TTestActorRuntime& runtime, ui64 tabletId); ui64 GetStatDisabled(TTestActorRuntime& runtime, ui64 tabletId); - ui64 GetExecutorCacheSize(TTestActorRuntime& runtime, ui64 tabletId); bool GetFastLogPolicy(TTestActorRuntime& runtime, ui64 tabletId); bool GetByKeyFilterEnabled(TTestActorRuntime& runtime, ui64 tabletId, ui32 table); bool GetEraseCacheEnabled(TTestActorRuntime& runtime, ui64 tabletId, ui32 table); |