pub struct MockDaemon { /* private fields */ }Expand description
An in-process daemon for unit tests.
Implementations§
Source§impl MockDaemon
impl MockDaemon
Sourcepub fn start() -> Result<Self>
pub fn start() -> Result<Self>
Starts a daemon on a runtime of its own choosing.
§Errors
NodeError::Runtime when no runtime is running and one cannot be
built.
Sourcepub fn start_with(
runtime: NodeRuntime,
dataflow: DataflowId,
auth: AuthToken,
) -> Result<Self>
pub fn start_with( runtime: NodeRuntime, dataflow: DataflowId, auth: AuthToken, ) -> Result<Self>
Starts a daemon with an explicit runtime, dataflow and token.
§Errors
Nothing today; the signature is fallible so a future backing store can report a failure without a breaking change.
Sourcepub fn dataflow(&self) -> DataflowId
pub fn dataflow(&self) -> DataflowId
The dataflow every node joins.
Sourcepub fn runtime(&self) -> &NodeRuntime
pub fn runtime(&self) -> &NodeRuntime
The runtime the serving tasks run on.
Sourcepub fn connect_node(&self, spec: NodeSpawnSpec) -> Result<(Node, EventStream)>
pub fn connect_node(&self, spec: NodeSpawnSpec) -> Result<(Node, EventStream)>
Connects a node with the given specification.
§Errors
NodeError::Testing when the greeting or registration fails, plus
whatever NodeBuilder::finish reports.
Sourcepub async fn connect_node_async(
&self,
spec: NodeSpawnSpec,
) -> Result<(Node, EventStream)>
pub async fn connect_node_async( &self, spec: NodeSpawnSpec, ) -> Result<(Node, EventStream)>
Sourcepub fn send_input(
&self,
node: &NodeId,
input: &DataId,
metadata: Metadata,
payload: Vec<u8>,
) -> Result<()>
pub fn send_input( &self, node: &NodeId, input: &DataId, metadata: Metadata, payload: Vec<u8>, ) -> Result<()>
Sourcepub fn close_input(
&self,
node: &NodeId,
input: &DataId,
reason: RouteCloseReason,
) -> Result<()>
pub fn close_input( &self, node: &NodeId, input: &DataId, reason: RouteCloseReason, ) -> Result<()>
Sourcepub fn upgrade_route(
&self,
node: &NodeId,
output: &DataId,
segment: ShmSegmentSpec,
consumers: Vec<PortRef>,
) -> Result<()>
pub fn upgrade_route( &self, node: &NodeId, output: &DataId, segment: ShmSegmentSpec, consumers: Vec<PortRef>, ) -> Result<()>
Sourcepub fn downgrade_route(
&self,
node: &NodeId,
output: &DataId,
reason: RouteDowngradeReason,
) -> Result<()>
pub fn downgrade_route( &self, node: &NodeId, output: &DataId, reason: RouteDowngradeReason, ) -> Result<()>
Sourcepub fn requests(&self) -> Vec<RecordedRequest>
pub fn requests(&self) -> Vec<RecordedRequest>
Every request the daemon has received.
Sourcepub fn sends(&self) -> Vec<RecordedSend>
pub fn sends(&self) -> Vec<RecordedSend>
Every message the daemon has seen published.
Sourcepub fn sends_on(&self, node: &NodeId, output: &DataId) -> Vec<RecordedSend>
pub fn sends_on(&self, node: &NodeId, output: &DataId) -> Vec<RecordedSend>
The messages one node published on one output.
Sourcepub fn extension(&self, key: &ExtensionKey) -> Option<Vec<u8>>
pub fn extension(&self, key: &ExtensionKey) -> Option<Vec<u8>>
One entry of the extension table.
Sourcepub fn is_subscribed(&self, node: &NodeId) -> bool
pub fn is_subscribed(&self, node: &NodeId) -> bool
Whether a node has subscribed to its inputs.
Sourcepub fn wait_for(
&self,
timeout: Duration,
predicate: impl FnMut(&[RecordedRequest]) -> bool,
) -> Result<()>
pub fn wait_for( &self, timeout: Duration, predicate: impl FnMut(&[RecordedRequest]) -> bool, ) -> Result<()>
Waits until predicate holds over the recorded requests.
The synchronisation primitive a test needs when the node’s own thread is doing the work: assert on what the daemon saw, not on a sleep.
§Errors
NodeError::Timeout when it never holds.
Sourcepub fn wait_for_sends(
&self,
node: &NodeId,
output: &DataId,
count: usize,
timeout: Duration,
) -> Result<Vec<RecordedSend>>
pub fn wait_for_sends( &self, node: &NodeId, output: &DataId, count: usize, timeout: Duration, ) -> Result<Vec<RecordedSend>>
Sourcepub fn listen_unix(&self, path: impl AsRef<Path>) -> Result<UnixEndpoint>
Available on Unix only.
pub fn listen_unix(&self, path: impl AsRef<Path>) -> Result<UnixEndpoint>
Listens on a real Unix-domain socket, the way a daemon actually does (§4.2).
Every other entry point here hands a node one end of an in-process
duplex; this one exercises the dial, the socket and the greeting a
deployed node performs. Nodes that connect this way are admitted from
their Register handshake, so a path: dynamic node (§8.3) can attach
itself with nothing pre-arranged.
§Errors
NodeError::Testing when the socket cannot be bound.