Files
floci/compatibility-tests/sdk-test-java
Mario Toffia fa4d4663a2 feat(lambda): honour the Invoke Qualifier and wait between asynchronous retries as AWS does (#4733)
* feat(lambda): honour the Invoke Qualifier query parameter

* feat(lambda): wait between asynchronous retries as AWS does

A failed Event invocation now waits floci.services.lambda.async-retry-delay-seconds before its first retry and twice that before its second (default 60, matching AWS), capped at the event's remaining maximum age. The concurrency permit is held only for each attempt, and an emulator reset drops retries still waiting.

* test(lambda): prove asynchronous retries end to end

* docs(lambda): document asynchronous retry timing and the Invoke Qualifier

* fix(lambda): drop retries of deleted functions and tighten async retry edges

- Drop a pending asynchronous retry when its function (or version) was deleted.
- Decide expiry once, on the injected clock, when a retry is scheduled.
- Check the reset generation at routing, so no stale outcome is delivered.
- Restore upstream behavior when an attempt throws: stop retrying and route
  the previous result, or UnknownError when there is none.
- Harden tests: in-order permit release, deterministic reset, error types
  and an unqualified-ARN Qualifier case for Invoke.

* fix(lambda): drop a deleted function's pending events on every path

Replace the store lookup with a per-function deletion counter, captured
when the event is invoked and checked wherever an event is attempted or
routed. This covers the expiry path, which bypassed the old check, and a
delete-and-recreate of the same name during the wait, which the lookup
could not see. Verified against AWS that DeleteFunction drops pending
retries without delivering a record.

* fix(lambda): clear deletion counts before bumping the reset generation

An invoke between the two statements of clear() captured the new
generation with a stale deletion count and its event was dropped.
The expiry-path deletion test now drops inside the first attempt,
so it no longer races the one-second maximum event age.

* fix(lambda): keep deletion counts across a reset

Clearing them while the old generation was still current let a
deleted function's pending event see a zero count and be routed.
A reset now only bumps the generation, in one atomic step.

* fix(lambda): drop an Event invoke that races DeleteFunction

An Event invoke that resolved the function just before a concurrent
DeleteFunction could take its deletion-count snapshot after the delete
had already moved the count. The event then never looked stale, so the
deleted function could still be started and a failure record could
still reach its destination.

DeleteFunction now moves the deletion count only after the function has
left the store, and an Event invoke checks that the function is still in
the store after it takes its snapshot and before it queues the event.
Either the check sees the function gone and the invoke answers 202
without queueing anything, or the snapshot predates the count change and
the event is dropped as stale later.

* fix(lambda): validate the Invoke Qualifier query parameter

Invoke treated an empty or blank Qualifier as if none had been given
and ran $LATEST, and it passed a qualifier longer than 128 characters on
to the lookup, which answered 404. AWS rejects both with a 400.

A supplied Qualifier must now be 1 to 128 characters of letters,
digits, $, _ and -, or Invoke fails with ValidationException. The
controller reads the parameter from the raw query, because @QueryParam
reports a present but empty value as null and the check could not see
it.

* fix(lambda): stop pending events before a delete or reset removes state

DeleteFunction moved a function's deletion count only after it had
removed the function's code and store entry. A retry whose timer fired
in that gap still passed the staleness check, tried to start a function
with no code, and could deliver a failure record to its destination. An
attempt that finished in that gap could deliver its OnFailure record.
DeleteFunction now moves the count before it deletes anything, which
stops every queued or running event, and again after the store entry is
gone, which stops an Event invoke that read the count in between.

An emulator reset wiped storage before the executor's clear() moved the
reset generation, so a retry firing during the wipe could run or deliver
against half-cleared state. The executor now also moves the generation
in beforeReset(), which runs before the wipe. clear() still moves it, to
drop events accepted between the two.

* test(lambda): fix a doc comment and name the tolerated Docker ping failure

The class comment now reads "wait as they do on AWS". The Docker ping
check names its caught exception "expected" and says why returning
false is safe: the test is then skipped rather than failed.

* fix(lambda): count version and alias invokes against the function's reservation

Routing the Invoke Qualifier to a published version meant a qualified
invoke took its permit against the version's snapshot, which carries no
reservation, so a reserved concurrency of 0 on the function no longer
throttled it and a positive one stopped counting those invokes. The
name-qualified path (fn:1, fn:alias) already had the same gap.

Reserved concurrency is function-wide in AWS, so the executor now takes
the permit against the function's $LATEST record, which holds the
reservation. That covers direct Invoke with a Qualifier, qualified names
and ARNs, aliases, event source mappings and asynchronous retries alike.
It reads the stored record rather than the limiter's region registry
because event source pollers can invoke before LambdaService has
rehydrated that registry after a restart.

* fix(lambda): drop a deleted function's pending events before draining its containers

DeleteFunction drained the warm pool before fencing pending asynchronous
events, and draining blocks while idle containers stop. A retry whose
timer fired in that window still passed the staleness check and could
cold-start a container after the drain, leaving it warm for a function
that no longer exists. The fence now goes up first.
2026-10-01 10:00:47 -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_REGION us-east-1 Region the TestFixtures clients sign for

AWS credentials are always test / test. Setting AWS_REGION=cn-north-1 (with Floci started with FLOCI_DEFAULT_REGION=cn-north-1) runs the suite in the China partition; the nightly Partition Compatibility workflow does exactly that, and tolerates only the failures listed in .github/ci/compat-partition-allowlist-cn-north-1.txt. Tests that build their own client with an explicit region keep that region.

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