mirror of
https://github.com/floci-io/floci.git
synced 2026-11-22 21:50:46 -05:00
* fix(lambda): restore create-copy-start ordering for provided runtimes The refactor in #466 changed ContainerLauncher from create → copy → start to createAndStart → copy, breaking provided.* runtimes whose entrypoint execs /var/runtime/bootstrap immediately on start — before the file has been copied in. Split ContainerLifecycleManager into create(spec) and startCreated(containerId, spec) so ContainerLauncher can copy code and the bootstrap file into the container filesystem before starting it. Other services (ECS, ECR, EKS, MSK, ElastiCache, RDS) continue using createAndStart since they have no pre-start file copy requirement. Fixes #494 * test(lambda): verify create-copy-start ordering for provided runtimes Update ContainerLauncherTest to use the new create/startCreated API and add two ordering tests: - launchFunction_createsBeforeCopyAndStartsAfter: verifies the create → copy → startCreated sequence for any runtime using Mockito InOrder. - launchProvidedRuntime_copiesBootstrapBeforeStart: verifies the same ordering specifically for provided.al2023 with a bootstrap file, and asserts createAndStart is never called. This is the exact regression from #466 that caused exit 127. * refactor: delegate createAndStart to create + startCreated Eliminate duplicated container-creation logic by making createAndStart a thin delegate to create(spec) + startCreated(containerId, spec). Future fixes to either step now apply to both call paths automatically. * test(lambda): add SDK compatibility test for provided runtime invoke Create and invoke a provided.al2023 function using the shell-based bootstrap from LambdaUtils.providedRuntimeZip(). Asserts the response contains the expected payload without timeout or FunctionError. This test fails on 1.5.4 (Read timed out after 120s due to the create-start ordering regression in #466) and passes on the fix. * docs: add @param to create() and rename misleading test - Add missing @param spec tag to ContainerLifecycleManager.create() for consistency with surrounding methods. - Rename launchFunctionCopiesCode to launchFunction_createsWithoutBindMounts to reflect what the test actually asserts. Remove the getDockerClient verify that didn't prove code copying. * test(lambda): stub Docker copy chain and add cleanup for provided runtime test - Stub dockerClient.copyArchiveToContainerCmd → withRemotePath → withTarInputStream so copy operations execute against the mock instead of throwing silently. Ordering tests now verify actual Docker copy invocations between create and startCreated. - Provided runtime test asserts both /var/task and /var/runtime remote paths were targeted. - Add sdk-test-provided-fn to @AfterAll cleanup in LambdaTest so assertion failures don't leak the function across test runs. * test(lambda): drain tar InputStream in copy mock to prevent thread leaks Each copy mock now returns a fresh CopyArchiveToContainerCmd that drains the PipedInputStream on exec(), so the background tar writer thread can complete instead of blocking when the pipe buffer fills. Remote paths are captured via the mock's withRemotePath answer and asserted from the shared list. Also adds sdk-test-provided-fn to @AfterAll cleanup in the compat test to prevent function leaks on assertion failure. * refactor(lambda): drop unused ContainerInfo variable from launch The return value of startCreated() was assigned but never read. Remove the variable and its now-unused import. * test(lambda): include getDockerClient in InOrder verification Add the getDockerClient() call between create() and copyArchiveToContainerCmd() in both ordering tests so the verified sequence matches the actual call flow in ContainerLauncher.launch(). * style: remove redundant doAnswer import The wildcard import already covers it.
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 |
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