Files
floci/compatibility-tests/sdk-test-java
Hector Ventura 0655be9d23 fix(ecs): reconcile task lifecycle when container exits naturally (#1078)
* fix(ecs): reconcile task lifecycle when container exits naturally

ECS tasks stayed in RUNNING indefinitely after the underlying Docker
container exited, causing `aws ecs wait tasks-stopped` to hang forever
and exitCode to remain null. Fixes #889.

The 5-second reconciler now also polls running task handles. When all
containers for a task have exited, it atomically claims the handle
(guarding against a concurrent explicit stopTask), closes log streams,
removes the Docker containers, and transitions the task to STOPPED with
stoppedAt and per-container exitCode populated.

Explicit stopTask is also fixed: it now calls stopTaskAndCollectExitCodes
to capture exit codes before the container record is removed, and
propagates them to the ECS container model. An idempotency guard prevents
double-decrement of runningTasksCount when stopTask is called on a task
already transitioned by the reconciler.

cleanupStoppedTask is used by the reconciler to avoid re-inspecting
containers whose exit codes were already collected in the inspection pass.

* fix(ecs): capture exit code after stop, not before

stopTaskAndCollectExitCodes inspected containers before stopping them,
so getExitCodeIfStopped returned null for still-running containers and
the exit code was lost once stopAndRemove deleted the record.

Split the operation into two phases: stop all containers first, then
inspect exit codes, then remove. Containers already exited skip the
stop call silently.
2026-05-29 02:14:23 -05:00
..

sdk-test-java

Compatibility tests for Floci using the AWS SDK for Java v2 (2.31.8).

Runs 313 tests across 16 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
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