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
94100void 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-
0 commit comments