77import org .junit .Assert ;
88import org .junit .Test ;
99
10+ import tech .ydb .common .retry .RetryConfig ;
1011import tech .ydb .core .Status ;
1112import tech .ydb .core .StatusCode ;
12- import tech .ydb .topic . settings . RetryMode ;
13+ import tech .ydb .core . UnexpectedResultException ;
1314import tech .ydb .topic .settings .WriterSettings ;
1415import tech .ydb .topic .write .Message ;
1516import tech .ydb .topic .write .SyncWriter ;
1819 *
1920 * @author Aleksandr Gorshenin
2021 */
21- public class RetryModeTest extends BaseMockedTest {
22+ public class TopicRetriesTest extends BaseMockedTest {
2223
2324 @ Test
24- public void alwaysRetryWriterTest () throws InterruptedException , ExecutionException , TimeoutException {
25+ public void defaultRetryWriterTest () throws InterruptedException , ExecutionException , TimeoutException {
2526 mockStreams ()
2627 .then (errorStreamMockAnswer (StatusCode .TRANSPORT_UNAVAILABLE ))
2728 .then (defaultStreamMockAnswer ())
@@ -30,7 +31,6 @@ public void alwaysRetryWriterTest() throws InterruptedException, ExecutionExcept
3031
3132 SyncWriter writer = client .createSyncWriter (WriterSettings .newBuilder ()
3233 .setTopicPath ("/mocked_topic" )
33- .setRetryMode (RetryMode .ALWAYS )
3434 .build ());
3535 writer .init ();
3636
@@ -47,7 +47,7 @@ public void alwaysRetryWriterTest() throws InterruptedException, ExecutionExcept
4747 stream1 .nextMsg ().isWrite ().hasWrite (2 , 1 );
4848 stream1 .responseWriteWritten (1 , 1 );
4949
50- stream1 .complete (Status .SUCCESS );
50+ stream1 .complete (Status .of ( StatusCode . SUCCESS ) );
5151
5252 // Retry #2 - Stream is closed by server
5353 getScheduler ().hasTasks (1 ).executeNextTasks (1 );
@@ -88,7 +88,7 @@ public void disabledRetryNetworkErrorTest() throws InterruptedException, Executi
8888
8989 WriterSettings settings = WriterSettings .newBuilder ()
9090 .setTopicPath ("/mocked_topic" )
91- .setRetryMode ( RetryMode . NONE )
91+ .setRetryConfig ( RetryConfig . noRetries () )
9292 .build ();
9393
9494 SyncWriter writer = client .createSyncWriter (settings );
@@ -109,7 +109,7 @@ public void disabledRetryNetworkErrorTest() throws InterruptedException, Executi
109109 public void disabledRetryStreamCloseTest () throws InterruptedException , ExecutionException , TimeoutException {
110110 WriterSettings settings = WriterSettings .newBuilder ()
111111 .setTopicPath ("/mocked_topic" )
112- .setRetryMode ( RetryMode . NONE )
112+ .setRetryConfig ( RetryConfig . noRetries () )
113113 .build ();
114114
115115 SyncWriter writer = client .createSyncWriter (settings );
@@ -134,7 +134,7 @@ public void disabledRetryStreamCloseTest() throws InterruptedException, Executio
134134 public void disabledRetryStreamErrorTest () throws InterruptedException , ExecutionException , TimeoutException {
135135 WriterSettings settings = WriterSettings .newBuilder ()
136136 .setTopicPath ("/mocked_topic" )
137- .setRetryMode ( RetryMode . NONE )
137+ .setRetryConfig ( RetryConfig . noRetries () )
138138 .build ();
139139
140140 SyncWriter writer = client .createSyncWriter (settings );
@@ -162,7 +162,7 @@ public void recoverRetryNetworkErrorTest() throws InterruptedException, Executio
162162
163163 WriterSettings settings = WriterSettings .newBuilder ()
164164 .setTopicPath ("/mocked_topic" )
165- .setRetryMode ( RetryMode . RECOVER )
165+ .setRetryConfig ( RetryConfig . noRetries () )
166166 .build ();
167167
168168 SyncWriter writer = client .createSyncWriter (settings );
@@ -180,7 +180,7 @@ public void recoverRetryNetworkErrorTest() throws InterruptedException, Executio
180180 }
181181
182182 @ Test
183- public void recoverRetryWriterTest () throws InterruptedException , ExecutionException , TimeoutException {
183+ public void idempotentRetryWriterTest () throws InterruptedException , ExecutionException , TimeoutException {
184184 mockStreams ()
185185 .then (defaultStreamMockAnswer ())
186186 .then (errorStreamMockAnswer (StatusCode .OVERLOADED ))
@@ -190,7 +190,7 @@ public void recoverRetryWriterTest() throws InterruptedException, ExecutionExcep
190190
191191 SyncWriter writer = client .createSyncWriter (WriterSettings .newBuilder ()
192192 .setTopicPath ("/mocked_topic" )
193- .setRetryMode ( RetryMode . RECOVER )
193+ .setRetryConfig ( RetryConfig . idempotentRetryForever () )
194194 .build ());
195195 writer .init ();
196196
@@ -203,7 +203,9 @@ public void recoverRetryWriterTest() throws InterruptedException, ExecutionExcep
203203 stream1 .nextMsg ().isWrite ().hasWrite (2 , 1 );
204204 stream1 .responseWriteWritten (1 , 1 );
205205
206- stream1 .complete (new RuntimeException ("io exception" ));
206+ stream1 .complete (new RuntimeException ("io exception" ,
207+ new UnexpectedResultException ("inner" , Status .of (StatusCode .CLIENT_INTERNAL_ERROR )))
208+ );
207209
208210 // Retry #1 - Stream is by runtime exception
209211 getScheduler ().hasTasks (1 ).executeNextTasks (1 );
0 commit comments