Skip to content

Commit

Permalink
feat!: Spring Cloud 2023 and Spring Boot 3.2.0 (#2438)
Browse files Browse the repository at this point in the history
* BREAKING CHANGE: Spring Cloud 2023 and Spring Boot 3.2.0

* deps: spring-cloud-build 4.1.0

* fix: don't base AutoConfiguration enable check on bean that is now auto-created by Spring Boot 3.2

(See https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-3.2-Release-Notes#observability-improvements)

* fix: use @DisabledInAotMode for incompatible features

* fix: use @DisabledInAotMode for incompatible features

* fix: add trace-class-initialization for AotDetector

* fix: disable incompatible native tests
  • Loading branch information
burkedavison authored Dec 13, 2023
1 parent e7e7a83 commit ee4a9d6
Show file tree
Hide file tree
Showing 20 changed files with 48 additions and 15 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/NativeTests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ jobs:
it:
- bigquery-sample
- core
- data-firestore
#- data-firestore ## https://github.com/GoogleCloudPlatform/spring-cloud-gcp/issues/2455
- data-firestore-sample
- datastore
#- datastore ## https://github.com/GoogleCloudPlatform/spring-cloud-gcp/issues/2455
- datastore-basic-sample
- kms
- kms-sample
Expand All @@ -38,7 +38,7 @@ jobs:
- pubsub-sample
- pubsub-bus-sample
- pubsub-integration-sample
- pubsub-stream-sample
#- pubsub-stream-sample ## https://github.com/GoogleCloudPlatform/spring-cloud-gcp/issues/2456
- secretmanager
- secretmanager-sample
- spanner
Expand Down
2 changes: 1 addition & 1 deletion docs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-build</artifactId>
<version>4.0.5</version>
<version>4.1.0</version>
<relativePath/>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
<properties>
<project.parent.version>${project.version}</project.parent.version>
<!-- Dependency versions -->
<spring-cloud-dependencies.version>2022.0.4</spring-cloud-dependencies.version>
<spring-boot-dependencies.version>3.1.5</spring-boot-dependencies.version>
<spring-cloud-dependencies.version>2023.0.0</spring-cloud-dependencies.version>
<spring-boot-dependencies.version>3.2.0</spring-boot-dependencies.version>
<spring-cloud-gcp-dependencies.version>${project.parent.version}</spring-cloud-gcp-dependencies.version>
<zipkin-gcp.version>1.0.4</zipkin-gcp.version>
<java-cfenv.version>2.5.0</java-cfenv.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ void test() {

@Test
void testPubSubTracingDisabledByDefault() {
this.contextRunner.run(
context -> {
assertThat(context.getBeansOfType(TracePubSubBeanPostProcessor.class)).isEmpty();
assertThat(context.getBeansOfType(PubSubTracing.class)).isEmpty();
assertThat(context.getBeansOfType(MessagingTracing.class)).isEmpty();
assertThat(context.getBeansOfType(ObservedAspect.class)).isEmpty();
});
this.contextRunner
.run(
context -> {
assertThat(context.getBeansOfType(TracePubSubBeanPostProcessor.class)).isEmpty();
assertThat(context.getBeansOfType(PubSubTracing.class)).isEmpty();
assertThat(context.getBeansOfType(MessagingTracing.class)).isEmpty();
});
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.domain.AuditorAware;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.aot.DisabledInAotMode;
import org.springframework.test.context.junit.jupiter.SpringExtension;

/** Tests the auditing features of the template. */
@ExtendWith(SpringExtension.class)
@ContextConfiguration
@DisabledInAotMode
class DatastoreTemplateAuditingTests {

private static final Instant LONG_AGO = Instant.parse("2000-01-01T00:00:00.00Z");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import org.springframework.context.annotation.Configuration;
import org.springframework.data.annotation.Id;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.aot.DisabledInAotMode;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.transaction.annotation.Isolation;
Expand All @@ -57,6 +58,7 @@
*/
@ExtendWith(SpringExtension.class)
@ContextConfiguration
@DisabledInAotMode
class DatastoreTransactionTemplateTests {

private final Key key = Key.newBuilder("a", "b", "c").build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
import org.springframework.data.domain.Sort;
import org.springframework.data.repository.query.FluentQuery.FetchableFluentQuery;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.aot.DisabledInAotMode;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.util.AopTestUtils;
import org.springframework.transaction.TransactionSystemException;
Expand All @@ -106,6 +107,7 @@
@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = {DatastoreIntegrationTestConfiguration.class})
@ImportRuntimeHints({TestRuntimeHints.class})
@DisabledInAotMode
class DatastoreIntegrationTests extends AbstractDatastoreIntegrationTests {

// This value is multiplied against recorded actual times needed to wait for eventual
Expand Down Expand Up @@ -712,6 +714,7 @@ void referenceTest() {

@Test
@DisabledInNativeImage
@DisabledInAotMode
void lazyReferenceCollectionTest() {
ReferenceLazyEntity parent = saveEntitiesGraph();

Expand All @@ -728,6 +731,7 @@ void lazyReferenceCollectionTest() {

@Test
@DisabledInNativeImage
@DisabledInAotMode
void lazyReferenceTest() throws InterruptedException {
LazyEntity lazyParentEntity = new LazyEntity(new LazyEntity(new LazyEntity()));
this.datastoreTemplate.save(lazyParentEntity);
Expand All @@ -744,6 +748,7 @@ void lazyReferenceTest() throws InterruptedException {

@Test
@DisabledInNativeImage
@DisabledInAotMode
void singularLazyPropertyTest() {
LazyEntity lazyParentEntity = new LazyEntity(new LazyEntity(new LazyEntity()));
this.datastoreTemplate.save(lazyParentEntity);
Expand All @@ -755,6 +760,7 @@ void singularLazyPropertyTest() {

@Test
@DisabledInNativeImage
@DisabledInAotMode
void lazyReferenceTransactionTest() {
ReferenceLazyEntity parent = saveEntitiesGraph();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Slice;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.aot.DisabledInAotMode;
import org.springframework.test.context.junit.jupiter.SpringExtension;

/** Projection tests separated from DatastoreIntegrationTests.java that needs mockito */
@DisabledInNativeImage
@DisabledInAotMode
@EnabledIfSystemProperty(named = "it.datastore", matches = "true")
@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = {DatastoreIntegrationTestConfiguration.class})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.aot.DisabledInAotMode;
import org.springframework.test.context.junit.jupiter.SpringExtension;

/** Tests performing many operations at the same time using single instances of the repository. */
@EnabledIfSystemProperty(named = "it.datastore", matches = "true")
@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = {DatastoreIntegrationTestConfiguration.class})
@DisabledInAotMode
class ParallelDatastoreIntegrationTests extends AbstractDatastoreIntegrationTests {

private static final int PARALLEL_OPERATIONS = 10;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,18 @@
import java.util.List;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledInNativeImage;
import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.aot.DisabledInAotMode;
import org.springframework.test.context.junit.jupiter.SpringExtension;

@EnabledIfSystemProperty(named = "it.datastore", matches = "true")
@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = {DatastoreIntegrationTestConfiguration.class})
@DisabledInAotMode
class SubclassesDescendantsIntegrationTests extends AbstractDatastoreIntegrationTests {

@Autowired SubclassesDescendantsEntityArepository entityArepository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.aot.DisabledInAotMode;
import org.springframework.test.context.junit.jupiter.SpringExtension;

@EnabledIfSystemProperty(named = "it.datastore", matches = "true")
@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = {DatastoreIntegrationTestConfiguration.class})
@DisabledInAotMode
class SubclassesReferencesIntegrationTests extends AbstractDatastoreIntegrationTests {

@Autowired SubclassesReferencesEntityArepository entityArepository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.aot.DisabledInAotMode;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.transaction.reactive.TransactionalOperator;
import org.springframework.transaction.support.DefaultTransactionDefinition;
Expand All @@ -42,6 +43,7 @@
@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = FirestoreTransactionIntegrationTestsConfiguration.class)
@DisabledInNativeImage
@DisabledInAotMode
class FirestoreRepositoryTransactionIntegrationTests {
// tag::autowire[]
@Autowired UserRepository userRepository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.aot.DisabledInAotMode;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.transaction.reactive.TransactionalOperator;
import org.springframework.transaction.support.DefaultTransactionDefinition;
Expand All @@ -50,6 +51,7 @@
@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = FirestoreTransactionIntegrationTestsConfiguration.class)
@DisabledInNativeImage
@DisabledInAotMode
class FirestoreTransactionIntegrationTests {

@Autowired FirestoreTemplate firestoreTemplate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.domain.AuditorAware;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.aot.DisabledInAotMode;
import org.springframework.test.context.junit.jupiter.SpringExtension;

/** Tests the auditing features of the template. */
@ExtendWith(SpringExtension.class)
@ContextConfiguration
@DisabledInAotMode
class SpannerTemplateAuditingTests {

private static final List<Mutation> UPSERT_MUTATION =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,15 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.aot.DisabledInAotMode;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.transaction.annotation.Transactional;

/** Tests for Spanner Template when using transactional annotation. */
@ExtendWith(SpringExtension.class)
@ContextConfiguration
@DisabledInAotMode
class SpannerTemplateTransactionManagerTests {
private static final List<Mutation> INSERT_MUTATION =
Arrays.asList(Mutation.newInsertBuilder("custom_test_table").build());
Expand Down
2 changes: 1 addition & 1 deletion spring-cloud-gcp-samples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.1.5</version>
<version>3.2.0</version>
<relativePath/>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<name>Spring Framework on Google Cloud Code Sample - Pub/Sub Bus Configuration Management</name>

<properties>
<spring-cloud-config.version>4.0.4</spring-cloud-config.version>
<spring-cloud-config.version>4.1.0</spring-cloud-config.version>
</properties>

<!-- The Spring Framework on Google Cloud BOM will manage spring-cloud-gcp version numbers for you. -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,14 @@
import org.springframework.integration.file.filters.AcceptOnceFileListFilter;
import org.springframework.messaging.Message;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.aot.DisabledInAotMode;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

/** Tests for inbound file synchronizer. */
@ExtendWith(SpringExtension.class)
@ContextConfiguration
@DisabledInAotMode
class GcsInboundFileSynchronizerTests {

@Autowired private Storage gcs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,13 @@
import org.springframework.messaging.Message;
import org.springframework.messaging.PollableChannel;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.aot.DisabledInAotMode;
import org.springframework.test.context.junit.jupiter.SpringExtension;

/** Tests for the streaming message source. */
@ExtendWith(SpringExtension.class)
@ContextConfiguration
@DisabledInAotMode
class GcsStreamingMessageSourceTests {

@Autowired private PollableChannel unsortedChannel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,13 @@
import org.springframework.messaging.MessageHandler;
import org.springframework.messaging.support.GenericMessage;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.aot.DisabledInAotMode;
import org.springframework.test.context.junit.jupiter.SpringExtension;

/** Tests for the message handler. */
@ExtendWith(SpringExtension.class)
@ContextConfiguration
@DisabledInAotMode
class GcsMessageHandlerTests {

private static Storage GCS;
Expand Down

0 comments on commit ee4a9d6

Please sign in to comment.