-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
INC-1064: update to DPS Gradle Plugin v5 which includes Spring Boot v3 and AWS SDK v2 #407
Conversation
…s we're now using SqsAsyncClient It was added with ministryofjustice/hmpps-spring-boot-sqs#122
@@ -10,7 +10,7 @@ import org.springframework.security.web.server.SecurityWebFilterChain | |||
|
|||
@Configuration | |||
@EnableWebFluxSecurity | |||
@EnableReactiveMethodSecurity | |||
@EnableReactiveMethodSecurity(useAuthorizationManager = false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
applicationinsights.json
Outdated
@@ -6,6 +6,9 @@ | |||
"service.version": "${BUILD_NUMBER}" | |||
}, | |||
"instrumentation": { | |||
"springScheduling": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
microsoft/ApplicationInsights-Java#2870 (comment) – can’t tell if this is still required to throttle app insights logging?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good spot! Removed with be9b7a0
@@ -17,14 +17,19 @@ configurations { | |||
testImplementation { exclude(group = "org.junit.vintage") } | |||
} | |||
|
|||
repositories { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -768,7 +768,7 @@ class IepLevelResourceTest : IncentiveLevelResourceTestBase() { | |||
}""", | |||
) | |||
.exchange() | |||
.expectErrorResponse(HttpStatus.BAD_REQUEST, "Invalid parameters: `iepLevel` must have length of at most 6") | |||
.expectErrorResponse(HttpStatus.BAD_REQUEST, "Parameter conversion failure: 400 BAD_REQUEST \"Failed to read HTTP message\"") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a funny one - putting a debug break point on HmppsIncentivesApiExceptionHandlerhandleServerWebInputException
the e.cause
is
org.springframework.core.codec.DecodingException:
JSON decoding error:
Cannot construct instance of `uk.gov.justice.digital.hmpps.incentivesapi.dto.SyncPostRequest`,
problem: Invalid parameters: `iepLevel` must have length of at most 6
I'm not entirely sure why it now drops into there, rather than handleParameterValidationException
which it previously used to do, perhaps because a change to jakarta.validation.ValidationException
🤔 Do folks think it's worth investigating further?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i would like to look into it. we should either assert that the "cause" still has the right message, or (if not too tough) make the right exception bubble up
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed - raised https://dsdmoj.atlassian.net/browse/INC-1199
import org.springframework.context.annotation.Bean | ||
import org.springframework.context.annotation.Configuration | ||
|
||
/** | ||
* Application insights now controlled by the spring-boot-starter dependency. However when the key is not specified | ||
* we don't get a telemetry bean and application won't start. Therefore need this backup configuration. | ||
* TelemetryClient gets altered at runtime by the java agent and so is a no-op otherwise |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dependencies { | ||
implementation("org.springframework.boot:spring-boot-starter-webflux") | ||
implementation("org.springframework.boot:spring-boot-starter-data-r2dbc") | ||
implementation("org.springframework.boot:spring-boot-starter-oauth2-resource-server") | ||
implementation("org.springframework.boot:spring-boot-starter-security") | ||
implementation("org.springframework.boot:spring-boot-starter-oauth2-client") | ||
|
||
implementation("uk.gov.justice.service.hmpps:hmpps-sqs-spring-boot-starter:1.2.0") | ||
implementation("uk.gov.justice.service.hmpps:hmpps-sqs-spring-boot-starter:2.0.0-beta-14") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Upgrading this as it's compatible with Spring Boot v3 - see https://github.com/ministryofjustice/hmpps-spring-boot-sqs/blob/spring-boot-3/release-notes/2.0.0.md
import uk.gov.justice.digital.hmpps.incentivesapi.jpa.IncentiveLevel | ||
import uk.gov.justice.digital.hmpps.incentivesapi.jpa.PrisonIncentiveLevel | ||
import uk.gov.justice.digital.hmpps.incentivesapi.jpa.repository.IncentiveLevelRepository | ||
import uk.gov.justice.digital.hmpps.incentivesapi.jpa.repository.PrisonIncentiveLevelRepository | ||
import uk.gov.justice.digital.hmpps.incentivesapi.service.AuditEvent | ||
import uk.gov.justice.digital.hmpps.incentivesapi.service.HMPPSDomainEvent | ||
import uk.gov.justice.digital.hmpps.incentivesapi.service.HMPPSMessage | ||
import uk.gov.justice.hmpps.sqs.countMessagesOnQueue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was added with ministryofjustice/hmpps-spring-boot-sqs#122 so removed our function AmazonSQS.getApproxQueueSize
import uk.gov.justice.digital.hmpps.incentivesapi.integration.LocalStackContainer.setLocalStackProperties | ||
import uk.gov.justice.hmpps.sqs.HmppsQueue | ||
import uk.gov.justice.hmpps.sqs.HmppsQueueService | ||
import uk.gov.justice.hmpps.sqs.HmppsSqsProperties | ||
import uk.gov.justice.hmpps.sqs.MissingQueueException | ||
import uk.gov.justice.hmpps.sqs.MissingTopicException | ||
import uk.gov.justice.hmpps.sqs.countMessagesOnQueue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was added with ministryofjustice/hmpps-spring-boot-sqs#122 so removed our function getNumberOfMessagesCurrentlyOnQueue
@@ -16,7 +16,7 @@ class PrisonOffenderEventListener( | |||
val log: Logger = LoggerFactory.getLogger(this::class.java) | |||
} | |||
|
|||
@JmsListener(destination = "incentives", containerFactory = "hmppsQueueContainerFactoryProxy") | |||
@SqsListener("incentives", factory = "hmppsQueueContainerFactoryProxy") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I spotted ministryofjustice/hmpps-prisoner-to-nomis-update#164 - which we could also include if folks think it would be helpful?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not a bad idea. maybe we can do that in a separate pr as there are probs other methods that would benefit with span annotations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good shout - raised https://dsdmoj.atlassian.net/browse/INC-1198
applicationinsights.json
Outdated
@@ -6,6 +6,9 @@ | |||
"service.version": "${BUILD_NUMBER}" | |||
}, | |||
"instrumentation": { | |||
"springScheduling": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
microsoft/ApplicationInsights-Java#2870 (comment) – can’t tell if this is still required to throttle app insights logging?
@@ -13,7 +13,7 @@ import io.swagger.v3.oas.models.security.Scopes | |||
import io.swagger.v3.oas.models.security.SecurityRequirement | |||
import io.swagger.v3.oas.models.security.SecurityScheme | |||
import io.swagger.v3.oas.models.servers.Server | |||
import org.springdoc.core.customizers.OpenApiCustomiser | |||
import org.springdoc.core.customizers.OpenApiCustomizer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😒
@@ -16,7 +16,7 @@ class PrisonOffenderEventListener( | |||
val log: Logger = LoggerFactory.getLogger(this::class.java) | |||
} | |||
|
|||
@JmsListener(destination = "incentives", containerFactory = "hmppsQueueContainerFactoryProxy") | |||
@SqsListener("incentives", factory = "hmppsQueueContainerFactoryProxy") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not a bad idea. maybe we can do that in a separate pr as there are probs other methods that would benefit with span annotations
@@ -59,7 +59,7 @@ class JwtAuthHelper { | |||
.setSubject(subject) | |||
.addClaims(it.toMap()) | |||
.setExpiration(Date(System.currentTimeMillis() + expiryTime.toMillis())) | |||
.signWith(SignatureAlgorithm.RS256, keyPair.private) | |||
.signWith(keyPair.private, SignatureAlgorithm.RS256) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤣
@@ -768,7 +768,7 @@ class IepLevelResourceTest : IncentiveLevelResourceTestBase() { | |||
}""", | |||
) | |||
.exchange() | |||
.expectErrorResponse(HttpStatus.BAD_REQUEST, "Invalid parameters: `iepLevel` must have length of at most 6") | |||
.expectErrorResponse(HttpStatus.BAD_REQUEST, "Parameter conversion failure: 400 BAD_REQUEST \"Failed to read HTTP message\"") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i would like to look into it. we should either assert that the "cause" still has the right message, or (if not too tough) make the right exception bubble up
@@ -134,7 +134,7 @@ class IncentiveReviewsResourceTest : IncentiveLevelResourceTestBase() { | |||
.uri("/incentives-reviews/prison/MDI/location/MDI-1/level/STD?sort=PRISON") | |||
.headers(setAuthorisation(roles = listOf("ROLE_INCENTIVES"))) | |||
.exchange() | |||
.expectErrorResponse(HttpStatus.BAD_REQUEST, "No enum constant") | |||
.expectErrorResponse(HttpStatus.BAD_REQUEST, "Parameter conversion failure: 400 BAD_REQUEST \"Type mismatch.\"") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if "No enum constant" doesn't appear anywhere including the "cause", then this seems reasonable. though i'd only search for "Type mismatch".
related to https://github.com/ministryofjustice/hmpps-incentives-api/pull/407/files#r1159704464
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
happy to approve, but i would like to re-evaluate that exception testing to see if it can assert for the right message. or you can if you have an idea how to :)
assertThat(queueSize).isEqualTo(0) | ||
} | ||
|
||
protected fun assertDomainEventSent(eventType: String): HMPPSDomainEvent { | ||
val sqsClient = incentivesQueue.sqsClient | ||
val queueSize = sqsClient.getApproxQueueSize(testDomainEventQueueUrl!!) | ||
assertThat(queueSize).isEqualTo(1) | ||
await untilCallTo { sqsClient.countMessagesOnQueue(testDomainEventQueueUrl!!).get() } matches { it == 1 } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added this, and other awaits
, because was finding tests were consistently failing
Assumed it was because we're now using software.amazon.awssdk.services.sqs.SqsAsyncClient
(via uk.gov.justice.service.hmpps:hmpps-sqs-spring-boot-starter:2.0.0-beta-14
) whereas previously we were using the synchronous class com.amazonaws.services.sqs.AmazonSQS
https://dsdmoj.atlassian.net/browse/INC-1064