mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
feat(redshift): take a DynamoDB table and a Serverless namespace in zero-ETL integrations (#7332)
* feat(redshift): take a DynamoDB table and a Serverless namespace in zero-ETL integrations CreateIntegration took only a DynamoDB stream ARN as SourceArn and a provisioned cluster ARN as TargetArn. AWS takes the table ARN and a Redshift Serverless namespace ARN (its model allows no cluster: ARN), so a Terraform aws_redshift_integration written for AWS failed to create. Both AWS forms are now accepted and the original ones are kept. A missing table is IntegrationSourceNotFoundFault and a missing namespace IntegrationTargetNotFoundFault, as the API reference lists. A namespace is written through its workgroup into the namespace's database. A table source reads changes from the table's latest stream, following one turned on after the integration was created. Stream records never landed: the writer bound ApproximateCreationDateTime as an Instant, which the PostgreSQL driver refuses, so only backfilled items reached the landing table. It now binds an OffsetDateTime as TIMESTAMPTZ. * fix(redshift): drain a table's replaced stream and match the source table ARN A table source moved to the table's latest stream as soon as it changed, dropping records the old stream still held, and moved to no stream when DynamoDB Local reported none for a table whose streams were turned off. It now reads the followed stream until a read comes back empty, or until the stream has expired, before moving, keeps it while the table reports no stream, and persists the move. A source table ARN was resolved by its table name alone, so a table of another account, or an ARN with more after the name, was taken for the caller's table of that name. The resolved table must now have the supplied ARN. The docs no longer promise IntegrationSourceNotFoundFault for a missing stream. * test(redshift): use the shared Docker probe and Query request helpers in the zero-ETL test
This commit is contained in:
1 parent
56efb188b1
commit
6abdb4cc44
11 files changed
+852
-62
No files matched your search
+183
-10
@@ -16,6 +16,7 @@ import io.github.hectorvent.floci.services.dynamodb.backend.RecordingDynamoDbBac
|
||||
import io.github.hectorvent.floci.services.dynamodb.backend.RecordingDynamoDbBackend.Invocation;
|
||||
import io.github.hectorvent.floci.services.dynamodb.model.AttributeDefinition;
|
||||
import io.github.hectorvent.floci.services.dynamodb.model.KeySchemaElement;
|
||||
import io.github.hectorvent.floci.services.dynamodb.model.TableDefinition;
|
||||
import io.github.hectorvent.floci.services.redshift.model.Cluster;
|
||||
import io.github.hectorvent.floci.services.redshift.model.Integration;
|
||||
import io.github.hectorvent.floci.services.redshiftdata.RedshiftZeroEtlWriter;
|
||||
@@ -69,6 +70,7 @@ class RedshiftDynamoDbZeroEtlConsumerTest {
|
||||
DynamoDbFacade dynamoDb;
|
||||
|
||||
private static final String SHARD_ID = "shardId-0000000001-00000000001";
|
||||
private static final String WAREHOUSE_ARN = "arn:aws:redshift:us-east-1:111111111111:cluster:warehouse";
|
||||
|
||||
@Test
|
||||
void healthyIdlePollsDoNotRewriteCheckpointState() {
|
||||
@@ -111,7 +113,7 @@ class RedshiftDynamoDbZeroEtlConsumerTest {
|
||||
verify(service, never()).updateIntegrationRuntime(any(), any(), any(), anyBoolean(), any());
|
||||
cluster.setClusterStatus("available");
|
||||
consumer.pollOnce(integration);
|
||||
verify(writer).writeBatch(integration.getAccountId(), "warehouse", "floci_zetl_orders",
|
||||
verify(writer).writeBatch(integration.getAccountId(), WAREHOUSE_ARN, "floci_zetl_orders",
|
||||
List.of(streamRecord("s2").awsRecord()));
|
||||
assertEquals(Map.of(SHARD_ID, "s2"), integration.getShardSequenceNumbers());
|
||||
}
|
||||
@@ -169,6 +171,9 @@ class RedshiftDynamoDbZeroEtlConsumerTest {
|
||||
private final List<Shard> shards = new CopyOnWriteArrayList<>();
|
||||
private final Map<String, List<Record>> records = new ConcurrentHashMap<>();
|
||||
private final Set<String> closed = ConcurrentHashMap.newKeySet();
|
||||
/** Shards of one named stream, for tests that tell a table's streams apart. */
|
||||
private final Map<String, List<Shard>> streamShards = new ConcurrentHashMap<>();
|
||||
private final Set<String> expired = ConcurrentHashMap.newKeySet();
|
||||
private final CheckpointLifetime lifetime;
|
||||
|
||||
FakeStreamReader(CheckpointLifetime lifetime) {
|
||||
@@ -180,24 +185,39 @@ class RedshiftDynamoDbZeroEtlConsumerTest {
|
||||
return records.computeIfAbsent(shardId, ignored -> new CopyOnWriteArrayList<>());
|
||||
}
|
||||
|
||||
List<Record> shard(String streamArn, String shardId, String parentShardId) {
|
||||
streamShards.computeIfAbsent(streamArn, ignored -> new CopyOnWriteArrayList<>())
|
||||
.add(new Shard(shardId, parentShardId, null, null));
|
||||
return records.computeIfAbsent(streamArn + " " + shardId, ignored -> new CopyOnWriteArrayList<>());
|
||||
}
|
||||
|
||||
void close(String shardId) {
|
||||
closed.add(shardId);
|
||||
}
|
||||
|
||||
void expire(String streamArn) {
|
||||
expired.add(streamArn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ShardsPage describeStream(Stream stream, String exclusiveStartShardId, Integer limit) {
|
||||
return new ShardsPage(stream, List.copyOf(shards), null);
|
||||
if (expired.contains(stream.arn())) {
|
||||
throw new AwsException("ResourceNotFoundException", "Stream not found: " + stream.arn(), 400);
|
||||
}
|
||||
return new ShardsPage(stream, List.copyOf(streamShards.getOrDefault(stream.arn(), shards)), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cursor getShardIterator(Stream stream, String shardId, Position position, String sequenceNumber) {
|
||||
iteratorRequests.add(shardId + ":" + position + ":" + sequenceNumber);
|
||||
iteratorRequests.add((streamShards.containsKey(stream.arn()) ? stream.arn() + " " : "")
|
||||
+ shardId + ":" + position + ":" + sequenceNumber);
|
||||
return new Cursor(stream, shardId, position == Position.TRIM_HORIZON ? "" : sequenceNumber);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecordsPage getRecords(Cursor cursor, int limit) {
|
||||
List<Record> held = new ArrayList<>(records.get(cursor.shardId()));
|
||||
List<Record> held = new ArrayList<>(records.getOrDefault(cursor.stream().arn() + " " + cursor.shardId(),
|
||||
records.get(cursor.shardId())));
|
||||
String after = cursor.token();
|
||||
if (!after.isEmpty() && !held.isEmpty() && after.compareTo(held.get(0).sequenceNumber()) < 0) {
|
||||
throw new AwsException("TrimmedDataAccessException",
|
||||
@@ -232,8 +252,8 @@ class RedshiftDynamoDbZeroEtlConsumerTest {
|
||||
|
||||
new RedshiftDynamoDbZeroEtlConsumer(streams, dynamoDb, redshiftService, writer).pollOnce(integration);
|
||||
|
||||
verify(writer).createLandingTable(integration.getAccountId(), "warehouse", "floci_zetl_orders");
|
||||
verify(writer).writeBatch(integration.getAccountId(), "warehouse", "floci_zetl_orders",
|
||||
verify(writer).createLandingTable(integration.getAccountId(), WAREHOUSE_ARN, "floci_zetl_orders");
|
||||
verify(writer).writeBatch(integration.getAccountId(), WAREHOUSE_ARN, "floci_zetl_orders",
|
||||
List.of(first.awsRecord(), second.awsRecord()));
|
||||
verify(redshiftService).updateIntegrationRuntime(integration.getAccountId(), integration.getIntegrationArn(),
|
||||
Map.of(SHARD_ID, "s2"), true, null);
|
||||
@@ -282,7 +302,7 @@ class RedshiftDynamoDbZeroEtlConsumerTest {
|
||||
|
||||
consumer.pollOnce(integration);
|
||||
|
||||
verify(writer, times(2)).writeBatch(integration.getAccountId(), "warehouse", "floci_zetl_orders",
|
||||
verify(writer, times(2)).writeBatch(integration.getAccountId(), WAREHOUSE_ARN, "floci_zetl_orders",
|
||||
List.of(second.awsRecord()));
|
||||
assertEquals(Map.of(SHARD_ID, "s2"), integration.getShardSequenceNumbers());
|
||||
}
|
||||
@@ -414,7 +434,7 @@ class RedshiftDynamoDbZeroEtlConsumerTest {
|
||||
|
||||
consumer.afterReset();
|
||||
consumer.pollOnce(integration);
|
||||
verify(writer).writeBatch(integration.getAccountId(), "warehouse", "floci_zetl_orders",
|
||||
verify(writer).writeBatch(integration.getAccountId(), WAREHOUSE_ARN, "floci_zetl_orders",
|
||||
List.of(second.awsRecord()));
|
||||
assertEquals(Map.of(SHARD_ID, "s2"), integration.getShardSequenceNumbers());
|
||||
}
|
||||
@@ -441,7 +461,7 @@ class RedshiftDynamoDbZeroEtlConsumerTest {
|
||||
|
||||
consumer.pollTask(integration).run();
|
||||
|
||||
verify(writer).writeBatch(integration.getAccountId(), "warehouse", "floci_zetl_orders",
|
||||
verify(writer).writeBatch(integration.getAccountId(), WAREHOUSE_ARN, "floci_zetl_orders",
|
||||
List.of(first.awsRecord()));
|
||||
verify(redshiftService).updateIntegrationRuntime(integration.getAccountId(), integration.getIntegrationArn(),
|
||||
Map.of(SHARD_ID, "s1"), true, null);
|
||||
@@ -576,7 +596,7 @@ class RedshiftDynamoDbZeroEtlConsumerTest {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
ArgumentCaptor<List<JsonNode>> captor = ArgumentCaptor.forClass(List.class);
|
||||
verify(writer).writeBatch(eq(integration.getAccountId()), eq("warehouse"), eq("floci_zetl_orders"),
|
||||
verify(writer).writeBatch(eq(integration.getAccountId()), eq(WAREHOUSE_ARN), eq("floci_zetl_orders"),
|
||||
captor.capture());
|
||||
assertEquals(100, captor.getValue().size());
|
||||
JsonNode written = captor.getValue().get(0);
|
||||
@@ -659,6 +679,158 @@ class RedshiftDynamoDbZeroEtlConsumerTest {
|
||||
new Invocation("scan", "111111111111", "eu-west-1")), backend.invocations());
|
||||
}
|
||||
|
||||
@Test
|
||||
void aTableSourceDrainsItsStreamBeforeMovingToTheTablesLatestAndDropsItsCheckpoints() {
|
||||
FakeStreamReader streams = new FakeStreamReader(CheckpointLifetime.PROCESS);
|
||||
RedshiftService redshiftService = mock(RedshiftService.class);
|
||||
RedshiftZeroEtlWriter writer = mock(RedshiftZeroEtlWriter.class);
|
||||
String tableName = "orders-streamed-" + System.nanoTime();
|
||||
TableDefinition table = createTableAs("111111111111", tableName, true);
|
||||
Integration integration = tableSourceIntegration(table);
|
||||
integration.setBackfillCompleted(true);
|
||||
// Progress made on the stream the table had before its streams were turned off and on again,
|
||||
// which still holds a record the integration has not read.
|
||||
String previous = table.getTableArn() + "/stream/2026-01-01T00:00:00.000";
|
||||
integration.setSourceStreamArn(previous);
|
||||
integration.setShardSequenceNumbers(Map.of(SHARD_ID, "s1"));
|
||||
DynamoDbStreamReader.Record unread = streamRecord("s2");
|
||||
streams.shard(previous, SHARD_ID, null).addAll(List.of(streamRecord("s1"), unread));
|
||||
DynamoDbStreamReader.Record first = streamRecord("s1");
|
||||
DynamoDbStreamReader.Record second = streamRecord("s2");
|
||||
streams.shard(table.getStreamArn(), SHARD_ID, null).addAll(List.of(first, second));
|
||||
RedshiftDynamoDbZeroEtlConsumer consumer =
|
||||
new RedshiftDynamoDbZeroEtlConsumer(streams, dynamoDb, redshiftService, writer);
|
||||
|
||||
consumer.pollOnce(integration);
|
||||
assertEquals(previous, integration.getSourceStreamArn());
|
||||
verify(writer).writeBatch(integration.getAccountId(), WAREHOUSE_ARN, "floci_zetl_orders",
|
||||
List.of(unread.awsRecord()));
|
||||
|
||||
consumer.pollOnce(integration);
|
||||
assertEquals(table.getStreamArn(), integration.getSourceStreamArn());
|
||||
assertTrue(integration.getShardSequenceNumbers().isEmpty());
|
||||
verify(redshiftService).updateIntegrationSourceStream(integration.getAccountId(),
|
||||
integration.getIntegrationArn(), table.getStreamArn());
|
||||
|
||||
consumer.pollOnce(integration);
|
||||
assertEquals(List.of(
|
||||
previous + " " + SHARD_ID + ":AFTER_SEQUENCE_NUMBER:s1",
|
||||
previous + " " + SHARD_ID + ":AFTER_SEQUENCE_NUMBER:s2",
|
||||
table.getStreamArn() + " " + SHARD_ID + ":TRIM_HORIZON:null"), streams.iteratorRequests);
|
||||
verify(writer).writeBatch(integration.getAccountId(), WAREHOUSE_ARN, "floci_zetl_orders",
|
||||
List.of(first.awsRecord(), second.awsRecord()));
|
||||
assertEquals(Map.of(SHARD_ID, "s2"), integration.getShardSequenceNumbers());
|
||||
}
|
||||
|
||||
@Test
|
||||
void aTableSourceKeepsReadingItsStreamWhileTheTableHasStreamsTurnedOff() {
|
||||
FakeStreamReader streams = new FakeStreamReader(CheckpointLifetime.PROCESS);
|
||||
RedshiftService redshiftService = mock(RedshiftService.class);
|
||||
RedshiftZeroEtlWriter writer = mock(RedshiftZeroEtlWriter.class);
|
||||
String tableName = "orders-stream-off-" + System.nanoTime();
|
||||
// A backend that reports no stream for a table whose streams are off, as DynamoDB Local does.
|
||||
TableDefinition table = createTableAs("111111111111", tableName, false);
|
||||
Integration integration = tableSourceIntegration(table);
|
||||
integration.setBackfillCompleted(true);
|
||||
String disabled = table.getTableArn() + "/stream/2026-01-01T00:00:00.000";
|
||||
integration.setSourceStreamArn(disabled);
|
||||
DynamoDbStreamReader.Record last = streamRecord("s1");
|
||||
streams.shard(disabled, SHARD_ID, null).add(last);
|
||||
RedshiftDynamoDbZeroEtlConsumer consumer =
|
||||
new RedshiftDynamoDbZeroEtlConsumer(streams, dynamoDb, redshiftService, writer);
|
||||
|
||||
consumer.pollOnce(integration);
|
||||
consumer.pollOnce(integration);
|
||||
|
||||
assertEquals(disabled, integration.getSourceStreamArn());
|
||||
verify(writer).writeBatch(integration.getAccountId(), WAREHOUSE_ARN, "floci_zetl_orders",
|
||||
List.of(last.awsRecord()));
|
||||
assertEquals(Map.of(SHARD_ID, "s1"), integration.getShardSequenceNumbers());
|
||||
verify(redshiftService, never()).updateIntegrationSourceStream(any(), any(), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
void aTableSourceMovesOnWhenItsReplacedStreamHasExpired() {
|
||||
FakeStreamReader streams = new FakeStreamReader(CheckpointLifetime.PROCESS);
|
||||
RedshiftService redshiftService = mock(RedshiftService.class);
|
||||
RedshiftZeroEtlWriter writer = mock(RedshiftZeroEtlWriter.class);
|
||||
String tableName = "orders-stream-expired-" + System.nanoTime();
|
||||
TableDefinition table = createTableAs("111111111111", tableName, true);
|
||||
Integration integration = tableSourceIntegration(table);
|
||||
integration.setBackfillCompleted(true);
|
||||
String expired = table.getTableArn() + "/stream/2026-01-01T00:00:00.000";
|
||||
integration.setSourceStreamArn(expired);
|
||||
integration.setShardSequenceNumbers(Map.of(SHARD_ID, "s1"));
|
||||
streams.expire(expired);
|
||||
|
||||
new RedshiftDynamoDbZeroEtlConsumer(streams, dynamoDb, redshiftService, writer).pollOnce(integration);
|
||||
|
||||
assertEquals(table.getStreamArn(), integration.getSourceStreamArn());
|
||||
assertTrue(integration.getShardSequenceNumbers().isEmpty());
|
||||
verify(redshiftService).updateIntegrationSourceStream(integration.getAccountId(),
|
||||
integration.getIntegrationArn(), table.getStreamArn());
|
||||
}
|
||||
|
||||
@Test
|
||||
void aTableSourceWithoutAStreamIsBackfilledAndThenIdle() {
|
||||
FakeStreamReader streams = new FakeStreamReader(CheckpointLifetime.PROCESS);
|
||||
RedshiftService redshiftService = mock(RedshiftService.class);
|
||||
RedshiftZeroEtlWriter writer = mock(RedshiftZeroEtlWriter.class);
|
||||
String tableName = "orders-unstreamed-" + System.nanoTime();
|
||||
TableDefinition table = createTableAs("111111111111", tableName, false);
|
||||
RequestScopes.runAs("111111111111",
|
||||
() -> dynamoDbService.putItem(tableName, itemWithId("1"), "us-east-1"));
|
||||
Integration integration = tableSourceIntegration(table);
|
||||
streams.shard(SHARD_ID, null).add(streamRecord("s1"));
|
||||
RedshiftDynamoDbZeroEtlConsumer consumer =
|
||||
new RedshiftDynamoDbZeroEtlConsumer(streams, dynamoDb, redshiftService, writer);
|
||||
|
||||
consumer.pollOnce(integration);
|
||||
consumer.pollOnce(integration);
|
||||
|
||||
assertTrue(integration.isBackfillCompleted());
|
||||
verify(writer, times(1)).writeBatch(any(), eq(WAREHOUSE_ARN), any(), any());
|
||||
verify(redshiftService).recoverIntegrationRuntime(integration.getAccountId(), integration.getIntegrationArn());
|
||||
assertTrue(streams.iteratorRequests.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
void aServerlessTargetIsNeverPausedAndIsWrittenByItsArn() {
|
||||
FakeStreamReader streams = new FakeStreamReader(CheckpointLifetime.PROCESS);
|
||||
RedshiftService redshiftService = mock(RedshiftService.class);
|
||||
RedshiftZeroEtlWriter writer = mock(RedshiftZeroEtlWriter.class);
|
||||
String namespaceArn = "arn:aws:redshift-serverless:us-east-1:111111111111:namespace/"
|
||||
+ "8f3e0b52-6c1a-4f0e-9d7b-2a4c5e6f7a8b";
|
||||
Integration integration = streamingIntegration();
|
||||
integration.setTargetArn(namespaceArn);
|
||||
integration.setTargetClusterIdentifier(null);
|
||||
DynamoDbStreamReader.Record first = streamRecord("s1");
|
||||
streams.shard(SHARD_ID, null).add(first);
|
||||
|
||||
new RedshiftDynamoDbZeroEtlConsumer(streams, dynamoDb, redshiftService, writer).pollOnce(integration);
|
||||
|
||||
verify(redshiftService, never()).describeClustersForAccount(any(), any());
|
||||
verify(writer).createLandingTable(integration.getAccountId(), namespaceArn, "floci_zetl_orders");
|
||||
verify(writer).writeBatch(integration.getAccountId(), namespaceArn, "floci_zetl_orders",
|
||||
List.of(first.awsRecord()));
|
||||
}
|
||||
|
||||
private TableDefinition createTableAs(String accountId, String tableName, boolean streamed) {
|
||||
return RequestScopes.callAs(accountId, () -> {
|
||||
dynamoDbService.createTable(tableName, List.of(new KeySchemaElement("id", "HASH")),
|
||||
List.of(new AttributeDefinition("id", "S")), 5L, 5L, "us-east-1");
|
||||
return streamed ? dynamoDbService.enableStream(tableName, null, "us-east-1")
|
||||
: dynamoDbService.describeTable(tableName, "us-east-1");
|
||||
});
|
||||
}
|
||||
|
||||
private static Integration tableSourceIntegration(TableDefinition table) {
|
||||
Integration integration = integration(table.getTableName());
|
||||
integration.setSourceArn(table.getTableArn());
|
||||
integration.setSourceStreamArn(table.getStreamArn());
|
||||
return integration;
|
||||
}
|
||||
|
||||
private static ObjectNode itemWithId(String id) {
|
||||
ObjectNode item = MAPPER.createObjectNode();
|
||||
ObjectNode idAttr = MAPPER.createObjectNode();
|
||||
@@ -672,6 +844,7 @@ class RedshiftDynamoDbZeroEtlConsumerTest {
|
||||
integration.setIntegrationArn("arn:aws:redshift:us-east-1:111111111111:integration:one");
|
||||
integration.setAccountId("111111111111");
|
||||
integration.setSourceStreamArn("arn:aws:dynamodb:us-east-1:111111111111:table/" + tableName + "/stream/one");
|
||||
integration.setTargetArn(WAREHOUSE_ARN);
|
||||
integration.setTargetClusterIdentifier("warehouse");
|
||||
integration.setLandingTableName("floci_zetl_orders");
|
||||
integration.setPollingEnabled(true);
|
||||
|
||||
+187
@@ -0,0 +1,187 @@
|
||||
package io.github.hectorvent.floci.services.redshift;
|
||||
|
||||
import io.github.hectorvent.floci.services.redshiftserverless.RedshiftServerlessService;
|
||||
import io.github.hectorvent.floci.testing.DockerAvailability;
|
||||
import io.github.hectorvent.floci.testing.QueryRequests;
|
||||
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.restassured.response.ExtractableResponse;
|
||||
import io.restassured.response.Response;
|
||||
import jakarta.inject.Inject;
|
||||
import org.awaitility.Awaitility;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.Assumptions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestInstance;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.time.Duration;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
* A DynamoDB zero-ETL integration in the form AWS takes it, a table ARN as {@code SourceArn} and a
|
||||
* Redshift Serverless namespace ARN as {@code TargetArn}, replicating into the namespace's workgroup.
|
||||
* Needs Docker.
|
||||
*/
|
||||
@QuarkusTest
|
||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||
class RedshiftServerlessZeroEtlIntegrationTest {
|
||||
|
||||
private static final String TABLE = "zetl-serverless-orders";
|
||||
private static final String NAMESPACE = "zetl-serverless-ns";
|
||||
private static final String WORKGROUP = "zetl-serverless-wg";
|
||||
private static final String ADMIN_PASSWORD = "Secret123";
|
||||
// Not "dev", to show the landing table goes to the namespace's own database.
|
||||
private static final String DATABASE = "warehouse";
|
||||
private static final String REGION = "us-east-1";
|
||||
|
||||
@Inject
|
||||
RedshiftServerlessService serverless;
|
||||
|
||||
private String tableArn;
|
||||
private String namespaceArn;
|
||||
private int endpointPort;
|
||||
private boolean created;
|
||||
|
||||
/** Creates the resources once, after Quarkus has pointed RestAssured at the test server. */
|
||||
@BeforeEach
|
||||
void ensureResources() throws InterruptedException {
|
||||
Assumptions.assumeTrue(DockerAvailability.isAvailable(), "Docker is required for Redshift Serverless zero-ETL tests");
|
||||
RestAssuredJsonUtils.configureAwsContentTypes();
|
||||
if (created) {
|
||||
return;
|
||||
}
|
||||
tableArn = dynamoDb("CreateTable", """
|
||||
{
|
||||
"TableName": "%s",
|
||||
"KeySchema": [{"AttributeName":"id","KeyType":"HASH"}],
|
||||
"AttributeDefinitions": [{"AttributeName":"id","AttributeType":"S"}],
|
||||
"BillingMode": "PAY_PER_REQUEST",
|
||||
"StreamSpecification": {"StreamEnabled": true, "StreamViewType": "NEW_AND_OLD_IMAGES"}
|
||||
}
|
||||
""".formatted(TABLE)).path("TableDescription.TableArn");
|
||||
putItem("before-integration");
|
||||
namespaceArn = RestAssuredJsonUtils.awsAction("RedshiftServerless", "CreateNamespace", """
|
||||
{"namespaceName":"%s","adminUsername":"admin","adminUserPassword":"%s","dbName":"%s"}
|
||||
""".formatted(NAMESPACE, ADMIN_PASSWORD, DATABASE)).then().statusCode(200)
|
||||
.extract().path("namespace.namespaceArn");
|
||||
created = true;
|
||||
endpointPort = RestAssuredJsonUtils.awsAction("RedshiftServerless", "CreateWorkgroup", """
|
||||
{"workgroupName":"%s","namespaceName":"%s"}
|
||||
""".formatted(WORKGROUP, NAMESPACE)).then().statusCode(200)
|
||||
.extract().path("workgroup.endpoint.port");
|
||||
}
|
||||
|
||||
/** Through the service: Quarkus has already pointed RestAssured away from the test server by now. */
|
||||
@AfterAll
|
||||
void deleteResources() {
|
||||
if (created) {
|
||||
serverless.deleteWorkgroup(WORKGROUP, REGION);
|
||||
serverless.deleteNamespace(NAMESPACE, REGION);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void aTableReplicatesIntoTheNamespaceWorkgroup() throws SQLException {
|
||||
String response = redshift("CreateIntegration", "IntegrationName", "zetl-serverless",
|
||||
"SourceArn", tableArn, "TargetArn", namespaceArn)
|
||||
.then().statusCode(200)
|
||||
.body(containsString("<SourceArn>" + tableArn + "</SourceArn>"))
|
||||
.body(containsString("<TargetArn>" + namespaceArn + "</TargetArn>"))
|
||||
.extract().body().asString();
|
||||
String integrationArn = response.substring(response.indexOf("<IntegrationArn>") + "<IntegrationArn>".length(),
|
||||
response.indexOf("</IntegrationArn>"));
|
||||
String landingTable = "floci_zetl_"
|
||||
+ integrationArn.substring(integrationArn.lastIndexOf(':') + 1).replace('-', '_');
|
||||
try {
|
||||
awaitLanded(landingTable, "before-integration", true);
|
||||
Awaitility.await().atMost(Duration.ofSeconds(30)).pollInterval(Duration.ofMillis(500))
|
||||
.untilAsserted(() -> redshift("DescribeIntegrations", "IntegrationArn", integrationArn)
|
||||
.then().statusCode(200)
|
||||
.body(containsString("<Status>active</Status>"))
|
||||
.body(containsString("<SourceArn>" + tableArn + "</SourceArn>"))
|
||||
.body(containsString("<TargetArn>" + namespaceArn + "</TargetArn>")));
|
||||
|
||||
putItem("after-integration");
|
||||
awaitLanded(landingTable, "after-integration", false);
|
||||
} finally {
|
||||
redshift("DeleteIntegration", "IntegrationArn", integrationArn).then().statusCode(200);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void aTableThatDoesNotExistIsIntegrationSourceNotFound() {
|
||||
redshift("CreateIntegration", "IntegrationName", "zetl-no-source",
|
||||
"SourceArn", tableArn.replace(TABLE, "no-such-table"), "TargetArn", namespaceArn)
|
||||
.then().statusCode(404)
|
||||
.body(containsString("IntegrationSourceNotFoundFault"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void aNamespaceThatDoesNotExistIsIntegrationTargetNotFound() {
|
||||
String otherNamespace = namespaceArn.substring(0, namespaceArn.lastIndexOf('/') + 1)
|
||||
+ "00000000-0000-0000-0000-000000000000";
|
||||
redshift("CreateIntegration", "IntegrationName", "zetl-no-target",
|
||||
"SourceArn", tableArn, "TargetArn", otherNamespace)
|
||||
.then().statusCode(404)
|
||||
.body(containsString("IntegrationTargetNotFoundFault"));
|
||||
}
|
||||
|
||||
private void awaitLanded(String landingTable, String itemId, boolean backfilled) {
|
||||
Awaitility.await()
|
||||
.atMost(Duration.ofSeconds(30))
|
||||
.pollInterval(Duration.ofMillis(500))
|
||||
.ignoreExceptions()
|
||||
.untilAsserted(() -> assertTrue(landedEventIds(landingTable, itemId).stream()
|
||||
.anyMatch(eventId -> eventId.startsWith("backfill#") == backfilled)));
|
||||
}
|
||||
|
||||
/** Event ids of the landed records whose new image is the item with this id. */
|
||||
private List<String> landedEventIds(String landingTable, String itemId) throws SQLException {
|
||||
// 127.0.0.1 rather than the advertised address: CI sets floci.emulator.hostname to a name
|
||||
// that does not resolve from the test JVM.
|
||||
String url = "jdbc:postgresql://127.0.0.1:" + endpointPort + "/" + DATABASE;
|
||||
List<String> eventIds = new ArrayList<>();
|
||||
try (Connection connection = DriverManager.getConnection(url, "admin", ADMIN_PASSWORD);
|
||||
Statement statement = connection.createStatement();
|
||||
ResultSet rows = statement.executeQuery("SELECT event_id, new_image_json FROM " + landingTable)) {
|
||||
while (rows.next()) {
|
||||
if (rows.getString(2) != null && rows.getString(2).contains("\"" + itemId + "\"")) {
|
||||
eventIds.add(rows.getString(1));
|
||||
}
|
||||
}
|
||||
}
|
||||
return eventIds;
|
||||
}
|
||||
|
||||
private static void putItem(String id) {
|
||||
dynamoDb("PutItem", """
|
||||
{"TableName": "%s", "Item": {"id": {"S": "%s"}}}
|
||||
""".formatted(TABLE, id));
|
||||
}
|
||||
|
||||
private static ExtractableResponse<Response> dynamoDb(String action, String body) {
|
||||
return given()
|
||||
.header("X-Amz-Target", "DynamoDB_20120810." + action)
|
||||
.contentType("application/x-amz-json-1.0")
|
||||
.body(body)
|
||||
.when().post("/")
|
||||
.then().statusCode(200).extract();
|
||||
}
|
||||
|
||||
private static Response redshift(String action, String... params) {
|
||||
return QueryRequests.request("test", "redshift", action, params)
|
||||
.formParam("Version", "2012-12-01")
|
||||
.when().post("/");
|
||||
}
|
||||
}
|
||||
+121
-1
@@ -9,9 +9,12 @@ import io.github.hectorvent.floci.core.common.docker.DockerHostResolver;
|
||||
import io.github.hectorvent.floci.core.storage.AccountAwareStorageBackend;
|
||||
import io.github.hectorvent.floci.core.storage.StorageFactory;
|
||||
import io.github.hectorvent.floci.services.cloudwatch.logs.CloudWatchLogsService;
|
||||
import io.github.hectorvent.floci.services.dynamodb.DynamoDbFacade;
|
||||
import io.github.hectorvent.floci.services.dynamodb.backend.DynamoDbApiStreamReader;
|
||||
import io.github.hectorvent.floci.services.dynamodb.backend.DynamoDbOperations;
|
||||
import io.github.hectorvent.floci.services.dynamodb.backend.DynamoDbStreamReader.CheckpointLifetime;
|
||||
import io.github.hectorvent.floci.services.dynamodb.backend.DynamoDbTableAccess;
|
||||
import io.github.hectorvent.floci.services.dynamodb.model.TableDefinition;
|
||||
import io.github.hectorvent.floci.services.rds.proxy.PasswordValidator;
|
||||
import io.github.hectorvent.floci.services.redshift.container.RedshiftContainerHandle;
|
||||
import io.github.hectorvent.floci.services.redshift.container.RedshiftContainerManager;
|
||||
@@ -26,6 +29,8 @@ import io.github.hectorvent.floci.services.redshift.model.Snapshot;
|
||||
import io.github.hectorvent.floci.services.redshift.model.SnapshotCopyGrant;
|
||||
import io.github.hectorvent.floci.services.redshift.model.SnapshotSchedule;
|
||||
import io.github.hectorvent.floci.services.redshift.proxy.RedshiftProxyManager;
|
||||
import io.github.hectorvent.floci.services.redshiftserverless.RedshiftServerlessService;
|
||||
import io.github.hectorvent.floci.services.redshiftserverless.model.Namespace;
|
||||
import io.github.hectorvent.floci.services.secretsmanager.SecretsManagerService;
|
||||
import io.github.hectorvent.floci.services.secretsmanager.model.Secret;
|
||||
import jakarta.ws.rs.core.MultivaluedHashMap;
|
||||
@@ -863,6 +868,8 @@ class RedshiftServiceTest {
|
||||
private RedshiftEventService events;
|
||||
private final Set<String> existingStreams = new HashSet<>();
|
||||
private RedshiftIntegrationEventPublisher integrationEvents;
|
||||
private DynamoDbTableAccess zeroEtlTables;
|
||||
private RedshiftServerlessService zeroEtlServerless;
|
||||
private RedshiftService service;
|
||||
|
||||
@BeforeEach
|
||||
@@ -911,6 +918,7 @@ class RedshiftServiceTest {
|
||||
when(sf.<Integration>create(eq("redshift"), eq("redshift-integrations.json"), any())).thenReturn(integrationBackend);
|
||||
when(sf.<SnapshotSchedule>create(eq("redshift"), eq("redshift-snapshot-schedules.json"), any())).thenReturn(snapshotScheduleBackend);
|
||||
when(clusterBackend.accountId()).thenReturn("111111111111");
|
||||
when(integrationBackend.accountId()).thenReturn("111111111111");
|
||||
|
||||
regionResolver = new RegionResolver("us-east-1", "111111111111");
|
||||
|
||||
@@ -929,9 +937,121 @@ class RedshiftServiceTest {
|
||||
};
|
||||
|
||||
integrationEvents = mock(RedshiftIntegrationEventPublisher.class);
|
||||
DynamoDbFacade zeroEtlDynamoDb = mock(DynamoDbFacade.class);
|
||||
zeroEtlTables = mock(DynamoDbTableAccess.class);
|
||||
when(zeroEtlDynamoDb.tables()).thenReturn(zeroEtlTables);
|
||||
zeroEtlServerless = mock(RedshiftServerlessService.class);
|
||||
service = new RedshiftService(sf, cm, config, regionResolver, proxyManager, dockerHostResolver,
|
||||
credentialBroker, secretsManagerService, mapper,
|
||||
new DynamoDbApiStreamReader(streams, CheckpointLifetime.PROCESS), null, events, integrationEvents);
|
||||
new DynamoDbApiStreamReader(streams, CheckpointLifetime.PROCESS), null, events, integrationEvents,
|
||||
new RedshiftZeroEtlEndpoints(zeroEtlDynamoDb, zeroEtlServerless));
|
||||
}
|
||||
|
||||
private static final String ORDERS_TABLE_ARN = "arn:aws:dynamodb:us-east-1:111111111111:table/orders";
|
||||
private static final String NAMESPACE_ARN = "arn:aws:redshift-serverless:us-east-1:111111111111:namespace/"
|
||||
+ "8f3e0b52-6c1a-4f0e-9d7b-2a4c5e6f7a8b";
|
||||
|
||||
@Test
|
||||
void createsAnIntegrationFromATableToAServerlessNamespaceAsAwsTakesThem() {
|
||||
TableDefinition table = new TableDefinition();
|
||||
table.setTableName("orders");
|
||||
table.setTableArn(ORDERS_TABLE_ARN);
|
||||
table.setStreamArn(ORDERS_TABLE_ARN + "/stream/2026-09-18T00:00:00.000");
|
||||
when(zeroEtlTables.describeTable(any(), eq("orders"))).thenReturn(table);
|
||||
when(zeroEtlServerless.findNamespaceByArn(NAMESPACE_ARN, "us-east-1")).thenReturn(Optional.of(new Namespace()));
|
||||
when(integrationBackend.scan(any())).thenReturn(List.of());
|
||||
|
||||
Integration integration = service.createIntegration("orders-to-warehouse", ORDERS_TABLE_ARN, NAMESPACE_ARN,
|
||||
null, null, Map.of(), Map.of(), "us-east-1");
|
||||
|
||||
assertEquals(ORDERS_TABLE_ARN, integration.getSourceArn());
|
||||
assertEquals(NAMESPACE_ARN, integration.getTargetArn());
|
||||
assertEquals(table.getStreamArn(), integration.getSourceStreamArn());
|
||||
assertNull(integration.getTargetClusterIdentifier());
|
||||
assertEquals("syncing", integration.getStatus());
|
||||
verify(integrationBackend).put(any(), eq(integration));
|
||||
}
|
||||
|
||||
@Test
|
||||
void aTableThatNeverHadAStreamIsAcceptedAsTheSource() {
|
||||
TableDefinition table = new TableDefinition();
|
||||
table.setTableName("orders");
|
||||
table.setTableArn(ORDERS_TABLE_ARN);
|
||||
when(zeroEtlTables.describeTable(any(), eq("orders"))).thenReturn(table);
|
||||
when(zeroEtlServerless.findNamespaceByArn(NAMESPACE_ARN, "us-east-1")).thenReturn(Optional.of(new Namespace()));
|
||||
when(integrationBackend.scan(any())).thenReturn(List.of());
|
||||
|
||||
Integration integration = service.createIntegration("orders-to-warehouse", ORDERS_TABLE_ARN, NAMESPACE_ARN,
|
||||
null, null, Map.of(), Map.of(), "us-east-1");
|
||||
|
||||
assertNull(integration.getSourceStreamArn());
|
||||
}
|
||||
|
||||
@Test
|
||||
void aTableArnOfAnotherAccountOrWithASuffixIsNotTheCallersSameNamedTable() {
|
||||
TableDefinition table = new TableDefinition();
|
||||
table.setTableName("orders");
|
||||
table.setTableArn(ORDERS_TABLE_ARN);
|
||||
when(zeroEtlTables.describeTable(any(), eq("orders"))).thenReturn(table);
|
||||
|
||||
for (String sourceArn : List.of("arn:aws:dynamodb:us-east-1:222222222222:table/orders",
|
||||
ORDERS_TABLE_ARN + "/bogus")) {
|
||||
AwsException error = assertThrows(AwsException.class, () -> service.createIntegration(
|
||||
"orders-to-warehouse", sourceArn, NAMESPACE_ARN, null, null, Map.of(), Map.of(), "us-east-1"));
|
||||
|
||||
assertEquals("IntegrationSourceNotFoundFault", error.getErrorCode(), sourceArn);
|
||||
assertEquals(404, error.getHttpStatus());
|
||||
}
|
||||
verify(integrationBackend, never()).put(any(), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
void aMissingSourceTableIsIntegrationSourceNotFound() {
|
||||
when(zeroEtlTables.describeTable(any(), eq("orders"))).thenThrow(
|
||||
new AwsException("ResourceNotFoundException", "Requested resource not found", 400));
|
||||
|
||||
AwsException error = assertThrows(AwsException.class, () -> service.createIntegration(
|
||||
"orders-to-warehouse", ORDERS_TABLE_ARN, NAMESPACE_ARN, null, null, Map.of(), Map.of(), "us-east-1"));
|
||||
|
||||
assertEquals("IntegrationSourceNotFoundFault", error.getErrorCode());
|
||||
assertEquals("The specified integration source can't be found.", error.getMessage());
|
||||
assertEquals(404, error.getHttpStatus());
|
||||
verify(integrationBackend, never()).put(any(), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
void aMissingTargetNamespaceIsIntegrationTargetNotFound() {
|
||||
TableDefinition table = new TableDefinition();
|
||||
table.setTableName("orders");
|
||||
table.setTableArn(ORDERS_TABLE_ARN);
|
||||
when(zeroEtlTables.describeTable(any(), eq("orders"))).thenReturn(table);
|
||||
when(zeroEtlServerless.findNamespaceByArn(NAMESPACE_ARN, "us-east-1")).thenReturn(Optional.empty());
|
||||
|
||||
AwsException error = assertThrows(AwsException.class, () -> service.createIntegration(
|
||||
"orders-to-warehouse", ORDERS_TABLE_ARN, NAMESPACE_ARN, null, null, Map.of(), Map.of(), "us-east-1"));
|
||||
|
||||
assertEquals("IntegrationTargetNotFoundFault", error.getErrorCode());
|
||||
assertEquals("The specified integration target can't be found.", error.getMessage());
|
||||
assertEquals(404, error.getHttpStatus());
|
||||
verify(integrationBackend, never()).put(any(), any());
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = {
|
||||
"arn:aws:redshift-serverless:us-east-1:111111111111:workgroup/8f3e0b52-6c1a-4f0e-9d7b-2a4c5e6f7a8b",
|
||||
"arn:aws:s3:::warehouse-bucket"})
|
||||
void aTargetThatIsNeitherANamespaceNorAClusterIsRefused(String targetArn) {
|
||||
TableDefinition table = new TableDefinition();
|
||||
table.setTableName("orders");
|
||||
table.setTableArn(ORDERS_TABLE_ARN);
|
||||
when(zeroEtlTables.describeTable(any(), eq("orders"))).thenReturn(table);
|
||||
|
||||
AwsException error = assertThrows(AwsException.class, () -> service.createIntegration(
|
||||
"orders-to-warehouse", ORDERS_TABLE_ARN, targetArn, null, null, Map.of(), Map.of(), "us-east-1"));
|
||||
|
||||
assertEquals("InvalidParameterValue", error.getErrorCode());
|
||||
assertEquals("TargetArn must identify a Redshift Serverless namespace or a provisioned Redshift cluster.",
|
||||
error.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+45
-5
@@ -4,22 +4,30 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import io.github.hectorvent.floci.services.redshift.RedshiftService;
|
||||
import io.github.hectorvent.floci.services.redshift.RedshiftZeroEtlEndpoints;
|
||||
import io.github.hectorvent.floci.services.redshift.model.Cluster;
|
||||
import io.github.hectorvent.floci.services.redshiftserverless.RedshiftServerlessService;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.Statement;
|
||||
import java.sql.Types;
|
||||
import java.time.Instant;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.mockito.ArgumentMatchers.contains;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
class RedshiftZeroEtlWriterTest {
|
||||
|
||||
private static final String WAREHOUSE_ARN = "arn:aws:redshift:us-east-1:111111111111:cluster:warehouse";
|
||||
|
||||
@Test
|
||||
void createsLandingTableWithStableEventColumns() throws Exception {
|
||||
RedshiftService redshiftService = mock(RedshiftService.class);
|
||||
@@ -32,8 +40,9 @@ class RedshiftZeroEtlWriterTest {
|
||||
when(connectionFactory.open(any())).thenReturn(connection);
|
||||
when(connection.createStatement()).thenReturn(statement);
|
||||
|
||||
RedshiftZeroEtlWriter writer = new RedshiftZeroEtlWriter(redshiftService, connectionFactory, objectMapper);
|
||||
writer.createLandingTable("111111111111", "warehouse", "floci_zetl_orders");
|
||||
RedshiftZeroEtlWriter writer = new RedshiftZeroEtlWriter(redshiftService,
|
||||
mock(RedshiftZeroEtlEndpoints.class), connectionFactory, objectMapper);
|
||||
writer.createLandingTable("111111111111", WAREHOUSE_ARN, "floci_zetl_orders");
|
||||
|
||||
verify(statement).executeUpdate(contains("event_id TEXT PRIMARY KEY"));
|
||||
verify(statement).executeUpdate(contains("new_image_json TEXT"));
|
||||
@@ -53,9 +62,10 @@ class RedshiftZeroEtlWriterTest {
|
||||
|
||||
JsonNode first = record("event-1", "000000000000000000001");
|
||||
JsonNode second = record("event-2", "000000000000000000002");
|
||||
RedshiftZeroEtlWriter writer = new RedshiftZeroEtlWriter(redshiftService, connectionFactory, objectMapper);
|
||||
RedshiftZeroEtlWriter writer = new RedshiftZeroEtlWriter(redshiftService,
|
||||
mock(RedshiftZeroEtlEndpoints.class), connectionFactory, objectMapper);
|
||||
|
||||
writer.writeBatch("111111111111", "warehouse", "floci_zetl_orders", List.of(first, second));
|
||||
writer.writeBatch("111111111111", WAREHOUSE_ARN, "floci_zetl_orders", List.of(first, second));
|
||||
|
||||
verify(statement, times(2)).executeUpdate();
|
||||
verify(statement).setString(1, "event-1");
|
||||
@@ -64,13 +74,43 @@ class RedshiftZeroEtlWriterTest {
|
||||
verify(statement, times(2)).setString(3, "aws:dynamodb");
|
||||
verify(statement, times(2)).setString(4, "us-east-1");
|
||||
verify(statement).setString(5, "000000000000000000002");
|
||||
verify(statement, times(2)).setObject(6, Instant.ofEpochSecond(1_758_153_600L));
|
||||
verify(statement, times(2)).setObject(6,
|
||||
OffsetDateTime.ofInstant(Instant.ofEpochSecond(1_758_153_600L), ZoneOffset.UTC),
|
||||
Types.TIMESTAMP_WITH_TIMEZONE);
|
||||
verify(statement, times(2)).setString(7, "{\"id\":\"1\"}");
|
||||
verify(statement, times(2)).setNull(8, Types.VARCHAR);
|
||||
verify(statement, times(2)).setString(9, "{\"value\":\"new\"}");
|
||||
verify(connection).close();
|
||||
}
|
||||
|
||||
@Test
|
||||
void writesANamespaceThroughItsWorkgroupIntoTheNamespaceDatabase() throws Exception {
|
||||
String namespaceArn = "arn:aws:redshift-serverless:us-east-1:111111111111:namespace/"
|
||||
+ "8f3e0b52-6c1a-4f0e-9d7b-2a4c5e6f7a8b";
|
||||
RedshiftService redshiftService = mock(RedshiftService.class);
|
||||
RedshiftZeroEtlEndpoints endpoints = mock(RedshiftZeroEtlEndpoints.class);
|
||||
RedshiftDataConnectionFactory connectionFactory = mock(RedshiftDataConnectionFactory.class);
|
||||
Connection connection = mock(Connection.class);
|
||||
when(connection.createStatement()).thenReturn(mock(Statement.class));
|
||||
when(endpoints.targetWorkgroup("111111111111", namespaceArn)).thenReturn(
|
||||
new RedshiftServerlessService.WorkgroupTarget(
|
||||
"arn:aws:redshift-serverless:us-east-1:111111111111:workgroup/analytics", "analytics",
|
||||
"localhost", 5433, "warehouse", "admin", "password", "admin"));
|
||||
ArgumentCaptor<RedshiftDataResourceResolver.DatabaseTarget> target =
|
||||
ArgumentCaptor.forClass(RedshiftDataResourceResolver.DatabaseTarget.class);
|
||||
when(connectionFactory.open(target.capture())).thenReturn(connection);
|
||||
|
||||
new RedshiftZeroEtlWriter(redshiftService, endpoints, connectionFactory, new ObjectMapper())
|
||||
.createLandingTable("111111111111", namespaceArn, "floci_zetl_orders");
|
||||
|
||||
assertEquals("localhost", target.getValue().host());
|
||||
assertEquals(5433, target.getValue().port());
|
||||
assertEquals("warehouse", target.getValue().database());
|
||||
assertEquals("admin", target.getValue().user());
|
||||
assertEquals("password", target.getValue().password());
|
||||
verifyNoInteractions(redshiftService);
|
||||
}
|
||||
|
||||
private static Cluster cluster() {
|
||||
Cluster cluster = new Cluster();
|
||||
cluster.setClusterIdentifier("warehouse");
|
||||
|
||||
Reference in new issue
Block a user