From 3ed0965528146794abb027cedef29eee43615e08 Mon Sep 17 00:00:00 2001 From: marko-bekhta Date: Thu, 2 Jan 2025 16:51:42 +0100 Subject: [PATCH] HSEARCH-5297 Switch to narayana-spring-boot instead of atomikos --- build/parents/build/pom.xml | 13 ++++--------- integrationtest/mapper/orm-spring/pom.xml | 13 +++++++++---- .../RaisedTimeoutJtaAndSpringOutboxIT.java | 6 +++--- .../TransactionTimeoutJtaAndSpringOutboxIT.java | 9 ++++++--- .../testsupport/AbstractMapperOrmSpringIT.java | 13 +++++++++++++ .../spring/transaction/TransactionIT.java | 2 +- .../src/test/resources/application-jta.yaml | 14 ++++---------- .../application-transaction-timeout.yaml | 6 ++---- .../src/test/resources/application.yaml | 17 +++++++++-------- pom.xml | 14 -------------- 10 files changed, 51 insertions(+), 56 deletions(-) diff --git a/build/parents/build/pom.xml b/build/parents/build/pom.xml index b69162e6e2b..714577e64ed 100644 --- a/build/parents/build/pom.xml +++ b/build/parents/build/pom.xml @@ -181,15 +181,10 @@ 1.1.2.Final - - - 3.3.0 - - - 6.0.0 + + 3.4.1 + + 3.3.1 1.18.3 2.3 diff --git a/integrationtest/mapper/orm-spring/pom.xml b/integrationtest/mapper/orm-spring/pom.xml index 2a1ca2e93c9..929b5eee3b3 100644 --- a/integrationtest/mapper/orm-spring/pom.xml +++ b/integrationtest/mapper/orm-spring/pom.xml @@ -44,11 +44,16 @@ - - com.atomikos - transactions-spring-boot3-starter - ${version.com.atomikos} + dev.snowdrop + narayana-spring-boot-starter + ${version.dev.snowdrop} + test + + + io.agroal + agroal-spring-boot-starter + 2.5 test diff --git a/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/jta/timeout/RaisedTimeoutJtaAndSpringOutboxIT.java b/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/jta/timeout/RaisedTimeoutJtaAndSpringOutboxIT.java index a54408b0bb9..a99cd220f7f 100644 --- a/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/jta/timeout/RaisedTimeoutJtaAndSpringOutboxIT.java +++ b/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/jta/timeout/RaisedTimeoutJtaAndSpringOutboxIT.java @@ -20,7 +20,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import com.atomikos.icatch.jta.TransactionManagerImp; +import com.arjuna.ats.arjuna.coordinator.TxControl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @@ -48,8 +48,8 @@ void checkJta() { .getServiceRegistry().getService( TransactionCoordinatorBuilder.class ) ) .returns( true, TransactionCoordinatorBuilder::isJta ); - // We changed the default Atomikos timeout to 1s (1000ms) - assertThat( TransactionManagerImp.getDefaultTimeout() ).isOne(); + // We changed the default timeout to 1s (1000ms) + assertThat( TxControl.getDefaultTimeout() ).isOne(); // However, the test is not supposed to time out, // because we raised the timeout to 60 seconds in Hibernate Search properties diff --git a/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/jta/timeout/TransactionTimeoutJtaAndSpringOutboxIT.java b/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/jta/timeout/TransactionTimeoutJtaAndSpringOutboxIT.java index 6f058061ead..313e6736bb0 100644 --- a/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/jta/timeout/TransactionTimeoutJtaAndSpringOutboxIT.java +++ b/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/jta/timeout/TransactionTimeoutJtaAndSpringOutboxIT.java @@ -7,6 +7,8 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.awaitility.Awaitility.await; +import java.util.concurrent.TimeUnit; + import jakarta.persistence.EntityManagerFactory; import org.hibernate.engine.spi.SessionFactoryImplementor; @@ -19,7 +21,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import com.atomikos.icatch.jta.TransactionManagerImp; +import com.arjuna.ats.arjuna.coordinator.TxControl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @@ -45,8 +47,8 @@ void checkJta() { .getServiceRegistry().getService( TransactionCoordinatorBuilder.class ) ) .returns( true, TransactionCoordinatorBuilder::isJta ); - // We changed the default Atomikos timeout to 1s (1000ms) - assertThat( TransactionManagerImp.getDefaultTimeout() ).isOne(); + // We changed the default timeout to 1s (1000ms) + assertThat( TxControl.getDefaultTimeout() ).isOne(); // The test is supposed to time out } @@ -62,6 +64,7 @@ void test() { snertDAO.persist( snert ); await( "Waiting for indexing assertions" ) + .pollDelay( 1, TimeUnit.SECONDS ) .untilAsserted( () -> assertThat( TimeoutFailureCollector.EXCEPTIONS ).isNotEmpty() ); Throwable exception = TimeoutFailureCollector.EXCEPTIONS.iterator().next(); diff --git a/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/testsupport/AbstractMapperOrmSpringIT.java b/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/testsupport/AbstractMapperOrmSpringIT.java index 605021a9462..46a96c4b4af 100644 --- a/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/testsupport/AbstractMapperOrmSpringIT.java +++ b/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/testsupport/AbstractMapperOrmSpringIT.java @@ -6,6 +6,12 @@ import org.hibernate.search.util.impl.integrationtest.mapper.orm.DatabaseContainer; +import org.junit.jupiter.api.BeforeEach; + +import com.arjuna.ats.arjuna.common.CoordinatorEnvironmentBean; +import com.arjuna.ats.arjuna.coordinator.TxControl; +import com.arjuna.common.internal.util.propertyservice.BeanPopulator; + import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.DynamicPropertyRegistry; import org.springframework.test.context.DynamicPropertySource; @@ -16,4 +22,11 @@ public abstract class AbstractMapperOrmSpringIT { static void configureProperties(DynamicPropertyRegistry registry) { DatabaseContainer.configuration().addAsSpring( (key, value) -> registry.add( key, () -> value ) ); } + + @BeforeEach + void setUp() { + // Because the default timeout is set as a static property it won't get reinitialized between tests on its own, + // that is why we set it ourselves here: + TxControl.setDefaultTimeout( BeanPopulator.getDefaultInstance( CoordinatorEnvironmentBean.class ).getDefaultTimeout() ); + } } diff --git a/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/transaction/TransactionIT.java b/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/transaction/TransactionIT.java index b2ace897630..57998ff0dfb 100644 --- a/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/transaction/TransactionIT.java +++ b/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/transaction/TransactionIT.java @@ -30,7 +30,7 @@ // Adding a property here is just a "workaround" to make sure that a different context is used for this test // otherwise there can be build errors when running all the tests via maven. -@SpringBootTest(properties = "spring.jta.atomikos.datasource.bean-name=hsearch-datasource1") +@SpringBootTest(properties = "spring.datasource.name=hsearch-datasource1") @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) class TransactionIT extends AbstractMapperOrmSpringIT { diff --git a/integrationtest/mapper/orm-spring/src/test/resources/application-jta.yaml b/integrationtest/mapper/orm-spring/src/test/resources/application-jta.yaml index 09303d84419..bc7f429906b 100644 --- a/integrationtest/mapper/orm-spring/src/test/resources/application-jta.yaml +++ b/integrationtest/mapper/orm-spring/src/test/resources/application-jta.yaml @@ -11,13 +11,7 @@ spring.jpa: use_second_level_cache: false use_query_cache: false -spring: - jta: - atomikos: - datasource: - borrow-connection-timeout: 3000 - local-transaction-mode: true # allow-local-transactions ? - min-pool-size: 5 - max-pool-size: 100 - properties: - transaction-manager-unique-name: xaDataSource +spring.datasource: + agroal: + min-size: 5 + max-size: 100 diff --git a/integrationtest/mapper/orm-spring/src/test/resources/application-transaction-timeout.yaml b/integrationtest/mapper/orm-spring/src/test/resources/application-transaction-timeout.yaml index f26af91e6a1..8b8c5e7aa0d 100644 --- a/integrationtest/mapper/orm-spring/src/test/resources/application-transaction-timeout.yaml +++ b/integrationtest/mapper/orm-spring/src/test/resources/application-transaction-timeout.yaml @@ -6,7 +6,5 @@ spring.jpa: internal: configurer: org.hibernate.search.integrationtest.spring.jta.timeout.TimeoutOutboxPollingInternalConfigurer background_failure_handler: org.hibernate.search.integrationtest.spring.jta.timeout.TimeoutFailureCollector -atomikos: - properties: - # note this value is converted to seconds (default-jta-timeout/1000) so we should keep in mind when updating it: - default-jta-timeout: 1000 +narayana: + default-timeout: 1 diff --git a/integrationtest/mapper/orm-spring/src/test/resources/application.yaml b/integrationtest/mapper/orm-spring/src/test/resources/application.yaml index beabc016cf7..fc797aff8da 100644 --- a/integrationtest/mapper/orm-spring/src/test/resources/application.yaml +++ b/integrationtest/mapper/orm-spring/src/test/resources/application.yaml @@ -11,6 +11,12 @@ spring.datasource: url: ${JDBC_URL} # From environment variable username: ${JDBC_USERNAME} # From environment variable password: ${JDBC_PASSWORD} # From environment variable + generate-unique-name: false + name: hsearch-datasource + type: io.agroal.springframework.boot.AgroalDataSource + agroal: + min-size: 2 + max-size: 10 logging.level: org.springframework.core.env: DEBUG @@ -20,13 +26,8 @@ logging.level: org.hibernate.search.elasticsearch.client.request: DEBUG org.hibernate.search.backend.lucene: DEBUG -# since atomikos connection pool has a max size set to 1 ... -# we will not be able to execute more than one transaction at a time, leading to errors in tests spring: jta: - atomikos: - datasource: - bean-name: hsearch-datasource - min-pool-size: 2 - max-pool-size: 10 - + enabled: true +narayana: + log-dir: target/transaction-logs diff --git a/pom.xml b/pom.xml index 32727d06d3c..1e6249e0a53 100644 --- a/pom.xml +++ b/pom.xml @@ -1378,20 +1378,6 @@ - - testWithJdk23 - - - java-version.test.release - 23 - - - - - true - - - testWithJdk24