aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorildar-khisam <ikhis@ydb.tech>2023-08-01 12:11:43 +0300
committerildar-khisam <ikhis@ydb.tech>2023-08-01 12:11:43 +0300
commit1ab00fd81ce534b158e55f27450d5559833cb70a (patch)
tree667cc7a22d608e2d9582bd8887296cff32c7b80d
parentf7019bf34ad6f821cd40ac2f12c59b315b6b0b1d (diff)
downloadydb-1ab00fd81ce534b158e55f27450d5559833cb70a.tar.gz
test for topic client custom connection
add test
-rw-r--r--ydb/public/sdk/cpp/client/ydb_topic/ut/basic_usage_ut.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/ydb/public/sdk/cpp/client/ydb_topic/ut/basic_usage_ut.cpp b/ydb/public/sdk/cpp/client/ydb_topic/ut/basic_usage_ut.cpp
index c5cd385d07..566c70490b 100644
--- a/ydb/public/sdk/cpp/client/ydb_topic/ut/basic_usage_ut.cpp
+++ b/ydb/public/sdk/cpp/client/ydb_topic/ut/basic_usage_ut.cpp
@@ -19,6 +19,48 @@
namespace NYdb::NTopic::NTests {
Y_UNIT_TEST_SUITE(BasicUsage) {
+ Y_UNIT_TEST(ConnectToYDB) {
+ auto setup = std::make_shared<NPersQueue::NTests::TPersQueueYdbSdkTestSetup>(TEST_CASE_NAME);
+
+ NYdb::TDriverConfig cfg;
+ cfg.SetEndpoint(TStringBuilder() << "invalid:" << setup->GetGrpcPort());
+ cfg.SetDatabase("/Invalid");
+ cfg.SetLog(CreateLogBackend("cerr", ELogPriority::TLOG_DEBUG));
+ auto driver = NYdb::TDriver(cfg);
+
+ {
+ TTopicClient client(driver);
+
+ auto writeSettings = TWriteSessionSettings()
+ .Path(setup->GetTestTopic())
+ .MessageGroupId("group_id")
+ // TODO why retries? see LOGBROKER-8490
+ .RetryPolicy(IRetryPolicy::GetNoRetryPolicy());
+ auto writeSession = client.CreateWriteSession(writeSettings);
+
+ auto event = writeSession->GetEvent(true);
+ UNIT_ASSERT(event.Defined() && std::holds_alternative<TSessionClosedEvent>(event.GetRef()));
+ }
+
+ {
+ auto settings = TTopicClientSettings()
+ .Database({"/Root"})
+ .DiscoveryEndpoint({TStringBuilder() << "localhost:" << setup->GetGrpcPort()});
+
+ TTopicClient client(driver, settings);
+
+ auto writeSettings = TWriteSessionSettings()
+ .Path(setup->GetTestTopic())
+ .MessageGroupId("group_id")
+ .RetryPolicy(IRetryPolicy::GetNoRetryPolicy());
+ auto writeSession = client.CreateWriteSession(writeSettings);
+
+ auto event = writeSession->GetEvent(true);
+ UNIT_ASSERT(event.Defined() && !std::holds_alternative<TSessionClosedEvent>(event.GetRef()));
+ }
+ }
+
+
Y_UNIT_TEST(WriteRead) {
auto setup = std::make_shared<NPersQueue::NTests::TPersQueueYdbSdkTestSetup>(TEST_CASE_NAME);
TTopicClient client(setup->GetDriver());