Skip to content

Commit 2132566

Browse files
committed
Updated CMakeLists for import 13
1 parent 2e4742b commit 2132566

File tree

11 files changed

+137
-36
lines changed

11 files changed

+137
-36
lines changed

CMakePresets.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,26 @@
7878
"name": "release-test-gcc",
7979
"inherits": ["release-base", "gcc-toolchain", "test"],
8080
"displayName": "Default Release Test Config (GCC)"
81+
},
82+
{
83+
"name": "debug-clang",
84+
"inherits": ["debug-base", "clang-toolchain"],
85+
"displayName": "Default Debug Config (Clang)"
86+
},
87+
{
88+
"name": "debug-gcc",
89+
"inherits": ["debug-base", "gcc-toolchain"],
90+
"displayName": "Default Debug Config (GCC)"
91+
},
92+
{
93+
"name": "debug-test-clang",
94+
"inherits": ["debug-base", "clang-toolchain", "test"],
95+
"displayName": "Default Debug Test Config (Clang)"
96+
},
97+
{
98+
"name": "debug-test-gcc",
99+
"inherits": ["debug-base", "gcc-toolchain", "test"],
100+
"displayName": "Default Debug Test Config (GCC)"
81101
}
82102
],
83103
"buildPresets": [

cmake/testing.cmake

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
11
enable_testing()
22

3-
find_package(GTest REQUIRED)
3+
include(FetchContent)
4+
5+
FetchContent_Declare(
6+
googletest
7+
GIT_REPOSITORY https://github.com/google/googletest.git
8+
GIT_TAG 1.15.2
9+
FIND_PACKAGE_ARGS NAMES GTest
10+
)
11+
12+
FetchContent_MakeAvailable(googletest)
13+
414
include(GoogleTest)
515

616
function(add_ydb_test)
717
set(opts GTEST)
818
set(oneval_args NAME WORKING_DIRECTORY OUTPUT_DIRECTORY)
9-
set(multival_args INCLUDE_DIRS SOURCES LINK_LIBRARIES LABELS TEST_ARG)
19+
set(multival_args INCLUDE_DIRS SOURCES LINK_LIBRARIES LABELS TEST_ARG ENV)
1020
cmake_parse_arguments(YDB_TEST
1121
"${opts}"
1222
"${oneval_args}"
@@ -49,16 +59,24 @@ function(add_ydb_test)
4959
endif()
5060

5161
if (YDB_TEST_GTEST)
62+
set(env_vars "")
63+
foreach(env_var ${YDB_TEST_ENV})
64+
list(APPEND env_vars "ENVIRONMENT")
65+
list(APPEND env_vars ${env_var})
66+
endforeach()
67+
5268
gtest_discover_tests(${YDB_TEST_NAME}
5369
EXTRA_ARGS ${YDB_TEST_TEST_ARG}
5470
WORKING_DIRECTORY ${YDB_TEST_WORKING_DIRECTORY}
55-
PROPERTIES LABELS ${YDB_TEST_LABELS}
56-
PROPERTIES PROCESSORS 1
57-
PROPERTIES TIMEOUT 600
71+
PROPERTIES
72+
LABELS ${YDB_TEST_LABELS}
73+
ENVIRONMENT "YDB_TEST_ROOT=sdk_tests"
74+
${env_vars}
5875
)
5976

6077
target_link_libraries(${YDB_TEST_NAME} PRIVATE
61-
GTest::gtest_main
78+
GTest::gtest_main
79+
GTest::gmock_main
6280
)
6381
else()
6482
add_test(NAME ${YDB_TEST_NAME}
@@ -77,8 +95,10 @@ function(add_ydb_test)
7795
)
7896

7997
set_tests_properties(${YDB_TEST_NAME} PROPERTIES LABELS ${YDB_TEST_LABELS})
80-
set_tests_properties(${YDB_TEST_NAME} PROPERTIES PROCESSORS 1)
81-
set_tests_properties(${YDB_TEST_NAME} PROPERTIES TIMEOUT 600)
98+
set_tests_properties(${YDB_TEST_NAME} PROPERTIES ENVIRONMENT "YDB_TEST_ROOT=sdk_tests")
99+
if (YDB_TEST_ENV)
100+
set_tests_properties(${YDB_TEST_NAME} PROPERTIES ENVIRONMENT ${YDB_TEST_ENV})
101+
endif()
82102
endif()
83103

84104
vcs_info(${YDB_TEST_NAME})

include/ydb-cpp-sdk/library/retry/retry_policy.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#pragma once
22

33
#include <util/datetime/base.h>
4+
#include <util/generic/maybe.h>
45
#include <util/generic/typetraits.h>
56
#include <util/random/random.h>
67

@@ -41,7 +42,7 @@ struct IRetryPolicy {
4142

4243
//! Calculate delay before next retry if next retry is allowed.
4344
//! Returns empty maybe if retry is not allowed anymore.
44-
[[nodiscard]] virtual std::optional<TDuration> GetNextRetryDelay(typename TTypeTraits<TArgs>::TFuncParam... args) = 0;
45+
[[nodiscard]] virtual TMaybe<TDuration> GetNextRetryDelay(typename TTypeTraits<TArgs>::TFuncParam... args) = 0;
4546
};
4647

4748
virtual ~IRetryPolicy() = default;
@@ -81,8 +82,8 @@ struct TNoRetryPolicy : IRetryPolicy<TArgs...> {
8182
using IRetryState = typename IRetryPolicy<TArgs...>::IRetryState;
8283

8384
struct TNoRetryState : IRetryState {
84-
std::optional<TDuration> GetNextRetryDelay(typename TTypeTraits<TArgs>::TFuncParam...) override {
85-
return std::nullopt;
85+
TMaybe<TDuration> GetNextRetryDelay(typename TTypeTraits<TArgs>::TFuncParam...) override {
86+
return {};
8687
}
8788
};
8889

@@ -123,10 +124,10 @@ struct TExponentialBackoffPolicy : IRetryPolicy<TArgs...> {
123124
{
124125
}
125126

126-
std::optional<TDuration> GetNextRetryDelay(typename TTypeTraits<TArgs>::TFuncParam... args) override {
127+
TMaybe<TDuration> GetNextRetryDelay(typename TTypeTraits<TArgs>::TFuncParam... args) override {
127128
const ERetryErrorClass errorClass = RetryClassFunction(args...);
128129
if (errorClass == ERetryErrorClass::NoRetry || AttemptsDone >= MaxRetries || StartTime && TInstant::Now() - StartTime >= MaxTime) {
129-
return std::nullopt;
130+
return {};
130131
}
131132

132133
if (errorClass == ERetryErrorClass::LongRetry) {
@@ -212,10 +213,10 @@ struct TFixedIntervalPolicy : IRetryPolicy<TArgs...> {
212213
{
213214
}
214215

215-
std::optional<TDuration> GetNextRetryDelay(typename TTypeTraits<TArgs>::TFuncParam... args) override {
216+
TMaybe<TDuration> GetNextRetryDelay(typename TTypeTraits<TArgs>::TFuncParam... args) override {
216217
const ERetryErrorClass errorClass = RetryClassFunction(args...);
217218
if (errorClass == ERetryErrorClass::NoRetry || AttemptsDone >= MaxRetries || StartTime && TInstant::Now() - StartTime >= MaxTime) {
218-
return std::nullopt;
219+
return {};
219220
}
220221

221222
const TDuration delay = NRetryDetails::RandomizeDelay(errorClass == ERetryErrorClass::LongRetry ? LongRetryDelay : Delay);

src/library/retry/retry.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ class TRetryOptionsWithRetCodePolicy : public IRetryPolicy<bool> {
1717
{
1818
}
1919

20-
std::optional<TDuration> GetNextRetryDelay(bool ret) override {
20+
TMaybe<TDuration> GetNextRetryDelay(bool ret) override {
2121
if (ret || Attempt == Opts.RetryCount) {
22-
return std::nullopt;
22+
return {};
2323
}
2424
return Opts.GetTimeToSleep(Attempt++);
2525
}

src/library/retry/retry.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ class TRetryOptionsPolicy : public IRetryPolicy<const TException&> {
104104
{
105105
}
106106

107-
std::optional<TDuration> GetNextRetryDelay(const TException&) override {
107+
TMaybe<TDuration> GetNextRetryDelay(const TException&) override {
108108
if (Attempt == Opts.RetryCount) {
109-
return std::nullopt;
109+
return {};
110110
}
111111
return Opts.GetTimeToSleep(Attempt++);
112112
}
@@ -151,7 +151,7 @@ std::optional<TResult> DoWithRetry(std::function<TResult()> func, const typename
151151
retryState = retryPolicy->CreateRetryState();
152152
}
153153

154-
if (const std::optional<TDuration> delay = retryState->GetNextRetryDelay(ex)) {
154+
if (const TMaybe<TDuration> delay = retryState->GetNextRetryDelay(ex)) {
155155
if (*delay) {
156156
if (sleepFunction) {
157157
sleepFunction(*delay);
@@ -167,7 +167,7 @@ std::optional<TResult> DoWithRetry(std::function<TResult()> func, const typename
167167
}
168168
}
169169
}
170-
return std::nullopt;
170+
return {};
171171
}
172172

173173
template <typename TResult, typename TException = yexception>
@@ -204,7 +204,7 @@ TRetCode DoWithRetryOnRetCode(std::function<TRetCode()> func, const typename IRe
204204
auto retryState = retryPolicy->CreateRetryState();
205205
while (true) {
206206
TRetCode code = func();
207-
if (const std::optional<TDuration> delay = retryState->GetNextRetryDelay(code)) {
207+
if (const TMaybe<TDuration> delay = retryState->GetNextRetryDelay(code)) {
208208
if (*delay) {
209209
if (sleepFunction) {
210210
sleepFunction(*delay);
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,40 @@
1+
add_subdirectory(setup)
2+
add_subdirectory(utils)
3+
14
add_ydb_test(NAME topic_it GTEST
25
SOURCES
36
basic_usage.cpp
7+
describe_topic.cpp
8+
local_partition.cpp
9+
trace.cpp
410
LINK_LIBRARIES
11+
topic_it_utils
12+
topic_it_setup
13+
cpp-client-ydb_persqueue_public
14+
api-grpc
515
yutil
616
YDB-CPP-SDK::Topic
17+
LABELS
18+
integration
19+
)
20+
21+
add_ydb_test(NAME topic_direct_read_it GTEST
22+
SOURCES
23+
basic_usage.cpp
24+
describe_topic.cpp
25+
local_partition.cpp
26+
direct_read.cpp
27+
LINK_LIBRARIES
28+
topic_it_utils
29+
topic_it_setup
730
cpp-client-ydb_persqueue_public
831
api-grpc
32+
yutil
33+
YDB-CPP-SDK::Topic
934
LABELS
1035
integration
36+
ENV
37+
PQ_EXPERIMENTAL_DIRECT_READ=1
1138
)
39+
40+
target_compile_definitions(topic_direct_read_it PUBLIC PQ_EXPERIMENTAL_DIRECT_READ=1)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
_ydb_sdk_add_library(topic_it_setup)
2+
3+
target_sources(topic_it_setup
4+
PRIVATE
5+
fixture.cpp
6+
)
7+
8+
target_link_libraries(topic_it_setup
9+
PUBLIC
10+
YDB-CPP-SDK::Discovery
11+
YDB-CPP-SDK::Topic
12+
GTest::gtest
13+
)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
_ydb_sdk_add_library(topic_it_utils)
2+
3+
target_sources(topic_it_utils
4+
PRIVATE
5+
trace.cpp
6+
)
7+
8+
target_link_libraries(topic_it_utils
9+
PUBLIC
10+
string_utils-helpers
11+
YDB-CPP-SDK::Topic
12+
)

tests/unit/client/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
add_subdirectory(oauth2_token_exchange/helpers)
2+
13
add_ydb_test(NAME client-ydb_coordination_ut
24
SOURCES
35
coordination/coordination_ut.cpp
@@ -53,6 +55,7 @@ add_ydb_test(NAME client-oauth2_ut
5355
json
5456
string_utils-base64
5557
client-ydb_types-credentials-oauth2
58+
client-oauth2-ut-helpers
5659
LABELS
5760
unit
5861
)

tests/unit/client/oauth2_token_exchange/CMakeLists.txt

Lines changed: 0 additions & 14 deletions
This file was deleted.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
_ydb_sdk_add_library(client-oauth2-ut-helpers)
2+
3+
target_sources(client-oauth2-ut-helpers
4+
PRIVATE
5+
test_token_exchange_server.cpp
6+
)
7+
8+
target_link_libraries(client-oauth2-ut-helpers
9+
PUBLIC
10+
jwt-cpp::jwt-cpp
11+
cgiparam
12+
http-misc
13+
http-server
14+
json
15+
string_utils-base64
16+
client-ydb_types-credentials-oauth2
17+
)

0 commit comments

Comments
 (0)