@@ -38,6 +38,7 @@ Y_UNIT_TEST_SUITE(WithSDK) {
3838 return setup.DescribeConsumer (TEST_TOPIC, TEST_CONSUMER);
3939 };
4040
41+ std::deque<TString> messagesTextQueue;
4142 auto write = [&](size_t seqNo) {
4243 TTopicClient client (setup.MakeDriver ());
4344
@@ -49,9 +50,11 @@ Y_UNIT_TEST_SUITE(WithSDK) {
4950
5051 TString msgTxt = TStringBuilder () << " message_" << seqNo;
5152 TWriteMessage msg (msgTxt);
52- msg.CreateTimestamp (TInstant::Now () - TDuration::Seconds (10 - seqNo));
53+ constexpr size_t maxSeqNo = 10 ;
54+ Y_ASSERT (seqNo <= maxSeqNo);
55+ msg.CreateTimestamp (TInstant::Now () - TDuration::Seconds (maxSeqNo - seqNo));
5356 UNIT_ASSERT (session->Write (std::move (msg)));
54-
57+ messagesTextQueue. push_back (msgTxt);
5558 session->Close (TDuration::Seconds (5 ));
5659 };
5760
@@ -78,7 +81,7 @@ Y_UNIT_TEST_SUITE(WithSDK) {
7881 Sleep (TDuration::Seconds (2 ));
7982 write (7 );
8083 Sleep (TDuration::Seconds (2 ));
81- write (11 );
84+ write (10 );
8285
8386 Cerr << " >>>>> Check describe for topic which contains messages, but consumer hasn`t read\n " ;
8487 {
@@ -100,6 +103,7 @@ Y_UNIT_TEST_SUITE(WithSDK) {
100103 }
101104
102105 UNIT_ASSERT (setup.Commit (TEST_TOPIC, TEST_CONSUMER, 0 , 1 ).IsSuccess ());
106+ messagesTextQueue.pop_front ();
103107
104108 Cerr << " >>>>> Check describe for topic whis contains messages, has commited offset but hasn`t read (restart tablet for example)\n " ;
105109 {
@@ -115,7 +119,7 @@ Y_UNIT_TEST_SUITE(WithSDK) {
115119 UNIT_ASSERT_VALUES_EQUAL (1 , c->GetCommittedOffset ());
116120 UNIT_ASSERT_VALUES_EQUAL (TDuration::Seconds (7 ), c->GetMaxWriteTimeLag ());
117121 UNIT_ASSERT_VALUES_EQUAL (TDuration::Seconds (0 ), c->GetMaxReadTimeLag ());
118- UNIT_ASSERT_VALUES_EQUAL (TDuration::Seconds (4 ), c->GetMaxCommittedTimeLag ());
122+ UNIT_ASSERT_VALUES_EQUAL (TDuration::Seconds (2 ), c->GetMaxCommittedTimeLag ());
119123 UNIT_ASSERT_TIME_EQUAL (TInstant::Now (), c->GetLastReadTime (), TDuration::Seconds (3 )); // why not zero?
120124 UNIT_ASSERT_VALUES_EQUAL (1 , c->GetLastReadOffset ());
121125 }
@@ -135,8 +139,15 @@ Y_UNIT_TEST_SUITE(WithSDK) {
135139 Cerr << " >>>>> Event = " << e->index () << Endl << Flush;
136140 }
137141 if (e && std::holds_alternative<NYdb::NTopic::TReadSessionEvent::TDataReceivedEvent>(e.value ())) {
138- // we must recive only one date event with second message
139- break ;
142+ for (const auto & message : std::get<NYdb::NTopic::TReadSessionEvent::TDataReceivedEvent>(e.value ()).GetMessages ()) {
143+ UNIT_ASSERT (!messagesTextQueue.empty ());
144+ UNIT_ASSERT_VALUES_EQUAL (message.GetData (), messagesTextQueue.front ());
145+ messagesTextQueue.pop_front ();
146+ }
147+ if (messagesTextQueue.empty ()) {
148+ // we must receive data events for all messages except the first one
149+ break ;
150+ }
140151 } else if (e && std::holds_alternative<NYdb::NTopic::TReadSessionEvent::TStartPartitionSessionEvent>(e.value ())) {
141152 std::get<NYdb::NTopic::TReadSessionEvent::TStartPartitionSessionEvent>(e.value ()).Confirm ();
142153 }
@@ -160,7 +171,7 @@ Y_UNIT_TEST_SUITE(WithSDK) {
160171 UNIT_ASSERT_VALUES_EQUAL (1 , c->GetCommittedOffset ());
161172 // UNIT_ASSERT_VALUES_EQUAL(TDuration::Seconds(7), c->GetMaxWriteTimeLag());
162173 UNIT_ASSERT_VALUES_EQUAL (TDuration::Seconds (0 ), c->GetMaxReadTimeLag ());
163- UNIT_ASSERT_VALUES_EQUAL (TDuration::Seconds (4 ), c->GetMaxCommittedTimeLag ());
174+ UNIT_ASSERT_VALUES_EQUAL (TDuration::Seconds (2 ), c->GetMaxCommittedTimeLag ());
164175 UNIT_ASSERT_TIME_EQUAL (TInstant::Now (), c->GetLastReadTime (), TDuration::Seconds (3 ));
165176 UNIT_ASSERT_VALUES_EQUAL (3 , c->GetLastReadOffset ());
166177 }
0 commit comments