Skip to content

Import YDB C++ SDK 13 #526

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jun 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/import_generation.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
13
14
2 changes: 1 addition & 1 deletion .github/last_commit.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6e380d54416c706390bbe2609c7a054de2bf3b89
71f3186a075dd5aa34e2840ef29fc3958a89d2fa
20 changes: 20 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,26 @@
"name": "release-test-gcc",
"inherits": ["release-base", "gcc-toolchain", "test"],
"displayName": "Default Release Test Config (GCC)"
},
{
"name": "debug-clang",
"inherits": ["debug-base", "clang-toolchain"],
"displayName": "Default Debug Config (Clang)"
},
{
"name": "debug-gcc",
"inherits": ["debug-base", "gcc-toolchain"],
"displayName": "Default Debug Config (GCC)"
},
{
"name": "debug-test-clang",
"inherits": ["debug-base", "clang-toolchain", "test"],
"displayName": "Default Debug Test Config (Clang)"
},
{
"name": "debug-test-gcc",
"inherits": ["debug-base", "gcc-toolchain", "test"],
"displayName": "Default Debug Test Config (GCC)"
}
],
"buildPresets": [
Expand Down
36 changes: 28 additions & 8 deletions cmake/testing.cmake
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
enable_testing()

find_package(GTest REQUIRED)
include(FetchContent)

FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG 1.15.2
FIND_PACKAGE_ARGS NAMES GTest
)

FetchContent_MakeAvailable(googletest)

include(GoogleTest)

