Files
floci/compatibility-tests/sdk-test-java
lex00 337dead734 fix(ec2): derive default vpc/subnet/sg ids per region (#2384)
* fix(ec2): derive default vpc/subnet/sg ids per region

The default VPC, subnets, and security group seeded by ensureDefaultResources
used literal ids ("vpc-default", "subnet-default-a/b/c", "sg-default")
regardless of region. Storage was already keyed by region, so nothing
actually collided server-side, but every region echoed identical ids back
to callers, making a region's default resources indistinguishable from any
other region's via the AWS SDK/CLI.

Add Ec2Service.defaultVpcId/defaultSubnetId/defaultSecurityGroupId, which
derive region-scoped ids (e.g. "vpc-default-eu-west-1"), and use them at
every seeding and fallback-resolution call site in Ec2Service. RdsService's
default DB subnet group lookup now calls Ec2Service.defaultVpcId(region) too,
so it keeps resolving against the right region's default VPC.

Updates tests across Ec2Service/Ec2Integration/Eks/ElbV2/AutoScaling/
CloudFormation that asserted on the old literal ids, and adds a regression
test (Ec2ServiceTest#defaultVpcSubnetAndSecurityGroupIdsAreRegionScoped)
asserting two different regions get distinct default vpc/subnet/sg ids.

Fixes lex00/floci#21

* fix(ec2,rds): resolve default vpc/sg ids against persisted storage

ensureDefaultResources skips reseeding a region that already has a VPC on
file, so storage written before default ids were made region-scoped keeps
its old unscoped literal ("vpc-default"/"sg-default") forever. Every lookup
that blindly computed the new scoped id instead of resolving against what
storage actually holds would silently stop finding that region's real
default VPC and security group.

Added Ec2Service.resolveDefaultVpcId/resolveDefaultSecurityGroupId, which
check the scoped id first and fall back to the pre-#21 literal. Used them
at every lookup call site (runInstances' default subnet/SG fallback,
createSecurityGroup's default-VPC fallback, DescribeAccountAttributes,
and RdsService.buildDefaultSubnetGroup's vpc-id filter). Seeding itself is
unchanged, it always assigns the new scoped id for a genuinely fresh
region.

RdsServiceTest mocks Ec2Service, so its shared setup now stubs
resolveDefaultVpcId to match the old static call's behavior.

* test(compat): fetch RDS proxy subnet ids per signed region

sdkScopesTheSameDbProxyNameBySignedRegion reused the shared us-east-1
subnetIds field for both the east and west proxy, which only worked
because default subnet ids collided across regions before #21. Real AWS
scopes subnet ids per region and rejects a cross-region id, which is
exactly what floci now correctly does too.

Added subnetIdsFor(Region) and an ec2Client(Region) fixture, and changed
createIamProxy to take explicit subnet ids instead of the shared field.

* test(cloudformation): use region-scoped subnet ids in the update-reconcile test

dbSubnetGroupTemplate hardcoded the pre-#21 unscoped "subnet-default-a/b"
literals, written before this branch's default-id fix landed. Broke on
rebase since those subnets no longer exist under that name. Matches the
sibling test method in the same file, which already used
Ec2Service.defaultSubnetId(region, az).

* docs(ec2): spell out the #21 comment references

Bare #21 in this repo links to floci-io/floci#21, not the fork issue the
comment means.
2026-08-19 17:14:48 -04:00
..

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.

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