Skip to content

Commit 72babd1

Browse files
committed
fix
1 parent 40fc975 commit 72babd1

File tree

9 files changed

+118
-54
lines changed

9 files changed

+118
-54
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: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
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)

tests/integration/topic/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ add_ydb_test(NAME topic_it GTEST
1313
cpp-client-ydb_persqueue_public
1414
api-grpc
1515
yutil
16+
YDB-CPP-SDK::Topic
1617
LABELS
1718
integration
1819
)
@@ -29,9 +30,11 @@ add_ydb_test(NAME topic_direct_read_it GTEST
2930
cpp-client-ydb_persqueue_public
3031
api-grpc
3132
yutil
33+
YDB-CPP-SDK::Topic
3234
LABELS
3335
integration
3436
ENV
3537
PQ_EXPERIMENTAL_DIRECT_READ=1
36-
YDB_TEST_TOPIC_PATH=topic_direct_read
3738
)
39+
40+
target_compile_definitions(topic_direct_read_it PUBLIC PQ_EXPERIMENTAL_DIRECT_READ=1)

tests/integration/topic/basic_usage.cpp

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@
1010
#include <util/generic/overloaded.h>
1111
#include <util/stream/zlib.h>
1212

13-
#include <future>
14-
13+
#include <gtest/gtest.h>
1514

16-
static const bool EnableDirectRead = !std::string{std::getenv("PQ_EXPERIMENTAL_DIRECT_READ") ? std::getenv("PQ_EXPERIMENTAL_DIRECT_READ") : ""}.empty();
15+
#include <future>
1716

1817

