Overview
The hydro2-mock crate provides test utilities for the broader hydro2 ecosystem. Specifically, it offers:
- Mock checkpoint callbacks that record each checkpoint invocation into a shared vector, which is especially helpful for verifying partial progress or node-completion sequences in your tests.
- Mock or sample networks of operators, often using minimal or no-op operators, so you can easily set up realistic test scenarios for DAG scheduling without manually constructing every node or edge each time.
What’s Included?
-
MockCheckpointCallback
A simpleCheckpointCallbackimplementation that appends each invocation’s list of completed nodes to a shared, thread‐safe vector. This provides a transparent way to verify that your scheduler or orchestrator is checking in at the correct times. -
mock_networkmodulesingle_noop_operator_i32_network(): a single‐node network with aNoOpOperator.triple_noop_operator_usize_network(): a triple‐node network, each node is no‐op, for basic concurrency or connection testing.empty_i32_network()andempty_usize_network(): empty networks for boundary or error handling checks.build_single_node_network(): a one‐nodeIncrementOperatornetwork.build_chain_network(n, initial_value): a simple linear chain ofnnodes, each incrementing the value.build_branching_network(): an example multi‐branch layout (0 → 1, 0 → 2, then 1 and 2 feed into 3) to test concurrency.
All of these are wrapped in Arc<AsyncMutex<Network<...>>> for easy integration with asynchronous schedulers like hydro2_async_scheduler.
Usage Example
async
async
Why Use hydro2-mock?
- Faster Test Prototyping
Instead of building new operators, you can rely on no‐op or simple increment operators and minimal networks. - Consistent Checkpoint Verification
TheMockCheckpointCallbackmechanism helps confirm that each node completion triggers the correct checkpoint logic in your system under test.
License
Distributed under the OGPv1 License (see ogp-license-text crate for more details).
Repository
Source code is maintained on GitHub at:
https://github.com/klebs6/klebs-general