@@ -478,7 +478,6 @@ func TestStreamReaderImpl_OnPartitionCloseHandle(t *testing.T) {
478478func TestStreamReaderImpl_TestEndSessionForSplitMergePartitions (t * testing.T ) {
479479 t .Run ("Split" , func (t * testing.T ) {
480480 xtest .TestManyTimes (t , func (t testing.TB ) {
481-
482481 e := newTopicReaderTestEnv (t )
483482
484483 // doesn't check sends
@@ -562,7 +561,6 @@ func TestStreamReaderImpl_TestEndSessionForSplitMergePartitions(t *testing.T) {
562561 })
563562 t .Run ("Merge" , func (t * testing.T ) {
564563 xtest .TestManyTimes (t , func (t testing.TB ) {
565-
566564 e := newTopicReaderTestEnv (t )
567565
568566 // doesn't check sends
@@ -1159,132 +1157,6 @@ func TestTopicStreamReadImpl_CommitWithBadSession(t *testing.T) {
11591157 })
11601158}
11611159
1162- func TestTopicSplitPartitions (t * testing.T ) {
1163- t .Run ("SplitPartition" , func (t * testing.T ) {
1164- e := newTopicReaderTestEnv (t )
1165- e .Start ()
1166-
1167- // Create initial partition session
1168- initialSession := newTestPartitionSessionReaderID (e .reader .readerID , e .partitionSessionID )
1169- require .NoError (t , e .reader .sessionController .Add (initialSession ))
1170-
1171- // Create split sessions
1172- splitSession1 := newTestPartitionSessionReaderID (e .reader .readerID , e .partitionSessionID + 1 )
1173- splitSession2 := newTestPartitionSessionReaderID (e .reader .readerID , e .partitionSessionID + 2 )
1174-
1175- // Send split partition request
1176- splitRequestReceived := make (empty.Chan )
1177- e .stream .EXPECT ().Send (& rawtopicreader.SplitPartitionSessionRequest {
1178- PartitionSessionID : e .partitionSessionID ,
1179- }).DoAndReturn (func (_ rawtopicreader.ClientMessage ) error {
1180- close (splitRequestReceived )
1181- return nil
1182- })
1183-
1184- // Send split response
1185- e .SendFromServer (& rawtopicreader.SplitPartitionSessionResponse {
1186- PartitionSessionID : e .partitionSessionID ,
1187- SplitSession1 : e .partitionSessionID + 1 ,
1188- SplitSession2 : e .partitionSessionID + 2 ,
1189- })
1190-
1191- // Wait for split request to be sent
1192- xtest .WaitChannelClosed (t , splitRequestReceived )
1193-
1194- // Verify split sessions are added to storage
1195- session1 , err := e .reader .sessionController .Get (e .partitionSessionID + 1 )
1196- require .NoError (t , err )
1197- require .Equal (t , splitSession1 , session1 )
1198-
1199- session2 , err := e .reader .sessionController .Get (e .partitionSessionID + 2 )
1200- require .NoError (t , err )
1201- require .Equal (t , splitSession2 , session2 )
1202-
1203- // Verify initial session is removed
1204- _ , err = e .reader .sessionController .Get (e .partitionSessionID )
1205- require .Error (t , err )
1206- })
1207-
1208- t .Run ("SplitPartitionError" , func (t * testing.T ) {
1209- e := newTopicReaderTestEnv (t )
1210- e .Start ()
1211-
1212- // Create initial partition session
1213- initialSession := newTestPartitionSessionReaderID (e .reader .readerID , e .partitionSessionID )
1214- require .NoError (t , e .reader .sessionController .Add (initialSession ))
1215-
1216- // Send split partition request with error
1217- splitRequestReceived := make (empty.Chan )
1218- testErr := errors .New ("test error" )
1219- e .stream .EXPECT ().Send (& rawtopicreader.SplitPartitionSessionRequest {
1220- PartitionSessionID : e .partitionSessionID ,
1221- }).DoAndReturn (func (_ rawtopicreader.ClientMessage ) error {
1222- close (splitRequestReceived )
1223- return testErr
1224- })
1225-
1226- // Send split response
1227- e .SendFromServer (& rawtopicreader.SplitPartitionSessionResponse {
1228- PartitionSessionID : e .partitionSessionID ,
1229- SplitSession1 : e .partitionSessionID + 1 ,
1230- SplitSession2 : e .partitionSessionID + 2 ,
1231- })
1232-
1233- // Wait for split request to be sent
1234- xtest .WaitChannelClosed (t , splitRequestReceived )
1235-
1236- // Verify initial session is still present
1237- session , err := e .reader .sessionController .Get (e .partitionSessionID )
1238- require .NoError (t , err )
1239- require .Equal (t , initialSession , session )
1240-
1241- // Verify split sessions are not added
1242- _ , err = e .reader .sessionController .Get (e .partitionSessionID + 1 )
1243- require .Error (t , err )
1244- _ , err = e .reader .sessionController .Get (e .partitionSessionID + 2 )
1245- require .Error (t , err )
1246- })
1247-
1248- t .Run ("SplitPartitionFromOtherReader" , func (t * testing.T ) {
1249- e := newTopicReaderTestEnv (t )
1250- e .Start ()
1251-
1252- // Create initial partition session from different reader
1253- initialSession := newTestPartitionSessionReaderID (e .reader .readerID + 1 , e .partitionSessionID )
1254- require .NoError (t , e .reader .sessionController .Add (initialSession ))
1255-
1256- // Send split partition request
1257- splitRequestReceived := make (empty.Chan )
1258- e .stream .EXPECT ().Send (& rawtopicreader.SplitPartitionSessionRequest {
1259- PartitionSessionID : e .partitionSessionID ,
1260- }).DoAndReturn (func (_ rawtopicreader.ClientMessage ) error {
1261- close (splitRequestReceived )
1262- return nil
1263- })
1264-
1265- // Send split response
1266- e .SendFromServer (& rawtopicreader.SplitPartitionSessionResponse {
1267- PartitionSessionID : e .partitionSessionID ,
1268- SplitSession1 : e .partitionSessionID + 1 ,
1269- SplitSession2 : e .partitionSessionID + 2 ,
1270- })
1271-
1272- // Wait for split request to be sent
1273- xtest .WaitChannelClosed (t , splitRequestReceived )
1274-
1275- // Verify initial session is still present
1276- session , err := e .reader .sessionController .Get (e .partitionSessionID )
1277- require .NoError (t , err )
1278- require .Equal (t , initialSession , session )
1279-
1280- // Verify split sessions are not added
1281- _ , err = e .reader .sessionController .Get (e .partitionSessionID + 1 )
1282- require .Error (t , err )
1283- _ , err = e .reader .sessionController .Get (e .partitionSessionID + 2 )
1284- require .Error (t , err )
1285- })
1286- }
1287-
12881160type streamEnv struct {
12891161 TopicClient * MockTopicClient
12901162 ctx context.Context //nolint:containedctx
0 commit comments