/
githubmirror
/
ydb-java-dialects
Обзор
Документация
Войти
/
githubmirror
/
ydb-java-dialects
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
spring-ydb-retry/src/test/java/tech/ydb/retry/TransactionPropagationRetryTest.java
63 строки
2 KB
Kirill Kurdyukov
Add spring-ydb-retry module (v0.10.0) (#226)
15 июн 2026, 14:09
Не верифицирован
15 июн 2026, 14:09
3e8a6c8
Код
Авторство
О чём код?
package tech.ydb.retry; import org.junit.jupiter.api.Test; import org.springframework.transaction.support.TransactionSynchronizationManager; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; import static tech.ydb.core.StatusCode.ABORTED; import static tech.ydb.core.StatusCode.BAD_SESSION; class TransactionPropagationRetryTest extends InterceptorTestSupport { @Test void shouldDisableRetryWhenParticipatingInOuterTransaction() { TransactionSynchronizationManager.setActualTransactionActive(true); TestableInterceptor interceptor = interceptorWithConfig(true, 2, 0, 0, 0, 0); interceptor.enqueueOutcome(new IllegalStateException("no retry expected")); assertThrows( IllegalStateException.class, () -> interceptor.invoke(invocationFor("ydbRequiredRetry"))); assertEquals(1, interceptor.allInvocations()); } @Test void shouldRetryWithRequiresNewInsideOuterTransaction() throws Throwable { TransactionSynchronizationManager.setActualTransactionActive(true); TestableInterceptor interceptor = interceptorWithConfig(true, 2, 0, 0, 0, 0); interceptor.enqueueOutcome(new ConfigurableStatusException(BAD_SESSION), "ok"); Object result = interceptor.invoke(invocationFor("ydbRequiresNewRetry")); assertEquals("ok", result); assertEquals(2, interceptor.allInvocations()); } @Test void shouldDisableRetryWithNestedPropagationInsideOuterTransaction() { TransactionSynchronizationManager.setActualTransactionActive(true); TestableInterceptor interceptor = interceptorWithConfig(true, 2, 0, 0, 0, 0); interceptor.enqueueOutcome(new ConfigurableStatusException(ABORTED)); assertThrows( ConfigurableStatusException.class, () -> interceptor.invoke(invocationFor("ydbNestedRetry"))); assertEquals(1, interceptor.allInvocations()); } @Test void shouldRetryWithNotSupportedPropagationInsideOuterTransaction() throws Throwable { TransactionSynchronizationManager.setActualTransactionActive(true); TestableInterceptor interceptor = interceptorWithConfig(true, 2, 0, 0, 0, 0); interceptor.enqueueOutcome(new ConfigurableStatusException(BAD_SESSION), "ok"); Object result = interceptor.invoke(invocationFor("ydbNotSupportedRetry")); assertEquals("ok", result); assertEquals(2, interceptor.allInvocations()); } }