mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 15:49:33 -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.
floci-compatibility-tests
Compatibility test suite for Floci — a local AWS emulator.
Verifies that standard AWS tooling (SDKs, CDK, OpenTofu/Terraform) works correctly against the emulator without modification. Tests run against a live Floci instance and use real AWS SDK clients — no mocks.
Quick Start
# Install just (task runner)
# macOS: brew install just
# Linux: cargo install just
# Copy and configure environment
cp env.example .env
# Install dependencies
just setup
# Run all tests
just test-all
# Run specific SDK tests
just test-python
just test-typescript
just test-awscli
Test Runners
| Module | Language | Test Framework | Command |
|---|---|---|---|
sdk-test-python |
Python 3 | pytest | just test-python |
sdk-test-node |
TypeScript | vitest | just test-typescript |
sdk-test-awscli |
Bash / AWS CLI | bats-core | just test-awscli |
sdk-test-java |
Java 17 | JUnit 5 | just test-java |
sdk-test-go |
Go 1.24 | go test | just test-go |
sdk-test-rust |
Rust | cargo-nextest | just test-rust |
IaC Compatibility
| Module | Tool | Command |
|---|---|---|
compat-cdk |
AWS CDK v2 | ./run.sh |
compat-opentofu |
OpenTofu | ./run.sh |
compat-terraform |
Terraform | ./run.sh |
Prerequisites
- Floci running on
http://localhost:4566(or setFLOCI_ENDPOINT) - Docker — required for Lambda invocation tests
- just — task runner for orchestration
Per-module requirements:
| Module | Requirements |
|---|---|
sdk-test-python |
Python 3.9+, pip |
sdk-test-node |
Node.js 20+, npm, vitest |
sdk-test-awscli |
AWS CLI v2, bash, jq |
sdk-test-java |
Java 17+, Maven |
sdk-test-go |
Go 1.24+ |
sdk-test-rust |
Rust (stable), Cargo, cargo-nextest |
Setup
# Setup all SDKs
just setup
# Setup individual SDKs
just setup-python # pip install -r requirements.txt
just setup-typescript # npm install
just setup-awscli # Clone bats-core, bats-support, bats-assert
Running Tests
All SDKs
just test-all
Individual SDKs
# Python (pytest)
just test-python
# TypeScript (vitest)
just test-typescript
# AWS CLI (bats-core)
just test-awscli
Bats-based suites keep their normal console output and also write JUnit XML reports:
sdk-test-awscli/test-results/junit.xmlcompat-cdk/test-results/junit.xmlcompat-terraform/test-results/junit.xmlcompat-opentofu/test-results/junit.xml
Configuration
All modules read from environment variables (see .env.example):
FLOCI_ENDPOINT=http://localhost:4566
AWS_ACCESS_KEY_ID=test
AWS_SECRET_ACCESS_KEY=test
AWS_DEFAULT_REGION=us-east-1
Running with Docker
Each module includes a Dockerfile for isolated execution:
# Python
docker build -t floci-sdk-python sdk-test-python/
docker run --rm --network host floci-sdk-python pytest
# TypeScript
docker build -t floci-sdk-node sdk-test-node/
docker run --rm --network host floci-sdk-node npm test
On macOS/Windows, use host.docker.internal instead of localhost:
docker run --rm -e FLOCI_ENDPOINT=http://host.docker.internal:4566 floci-sdk-python pytest
Exit Codes
All test runners exit 0 on full pass and non-zero if any test fails — suitable for CI pipelines.