function(add_ydb_test)
set(opts GTEST)
set(oneval_args NAME WORKING_DIRECTORY OUTPUT_DIRECTORY)
set(multival_args INCLUDE_DIRS SOURCES LINK_LIBRARIES LABELS TEST_ARG)
set(multival_args INCLUDE_DIRS SOURCES LINK_LIBRARIES LABELS TEST_ARG ENV)
cmake_parse_arguments(YDB_TEST
"${opts}"
"${oneval_args}"
Expand Down Expand Up @@ -49,16 +59,24 @@ function(add_ydb_test)
endif()

if (YDB_TEST_GTEST)
set(env_vars "")
foreach(env_var ${YDB_TEST_ENV})
list(APPEND env_vars "ENVIRONMENT")
list(APPEND env_vars ${env_var})
endforeach()

gtest_discover_tests(${YDB_TEST_NAME}
EXTRA_ARGS ${YDB_TEST_TEST_ARG}
WORKING_DIRECTORY ${YDB_TEST_WORKING_DIRECTORY}
PROPERTIES LABELS ${YDB_TEST_LABELS}
PROPERTIES PROCESSORS 1
PROPERTIES TIMEOUT 600
PROPERTIES
LABELS ${YDB_TEST_LABELS}
ENVIRONMENT "YDB_TEST_ROOT=sdk_tests"
${env_vars}
)

target_link_libraries(${YDB_TEST_NAME} PRIVATE
GTest::gtest_main
GTest::gtest_main
GTest::gmock_main
)
else()
add_test(NAME ${YDB_TEST_NAME}
Expand All @@ -77,8 +95,10 @@ function(add_ydb_test)
)

set_tests_properties(${YDB_TEST_NAME} PROPERTIES LABELS ${YDB_TEST_LABELS})
set_tests_properties(${YDB_TEST_NAME} PROPERTIES PROCESSORS 1)
set_tests_properties(${YDB_TEST_NAME} PROPERTIES TIMEOUT 600)
set_tests_properties(${YDB_TEST_NAME} PROPERTIES ENVIRONMENT "YDB_TEST_ROOT=sdk_tests")
if (YDB_TEST_ENV)
set_tests_properties(${YDB_TEST_NAME} PROPERTIES ENVIRONMENT ${YDB_TEST_ENV})
endif()
endif()

vcs_info(${YDB_TEST_NAME})
Expand Down
1 change: 1 addition & 0 deletions include/ydb-cpp-sdk/client/iam/common/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ struct TIamEndpoint {
TDuration RefreshPeriod = NIam::DEFAULT_REFRESH_PERIOD;
TDuration RequestTimeout = NIam::DEFAULT_REQUEST_TIMEOUT;
bool EnableSsl = NIam::DEFAULT_ENABLE_SSL;
std::string CaCerts;
};

struct TIamJwtFilename : TIamEndpoint { std::string JwtFilename; };
Expand Down
1 change: 1 addition & 0 deletions include/ydb-cpp-sdk/client/query/query.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ std::string_view StatsModeToString(const EStatsMode statsMode);
enum class EExecStatus {
Unspecified = 0,
Starting = 10,
Running = 15,
Aborted = 20,
Canceled = 30,
Completed = 40,
Expand Down
1 change: 1 addition & 0 deletions src/api/protos/ydb_query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ message ExecuteScriptRequest {
enum ExecStatus {
EXEC_STATUS_UNSPECIFIED = 0;
EXEC_STATUS_STARTING = 10;
EXEC_STATUS_RUNNING = 15;
EXEC_STATUS_ABORTED = 20;
EXEC_STATUS_CANCELLED = 30;
EXEC_STATUS_COMPLETED = 40;
Expand Down
3 changes: 3 additions & 0 deletions src/client/iam/common/iam.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ class TGrpcIamCredentialsProvider : public ICredentialsProvider {
NYdbGrpc::TGRpcClientConfig grpcConf;
grpcConf.Locator = IamEndpoint_.Endpoint;
grpcConf.EnableSsl = IamEndpoint_.EnableSsl;
if (!IamEndpoint_.CaCerts.empty()) {
grpcConf.SslCredentials.pem_root_certs = IamEndpoint_.CaCerts;
}
Connection_ = std::unique_ptr<NYdbGrpc::TServiceConnection<TService>>(Client->CreateGRpcServiceConnection<TService>(grpcConf).release());
}

Expand Down
107 changes: 1 addition & 106 deletions src/client/topic/ut/describe_topic_ut.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
#include "ut_utils/topic_sdk_test_setup.h"

#include <format>
#include <src/library/persqueue/topic_parser_public/topic_parser.h>
#include <src/api/protos/persqueue_error_codes_v1.pb.h>
#include <ydb-cpp-sdk/client/topic/client.h>
#include <src/client/persqueue_public/persqueue.h>
#include <src/client/topic/common/log_lazy.h>
#include <src/client/topic/impl/common.h>

#include <library/cpp/testing/unittest/registar.h>
#include <library/cpp/testing/unittest/tests_data.h>
#include <library/cpp/threading/future/future.h>
#include <library/cpp/threading/future/async.h>

namespace NYdb::NTopic::NTests {

Expand Down Expand Up @@ -258,106 +249,10 @@ namespace NYdb::NTopic::NTests {
}
}

Y_UNIT_TEST(Basic) {
Y_UNIT_TEST(LocationWithKillTablets) {
TTopicSdkTestSetup setup(TEST_CASE_NAME);
TTopicClient client = setup.MakeClient();

DescribeTopic(setup, client, false, false, false, false);
DescribeConsumer(setup, client, false, false, false, false);
DescribePartition(setup, client, false, false, false, false);
}

Y_UNIT_TEST(Statistics) {
// TODO(abcdef): temporarily deleted
return;

TTopicSdkTestSetup setup(TEST_CASE_NAME);
TTopicClient client = setup.MakeClient();

// Get empty description
DescribeTopic(setup, client, true, false, false, false);
DescribeConsumer(setup, client, true, false, false, false);
DescribePartition(setup, client, true, false, false, false);

const size_t messagesCount = 1;

// Write a message
{
auto writeSettings = TWriteSessionSettings().Path(TEST_TOPIC).MessageGroupId(TEST_MESSAGE_GROUP_ID).Codec(ECodec::RAW);
auto writeSession = client.CreateSimpleBlockingWriteSession(writeSettings);
std::string message(32_MB, 'x');

for(size_t i = 0; i < messagesCount; ++i) {
UNIT_ASSERT(writeSession->Write(message, {}, TInstant::Now() - TDuration::Seconds(100)));
}
writeSession->Close();
}

// Read a message
{
auto readSettings = TReadSessionSettings().ConsumerName(TEST_CONSUMER).AppendTopics(TEST_TOPIC);
auto readSession = client.CreateReadSession(readSettings);

// Event 1: start partition session
{
std::optional<TReadSessionEvent::TEvent> event = readSession->GetEvent(true);
UNIT_ASSERT(event);
auto startPartitionSession = std::get_if<TReadSessionEvent::TStartPartitionSessionEvent>(&event.value());
UNIT_ASSERT_C(startPartitionSession, DebugString(*event));

startPartitionSession->Confirm();
}

// Event 2: data received
{
std::optional<TReadSessionEvent::TEvent> event = readSession->GetEvent(true);
UNIT_ASSERT(event);
auto dataReceived = std::get_if<TReadSessionEvent::TDataReceivedEvent>(&event.value());
UNIT_ASSERT_C(dataReceived, DebugString(*event));

dataReceived->Commit();
}

// Event 3: commit acknowledgement
{
std::optional<TReadSessionEvent::TEvent> event = readSession->GetEvent(true);
UNIT_ASSERT(event);
auto commitOffsetAck = std::get_if<TReadSessionEvent::TCommitOffsetAcknowledgementEvent>(&event.value());

UNIT_ASSERT_C(commitOffsetAck, DebugString(*event));

UNIT_ASSERT_VALUES_EQUAL(commitOffsetAck->GetCommittedOffset(), messagesCount);
}
}

// Additional write
{
auto writeSettings = TWriteSessionSettings().Path(TEST_TOPIC).MessageGroupId(TEST_MESSAGE_GROUP_ID).Codec(ECodec::RAW);
auto writeSession = client.CreateSimpleBlockingWriteSession(writeSettings);
std::string message(32, 'x');

for(size_t i = 0; i < messagesCount; ++i) {
UNIT_ASSERT(writeSession->Write(message));
}
writeSession->Close();
}
Sleep(TDuration::Seconds(3));

// Get non-empty description

DescribeTopic(setup, client, true, true, false, false);
DescribeConsumer(setup, client, true, true, false, false);
DescribePartition(setup, client, true, true, false, false);
}

Y_UNIT_TEST(Location) {
TTopicSdkTestSetup setup(TEST_CASE_NAME);
TTopicClient client = setup.MakeClient();

DescribeTopic(setup, client, false, false, true, false);
DescribeConsumer(setup, client, false, false, true, false);
DescribePartition(setup, client, false, false, true, false);

// Describe with KillTablets
DescribeTopic(setup, client, false, false, true, true);
DescribeConsumer(setup, client, false, false, true, true);
Expand Down
Loading
Loading