* feat(redshift): implement snapshot copy grant lifecycle Terraform's aws_redshift_snapshot_copy_grant needs the full CRUD, and all three actions returned InvalidAction. Add CreateSnapshotCopyGrant, DescribeSnapshotCopyGrants and DeleteSnapshotCopyGrant to the Query handler, backed by a new storage map on RedshiftService. The grant name is the key: a duplicate create raises SnapshotCopyGrantAlreadyExistsFault, and describe-by-name or delete of a missing grant raises SnapshotCopyGrantNotFoundFault. Describe without a name returns every grant. KmsKeyId is optional and defaults to the account's AWS-managed Redshift key alias ARN, mirroring how Ec2EbsEncryptionService stands in for a default key. Tags ride along on create, since the CLI sends them inline as Tags.Tag.N.Key/.Value on this action rather than via CreateTags, and snapshotcopygrant ARNs now resolve in the tagging operations alongside the other Redshift resource types. * test(redshift): cover snapshot copy grants through the real SDK * fix(redshift): paginate DescribeSnapshotCopyGrants The action returned every grant in one page and ignored MaxRecords and Marker, so a client with more grants than fit in a page had no way to walk them. Page through the shared Pagination helper, which sorts by the grant name and encodes the last returned name as an opaque base64 cursor, so ordering is stable and a marker stays resumable when grants are created or deleted between pages. Marker is emitted only while further pages remain, which is what tells a paginating client to stop. MaxRecords follows the Redshift model: default 100, and a value outside 20 to 100 is rejected with InvalidParameterValue rather than clamped. The model documents SnapshotCopyGrantName and Marker as mutually exclusive but declares no error for sending both, so this filters by name and then paginates instead of rejecting the pair. A name matches at most one grant, which fits in any page. * fix(redshift): enforce the SnapshotCopyGrantName contract AWS validates SnapshotCopyGrantName as 1-63 characters, first a lowercase letter, then lowercase letters, digits or single hyphens with no trailing or doubled hyphen. Create accepted anything non-blank, so names Redshift rejects (1grant, Grant, grant--copy, grant-, 64 characters) persisted locally and diverged from AWS. Validate in RedshiftService before persistence, matching the existing snapshot identifier check, and answer InvalidParameterValue as the rest of the handler does. * fix(redshift): return 400 for SnapshotCopyGrantNotFoundFault on Describe and Delete AWS documents SnapshotCopyGrantNotFoundFault as HTTP 400 in the error tables for both DescribeSnapshotCopyGrants and DeleteSnapshotCopyGrant; we returned 404. Two existing wire-level assertions in RedshiftOperationsTest pinned the wrong status, so they move with the code, and the unit tests now assert the status alongside the error code. The third throw site, in the tagging helper, deliberately stays 404: the status belongs to the action rather than the fault code, and that path is reached only from CreateTags/DeleteTags/DescribeTags, whose documented missing-resource error is ResourceNotFoundFault at 404. A regression pins that, and a comment says why the two differ. Refs: https://docs.aws.amazon.com/redshift/latest/APIReference/API_DescribeSnapshotCopyGrants.html https://docs.aws.amazon.com/redshift/latest/APIReference/API_DeleteSnapshotCopyGrant.html https://docs.aws.amazon.com/redshift/latest/APIReference/API_CreateTags.html * fix(redshift): serialize grant create/delete, and use ResourceNotFoundFault on the tag path Two findings from the latest review round. createSnapshotCopyGrant checked the name was free and then wrote, with nothing between the two steps, so two concurrent creates of one name could both succeed and the second would overwrite the first. create and delete are now synchronized, as createCluster and modifyCluster already are. The new wire-level test holds two threads on a latch and releases them into the same name: it fails on every run without the keyword (3/3 locally) and passes with it, so it pins the lock rather than describing it. The tagging path threw SnapshotCopyGrantNotFoundFault with HTTP 404. Both halves of that pairing cannot be right at once: botocore's Redshift model gives that shape httpStatusCode 400, and an error shape's status is a property of the shape, not of the calling action. But 404 is the correct status here, because CreateTags/DeleteTags/DescribeTags do not list that fault at all -- they document ResourceNotFoundFault, modelled at 404, for any missing resource. So the status stays and the code changes. That also explains why the three sibling cases in the same switch are already consistent: ClusterNotFound, ClusterSnapshotNotFound and ClusterParameterGroupNotFound are each modelled at 404 themselves. Describe and Delete still return SnapshotCopyGrantNotFoundFault at 400, which is what those two actions document. Docs gain a short section on the grant surface: the alias-ARN KmsKeyId default, the unvalidated tag limits, and why a missing grant reports two different faults depending on which action you reach it through. * style(test): name the new snapshot copy grant tests without the testX prefix AGENTS.md: "Name test methods either as a camelCase sentence or as method_scenario_expectation. Both are established. testX names are common in older tests and are not the pattern to copy." The 31 tests this PR adds to src/test all used testX because the three Redshift files they landed in are unusually full of it -- 7/7, 30/50 and 69/104 -- but that is the local exception, not the repo convention, and the rule is explicit about not copying it. Renames only; no test body changes. The two new tests in compatibility-tests/sdk-test-java keep testX: that module has the opposite idiom and AGENTS.md says to follow the module you are in, and all five methods in that file, three of them pre-existing, are named that way.
sdk-test-java
Compatibility tests for Floci using the AWS SDK for Java v2 (2.31.8).
Runs 352 tests across 17 test classes against a live Floci instance — no mocks.
Services Covered
| Test class | Description |
|---|---|
SsmTest |
Parameter Store — put, get, path, tags |
SqsTest |
Queues, send/receive/delete, DLQ, visibility |
SnsTest |
Topics, subscriptions, publish, SQS delivery |
S3Test |
Buckets, objects, tagging, copy, multipart, batch delete |
DynamoDbTest |
Tables, CRUD, batch, TTL, tags, streams |
DynamoDbScanConditionTests |
Scan filter and condition expressions |
LambdaTest |
Create/invoke/update/delete functions |
IamTest |
Users, roles, policies, access keys |
StsTest |
GetCallerIdentity, AssumeRole, GetSessionToken |
SecretsManagerTest |
Create/get/put/list/delete secrets, versioning, tags |
KmsTest |
Keys, aliases, encrypt/decrypt, data keys, sign/verify |
CloudWatchTest |
PutMetricData, ListMetrics, GetMetricStatistics, alarms |
CloudFormationVirtualHostTests |
Virtual host style S3 access via CloudFormation |
ApigwSfnJsonataCrudlTests |
API Gateway + Step Functions JSONata CRUDL integration |
ApiGatewayV2WebSocketAndExtendedOpsTest |
API GW v2 WebSocket APIs, Update ops, Route/Integration Responses, Models, Tagging |
Ec2Tests |
EC2 instances, VPCs, security groups, subnets |
AppSyncTest |
GraphQL API CRUDL, data sources, resolvers, functions, types, API keys, tags, schema validation |
EcsTests |
ECS clusters, task definitions, services |
Adding a New Test
Create a standard JUnit 5 test class in src/test/java/com/floci/test/. Tests run against a live Floci instance using real AWS SDK clients.
Requirements
- Java 17+
- Maven
Running
# All tests
mvn test -q
# Specific test class
mvn test -Dtest=S3Test
# Via just (from compatibility-tests/)
just test-java
Configuration
| Variable | Default | Description |
|---|---|---|
FLOCI_ENDPOINT |
http://localhost:4566 |
Floci emulator endpoint |
AWS credentials are always test / test / us-east-1.
Metric filter publishing checks
CloudWatchLogsMetricFilterTest and CloudFormationLogsMetricFilterTest run
with the rest of the suite. Against a server on another port:
# From compatibility-tests/sdk-test-java
FLOCI_ENDPOINT=http://127.0.0.1:18084 ../../mvnw test \
-Dtest=CloudWatchLogsMetricFilterTest,CloudFormationLogsMetricFilterTest
The publishing tests read their expected values from
src/test/resources/cloudwatchlogs/metric-filter-publishing-aws.json, a
byte-identical copy of the root fixture recorded from AWS. MetricFilterFixturePackagingTest
checks the copy loads from the classpath, and the root
CloudWatchLogsMetricFilterFixturePackagingTest fails when either SDK module
copy drifts from the root file. The SDK selects the CloudWatch JSON protocol;
MetricFilterQueryAssertions signs the same reads as legacy form-encoded Query
requests, so GetMetricStatistics and GetMetricData on both wire formats are
asserted against every statistic the fixture records (Sum, SampleCount, Minimum,
Maximum). Reads poll for the sample, since the server publishes it shortly after
PutLogEvents returns. Passing
these tests shows Floci matches the recorded values; it is not live AWS
verification. For the opt-in replay against AWS see ../sdk-test-python/README.md.
Docker
docker build -t floci-sdk-java .
docker run --rm --network host floci-sdk-java
# Custom endpoint (macOS/Windows)
docker run --rm -e FLOCI_ENDPOINT=http://host.docker.internal:4566 floci-sdk-java