@@ -108,6 +108,66 @@ func TestTopicStreamReaderImpl_CommitStolen(t *testing.T) {
108108 xtest .WaitChannelClosed (t , commitReceived )
109109 xtest .WaitChannelClosed (t , readRequestReceived )
110110 })
111+ xtest .TestManyTimesWithName (t , "WrongOrderCommitWithSyncMode" , func (t testing.TB ) {
112+ e := newTopicReaderTestEnv (t )
113+ e .reader .cfg .CommitMode = CommitModeSync
114+ e .Start ()
115+
116+ lastOffset := e .partitionSession .lastReceivedMessageOffset ()
117+ const dataSize = 4
118+ // request new data portion
119+ readRequestReceived := make (empty.Chan )
120+ e .stream .EXPECT ().Send (& rawtopicreader.ReadRequest {BytesSize : dataSize * 2 }).Do (func (_ interface {}) {
121+ close (readRequestReceived )
122+ })
123+
124+ e .SendFromServer (& rawtopicreader.ReadResponse {
125+ BytesSize : dataSize ,
126+ PartitionData : []rawtopicreader.PartitionData {
127+ {
128+ PartitionSessionID : e .partitionSessionID ,
129+ Batches : []rawtopicreader.Batch {
130+ {
131+ Codec : rawtopiccommon .CodecRaw ,
132+ ProducerID : "1" ,
133+ MessageData : []rawtopicreader.MessageData {
134+ {
135+ Offset : lastOffset + 1 ,
136+ },
137+ },
138+ },
139+ },
140+ },
141+ },
142+ })
143+
144+ e .SendFromServer (& rawtopicreader.ReadResponse {
145+ BytesSize : dataSize ,
146+ PartitionData : []rawtopicreader.PartitionData {
147+ {
148+ PartitionSessionID : e .partitionSessionID ,
149+ Batches : []rawtopicreader.Batch {
150+ {
151+ Codec : rawtopiccommon .CodecRaw ,
152+ ProducerID : "1" ,
153+ MessageData : []rawtopicreader.MessageData {
154+ {
155+ Offset : lastOffset + 2 ,
156+ },
157+ },
158+ },
159+ },
160+ },
161+ },
162+ })
163+
164+ opts := newReadMessageBatchOptions ()
165+ opts .MinCount = 2
166+ batch , err := e .reader .ReadMessageBatch (e .ctx , opts )
167+ require .NoError (t , err )
168+ require .ErrorIs (t , e .reader .Commit (e .ctx , batch .Messages [1 ].getCommitRange ().priv ), ErrWrongCommitOrderInSyncMode )
169+ xtest .WaitChannelClosed (t , readRequestReceived )
170+ })
111171
112172 xtest .TestManyTimesWithName (t , "CommitAfterGracefulStopPartition" , func (t testing.TB ) {
113173 e := newTopicReaderTestEnv (t )
0 commit comments