Skip to content

Commit df36813

Browse files
committed
fq cp tests have been moved
1 parent 5cb09f9 commit df36813

13 files changed

+11533
-0
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#include <ydb/core/fq/libs/control_plane_storage/control_plane_storage.h>
2+
3+
#include <ydb/library/actors/core/executor_pool_basic.h>
4+
#include <ydb/library/actors/core/scheduler_basic.h>
5+
#include <library/cpp/testing/unittest/registar.h>
6+
7+
#include <ydb/core/testlib/basics/runtime.h>
8+
#include <ydb/core/testlib/tablet_helpers.h>
9+
10+
#include <ydb/core/fq/libs/control_plane_storage/events/events.h>
11+
#include <ydb/core/fq/libs/ydb/util.h>
12+
#include <ydb/core/fq/libs/ydb/ydb.h>
13+
#include <ydb/core/fq/libs/actors/logging/log.h>
14+
15+
namespace NFq {
16+
17+
using namespace NActors;
18+
using namespace NKikimr;
19+
20+
namespace {
21+
22+
////////////////////////////////////////////////////////////////////////////////
23+
24+
using TRuntimePtr = std::unique_ptr<TTestActorRuntime>;
25+
26+
struct TTestBootstrap {
27+
NConfig::TControlPlaneStorageConfig Config;
28+
TRuntimePtr Runtime;
29+
30+
const TDuration RequestTimeout = TDuration::Seconds(10);
31+
32+
TTestBootstrap()
33+
{
34+
Runtime = PrepareTestActorRuntime();
35+
}
36+
37+
std::pair<FederatedQuery::CreateQueryResult, NYql::TIssues> CreateQuery()
38+
{
39+
TActorId sender = Runtime->AllocateEdgeActor();
40+
FederatedQuery::CreateQueryRequest proto;
41+
42+
FederatedQuery::QueryContent& content = *proto.mutable_content();
43+
content.set_name("my_query_1");
44+
content.set_text("SELECT 1;");
45+
content.set_type(FederatedQuery::QueryContent::ANALYTICS);
46+
content.mutable_acl()->set_visibility(FederatedQuery::Acl::SCOPE);
47+
48+
auto request = std::make_unique<TEvControlPlaneStorage::TEvCreateQueryRequest>("yandexcloud://my_cloud_1/my_folder_1", proto, "user@staff", "", "mock_cloud", TPermissions{}, TQuotaMap{}, std::make_shared<TTenantInfo>(), FederatedQuery::Internal::ComputeDatabaseInternal{});
49+
Runtime->Send(new IEventHandle(ControlPlaneStorageServiceActorId(), sender, request.release()));
50+
51+
TAutoPtr<IEventHandle> handle;
52+
TEvControlPlaneStorage::TEvCreateQueryResponse* event = Runtime->GrabEdgeEvent<TEvControlPlaneStorage::TEvCreateQueryResponse>(handle);
53+
return {event->Result, event->Issues};
54+
}
55+
56+
private:
57+
TRuntimePtr PrepareTestActorRuntime() {
58+
TRuntimePtr runtime(new TTestBasicRuntime(1));
59+
runtime->SetLogPriority(NKikimrServices::YQ_CONTROL_PLANE_STORAGE, NLog::PRI_DEBUG);
60+
61+
auto controlPlaneProxy = CreateInMemoryControlPlaneStorageServiceActor(Config);
62+
63+
runtime->AddLocalService(
64+
ControlPlaneStorageServiceActorId(),
65+
TActorSetupCmd(controlPlaneProxy, TMailboxType::Simple, 0));
66+
67+
SetupTabletServices(*runtime);
68+
69+
return runtime;
70+
}
71+
};
72+
73+
}
74+
75+
Y_UNIT_TEST_SUITE(CreateQueryRequest) {
76+
Y_UNIT_TEST(ShouldCreateSimpleQuery)
77+
{
78+
TTestBootstrap bootstrap;
79+
const auto [result, issues] = bootstrap.CreateQuery();
80+
UNIT_ASSERT(!issues);
81+
}
82+
}
83+
84+
85+
} // NFq
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
UNITTEST_FOR(ydb/core/fq/libs/control_plane_storage)
2+
3+
SUBSCRIBER(g:yq)
4+
5+
SIZE(MEDIUM)
6+
7+
SPLIT_FACTOR(18)
8+
9+
FORK_SUBTESTS()
10+
11+
IF (SANITIZER_TYPE OR WITH_VALGRIND)
12+
SIZE(MEDIUM)
13+
ENDIF()
14+
15+
PEERDIR(
16+
library/cpp/retry
17+
library/cpp/testing/unittest
18+
ydb/core/external_sources
19+
ydb/core/fq/libs/actors/logging
20+
ydb/core/fq/libs/init
21+
ydb/core/fq/libs/quota_manager/events
22+
ydb/core/fq/libs/rate_limiter/control_plane_service
23+
ydb/core/fq/libs/rate_limiter/events
24+
ydb/core/testlib/default
25+
ydb/library/security
26+
)
27+
28+
INCLUDE(${ARCADIA_ROOT}/ydb/public/tools/ydb_recipe/recipe.inc)
29+
30+
YQL_LAST_ABI_VERSION()
31+
32+
SRCS(
33+
in_memory_control_plane_storage_ut.cpp
34+
ydb_control_plane_storage_bindings_permissions_ut.cpp
35+
ydb_control_plane_storage_bindings_ut.cpp
36+
ydb_control_plane_storage_connections_permissions_ut.cpp
37+
ydb_control_plane_storage_connections_ut.cpp
38+
ydb_control_plane_storage_internal_ut.cpp
39+
ydb_control_plane_storage_queries_permissions_ut.cpp
40+
ydb_control_plane_storage_queries_ut.cpp
41+
ydb_control_plane_storage_quotas_ut.cpp
42+
ydb_control_plane_storage_ut.cpp
43+
)
44+
45+
END()

0 commit comments

Comments
 (0)