Accepted
This document defines the testing strategy (what to test) and implementation (how to test it) for the flowd runtime.
The goals are:
- ensure correctness of message flow
- guarantee stability under load and concurrency
- prevent regressions during architectural evolution
- validate system behavior, not just component logic
Tests are not a feature. They are the foundation of system reliability.
This strategy applies to:
- runtime execution
- message passing and transport
- scheduling behavior
- pipeline semantics
It explicitly covers:
- component-level behavior
- pipeline-level execution
- system-level guarantees
Test behavior, not implementation.
flowd uses multiple complementary test layers:
flowd is validated against:
FBP Protocol test suite
- ensure compatibility with established FBP semantics
- validate message format and protocol behavior
- guarantee interoperability
- message handling
- graph execution semantics
- protocol-level correctness
Unit-level tests for individual components.
- validate isolated logic
- ensure deterministic behavior
- no scheduler involved
- no full pipeline execution
- fast and minimal
Tests for complete graphs and execution flows.
- validate real runtime behavior
- test interaction between components
- verify scheduling + transport integration
- MUST run through the real runtime
- MUST use real components (not mocks, where possible)
- MUST include realistic data flow scenarios
- linear pipelines
- fan-out / fan-in graphs
- mixed processing chains
Tests that validate system invariants.
- ensure fundamental correctness under all conditions
- detect subtle concurrency and flow bugs
Messages are never lost.
Messages are never duplicated (unless explicitly intended).
Message order is preserved where required by the graph semantics.
Backpressure propagates correctly through the system.
Producers are slowed or blocked when downstream is saturated.
Given identical inputs and configuration, execution produces consistent results.
- Not all pipelines require strict ordering
- Properties must be defined per scenario
Tests for error conditions and system resilience.
- ensure predictable behavior under failure
- validate recovery mechanisms
- component panics or returns error
- downstream behavior is defined and stable
- abrupt stop of execution
- partial processing scenarios
- graph restart
- re-initialization of components
- state consistency
- full buffers
- memory pressure
- slow consumers
- no undefined behavior
- no deadlocks
- no silent data corruption
Tests under high load and parallel conditions.
- detect race conditions
- validate scheduler fairness
- ensure stability under pressure
- high message throughput
- large fan-out graphs
- mixed IO and CPU workloads
Continuous validation across commits.
- tests run on every commit
- failures block changes
- no reliance on manual testing
- combined with performance benchmarks
- ensures correctness AND performance stability
Tests must use the actual runtime, not simplified models.
- mocks only where unavoidable
- prefer real components and real pipelines
- test what the system does
- not how it is implemented internally
- avoid timing-sensitive assertions where possible
- isolate non-deterministic behavior
This testing strategy does NOT aim to:
- maximize code coverage metrics
- test every internal function
- replace performance benchmarking
flowd testing ensures:
- correctness of message flow
- stability under load and failure
- predictable and debuggable execution
A system like flowd is only as good as its behavior under stress, not its behavior in ideal conditions.
To ensure consistency, maintainability, and correctness of pipeline-level tests, all runtime-based tests MUST be executed through a centralized test harness.
Tests MUST NOT construct or manage the runtime manually.
A shared test harness MUST be provided that:
- instantiates the runtime
- loads component configurations
- executes graphs
- captures outputs
- validates expected behavior
The test harness is responsible for:
- creating a runtime instance
- wiring components into a graph
- feeding input data
- executing the scheduler
- collecting outputs
- applying assertions
All pipeline-level tests MUST:
- run through the real runtime
- use the scheduler
- use real components
- avoid direct component invocation
The test harness is the only entry point for runtime-based tests.
Tests SHOULD define pipelines as:
- FBP graph definitions (preferred)
- or programmatically constructed graphs via the harness
Expected outcomes MUST be defined as:
- output message sequences
- state transitions
- invariants (e.g. no message loss)
Declarative expectations MAY be used, but MUST be:
- deterministic
- verifiable without timing assumptions
The harness MUST support:
- data-driven test scenarios
- multiple graph configurations
- varying input datasets
Examples:
- linear pipelines
- fan-out / fan-in
- mixed component chains
- edge cases
The harness SHOULD integrate with property-based testing frameworks.
Properties MUST be validated via:
- repeated randomized execution
- invariant checking
Components SHOULD be registered via a central configuration (e.g. flowd.build.json).
The harness MAY:
- dynamically load components
- generate test scenarios based on available components
Test infrastructure must reflect the actual system configuration.
Component tests:
- test logic in isolation
- DO NOT use the runtime
Pipeline tests:
- test behavior in context
- MUST use the harness
Changes to the runtime API MUST:
- NOT require rewriting all tests
- be absorbed by the test harness
The harness acts as a stability layer between tests and runtime evolution.
The following are explicitly forbidden:
- tests manually constructing runtime internals
- tests spawning their own scheduler
- tests directly invoking component internals in pipeline scenarios
- duplicating runtime logic inside tests
If tests reimplement the runtime, they are invalid.
This section defines how the testing strategy is implemented in practice.
While the previous sections define what must be tested, this section defines:
how tests are structured, executed, and validated in a flowd system.
Tests are active participants in the system, but remain external to the graph.
Tests are implemented as active drivers interacting with the runtime, not as components embedded inside the graph.
A test:
- injects messages into the system via the runtime API
- observes outputs via runtime subscriptions
- evaluates behavior
- determines completion
Test Code (Driver)
↓
Test Harness / Runtime API
↓
Runtime (Scheduler)
↓
Graph (Production Components Only)
Test → inject input → graph executes → outputs produced
→ observe outputs → perform assertions → complete test
Previous interpretations of this model as:
“Test Driver as a component inside the graph”
are explicitly rejected.
Tests MUST NOT:
- be implemented as FBP components
- be embedded into production graphs
- participate as nodes in the dataflow graph
Tests are active in behavior, but external in structure.
The central test harness:
-
creates runtime instances
-
loads and executes graphs
-
integrates test drivers
-
provides utilities for:
- input injection
- output capture
- scheduler execution control
The harness provides execution. Tests provide validation.
A test driver is responsible for:
- generating input messages
- collecting output messages
- evaluating expected behavior
- signaling test completion
- send initial messages into graph
- accumulate outputs from downstream nodes
- assert invariants or expected outputs
- terminate when conditions are met
Used when ordering is not guaranteed.
Expected: {A, B, C}
Actual: {C, A, B} → valid
- robust against scheduling variation
- compatible with parallel execution
- avoids brittle tests
Used only when ordering is semantically required.
Expected: A → B → C
- MUST only be used where ordering is guaranteed by design
- MUST NOT assume incidental ordering
Used for asynchronous or delayed behavior.
Event must occur within N scheduler cycles
- avoid hard timing dependencies
- ensure eventual correctness
Used for system invariants.
Examples:
- no message loss
- no unintended duplication
- ordering constraints (where applicable)
- backpressure correctness
flowd tests MUST assume:
- non-deterministic execution order (unless explicitly constrained)
- asynchronous input arrival
- variable scheduling interleavings
Tests MUST:
- avoid strict ordering assumptions
- prefer invariant-based validation
- use robust comparison strategies
For components using async IO or external event loops:
- events MUST be injected into the system via message queues
- test drivers MUST observe outputs through the same mechanisms as production
External systems are treated as message sources, not test-controlled flows.
- test isolated logic
- do NOT use runtime
- fast and deterministic
- test real execution behavior
- MUST use runtime + scheduler
- MUST use test harness
The idea of a declarative “flow test format” (e.g. JSON-based expected input/output) was considered.
- cannot express non-deterministic behavior reliably
- brittle under concurrency and scheduling variation
- difficult to represent timing and ordering constraints
- leads to fragile, over-specified tests
Static test definitions do not scale to dynamic dataflow systems.
Example:
run graph → collect outputs → assert externally
- breaks encapsulation of execution model
- ignores scheduling behavior
- cannot express incremental or temporal assertions
- tests run in real execution environment
- no duplication of runtime logic
- flexible assertion strategies
- robust against concurrency effects
- scalable to complex pipelines
Only the scheduler decides when execution happens. Tests must adapt to this model, not bypass it.
flowd tests are:
- runtime-driven
- behavior-focused
- resilient to non-determinism
- executed via a centralized harness
- validated through active participation
A dataflow system is not tested by comparing outputs — it is tested by participating in its execution and validating its behavior.
Section 13 applies to:
- pipeline-level tests
- system-level tests
- any test that validates behavior through the runtime
It does NOT apply to:
- component unit tests
- engine-level tests (see Section 14)
Section 13 defines how tests interact with the runtime as external clients.
It is only relevant when:
- the scheduler is involved
- components interact through message passing
- system behavior is being validated
Component-level tests remain isolated and do not use the runtime or test harness.
This section clarifies how testing integrates with the flowd runtime and explicitly defines the boundary between:
- the runtime system
- the graph (components)
- the test environment
Tests are clients of the runtime, not components within the graph.
Tests interact with the system via a runtime-level API, not via embedded test components.
Tests interact with the runtime via a local API that follows the same semantic model as FBP message passing, without requiring protocol-level implementation or network transport.
Test Code (Client)
↓
Test Harness / Runtime API
↓
Runtime (Scheduler)
↓
Graph (Production Components Only)
- tests MUST NOT be implemented as FBP components
- tests MUST NOT be embedded into production graphs
- tests MUST interact with the runtime externally
Tests inject data into the system via the runtime.
test → inject(port, message) → runtime → graph
- injection MUST follow normal runtime semantics
- injected messages MUST behave identically to production inputs
Tests observe system behavior via runtime-level subscriptions.
graph → runtime → test subscribes to port → receives messages
- observation MUST not bypass the runtime
- all observed outputs MUST reflect real execution behavior
Tests MAY control execution via the runtime:
- run until idle
- run a fixed number of scheduler steps
- await outputs
run_until_idle()
run_steps(n)
await_message(port)
- executes the system
- manages scheduling
- enforces backpressure
- contains production components only
- performs actual data processing
- injects input
- observes output
- performs assertions
Tests must not become part of the system under test.
The idea of implementing tests as FBP components (e.g. test_input_driver, test_output_validator, test_property_checker) was considered.
- mixes test logic with production graph
- pollutes component ecosystem
- introduces unnecessary complexity
- makes tests harder to understand and maintain
- creates implicit coupling between runtime and test behavior
Test logic must remain external to the graph.
Splitting test logic into multiple specialized components was considered.
- fragments test logic across nodes
- reduces readability
- increases boilerplate
- introduces unnecessary abstraction
A test must remain a single, coherent unit of behavior.
Tests conceptually behave like FBP protocol clients:
- sending information packets (IPs)
- receiving outputs
- controlling execution
However:
- tests are NOT required to use a networked protocol
- a direct runtime API is preferred for efficiency and control
The test harness is a local, programmatic equivalent of an FBP client.
The graph is the system under test. The test is its external user.
- tests interact via runtime API
- tests are external to the graph
- no test-specific components exist in production graphs
- test harness acts as execution boundary
- runtime evolution is isolated from test implementations
A correct test setup mirrors real system usage — not an artificial testing abstraction inside the system itself.
Engine-level tests validate internal runtime components in isolation.
Includes:
- scheduler behavior
- ringbuffer implementation
- internal data structures
- execution algorithms
Engine tests validate implementation correctness, not system behavior.
Engine tests MAY:
- directly invoke internal APIs
- test scheduler logic in isolation
- simulate execution scenarios without full runtime
Engine tests MUST NOT:
- replace pipeline-level tests
- validate component interaction
- simulate full graph execution
System behavior MUST always be validated through the test harness.
Some aspects of the system:
- cannot be efficiently tested through full pipelines
- require deterministic, isolated validation
Separating engine tests from pipeline tests ensures:
- fast feedback loops
- clear responsibility boundaries
- maintainable test structure
If the test requires the scheduler to behave correctly in context, it belongs in the harness. If it validates how the scheduler works internally, it belongs here.
Internal correctness is tested in isolation. System correctness is tested through execution.