From 5de9b0d6c1ea740c3fda828688e753dd51756aa1 Mon Sep 17 00:00:00 2001 From: Attila Kis <9131941+atosz33@users.noreply.github.com> Date: Fri, 2 Oct 2026 19:39:34 +0200 Subject: [PATCH] fix(dynamodb): match the AWS shape of the Kinesis destination responses (#4917) DisableKinesisStreamingDestination now returns EnableKinesisStreamingConfiguration with the precision the destination still carries, like AWS does. Drop DestinationStatusDescription from the Enable and Disable responses. AWS carries that member on DescribeKinesisStreamingDestination only, where it stays. Build both responses from one snapshot taken while the call runs, so a concurrent call on the same destination cannot change the status this answer reports. Add an SDK compatibility test, because the SDK parses the typed response members that handcrafted HTTP cannot check. Document that Enable and Disable report the precision too. --- ...namoDbKinesisStreamingDestinationTest.java | 158 ++++++++++++++++++ docs/services/dynamodb.md | 11 +- .../dynamodb/NativeDynamoDbJsonHandler.java | 35 ++-- .../dynamodb/NativeDynamoDbTableService.java | 43 +++-- ...namoDbKinesisStreamingIntegrationTest.java | 19 ++- .../NativeDynamoDbTableServiceTest.java | 17 +- 6 files changed, 245 insertions(+), 38 deletions(-) create mode 100644 compatibility-tests/sdk-test-java/src/test/java/com/floci/test/DynamoDbKinesisStreamingDestinationTest.java diff --git a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/DynamoDbKinesisStreamingDestinationTest.java b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/DynamoDbKinesisStreamingDestinationTest.java new file mode 100644 index 0000000000..e97608a6ac --- /dev/null +++ b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/DynamoDbKinesisStreamingDestinationTest.java @@ -0,0 +1,158 @@ +package com.floci.test; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.MethodOrderer; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestMethodOrder; +import software.amazon.awssdk.services.dynamodb.DynamoDbClient; +import software.amazon.awssdk.services.dynamodb.model.ApproximateCreationDateTimePrecision; +import software.amazon.awssdk.services.dynamodb.model.AttributeDefinition; +import software.amazon.awssdk.services.dynamodb.model.BillingMode; +import software.amazon.awssdk.services.dynamodb.model.CreateTableRequest; +import software.amazon.awssdk.services.dynamodb.model.DeleteTableRequest; +import software.amazon.awssdk.services.dynamodb.model.DescribeKinesisStreamingDestinationRequest; +import software.amazon.awssdk.services.dynamodb.model.DescribeKinesisStreamingDestinationResponse; +import software.amazon.awssdk.services.dynamodb.model.DestinationStatus; +import software.amazon.awssdk.services.dynamodb.model.DisableKinesisStreamingDestinationRequest; +import software.amazon.awssdk.services.dynamodb.model.DisableKinesisStreamingDestinationResponse; +import software.amazon.awssdk.services.dynamodb.model.EnableKinesisStreamingConfiguration; +import software.amazon.awssdk.services.dynamodb.model.EnableKinesisStreamingDestinationRequest; +import software.amazon.awssdk.services.dynamodb.model.EnableKinesisStreamingDestinationResponse; +import software.amazon.awssdk.services.dynamodb.model.KeySchemaElement; +import software.amazon.awssdk.services.dynamodb.model.KeyType; +import software.amazon.awssdk.services.dynamodb.model.KinesisDataStreamDestination; +import software.amazon.awssdk.services.dynamodb.model.ScalarAttributeType; +import software.amazon.awssdk.services.kinesis.KinesisClient; +import software.amazon.awssdk.services.kinesis.model.CreateStreamRequest; +import software.amazon.awssdk.services.kinesis.model.DeleteStreamRequest; +import software.amazon.awssdk.services.kinesis.model.DescribeStreamSummaryRequest; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Reads the Kinesis streaming destination responses back through the AWS SDK, which parses them + * into typed models: a status outside the enum lands as UNKNOWN_TO_SDK_VERSION, and a missing + * EnableKinesisStreamingConfiguration lands as null. Handcrafted HTTP cannot show either. + * + *
Floci used to ignore ApproximateCreationDateTimePrecision and always report MILLISECOND.
+ */
+@DisplayName("DynamoDB Kinesis Streaming Destination")
+@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
+class DynamoDbKinesisStreamingDestinationTest {
+
+ private static final String TABLE_NAME = "sdk-kinesis-destination-table";
+ private static final String STREAM_NAME = "sdk-kinesis-destination-stream";
+
+ private static DynamoDbClient ddb;
+ private static KinesisClient kinesis;
+ private static String streamArn;
+
+ @BeforeAll
+ static void setup() {
+ ddb = TestFixtures.dynamoDbClient();
+ kinesis = TestFixtures.kinesisClient();
+
+ kinesis.createStream(CreateStreamRequest.builder()
+ .streamName(STREAM_NAME)
+ .shardCount(1)
+ .build());
+ streamArn = kinesis.describeStreamSummary(DescribeStreamSummaryRequest.builder()
+ .streamName(STREAM_NAME)
+ .build())
+ .streamDescriptionSummary()
+ .streamARN();
+
+ ddb.createTable(CreateTableRequest.builder()
+ .tableName(TABLE_NAME)
+ .keySchema(KeySchemaElement.builder().attributeName("pk").keyType(KeyType.HASH).build())
+ .attributeDefinitions(AttributeDefinition.builder().attributeName("pk")
+ .attributeType(ScalarAttributeType.S).build())
+ .billingMode(BillingMode.PAY_PER_REQUEST)
+ .build());
+ }
+
+ @AfterAll
+ static void cleanup() {
+ try {
+ ddb.deleteTable(DeleteTableRequest.builder().tableName(TABLE_NAME).build());
+ } catch (Exception ignored) {
+ // The table may already be gone; cleanup must not mask a test failure.
+ }
+ try {
+ kinesis.deleteStream(DeleteStreamRequest.builder().streamName(STREAM_NAME).build());
+ } catch (Exception ignored) {
+ // Same for the stream.
+ }
+ if (ddb != null) {
+ ddb.close();
+ }
+ if (kinesis != null) {
+ kinesis.close();
+ }
+ }
+
+ @Test
+ @Order(1)
+ void enableEchoesTheRequestedPrecision() {
+ EnableKinesisStreamingDestinationResponse response = ddb.enableKinesisStreamingDestination(
+ EnableKinesisStreamingDestinationRequest.builder()
+ .tableName(TABLE_NAME)
+ .streamArn(streamArn)
+ .enableKinesisStreamingConfiguration(EnableKinesisStreamingConfiguration.builder()
+ .approximateCreationDateTimePrecision(
+ ApproximateCreationDateTimePrecision.MICROSECOND)
+ .build())
+ .build());
+
+ assertThat(response.tableName()).isEqualTo(TABLE_NAME);
+ assertThat(response.streamArn()).isEqualTo(streamArn);
+ assertThat(response.destinationStatus())
+ .as("a status the SDK does not know would be UNKNOWN_TO_SDK_VERSION")
+ .isEqualTo(DestinationStatus.ACTIVE);
+ assertThat(response.enableKinesisStreamingConfiguration())
+ .as("the response must carry the configuration, not just the status")
+ .isNotNull();
+ assertThat(response.enableKinesisStreamingConfiguration().approximateCreationDateTimePrecision())
+ .isEqualTo(ApproximateCreationDateTimePrecision.MICROSECOND);
+ }
+
+ @Test
+ @Order(2)
+ void describeReportsTheStoredPrecision() {
+ DescribeKinesisStreamingDestinationResponse response = ddb.describeKinesisStreamingDestination(
+ DescribeKinesisStreamingDestinationRequest.builder().tableName(TABLE_NAME).build());
+
+ assertThat(response.tableName()).isEqualTo(TABLE_NAME);
+ assertThat(response.kinesisDataStreamDestinations()).hasSize(1);
+
+ KinesisDataStreamDestination destination = response.kinesisDataStreamDestinations().get(0);
+ assertThat(destination.streamArn()).isEqualTo(streamArn);
+ assertThat(destination.destinationStatus()).isEqualTo(DestinationStatus.ACTIVE);
+ assertThat(destination.destinationStatusDescription()).isNotBlank();
+ assertThat(destination.approximateCreationDateTimePrecision())
+ .as("the precision the destination was enabled with, not the MILLISECOND default")
+ .isEqualTo(ApproximateCreationDateTimePrecision.MICROSECOND);
+ }
+
+ @Test
+ @Order(3)
+ void disableReportsTheStoredPrecision() {
+ DisableKinesisStreamingDestinationResponse response = ddb.disableKinesisStreamingDestination(
+ DisableKinesisStreamingDestinationRequest.builder()
+ .tableName(TABLE_NAME)
+ .streamArn(streamArn)
+ .build());
+
+ assertThat(response.tableName()).isEqualTo(TABLE_NAME);
+ assertThat(response.streamArn()).isEqualTo(streamArn);
+ assertThat(response.destinationStatus()).isEqualTo(DestinationStatus.DISABLED);
+ assertThat(response.enableKinesisStreamingConfiguration())
+ .as("AWS answers Disable with the destination's configuration as well")
+ .isNotNull();
+ assertThat(response.enableKinesisStreamingConfiguration().approximateCreationDateTimePrecision())
+ .isEqualTo(ApproximateCreationDateTimePrecision.MICROSECOND);
+ }
+}
diff --git a/docs/services/dynamodb.md b/docs/services/dynamodb.md
index 6eb99b1660..5b25fec9b8 100644
--- a/docs/services/dynamodb.md
+++ b/docs/services/dynamodb.md
@@ -392,13 +392,18 @@ AWS CDC envelope (`eventName`, `dynamodb.Keys`, `NewImage`/`OldImage`, `Approxim
`ApproximateCreationDateTime` follows the destination's
`EnableKinesisStreamingConfiguration.ApproximateCreationDateTimePrecision`: epoch milliseconds for
-`MILLISECOND` (the default) and epoch microseconds for `MICROSECOND`. The precision is returned by
-`DescribeKinesisStreamingDestination` and stamped on each record as
-`dynamodb.ApproximateCreationDateTimePrecision`.
+`MILLISECOND` (the default) and epoch microseconds for `MICROSECOND`. The precision is stamped on each
+record as `dynamodb.ApproximateCreationDateTimePrecision`, and reported by
+`DescribeKinesisStreamingDestination` as well as in the `EnableKinesisStreamingConfiguration` member of
+the `EnableKinesisStreamingDestination` and `DisableKinesisStreamingDestination` responses.
Enabling a Kinesis streaming destination does not change the table's DynamoDB Streams setting.
Kinesis forwarding works whether or not `StreamSpecification.StreamEnabled` is set.
+Both calls take effect at once, so `EnableKinesisStreamingDestination` answers `ACTIVE` and
+`DisableKinesisStreamingDestination` answers `DISABLED`. AWS reports the transitional `ENABLING` and
+`DISABLING` first, because it enables and disables the destination in the background.
+
### Delivery contract
Forwarding is **bounded best-effort with in-process retry**. A write is never blocked or failed by
diff --git a/src/main/java/io/github/hectorvent/floci/services/dynamodb/NativeDynamoDbJsonHandler.java b/src/main/java/io/github/hectorvent/floci/services/dynamodb/NativeDynamoDbJsonHandler.java
index 7bb2c71a92..4af0dead3f 100644
--- a/src/main/java/io/github/hectorvent/floci/services/dynamodb/NativeDynamoDbJsonHandler.java
+++ b/src/main/java/io/github/hectorvent/floci/services/dynamodb/NativeDynamoDbJsonHandler.java
@@ -9,6 +9,7 @@ import io.github.hectorvent.floci.core.common.AwsErrorResponse;
import io.github.hectorvent.floci.core.common.AwsException;
import io.github.hectorvent.floci.services.dynamodb.NativeDynamoDbTableService.CreateTableRequest;
import io.github.hectorvent.floci.services.dynamodb.NativeDynamoDbTableService.GsiThroughputUpdate;
+import io.github.hectorvent.floci.services.dynamodb.NativeDynamoDbTableService.KinesisDestination;
import io.github.hectorvent.floci.services.dynamodb.NativeDynamoDbTableService.OnDemandThroughput;
import io.github.hectorvent.floci.services.dynamodb.NativeDynamoDbTableService.TableSettings;
import io.github.hectorvent.floci.services.dynamodb.NativeDynamoDbTableService.Throughput;
@@ -2253,31 +2254,31 @@ public class NativeDynamoDbJsonHandler {
400);
}
- String resolvedTableName = tableService.enableKinesisStreamingDestination(
- tableName, streamArn, precision, region);
-
- ObjectNode response = objectMapper.createObjectNode();
- response.put("TableName", resolvedTableName);
- response.put("StreamArn", streamArn);
- response.put("DestinationStatus", "ACTIVE");
- response.put("DestinationStatusDescription", "Kinesis streaming is enabled for this table");
- response.putObject("EnableKinesisStreamingConfiguration")
- .put("ApproximateCreationDateTimePrecision", precision);
- return Response.ok(response).build();
+ return Response.ok(kinesisDestinationResponse(
+ tableService.enableKinesisStreamingDestination(tableName, streamArn, precision, region))).build();
}
private Response handleDisableKinesisStreamingDestination(JsonNode request, String region) {
String tableName = request.path("TableName").asText();
String streamArn = request.path("StreamArn").asText();
- String resolvedTableName = tableService.disableKinesisStreamingDestination(tableName, streamArn, region);
+ return Response.ok(kinesisDestinationResponse(
+ tableService.disableKinesisStreamingDestination(tableName, streamArn, region))).build();
+ }
+ /**
+ * The shape Enable and Disable both answer with: TableName, StreamArn, DestinationStatus and
+ * EnableKinesisStreamingConfiguration. DestinationStatusDescription belongs to Describe only.
+ */
+ private ObjectNode kinesisDestinationResponse(KinesisDestination result) {
ObjectNode response = objectMapper.createObjectNode();
- response.put("TableName", resolvedTableName);
- response.put("StreamArn", streamArn);
- response.put("DestinationStatus", "DISABLED");
- response.put("DestinationStatusDescription", "Kinesis streaming is disabled for this table");
- return Response.ok(response).build();
+ response.put("TableName", result.tableName());
+ response.put("StreamArn", result.streamArn());
+ response.put("DestinationStatus", result.destinationStatus());
+ response.putObject("EnableKinesisStreamingConfiguration")
+ .put("ApproximateCreationDateTimePrecision",
+ result.approximateCreationDateTimePrecision());
+ return response;
}
private Response handleDescribeKinesisStreamingDestination(JsonNode request, String region) {
diff --git a/src/main/java/io/github/hectorvent/floci/services/dynamodb/NativeDynamoDbTableService.java b/src/main/java/io/github/hectorvent/floci/services/dynamodb/NativeDynamoDbTableService.java
index 93ed32aaba..f743fe3541 100644
--- a/src/main/java/io/github/hectorvent/floci/services/dynamodb/NativeDynamoDbTableService.java
+++ b/src/main/java/io/github/hectorvent/floci/services/dynamodb/NativeDynamoDbTableService.java
@@ -65,6 +65,14 @@ public class NativeDynamoDbTableService {
List