Skip to content

Commit ad59a86

Browse files
authored
Attempt to use recipe for SDK tests (#3455)
Changelog entry The idea is to reduce number of UT binary statically linked with YDB. Recipe allow to use one binary for multiple tests. Changelog category Not for changelog (changelog entry is not required)
1 parent f6cd31c commit ad59a86

File tree

5 files changed

+39
-51
lines changed

5 files changed

+39
-51
lines changed

ydb/services/ydb/sdk_credprovider_ut/ya.make

Lines changed: 0 additions & 33 deletions
This file was deleted.

ydb/services/ydb/ya.make

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ PEERDIR(
3636
END()
3737

3838
RECURSE_FOR_TESTS(
39-
sdk_credprovider_ut
4039
sdk_sessions_ut
4140
sdk_sessions_pool_ut
4241
table_split_ut

ydb/services/ydb/sdk_credprovider_ut/dummy_provider_ut.cpp renamed to ydb/tests/functional/sdk/cpp/sdk_credprovider/dummy_provider_ut.cpp

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
#include <ydb/services/ydb/ydb_common_ut.h>
1+
#include <util/system/env.h>
2+
#include <library/cpp/testing/unittest/registar.h>
3+
4+
#include <ydb/public/api/grpc/ydb_table_v1.grpc.pb.h>
5+
26
#include <ydb/public/sdk/cpp/client/ydb_table/table.h>
37
#include <ydb/public/sdk/cpp/client/ydb_types/core_facility/core_facility.h>
48

@@ -27,25 +31,27 @@ class TExampleDummyProviderFactory : public ICredentialsProviderFactory {
2731
if (!strong)
2832
return false;
2933

30-
auto responseCb = [this](Draft::Dummy::PingResponse* resp, TPlainStatus status) -> void {
34+
auto responseCb = [this](Ydb::Table::CreateSessionResponse* resp, TPlainStatus status) -> void {
3135
if (status.Status == EStatus::CLIENT_CANCELLED)
3236
return;
3337

3438
UNIT_ASSERT_C(status.Ok(), status.Status);
35-
UNIT_ASSERT_VALUES_EQUAL(resp->payload(), "abc");
39+
UNIT_ASSERT(resp->operation().ready());
3640
(*RunCnt)++;
3741
};
3842

39-
Draft::Dummy::PingRequest request;
40-
request.set_copy(true);
41-
request.set_payload("abc");
43+
// use CreateSession as ping pong
44+
Ydb::Table::CreateSessionRequest request;
4245

4346
TRpcRequestSettings rpcSettings;
4447
rpcSettings.ClientTimeout = TDuration::Seconds(1);
4548

46-
TGRpcConnectionsImpl::RunOnDiscoveryEndpoint<Draft::Dummy::DummyService, Draft::Dummy::PingRequest, Draft::Dummy::PingResponse>(
47-
strong, std::move(request), std::move(responseCb), &Draft::Dummy::DummyService::Stub::AsyncPing,
48-
rpcSettings);
49+
TGRpcConnectionsImpl::RunOnDiscoveryEndpoint<Ydb::Table::V1::TableService,
50+
Ydb::Table::CreateSessionRequest, Ydb::Table::CreateSessionResponse>
51+
(
52+
strong, std::move(request), std::move(responseCb), &Ydb::Table::V1::TableService::Stub::AsyncCreateSession,
53+
rpcSettings
54+
);
4955
return true;
5056
};
5157
return periodicCb;
@@ -92,17 +98,13 @@ class TExampleDummyProviderFactory : public ICredentialsProviderFactory {
9298
};
9399

94100
void RunTest(bool sync) {
95-
TKikimrWithGrpcAndRootSchema server;
96-
ui16 grpc = server.GetPort();
97-
98-
TString location = TStringBuilder() << "localhost:" << grpc;
99-
100101
int runCnt = 0;
101102
int maxWait = 10;
102103

104+
TString connectionString = GetEnv("YDB_ENDPOINT") + "/?database=" + GetEnv("YDB_DATABASE");
105+
103106
auto driver = NYdb::TDriver(
104-
TDriverConfig()
105-
.SetEndpoint(location)
107+
TDriverConfig(connectionString)
106108
.SetDiscoveryMode(sync ? EDiscoveryMode::Sync : EDiscoveryMode::Async)
107109
.SetCredentialsProviderFactory(std::make_shared<TExampleDummyProviderFactory>(&runCnt)));
108110
// Creates DbDriverState in case of empty database
@@ -128,4 +130,3 @@ Y_UNIT_TEST_SUITE(SdkCredProvider) {
128130
RunTest(false);
129131
}
130132
}
131-
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
UNITTEST()
2+
3+
SRCS(
4+
dummy_provider_ut.cpp
5+
)
6+
7+
PEERDIR(
8+
ydb/public/sdk/cpp/client/ydb_scheme
9+
ydb/public/sdk/cpp/client/ydb_table
10+
ydb/public/api/grpc
11+
)
12+
13+
14+
INCLUDE(${ARCADIA_ROOT}/ydb/public/tools/ydb_recipe/recipe.inc)
15+
16+
SIZE(MEDIUM)
17+
18+
REQUIREMENTS(ram:16)
19+
20+
END()

ydb/tests/functional/ya.make

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ RECURSE(
2121
scheme_tests
2222
serializable
2323
serverless
24+
sdk/cpp/sdk_credprovider
2425
sqs
2526
suite_tests
2627
tenants

0 commit comments

Comments
 (0)