Files
floci/compatibility-tests/sdk-test-java
Jackson Price ab0737798d fix(elbv2): answer SetSubnets with one ALB subnet with ValidationError (#6116)
* test(elbv2): expect ValidationError for SetSubnets with one ALB subnet

SetSubnets on an Application Load Balancer with one subnet answers
InvalidConfigurationRequest with a message of Floci's own, once the
subnet has been looked up. The SetSubnets API reference states the
rule CreateLoadBalancer states, subnets from at least two Availability
Zones, and since #6098 CreateLoadBalancer answers one subnet with
ValidationError "At least two subnets in two different Availability
Zones must be specified", counted before any subnet is looked up.

- ElbV2ServiceTest, ElbV2IntegrationTest (Query protocol) and the
  compatibility suite's ElbV2Test expect that error for SetSubnets
  with one subnet, in Subnets or in SubnetMappings, and for one subnet
  that does not exist, with the balancer left on its subnets.
- CloudFormationElbV2SubnetUpdateIntegrationTest: an update that keeps
  the balancer and names one subnet rolls back with that error.
- A Network or Gateway Load Balancer is still set onto one subnet, and
  a move onto no subnets, which a CloudFormation rollback makes for a
  balancer an earlier version saved without subnets, is still taken.
- setSubnetsWithMissingSubnetReturnsSubnetNotFound sends an existing
  subnet beside the missing one, so it still reaches the lookup.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(elbv2): answer SetSubnets with one ALB subnet with ValidationError

SetSubnets on an Application Load Balancer with one subnet now answers
ValidationError (400) "At least two subnets in two different
Availability Zones must be specified", the answer CreateLoadBalancer
gives since #6098, instead of InvalidConfigurationRequest with a
message of Floci's own. setSubnets runs requireSubnets once it has
looked the balancer up for its type and before any subnet is looked
up, so one subnet that does not exist gets the same answer, as on
create. One SubnetMappings entry goes through the same check.

The answer follows the SetSubnets API reference, which states the
two-zone rule for an Application Load Balancer, and the answer AWS
gives CreateLoadBalancer; no public report shows what AWS answers
SetSubnets with one subnet. AWS does give a Network Load Balancer's
SetSubnets with no subnets CreateLoadBalancer's message.

A CloudFormation update that keeps an Application Load Balancer and
names one subnet moves it through setSubnets, so it now fails with
this error and rolls back. A move onto no subnets is not counted,
because a CloudFormation rollback moves a balancer an earlier version
saved without subnets back onto none. A Network or Gateway Load
Balancer can still be set onto one subnet.

resolveSubnetVpcId drops its own one-subnet refusal, which neither
caller reaches any more; its zone check still refuses an Application
Load Balancer whose subnets are all in one Availability Zone.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* docs(elbv2): say where SetSubnets' one-subnet answer comes from

Review follow-ups to the SetSubnets one-subnet fix:
- The requireSubnets Javadoc scopes what AWS is known to answer to
  CreateLoadBalancer, and says SetSubnets gets the create message and
  order because no public report shows what AWS answers there.
- The setSubnets comment says an empty list moves the balancer onto no
  subnets, rather than that the list is left alone.
- docs/services/elb.md says the same about the SetSubnets answer, and
  instead of saying a Gateway Load Balancer can be set onto one subnet,
  that Floci does not enforce AWS's rule that SetSubnets keeps every
  subnet a Gateway Load Balancer already has.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* test(elbv2): keep the SetSubnets tests to answers ELBv2 gives

Review follow-ups to the SetSubnets one-subnet fix:
- ElbV2CfnProvisionerTest: the update with a blank SubnetId keeps a
  Network Load Balancer, for which SubnetNotFound is still the answer
  ELBv2 gives; an Application Load Balancer now gets the subnet count
  error first. The move-and-move-back test moves the kept balancer
  onto two subnets, as ELBv2 refuses an Application Load Balancer on
  one.
- ElbV2ServiceTest: the move onto no subnets follows the rollback it
  stands for, a balancer saved without subnets moved onto subnets and
  back onto none. SetSubnets onto one subnet for a balancer that does
  not exist reports LoadBalancerNotFound before any subnet is looked
  up.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* docs(elbv2): word the SetSubnets count notes as the rules read

Second review round on the SetSubnets one-subnet fix:
- docs/services/elb.md no longer says Network and Gateway Load
  Balancers are not counted: they are, and a list that names a subnet
  cannot fail the count for them, while a SetSubnets with neither form
  is refused for every type once #6100 lands. It now says a Network
  Load Balancer can be set onto one subnet, and that AWS requires a
  Gateway Load Balancer's SetSubnets to list every subnet it is
  already on, which Floci does not enforce.
- The setSubnets comment says "an earlier Floci version", as the
  tests do.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* test(elbv2): give the blank SubnetId update a typed balancer

Second review round on the SetSubnets one-subnet fix: the update with
a blank SubnetId in ElbV2CfnProvisionerTest names a Network Load
Balancer in its template, and the balancer its describe stub returns
is now a network one too, so the template, the stub and the Javadoc
agree. The answer the stub gives, SubnetNotFound, is unchanged.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* docs(elbv2): scope the Gateway Load Balancer SetSubnets rule to Subnets

Third review round on the SetSubnets one-subnet fix: the SetSubnets API
reference states that a Gateway Load Balancer must include every
subnet it is already on under Subnets only, not under SubnetMappings,
so docs/services/elb.md now says the reference requires it of a
Gateway Load Balancer's Subnets, rather than of its SetSubnets as a
whole. Floci still does not enforce it.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* chore(elbv2): tidy what #6100 and the SetSubnets count both added

With #6100 merged, this branch and it each documented and tested the
same SetSubnets paths:
- ElbV2ServiceTest keeps aRollbackOntoNoSubnetsIsNotCounted, which
  models the CloudFormation rollback that needs setSubnets to take an
  empty list, and drops #6100's aMoveBackOntoNoSubnetsIsStillTaken,
  which tested the same call on a balancer that still had subnets. The
  two missing-balancer tests now say which path each pins: the
  SetSubnets action with neither form, or setSubnets with one subnet.
- The requireSubnets Javadoc names setSubnetsFromRequest beside
  setSubnets, and the setSubnets comment no longer repeats the
  empty-list reason its Javadoc gives.
- docs/services/elb.md has one SetSubnets bullet instead of two.

No behaviour changes.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* docs(elbv2): say what requireSubnets checks for SetSubnets

Review of the merge with #6100: the requireSubnets Javadoc gave the
two-zone rule as the reason setSubnetsFromRequest runs it, but that
call refuses a SetSubnets that names no subnets, for every type, and
requireSubnets only counts the list. It now says SetSubnets takes the
same subnets as CreateLoadBalancer, which of the two methods runs the
count on which list, and that the two-zone check comes after the
subnets are looked up. Javadoc only.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* docs(elbv2): say what the folded SetSubnets bullet counts like

Review of the tidy: once the two SetSubnets bullets in
docs/services/elb.md became one, "counted the same way" followed the
sentence about a SetSubnets with neither form, so it no longer read
as CreateLoadBalancer's count. It now says a SetSubnets that names
subnets is counted as CreateLoadBalancer counts them.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

---------

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
2026-10-21 10:47:07 -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.

STS presigned identity checks

StsPresignedIdentityTest checks user and role identity over HTTP/1.1 and HTTP/2. Valid identity requests run in both modes. Forged signatures and changed bodies are sent only when signature checking is enabled. To check signature refusal, start Floci with FLOCI_AUTH_VALIDATE_SIGNATURES=true and pass the same setting to this test:

FLOCI_AUTH_VALIDATE_SIGNATURES=true mvn test -Dtest=StsPresignedIdentityTest

The test setting must match the server setting; it does not configure the server. The enabled mode also checks missing and incorrect temporary-session tokens.

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