This directory contains the end-to-end test suite for the Ferron web server, written in Rust. It uses Testcontainers to spin up Ferron and helper services (like backends or databases) in Docker containers and verifies their behavior using standard Rust testing tools.
- Docker - the tests rely on Docker to run Ferron and auxiliary services. Ensure the Docker daemon is running and accessible by the user running the tests.
- Rust - you need a standard Rust toolchain installed (Cargo).
protoc- the tests use theprost-buildcrate to generate Rust code from Protocol Buffers definitions. Ensureprotocis installed and available in yourPATH.
To run the entire suite, execute the following command in this directory:
cargo testTo run a specific test file (e.g., acme):
cargo test --test acmeThe test suite automatically builds a Docker image for Ferron (e2e-test-ferron) from the local source code. However, if the image is not rebuilt, the tests will use already-built images, which might not reflect the latest changes.
To force a rebuild of the web server Docker image (e.g., after modifying Ferron's source code), you need to remove the existing containers and the image. On Linux hosts, you can run:
docker rm -f $(docker ps -a --filter ancestor=e2e-test-ferron -q)
docker image rm e2e-test-ferronThe next time you run cargo test, the image will be rebuilt.
Tests are located in the tests/ directory. Each test file is typically defined as a separate integration test in Cargo.toml.
To add a new test suite:
-
Create a new Rust source file in
tests/(e.g.,tests/my_new_feature.rs). -
Register the test in
Cargo.toml:[[test]] name = "my_new_feature" path = "tests/my_new_feature.rs"
-
Implement your tests using
testcontainersto spawn Ferron andreqwest(or other clients) to verify behavior. See existing tests liketests/static.rsortests/rproxy.rsfor examples of setting up the environment and writing configuration files dynamically.