Skip to content
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

Failing dynamo create requests when a range is specified since it is ignored. #390

Merged
merged 5 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ class DynamoDbBackfillOperator<I : Any, P : Any>(
val config = parametersOperator.constructBackfillConfig(request)
backfill.validate(config)

require(
request.range == null ||
(request.range.start == null && request.range.end == null),
) { "Range is an invalid input for this Dynamo Backfila client" }
mpawliszyn marked this conversation as resolved.
Show resolved Hide resolved

var table = dynamoDbClient.describeTable {
it.tableName(backfill.dynamoDbTable.tableName())
}.table()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,23 @@ class DynamoDbBackfillTest {
}.hasMessageContaining("Validate failed")
}

@Test
fun `adding a range fails creation`() {
testData.addThriller()

assertThatCode {
backfila.createWetRun<MakeTracksExplicitBackfill>(rangeStart = "start")
}.hasMessageContaining("Range is an invalid input for this Dynamo Backfila client")

assertThatCode {
backfila.createWetRun<MakeTracksExplicitBackfill>(rangeEnd = "end")
}.hasMessageContaining("Range is an invalid input for this Dynamo Backfila client")

assertThatCode {
backfila.createWetRun<MakeTracksExplicitBackfill>(rangeStart = "start", rangeEnd = "end")
}.hasMessageContaining("Range is an invalid input for this Dynamo Backfila client")
}

class MakeTracksExplicitBackfill @Inject constructor(
dynamoDb: DynamoDbClient,
private val dynamoDbEnhancedClient: DynamoDbEnhancedClient,
Expand Down
6 changes: 6 additions & 0 deletions client-dynamodb/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ dependencies {
testImplementation(project(":backfila-embedded"))
testImplementation(project(":client-testing"))

if (org.apache.tools.ant.taskdefs.condition.Os.isArch("aarch64")) {
// Without this, we can't compile on Apple Silicon currently. This is likely not necessary to
// have longterm, so we should remove it when platform fixes things across Square.
testImplementation("io.github.ganadist.sqlite4java:libsqlite4java-osx-aarch64:1.0.392")
}

// ****************************************
// For TESTING purposes only. We only want Misk for easy testing.
// DO NOT turn these into regular dependencies.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ class DynamoDbBackfillOperator<I : Any, P : Any>(
val config = parametersOperator.constructBackfillConfig(request)
backfill.validate(config)

require(
request.range == null ||
(request.range.start == null && request.range.end == null),
) { "Range is an invalid input for this Dynamo Backfila client" }
mpawliszyn marked this conversation as resolved.
Show resolved Hide resolved

val tableMapper = dynamoDb.newTableMapper<I, Any, Any>(backfill.itemType.java)
val tableDescription = tableMapper.describeTable()
if (backfill.mustHaveProvisionedBillingMode()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,23 @@ class DynamoDbBackfillTest {
}.hasMessageContaining("Validate failed")
}

@Test
fun `adding a range fails creation`() {
testData.addThriller()

assertThatCode {
backfila.createWetRun<MakeTracksExplicitBackfill>(rangeStart = "start")
}.hasMessageContaining("Range is an invalid input for this Dynamo Backfila client")

assertThatCode {
backfila.createWetRun<MakeTracksExplicitBackfill>(rangeEnd = "end")
}.hasMessageContaining("Range is an invalid input for this Dynamo Backfila client")

assertThatCode {
backfila.createWetRun<MakeTracksExplicitBackfill>(rangeStart = "start", rangeEnd = "end")
}.hasMessageContaining("Range is an invalid input for this Dynamo Backfila client")
}

class MakeTracksExplicitBackfill @Inject constructor(
dynamoDb: DynamoDBMapper,
) : UpdateInPlaceDynamoDbBackfill<TrackItem, MakeTracksExplicitBackfill.ExplicitParameters>(dynamoDb) {
Expand Down
Loading