rtf-orchestrator
This page documents how tests in the rtf-orchestrator crate are organized and implemented.
The crate uses two test styles:
- Unit tests follow the unit test style
- HTTP API integration tests follow the HTTP API integration test style
See Run rtf-orchestrator tests for a step-by-step guide to running each category locally.
Categories
| Category | Location | Requires |
|---|---|---|
| Unit tests | src/ (#[cfg(test)] mod tests blocks) | Nothing |
| DB tests | src/ (gated by db_tests feature) | PostgreSQL via make db-up |
| Integration tests | tests/suite.rs (gated by k8s_tests feature) | Full tilt stack |
Running cargo test from the workspace root skips all stack-dependent tests. They must be run
explicitly via make.
Unit test organization
Unit tests follow the Module → Function → Test class → Test case hierarchy from the unit test style:
#![allow(unused)]
fn main() {
// Without simple_test_case
module::path::tests::function_test_case
// With simple_test_case
module::path::tests::function_test_class::test_case
}
Integration test organization
Integration tests follow the Endpoint → Scenario naming described in the HTTP API integration test style:
#![allow(unused)]
fn main() {
endpoint_scenario
}
For example: trigger_valid_test_plan_returns_200.
Feature flag annotation
Stack-dependent tests must always carry this annotation to prevent the standard test run from failing without a stack:
#![allow(unused)]
fn main() {
#[cfg_attr(not(feature = "db_tests"), ignore)] // for DB tests
#[cfg_attr(not(feature = "k8s_tests"), ignore)] // for integration tests
}
Do not remove these annotations from existing tests.
Testing infrastructure
Integration tests use the following tools:
TestHelper— Defined intests/common/mod.rs. Wrapsreqwest::Clientand provides convenience methods for calling server endpointstokio—#[tokio::test]for async test functionsreqwest— HTTP client used insideTestHelperassert_fs— Temporary filesystem utilities; usesCARGO_TARGET_TMPDIRrather than/tmpto avoid macOS symlink issues with Docker volume mountssimple_test_case— Parameterized testing with#[test_case]for multiple input variations
TestHelper API
#![allow(unused)]
fn main() {
pub struct TestHelper {
client: Client,
}
}
| Method | Purpose |
|---|---|
prepare_orchestrator_payload | Prepares a TriggerPayload from a test plan directory |
json_get / json_post | Typed helpers that deserialize JSON responses into the expected type |
get / post | Raw helpers returning Response for status-code assertions |
Shared logic between tests should be added as further methods on TestHelper.
Make targets
| Target | Description |
|---|---|
make db-up / make db-down | Start/stop the lightweight DB-only test stack |
make db-tests | Run DB-gated tests against the running DB stack |
make cluster-setup && make cluster-up / make cluster-teardown | Start/stop the full stack |
make integration-tests | Run tests/suite.rs against the running full stack |
make ci-tests | Full CI flow: stack up → wait → test → stack down |