-
Notifications
You must be signed in to change notification settings - Fork 327
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: backport Spring Boot 3.2 compatibility updates to Spring Cloud G…
…CP 4.x (#2397) * feat: Spring Boot 3.2 compatibility (#2319) * deps: spring cloud 2023.0.0-M2 and spring boot 3.2.0-RC1 * fix: SpannerCompositeKeyProperty implements isReadable * fix: PubSubHealthIndicatorAutoConfiguration uses indicator factory injection * fix: SpannerHealthIndicatorAutoConfiguration uses indicator factory injection * chore: add PubSubSubscriptionHealthIndicatorAutoConfigurationTests * fix: PubSubSubscriptionHealthIndicatorAutoConfiguration explicitly does not support indicator creation * fix: Remove @OverRide from SpannerCompositeKeyProperty.isReadable * fix: PubSubSubscriptionHealthIndicatorAutoConfiguration generics changed * chore: Test PubSubSubscriptionHealthIndicatorAutoConfiguration * fix: imports * fix: GqlDatastoreQuery isPaged logic * chore: maintain spring boot 3.1.5 dependency after 3.2.x compatibility updates * fix: use mock MetricServiceClient in test * chore: formatting
- Loading branch information
1 parent
325f513
commit a640b75
Showing
7 changed files
with
103 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
.../autoconfigure/pubsub/health/PubSubSubscriptionHealthIndicatorAutoConfigurationTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
* Copyright 2018-2020 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.cloud.spring.autoconfigure.pubsub.health; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.mockito.Mockito.mock; | ||
|
||
import com.google.api.gax.core.CredentialsProvider; | ||
import com.google.auth.Credentials; | ||
import com.google.cloud.monitoring.v3.MetricServiceClient; | ||
import com.google.cloud.spring.autoconfigure.pubsub.GcpPubSubAutoConfiguration; | ||
import com.google.cloud.spring.core.GcpProjectIdProvider; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.boot.autoconfigure.AutoConfigurations; | ||
import org.springframework.boot.test.context.runner.ApplicationContextRunner; | ||
|
||
/** | ||
* Tests for Pub/Sub Health Indicator autoconfiguration. | ||
*/ | ||
class PubSubSubscriptionHealthIndicatorAutoConfigurationTests { | ||
|
||
private final ApplicationContextRunner contextRunner = | ||
new ApplicationContextRunner() | ||
.withConfiguration( | ||
AutoConfigurations.of( | ||
PubSubSubscriptionHealthIndicatorAutoConfiguration.class, | ||
GcpPubSubAutoConfiguration.class)) | ||
.withBean(GcpProjectIdProvider.class, () -> () -> "fake project") | ||
.withBean(CredentialsProvider.class, () -> () -> mock(Credentials.class)) | ||
.withBean(MetricServiceClient.class, () -> mock(MetricServiceClient.class)); | ||
|
||
@Test | ||
void healthIndicatorPresent_defaults() { | ||
this.contextRunner | ||
.withPropertyValues( | ||
"spring.cloud.gcp.pubsub.health.lagThreshold=1", | ||
"spring.cloud.gcp.pubsub.health.backlogThreshold=1") | ||
.run(ctx -> assertThat(ctx).hasSingleBean(PubSubSubscriptionHealthIndicator.class)); | ||
} | ||
|
||
@Test | ||
void healthIndicatorNotPresent_whenDisabled() { | ||
this.contextRunner | ||
.withPropertyValues( | ||
"management.health.pubsub-subscriber.enabled:false", | ||
"spring.cloud.gcp.pubsub.health.lagThreshold=1", | ||
"spring.cloud.gcp.pubsub.health.backlogThreshold=1") | ||
.run(ctx -> assertThat(ctx).doesNotHaveBean(PubSubSubscriptionHealthIndicator.class)); | ||
} | ||
|
||
@Test | ||
void healthIndicatorNotPresent_whenMissingLagThreshold() { | ||
this.contextRunner | ||
.withPropertyValues( | ||
"spring.cloud.gcp.pubsub.health.backlogThreshold=1") | ||
.run(ctx -> assertThat(ctx).doesNotHaveBean(PubSubSubscriptionHealthIndicator.class)); | ||
} | ||
|
||
@Test | ||
void healthIndicatorNotPresent_whenMissingBacklogThreshold() { | ||
this.contextRunner | ||
.withPropertyValues( | ||
"spring.cloud.gcp.pubsub.health.lagThreshold=1") | ||
.run(ctx -> assertThat(ctx).doesNotHaveBean(PubSubSubscriptionHealthIndicator.class)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters