Skip to main content

Overview

S2 Lite can run entirely in-memory without any external dependencies, making it an excellent emulator for integration testing. This eliminates the need for complex test infrastructure while ensuring your tests run against a real S2 implementation.
In-memory S2 Lite is a very effective S2 emulator for integration tests.

Running S2 Lite In-Memory

Using Docker

The simplest way to run S2 Lite for testing is with Docker:
This starts S2 Lite without any bucket configuration, causing it to operate entirely in-memory.

Using the CLI

If you have the S2 CLI installed:
Data stored in in-memory mode is lost when the process stops. This is perfect for tests that need a clean state.

Configuring Your Tests

To connect your tests to the local S2 Lite instance, configure the SDK endpoints:
In S2 Lite, the S2_ACCESS_TOKEN is required but the value is not validated. You can use any string value.

Example Test Setup

Rust

TypeScript

Go

Waiting for S2 Lite to be Ready

Before running tests, ensure S2 Lite is ready:

Creating Test Basins

For tests, create basins with auto-creation of streams enabled:
This allows your tests to create streams dynamically without explicit stream creation calls.

Best Practices

Use Unique Basin Names

Generate unique basin names per test or test suite to avoid conflicts:

Clean Up Resources

While in-memory mode loses all data on restart, consider cleaning up basins and streams explicitly:

Parallel Test Execution

Since each test can use unique basin names, tests can run in parallel without conflicts:

CI/CD Integration

GitHub Actions

Docker Compose

Advanced: Local Disk Persistence

For tests that need persistence across restarts, use --local-root:
Local disk persistence is useful for debugging failed tests or testing recovery scenarios.