|
| 1 | +# Integration Tests |
| 2 | + |
| 3 | +## Prerequisites |
| 4 | + |
| 5 | +| Dependency | Version | Purpose | |
| 6 | +|------------|----------|-------------------------------------------------| |
| 7 | +| Python | >= 3.9 | Test framework runtime | |
| 8 | +| Rust | stable | Build the FunctionStream binary | |
| 9 | +| Docker | >= 20.10 | Run a Kafka broker for streaming integration tests | |
| 10 | + |
| 11 | +> **Docker is required.** The test framework automatically pulls and manages |
| 12 | +> an `apache/kafka:3.7.0` container in KRaft mode to provide a real Kafka |
| 13 | +> broker for tests that involve Kafka input/output. Tests will fail if the |
| 14 | +> Docker daemon is not running. |
| 15 | +
|
| 16 | +## Quick Start |
| 17 | + |
| 18 | +```bash |
| 19 | +# From the project root |
| 20 | +make build # Build the release binary (with --features python) |
| 21 | +make integration-test |
| 22 | + |
| 23 | +# Or run directly from this directory |
| 24 | +cd tests/integration |
| 25 | +make test |
| 26 | +``` |
| 27 | + |
| 28 | +## Directory Layout |
| 29 | + |
| 30 | +``` |
| 31 | +tests/integration/ |
| 32 | +├── Makefile # test / clean targets |
| 33 | +├── requirements.txt # Python dependencies (pytest, grpcio, docker, ...) |
| 34 | +├── pytest.ini # Pytest configuration |
| 35 | +├── framework/ # Reusable test infrastructure |
| 36 | +│ ├── instance.py # FunctionStreamInstance facade |
| 37 | +│ ├── workspace.py # Per-test directory management |
| 38 | +│ ├── config.py # Server config generation |
| 39 | +│ ├── process.py # OS process lifecycle (start/stop/kill) |
| 40 | +│ ├── utils.py # Port allocation, readiness probes |
| 41 | +│ └── kafka_manager.py # Docker-managed Kafka broker (KRaft mode) |
| 42 | +├── test/ # Test suites |
| 43 | +│ ├── wasm/ # WASM function tests |
| 44 | +│ │ └── python_sdk/ # Python SDK integration tests |
| 45 | +│ └── streaming/ # Streaming engine tests (future) |
| 46 | +└── target/ # Test output (git-ignored) |
| 47 | + ├── .shared_cache/ # Shared WASM compilation cache across tests |
| 48 | + └── <suite>/<class>/<method>/<timestamp>/logs/ |
| 49 | +``` |
| 50 | + |
| 51 | +## Test Output |
| 52 | + |
| 53 | +Each test gets an isolated server instance with its own log directory: |
| 54 | + |
| 55 | +``` |
| 56 | +target/wasm/python_sdk/TestFunctionLifecycle/test_full_lifecycle_transitions/20260416_221655/ |
| 57 | + logs/ |
| 58 | + app.log # FunctionStream application log |
| 59 | + stdout.log # Server stdout |
| 60 | + stderr.log # Server stderr |
| 61 | +``` |
| 62 | + |
| 63 | +Only `logs/` is retained after tests complete; `conf/` and `data/` are |
| 64 | +automatically cleaned up. |
| 65 | + |
| 66 | +## Python Dependencies |
| 67 | + |
| 68 | +All Python packages are listed in `requirements.txt` and installed |
| 69 | +automatically by `make test`. Key dependencies: |
| 70 | + |
| 71 | +- `pytest` — test runner |
| 72 | +- `grpcio` / `protobuf` — gRPC client communication |
| 73 | +- `docker` — Docker SDK for managing the Kafka container |
| 74 | +- `confluent-kafka` — Kafka admin client for topic management |
| 75 | +- `functionstream-api` / `functionstream-client` — local editable installs |
| 76 | + |
| 77 | +## Running Specific Tests |
| 78 | + |
| 79 | +```bash |
| 80 | +# Single test |
| 81 | +make test PYTEST_ARGS="-k test_full_lifecycle_transitions" |
| 82 | + |
| 83 | +# Single file |
| 84 | +make test PYTEST_ARGS="test/wasm/python_sdk/test_lifecycle.py" |
| 85 | + |
| 86 | +# Verbose with live log |
| 87 | +make test PYTEST_ARGS="-v --log-cli-level=DEBUG" |
| 88 | +``` |
0 commit comments