Skip to content

Commit 9859e4f

Browse files
committed
New tests
1 parent ca70f87 commit 9859e4f

File tree

4 files changed

+291
-48
lines changed

4 files changed

+291
-48
lines changed

common/src/main/java/tech/ydb/common/retry/RetryConfig.java

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package tech.ydb.common.retry;
22

3+
34
import tech.ydb.core.Status;
45
import tech.ydb.core.UnexpectedResultException;
56

@@ -15,10 +16,10 @@ public interface RetryConfig {
1516
/**
1617
* Returns retry policy for the given {@link Status} and {@code null} if that status is not retryable
1718
*
18-
* @param code status to check
19+
* @param status status to check
1920
* @return policy of retries or {@code null} if the status is not retryable
2021
*/
21-
RetryPolicy getStatusRetryPolicy(Status code);
22+
RetryPolicy getStatusRetryPolicy(Status status);
2223

2324
/**
2425
* Returns retry policy for the given exception and {@code null} if that exception is not retryable
@@ -36,7 +37,7 @@ default RetryPolicy getThrowableRetryPolicy(Throwable th) {
3637
}
3738

3839
/**
39-
* Infinity retries with default exponential delay.<br>That policy <b>does not</b> retries <i>conditionally</i>
40+
* Infinity retries with default exponential delay.<br>This policy <b>does not</b> retries <i>conditionally</i>
4041
* retryable errors so it can be used for both as idempotent and non idempotent operations
4142
*
4243
* @return retry configuration object
@@ -46,7 +47,7 @@ static RetryConfig retryForever() {
4647
}
4748

4849
/**
49-
* Retries until the specified elapsed milliseconds expire.<br>That policy <b>does not</b> retries
50+
* Retries until the specified elapsed milliseconds expire.<br>This policy <b>does not</b> retries
5051
* <i>conditionally</i> retryable errors so it can be used for both as idempotent and non idempotent operations
5152
* @param maxElapsedMs maximum timeout for retries
5253
* @return retry configuration object
@@ -56,7 +57,7 @@ static RetryConfig retryUntilElapsed(long maxElapsedMs) {
5657
}
5758

5859
/**
59-
* Infinity retries with default exponential delay.<br>That policy <b>does</b> retries <i>conditionally</i>
60+
* Infinity retries with default exponential delay.<br>This policy <b>does</b> retries <i>conditionally</i>
6061
* retryable errors so it can be used <b>ONLY</b> for idempotent operations
6162
* @return retry configuration object
6263
*/
@@ -65,7 +66,7 @@ static RetryConfig idempotentRetryForever() {
6566
}
6667

6768
/**
68-
* Retries until the specified elapsed milliseconds expire.<br>That policy <b>does</b> retries
69+
* Retries until the specified elapsed milliseconds expire.<br>This policy <b>does</b> retries
6970
* <i>conditionally</i> retryable errors so it can be used <b>ONLY</b> for idempotent operations
7071
* @param maxElapsedMs maximum timeout for retries
7172
* @return retry configuration object

common/src/test/java/tech/ydb/common/transaction/impl/YdbTransactionImplTest.java

+11
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,15 @@ public void baseTest() {
3232
Assert.assertTrue(tx.isActive());
3333
Assert.assertFalse(tx.getStatusFuture().isDone());
3434
}
35+
36+
@Test
37+
public void nullTest() {
38+
MockTx tx = new MockTx(TxMode.NONE, null);
39+
40+
Assert.assertNull(tx.getId());
41+
Assert.assertEquals("MOCK", tx.getSessionId());
42+
Assert.assertEquals(TxMode.NONE, tx.getTxMode());
43+
Assert.assertFalse(tx.isActive());
44+
Assert.assertFalse(tx.getStatusFuture().isDone());
45+
}
3546
}

topic/src/test/java/tech/ydb/topic/impl/BaseMockedTest.java

+17-6
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,13 @@ public void responseErrorBadRequest() {
164164
observer.onNext(msg);
165165
}
166166

167+
public void responseErrorSchemeError() {
168+
YdbTopic.StreamWriteMessage.FromServer msg = YdbTopic.StreamWriteMessage.FromServer.newBuilder()
169+
.setStatus(StatusCodesProtos.StatusIds.StatusCode.SCHEME_ERROR)
170+
.build();
171+
observer.onNext(msg);
172+
}
173+
167174
public void responseInit(long lastSeqNo) {
168175
responseInit(lastSeqNo, 123, "mocked", new int[] { 0, 1, 2});
169176
}
@@ -205,23 +212,27 @@ public Checker(YdbTopic.StreamWriteMessage.FromClient msg) {
205212
}
206213

207214
public Checker isInit() {
208-
Assert.assertTrue(msg.hasInitRequest());
215+
Assert.assertTrue("next msg must be init request", msg.hasInitRequest());
209216
return this;
210217
}
211218

212219
public Checker hasInitPath(String path) {
213-
Assert.assertEquals(path, msg.getInitRequest().getPath());
220+
Assert.assertEquals("invalid init request path", path, msg.getInitRequest().getPath());
214221
return this;
215222
}
216223

217224
public Checker isWrite() {
218-
Assert.assertTrue(msg.hasWriteRequest());
225+
Assert.assertTrue("next msg must be write request", msg.hasWriteRequest());
219226
return this;
220227
}
221228

222-
public Checker hasWrite(int codec, int messagesCount) {
223-
Assert.assertEquals(codec, msg.getWriteRequest().getCodec());
224-
Assert.assertEquals(messagesCount, msg.getWriteRequest().getMessagesCount());
229+
public Checker hasWrite(int codec, long... seqnums) {
230+
Assert.assertEquals("invalid write codec", codec, msg.getWriteRequest().getCodec());
231+
Assert.assertEquals("invalid messages count", seqnums.length, msg.getWriteRequest().getMessagesCount());
232+
for (int idx = 0; idx < seqnums.length; idx++) {
233+
Assert.assertEquals("invalid msg seqNo " + idx, seqnums[idx],
234+
msg.getWriteRequest().getMessages(idx).getSeqNo());
235+
}
225236
return this;
226237
}
227238
}

0 commit comments

Comments
 (0)