1918
namespace NYdb::inline V3::NPersQueue::NTests {
@@ -174,7 +173,7 @@ TIntrusivePtr<TManagedExecutor> CreateSyncManagedExecutor()
174173

175174
class BasicUsage : public TTopicTestFixture {};
176175

177-
TEST_F(BasicUsage, ConnectToYDB) {
176+
TEST_F(BasicUsage, TEST_NAME(ConnectToYDB)) {
178177
auto cfg = NYdb::TDriverConfig()
179178
.SetEndpoint("invalid:2136")
180179
.SetDatabase("/Invalid")
@@ -213,7 +212,7 @@ TEST_F(BasicUsage, ConnectToYDB) {
213212
}
214213
}
215214

216-
TEST_F(BasicUsage, WriteRead) {
215+
TEST_F(BasicUsage, TEST_NAME(WriteRead)) {
217216
auto driver = MakeDriver();
218217

219218
TTopicClient client(driver);
@@ -245,7 +244,7 @@ TEST_F(BasicUsage, WriteRead) {
245244

246245
{
247246
auto readSettings = TReadSessionSettings()
248-
.ConsumerName("test-consumer")
247+
.ConsumerName(GetConsumerName())
249248
.AppendTopics(GetTopicPath())
250249
// .DirectRead(EnableDirectRead)
251250
;
@@ -270,7 +269,7 @@ TEST_F(BasicUsage, WriteRead) {
270269
}
271270
}
272271

273-
TEST_F(BasicUsage, MaxByteSizeEqualZero) {
272+
TEST_F(BasicUsage, TEST_NAME(MaxByteSizeEqualZero)) {
274273
auto driver = MakeDriver();
275274

276275
TTopicClient client(driver);
@@ -283,7 +282,7 @@ TEST_F(BasicUsage, MaxByteSizeEqualZero) {
283282
writeSession->Close();
284283

285284
auto readSettings = TReadSessionSettings()
286-
.ConsumerName("test-consumer")
285+
.ConsumerName(GetConsumerName())
287286
.AppendTopics(GetTopicPath())
288287
// .DirectRead(EnableDirectRead)
289288
;
@@ -305,7 +304,7 @@ TEST_F(BasicUsage, MaxByteSizeEqualZero) {
305304
dataReceived.Commit();
306305
}
307306

308-
TEST_F(BasicUsage, WriteAndReadSomeMessagesWithSyncCompression) {
307+
TEST_F(BasicUsage, TEST_NAME(WriteAndReadSomeMessagesWithSyncCompression)) {
309308
auto driver = MakeDriver();
310309

311310
IExecutor::TPtr executor = new TSyncExecutor();
@@ -353,7 +352,7 @@ TEST_F(BasicUsage, WriteAndReadSomeMessagesWithSyncCompression) {
353352
// Create read session.
354353
TReadSessionSettings readSettings;
355354
readSettings
356-
.ConsumerName("test-consumer")
355+
.ConsumerName(GetConsumerName())
357356
.MaxMemoryUsageBytes(1_MB)
358357
.AppendTopics(GetTopicPath())
359358
// .DirectRead(EnableDirectRead)
@@ -387,11 +386,11 @@ TEST_F(BasicUsage, WriteAndReadSomeMessagesWithSyncCompression) {
387386
ReadSession->Close(TDuration::MilliSeconds(10));
388387
check.store(0);
389388

390-
auto status = topicClient.CommitOffset(GetTopicPath(), 0, "test-consumer", 50);
389+
auto status = topicClient.CommitOffset(GetTopicPath(), 0, GetConsumerName(), 50);
391390
ASSERT_TRUE(status.GetValueSync().IsSuccess());
392391

393392
auto describeConsumerSettings = TDescribeConsumerSettings().IncludeStats(true);
394-
auto result = topicClient.DescribeConsumer(GetTopicPath(), "test-consumer", describeConsumerSettings).GetValueSync();
393+
auto result = topicClient.DescribeConsumer(GetTopicPath(), GetConsumerName(), describeConsumerSettings).GetValueSync();
395394
ASSERT_TRUE(result.IsSuccess());
396395

397396
auto description = result.GetConsumerDescription();
@@ -401,7 +400,7 @@ TEST_F(BasicUsage, WriteAndReadSomeMessagesWithSyncCompression) {
401400
ASSERT_EQ(stats->GetCommittedOffset(), 50u);
402401
}
403402

404-
TEST_F(BasicUsage, SessionNotDestroyedWhileCompressionInFlight) {
403+
TEST_F(BasicUsage, TEST_NAME(SessionNotDestroyedWhileCompressionInFlight)) {
405404
auto driver = MakeDriver();
406405

407406
// controlled executor
@@ -425,7 +424,7 @@ TEST_F(BasicUsage, SessionNotDestroyedWhileCompressionInFlight) {
425424
// Create read session.
426425
TReadSessionSettings readSettings;
427426
readSettings
428-
.ConsumerName("test-consumer")
427+
.ConsumerName(GetConsumerName())
429428
.MaxMemoryUsageBytes(1_MB)
430429
.AppendTopics(GetTopicPath())
431430
.DecompressionExecutor(stepByStepExecutor)
@@ -511,7 +510,7 @@ TEST_F(BasicUsage, SessionNotDestroyedWhileCompressionInFlight) {
511510
std::cerr << ">>> TEST: gracefully closed" << std::endl;
512511
}
513512

514-
TEST_F(BasicUsage, SessionNotDestroyedWhileUserEventHandlingInFlight) {
513+
TEST_F(BasicUsage, TEST_NAME(SessionNotDestroyedWhileUserEventHandlingInFlight)) {
515514
auto driver = MakeDriver();
516515

517516
// controlled executor
@@ -542,7 +541,7 @@ TEST_F(BasicUsage, SessionNotDestroyedWhileUserEventHandlingInFlight) {
542541

543542
// Create read session.
544543
auto readSettings = TReadSessionSettings()
545-
.ConsumerName("test-consumer")
544+
.ConsumerName(GetConsumerName())
546545
.MaxMemoryUsageBytes(1_MB)
547546
.AppendTopics(GetTopicPath())
548547
// .DirectRead(EnableDirectRead)
@@ -643,7 +642,7 @@ TEST_F(BasicUsage, SessionNotDestroyedWhileUserEventHandlingInFlight) {
643642
std::cerr << ">>> TEST: gracefully closed" << std::endl;
644643
}
645644

646-
TEST_F(BasicUsage, ReadSessionCorrectClose) {
645+
TEST_F(BasicUsage, TEST_NAME(ReadSessionCorrectClose)) {
647646
auto driver = MakeDriver();
648647

649648
NPersQueue::TWriteSessionSettings writeSettings;
@@ -672,7 +671,7 @@ TEST_F(BasicUsage, ReadSessionCorrectClose) {
672671
// Create read session.
673672
NYdb::NTopic::TReadSessionSettings readSettings;
674673
readSettings
675-
.ConsumerName("test-consumer")
674+
.ConsumerName(GetConsumerName())
676675
.MaxMemoryUsageBytes(1_MB)
677676
.Decompress(false)
678677
.RetryPolicy(NYdb::NTopic::IRetryPolicy::GetNoRetryPolicy())
@@ -700,7 +699,7 @@ TEST_F(BasicUsage, ReadSessionCorrectClose) {
700699
std::this_thread::sleep_for(std::chrono::seconds(5));
701700
}
702701

703-
TEST_F(BasicUsage, ConfirmPartitionSessionWithCommitOffset) {
702+
TEST_F(BasicUsage, TEST_NAME(ConfirmPartitionSessionWithCommitOffset)) {
704703
// TStartPartitionSessionEvent::Confirm(readOffset, commitOffset) should work,
705704
// if commitOffset passed to Confirm is greater than the offset committed previously by the consumer.
706705
// https://st.yandex-team.ru/KIKIMR-23015
@@ -723,7 +722,7 @@ TEST_F(BasicUsage, ConfirmPartitionSessionWithCommitOffset) {
723722
{
724723
// Read messages:
725724
auto settings = NTopic::TReadSessionSettings()
726-
.ConsumerName("test-consumer")
725+
.ConsumerName(GetConsumerName())
727726
.AppendTopics(GetTopicPath())
728727
// .DirectRead(EnableDirectRead)
729728
;
@@ -760,7 +759,7 @@ TEST_F(BasicUsage, ConfirmPartitionSessionWithCommitOffset) {
760759
}
761760
}
762761

763-
TEST_F(BasicUsage, TWriteSession_WriteEncoded) {
762+
TEST_F(BasicUsage, TEST_NAME(TWriteSession_WriteEncoded)) {
764763
// This test was adapted from ydb_persqueue tests.
765764
// It writes 4 messages: 2 with default codec, 1 with explicitly set GZIP codec, 1 with RAW codec.
766765
// The last message MUST be sent in a separate WriteRequest, as it has a codec field applied for all messages in the request.
@@ -831,7 +830,7 @@ TEST_F(BasicUsage, TWriteSession_WriteEncoded) {
831830
ASSERT_EQ(tokens, 2u);
832831

833832
auto readSettings = TReadSessionSettings()
834-
.ConsumerName("test-consumer")
833+
.ConsumerName(GetConsumerName())
835834
.AppendTopics(GetTopicPath())
836835
// .DirectRead(EnableDirectRead)
837836
;
@@ -886,7 +885,7 @@ namespace {
886885

887886
class TSettingsValidation : public TTopicTestFixture {};
888887

889-
TEST_F(TSettingsValidation, TestDifferentDedupParams) {
888+
TEST_F(TSettingsValidation, TEST_NAME(TestDifferentDedupParams)) {
890889
char* ydbVersion = std::getenv("YDB_VERSION");
891890
if (ydbVersion != nullptr && std::string(ydbVersion) != "trunk" && std::string(ydbVersion) < "24.3") {
892891
GTEST_SKIP() << "Skipping test for YDB version " << ydbVersion;
@@ -1003,13 +1002,13 @@ TEST_F(TSettingsValidation, TestDifferentDedupParams) {
10031002
runTest({}, "msgGroup", {}, false, EExpectedTestResult::SUCCESS);
10041003
}
10051004

1006-
TEST_F(TSettingsValidation, ValidateSettingsFailOnStart) {
1005+
TEST_F(TSettingsValidation, TEST_NAME(ValidateSettingsFailOnStart)) {
10071006
auto driver = MakeDriver();
10081007

10091008
TTopicClient client(driver);
10101009

10111010
auto readSettings = TReadSessionSettings()
1012-
.ConsumerName("test-consumer")
1011+
.ConsumerName(GetConsumerName())
10131012
.MaxMemoryUsageBytes(0)
10141013
.AppendTopics(GetTopicPath())
10151014
// .DirectRead(EnableDirectRead)

tests/integration/topic/describe_topic.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class Describe : public TTopicTestFixture {
5656
settings.IncludeLocation(requireLocation);
5757

5858
{
59-
auto result = client.DescribeConsumer(GetTopicPath(), "test-consumer", settings).GetValueSync();
59+
auto result = client.DescribeConsumer(GetTopicPath(), GetConsumerName(), settings).GetValueSync();
6060
EXPECT_TRUE(result.IsSuccess()) << result.GetIssues().ToString();
6161

6262
const auto& description = result.GetConsumerDescription();
@@ -149,15 +149,15 @@ class Describe : public TTopicTestFixture {
149149
}
150150
};
151151

152-
TEST_F(Describe, Basic) {
152+
TEST_F(Describe, TEST_NAME(Basic)) {
153153
TTopicClient client(MakeDriver());
154154

155155
DescribeTopic(client, false, false, false);
156156
DescribeConsumer(client, false, false, false);
157157
DescribePartition(client, false, false, false);
158158
}
159159

160-
TEST_F(Describe, Statistics) {
160+
TEST_F(Describe, TEST_NAME(Statistics)) {
161161
// TODO(abcdef): temporarily deleted
162162
GTEST_SKIP() << "temporarily deleted";
163163

@@ -184,7 +184,7 @@ TEST_F(Describe, Statistics) {
184184

185185
// Read a message
186186
{
187-
auto readSettings = TReadSessionSettings().ConsumerName("test-consumer").AppendTopics(GetTopicPath());
187+
auto readSettings = TReadSessionSettings().ConsumerName(GetConsumerName()).AppendTopics(GetTopicPath());
188188
auto readSession = client.CreateReadSession(readSettings);
189189

190190
// Event 1: start partition session
@@ -239,7 +239,7 @@ TEST_F(Describe, Statistics) {
239239
DescribePartition(client, true, true, false);
240240
}
241241

242-
TEST_F(Describe, Location) {
242+
TEST_F(Describe, TEST_NAME(Location)) {
243243
TTopicClient client(MakeDriver());
244244

245245
DescribeTopic(client, false, false, true);

tests/integration/topic/direct_read.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,7 @@ TEST_F(DirectReadWithClient, OneMessage) {
882882
// Read the message:
883883

884884
auto settings = TReadSessionSettings()
885-
.ConsumerName("test-consumer")
885+
.ConsumerName(GetConsumerName())
886886
.AppendTopics(GetTopicPath())
887887
// .DirectRead(true)
888888
;
@@ -929,7 +929,7 @@ TEST_F(DirectReadWithClient, ManyMessages) {
929929
constexpr std::size_t partitionCount = 2;
930930
std::size_t messageCount = 100;
931931
std::size_t totalMessageCount = partitionCount * messageCount;
932-
CreateTopic(GetTopicPath(), "test-consumer", partitionCount);
932+
CreateTopic(GetTopicPath(), GetConsumerName(), partitionCount);
933933
TTopicClient client{MakeDriver()};
934934

935935
std::string message(950_KB, 'x');
@@ -966,7 +966,7 @@ TEST_F(DirectReadWithClient, ManyMessages) {
966966
std::size_t gotMessages = 0;
967967
std::array<std::size_t, partitionCount> committedOffset{};
968968
auto settings = TReadSessionSettings()
969-
.ConsumerName("test-consumer")
969+
.ConsumerName(GetConsumerName())
970970
.AppendTopics(GetTopicPath())
971971
.MaxMemoryUsageBytes(1_MB)
972972
// .DirectRead(GetEnv("DIRECT", "0") == "1")
@@ -1064,6 +1064,9 @@ TEST_F(DirectReadWithControlSession, Init) {
10641064
}
10651065

10661066
TEST_F(DirectReadWithControlSession, StopPartitionSessionGracefully) {
1067+
#ifdef __GNUC__
1068+
GTEST_SKIP() << "Skip for gcc";
1069+
#endif
10671070
auto const startPartitionSessionRequest = TStartPartitionSessionRequest{
10681071
.PartitionId = 1,
10691072
.PartitionSessionId = 2,

0 commit comments

Comments
 (0)