diff --git a/ydb/core/testlib/common_helper.cpp b/ydb/core/testlib/common_helper.cpp index e3adecb11348..26841ce1af6b 100644 --- a/ydb/core/testlib/common_helper.cpp +++ b/ydb/core/testlib/common_helper.cpp @@ -5,6 +5,7 @@ #include #include +#include #include #include @@ -136,20 +137,18 @@ void THelper::StartDataRequest(const TString& request, const bool expectSuccess, UNIT_ASSERT(resultReady); } -void THelper::StartSchemaRequest(const TString& request, const bool expectSuccess, const bool waiting) const { +void THelper::StartSchemaRequestTableServiceImpl(const TString& request, const bool expectation, const bool waiting) const { NYdb::NTable::TTableClient tClient(Server.GetDriver(), NYdb::NTable::TClientSettings().UseQueryCache(false).AuthToken("root@builtin")); - auto expectation = expectSuccess; std::shared_ptr rrPtr = std::make_shared(false); - TString requestInt = request; - tClient.CreateSession().Subscribe([rrPtr, requestInt, expectation](NThreading::TFuture f) { + tClient.CreateSession().Subscribe([rrPtr, request, expectation](NThreading::TFuture f) { auto session = f.GetValueSync().GetSession(); - session.ExecuteSchemeQuery(requestInt).Subscribe([rrPtr, expectation, requestInt](NYdb::TAsyncStatus f) + session.ExecuteSchemeQuery(request).Subscribe([rrPtr, expectation, request](NYdb::TAsyncStatus f) { TStringStream ss; f.GetValueSync().GetIssues().PrintTo(ss, false); - Cerr << "REQUEST=" << requestInt << ";RESULT=" << ss.Str() << ";EXPECTATION=" << expectation << Endl; + Cerr << "REQUEST=" << request << ";RESULT=" << ss.Str() << ";EXPECTATION=" << expectation << Endl; UNIT_ASSERT(expectation == f.GetValueSync().IsSuccess()); *rrPtr = true; }); @@ -165,6 +164,39 @@ void THelper::StartSchemaRequest(const TString& request, const bool expectSucces } } +void THelper::StartSchemaRequestQueryServiceImpl(const TString& request, const bool expectation, const bool waiting) const { + NYdb::NQuery::TQueryClient qClient(Server.GetDriver(), + NYdb::NQuery::TClientSettings().AuthToken("root@builtin")); + + std::shared_ptr rrPtr = std::make_shared(false); + auto future = qClient.ExecuteQuery(request, NYdb::NQuery::TTxControl::NoTx()); + future.Subscribe([rrPtr, expectation, request](NYdb::NQuery::TAsyncExecuteQueryResult f) + { + TStringStream ss; + f.GetValueSync().GetIssues().PrintTo(ss, false); + Cerr << "REQUEST=" << request << ";RESULT=" << ss.Str() << ";EXPECTATION=" << expectation << Endl; + *rrPtr = true; + }); + Cerr << "REQUEST=" << request << ";EXPECTATION=" << expectation << ";WAITING=" << waiting << Endl; + if (waiting) { + const TInstant start = TInstant::Now(); + while (!*rrPtr && start + TDuration::Seconds(20) > TInstant::Now()) { + Server.GetRuntime()->SimulateSleep(TDuration::Seconds(1)); + } + UNIT_ASSERT(*rrPtr); + UNIT_ASSERT_C(expectation == future.GetValueSync().IsSuccess(), future.GetValueSync().GetIssues().ToString()); + Cerr << "FINISHED_REQUEST=" << request << ";EXPECTATION=" << expectation << ";WAITING=" << waiting << Endl; + } +} + +void THelper::StartSchemaRequest(const TString& request, const bool expectSuccess, const bool waiting) const { + if (UseQueryService) { + StartSchemaRequestQueryServiceImpl(request, expectSuccess, waiting); + } else { + StartSchemaRequestTableServiceImpl(request, expectSuccess, waiting); + } +} + void THelper::DropTable(const TString& tablePath) { auto* runtime = Server.GetRuntime(); Ydb::Table::DropTableRequest request; diff --git a/ydb/core/testlib/common_helper.h b/ydb/core/testlib/common_helper.h index d8b7c55b0442..0160f8e0e8a1 100644 --- a/ydb/core/testlib/common_helper.h +++ b/ydb/core/testlib/common_helper.h @@ -48,13 +48,21 @@ class THelper { void WaitForSchemeOperation(TActorId sender, ui64 txId); void PrintResultSet(const NYdb::TResultSet& resultSet, NYson::TYsonWriter& writer) const; + void StartSchemaRequestTableServiceImpl(const TString& request, const bool expectSuccess, const bool waiting) const; + void StartSchemaRequestQueryServiceImpl(const TString& request, const bool expectSuccess, const bool waiting) const; + Tests::TServer& Server; + bool UseQueryService = false; public: THelper(TServer& server) : Server(server) { } + void SetUseQueryService(bool use = true) { + UseQueryService = use; + } + void DropTable(const TString& tablePath); void StartScanRequest(const TString& request, const bool expectSuccess, TVector>* result) const; diff --git a/ydb/core/testlib/ya.make b/ydb/core/testlib/ya.make index 489c1be52ba6..02a6fa93e415 100644 --- a/ydb/core/testlib/ya.make +++ b/ydb/core/testlib/ya.make @@ -87,6 +87,7 @@ PEERDIR( ydb/public/lib/deprecated/kicli ydb/public/sdk/cpp/client/ydb_driver ydb/public/sdk/cpp/client/ydb_persqueue_public/codecs + ydb/public/sdk/cpp/client/ydb_query ydb/public/sdk/cpp/client/ydb_table ydb/services/auth ydb/services/cms diff --git a/ydb/services/metadata/secret/manager.cpp b/ydb/services/metadata/secret/manager.cpp index 01ea816b08e7..8f4d28516c83 100644 --- a/ydb/services/metadata/secret/manager.cpp +++ b/ydb/services/metadata/secret/manager.cpp @@ -46,18 +46,6 @@ NModifications::TOperationParsingResult TAccessManager::DoBuildPatchFromSettings return result; } -NMetadata::NModifications::IOperationsManager::TYqlConclusionStatus TAccessManager::DoPrepare(NKqpProto::TKqpSchemeOperation& /*schemeOperation*/, const NYql::TObjectSettingsImpl& /*settings*/, - const NMetadata::IClassBehaviour::TPtr& /*manager*/, NMetadata::NModifications::IOperationsManager::TInternalModificationContext& /*context*/) const { - return NMetadata::NModifications::IOperationsManager::TYqlConclusionStatus::Fail( - "Prepare operations for SECRET_ACCESS objects are not supported"); -} - -NThreading::TFuture TAccessManager::ExecutePrepared(const NKqpProto::TKqpSchemeOperation& /*schemeOperation*/, - const ui32 /*nodeId*/, const NMetadata::IClassBehaviour::TPtr& /*manager*/, const IOperationsManager::TExternalModificationContext& /*context*/) const { - return NThreading::MakeFuture(NMetadata::NModifications::IOperationsManager::TYqlConclusionStatus::Fail( - "Execution of prepare operations for SECRET_ACCESS objects is not supported")); -} - NModifications::TOperationParsingResult TSecretManager::DoBuildPatchFromSettings(const NYql::TObjectSettingsImpl& settings, TInternalModificationContext& context) const { static const TString ExtraPathSymbolsAllowed = "!\"#$%&'()*+,-.:;<=>?@[\\]^_`{|}~"; diff --git a/ydb/services/metadata/secret/manager.h b/ydb/services/metadata/secret/manager.h index d83911f67b19..ebaac399d887 100644 --- a/ydb/services/metadata/secret/manager.h +++ b/ydb/services/metadata/secret/manager.h @@ -24,12 +24,6 @@ class TAccessManager: public NModifications::TGenericOperationsManager virtual NModifications::TOperationParsingResult DoBuildPatchFromSettings(const NYql::TObjectSettingsImpl& settings, TInternalModificationContext& context) const override; - - virtual IOperationsManager::TYqlConclusionStatus DoPrepare(NKqpProto::TKqpSchemeOperation& schemeOperation, const NYql::TObjectSettingsImpl& settings, - const NMetadata::IClassBehaviour::TPtr& manager, IOperationsManager::TInternalModificationContext& context) const override; - - virtual NThreading::TFuture ExecutePrepared(const NKqpProto::TKqpSchemeOperation& schemeOperation, - const ui32 nodeId, const NMetadata::IClassBehaviour::TPtr& manager, const IOperationsManager::TExternalModificationContext& context) const override; }; } diff --git a/ydb/services/metadata/secret/ut/ut_secret.cpp b/ydb/services/metadata/secret/ut/ut_secret.cpp index e2bd35421f13..7a5fc1cf6b0e 100644 --- a/ydb/services/metadata/secret/ut/ut_secret.cpp +++ b/ydb/services/metadata/secret/ut/ut_secret.cpp @@ -152,19 +152,23 @@ Y_UNIT_TEST_SUITE(Secret) { } }; - Y_UNIT_TEST(Simple) { + void SimpleImpl(bool useQueryService) { TPortManager pm; ui32 grpcPort = pm.GetPort(); ui32 msgbPort = pm.GetPort(); + NKikimrConfig::TAppConfig appConfig; + appConfig.MutableTableServiceConfig()->SetEnablePreparedDdl(true); + Tests::TServerSettings serverSettings(msgbPort); serverSettings.Port = msgbPort; serverSettings.GrpcPort = grpcPort; serverSettings.SetDomainName("Root") .SetUseRealThreads(false) .SetEnableMetadataProvider(true) - .SetEnableOlapSchemaOperations(true); + .SetEnableOlapSchemaOperations(true) + .SetAppConfig(appConfig); ; Tests::TServer::TPtr server = new Tests::TServer(serverSettings); @@ -185,6 +189,8 @@ Y_UNIT_TEST_SUITE(Secret) { Cerr << "Initialization finished" << Endl; Tests::NCS::THelper lHelper(*server); + lHelper.SetUseQueryService(useQueryService); + lHelper.StartSchemaRequest("CREATE OBJECT secret1 (TYPE SECRET) WITH value = `100`"); lHelper.StartSchemaRequest("UPSERT OBJECT secret1_1 (TYPE SECRET) WITH value = `100`"); lHelper.StartSchemaRequest("UPSERT OBJECT secret1_1 (TYPE SECRET) WITH value = `200`"); @@ -235,19 +241,31 @@ Y_UNIT_TEST_SUITE(Secret) { } } - Y_UNIT_TEST(Validation) { + Y_UNIT_TEST(Simple) { + SimpleImpl(false); + } + + Y_UNIT_TEST(SimpleQueryService) { + SimpleImpl(true); + } + + void ValidationImpl(bool useQueryService) { TPortManager pm; ui32 grpcPort = pm.GetPort(); ui32 msgbPort = pm.GetPort(); + NKikimrConfig::TAppConfig appConfig; + appConfig.MutableTableServiceConfig()->SetEnablePreparedDdl(true); + Tests::TServerSettings serverSettings(msgbPort); serverSettings.Port = msgbPort; serverSettings.GrpcPort = grpcPort; serverSettings.SetDomainName("Root") .SetUseRealThreads(false) .SetEnableMetadataProvider(true) - .SetEnableOlapSchemaOperations(true); + .SetEnableOlapSchemaOperations(true) + .SetAppConfig(appConfig); ; Tests::TServer::TPtr server = new Tests::TServer(serverSettings); @@ -265,6 +283,8 @@ Y_UNIT_TEST_SUITE(Secret) { Cerr << "Initialization finished" << Endl; Tests::NCS::THelper lHelper(*server); + lHelper.SetUseQueryService(useQueryService); + lHelper.StartSchemaRequest("CREATE OBJECT secret-1 (TYPE SECRET) WITH value = `100`", false); lHelper.StartSchemaRequest("ALTER OBJECT secret1 (TYPE SECRET) SET value = `abcde`", false); lHelper.StartSchemaRequest("CREATE OBJECT secret1 (TYPE SECRET) WITH value = `100`"); @@ -281,19 +301,31 @@ Y_UNIT_TEST_SUITE(Secret) { } } - Y_UNIT_TEST(Deactivated) { + Y_UNIT_TEST(Validation) { + ValidationImpl(false); + } + + Y_UNIT_TEST(ValidationQueryService) { + ValidationImpl(true); + } + + void DeactivatedImpl(bool useQueryService) { TPortManager pm; ui32 grpcPort = pm.GetPort(); ui32 msgbPort = pm.GetPort(); + NKikimrConfig::TAppConfig appConfig; + appConfig.MutableTableServiceConfig()->SetEnablePreparedDdl(true); + Tests::TServerSettings serverSettings(msgbPort); serverSettings.Port = msgbPort; serverSettings.GrpcPort = grpcPort; serverSettings.SetDomainName("Root") .SetUseRealThreads(false) .SetEnableMetadataProvider(false) - .SetEnableOlapSchemaOperations(true); + .SetEnableOlapSchemaOperations(true) + .SetAppConfig(appConfig); ; Tests::TServer::TPtr server = new Tests::TServer(serverSettings); @@ -311,8 +343,18 @@ Y_UNIT_TEST_SUITE(Secret) { Cerr << "Initialization finished" << Endl; Tests::NCS::THelper lHelper(*server); + lHelper.SetUseQueryService(useQueryService); + lHelper.StartSchemaRequest("CREATE OBJECT secret1 (TYPE SECRET) WITH value = `100`", false); } } + + Y_UNIT_TEST(Deactivated) { + DeactivatedImpl(false); + } + + Y_UNIT_TEST(DeactivatedQueryService) { + DeactivatedImpl(true); + } } }