pub struct TopologyTestDriver { /* private fields */ }Expand description
Synchronous test driver.
This driver builds a runnable processor graph from a BuiltTopology. It
exposes pipe_input and read_output, so a test can exercise processing
logic without a real broker.
Implementations§
Source§impl TopologyTestDriver
impl TopologyTestDriver
Sourcepub fn new(built: &BuiltTopology) -> Result<Self, ProcessorError>
pub fn new(built: &BuiltTopology) -> Result<Self, ProcessorError>
Instantiates the topology’s graph for testing.
§Errors
Returns the ProcessorError that instantiation or a processor’s
init raises. A topology that build accepted raises none in
practice.
Sourcepub fn pipe_input<KS, VS>(
&mut self,
topic: &str,
consumed: impl Into<Consumed<KS, VS>>,
key: Option<KS::Target>,
value: VS::Target,
timestamp: i64,
)
pub fn pipe_input<KS, VS>( &mut self, topic: &str, consumed: impl Into<Consumed<KS, VS>>, key: Option<KS::Target>, value: VS::Target, timestamp: i64, )
Serializes and pipes one record on topic, then loops repartition
outputs back.
consumed is the same Consumed::with(key_serde, value_serde) pair the
source for topic reads with.
Sourcepub fn advance_wall_clock_time(&mut self, by: Duration)
pub fn advance_wall_clock_time(&mut self, by: Duration)
Advances the mock wall clock by by and fires wall-clock punctuators.
Each punctuator fires at most once, with the new clock as its value.
This mirrors the JVM TopologyTestDriver.advanceWallClockTime.
Sourcepub fn get_key_value_store<K: Send + Sync + 'static, V: Send + 'static>(
&mut self,
name: &str,
) -> Option<&mut dyn KeyValueStore<K, V>>
pub fn get_key_value_store<K: Send + Sync + 'static, V: Send + 'static>( &mut self, name: &str, ) -> Option<&mut dyn KeyValueStore<K, V>>
Inspects a state store’s contents after piping.
This method mirrors the JVM TopologyTestDriver.getKeyValueStore. It is
test-only. Do not use it for interactive queries.
Sourcepub fn store_get<K: Send + Sync + 'static, V: Send + 'static>(
&mut self,
store: &str,
key: &K,
) -> Option<V>
pub fn store_get<K: Send + Sync + 'static, V: Send + 'static>( &mut self, store: &str, key: &K, ) -> Option<V>
Test-only synchronous store read that calls block_on on the async
store.
The store API is async. This method drives one typed get to
completion, so sync #[test] assertions can inspect materialized state.
Sourcepub fn store_get_versioned<K: Send + Sync + 'static, V: Send + 'static>(
&mut self,
store_name: &str,
key: &K,
) -> Option<V>
pub fn store_get_versioned<K: Send + Sync + 'static, V: Send + 'static>( &mut self, store_name: &str, key: &K, ) -> Option<V>
Latest live value of a key in a versioned store. This is a test helper.
Sourcepub fn drain_changelog(
&mut self,
) -> Vec<(String, Bytes, Option<Bytes>, Option<i64>)>
pub fn drain_changelog( &mut self, ) -> Vec<(String, Bytes, Option<Bytes>, Option<i64>)>
Drains the changelog records the stores have produced so far. This is a test helper.
The records come back as (changelog_topic, key, value, record_ts) in
production order. A test can then assert byte-exact changelog records,
for example the KIP-889 versioned changelog, which holds bare value
bytes and the version timestamp in the record-timestamp field.
Sourcepub fn pipe_global<K, V>(&mut self, store_name: &str, key: K, value: V)
pub fn pipe_global<K, V>(&mut self, store_name: &str, key: K, value: V)
Populates a GLOBAL store directly. This method is test-only.
In a real app the global consumer reads all partitions of the source topic and applies them to the fully-replicated global store. The test driver instead injects values straight into the shared global store manager, so a stream-globaltable join can look them up.
Sourcepub async fn iq_kv_get<K: 'static, V: 'static>(
&self,
store: &str,
key: &K,
ks: &dyn Serde<K>,
vs: &dyn Serde<V>,
) -> Option<V>
pub async fn iq_kv_get<K: 'static, V: 'static>( &self, store: &str, key: &K, ks: &dyn Serde<K>, vs: &dyn Serde<V>, ) -> Option<V>
Interactive-query KV read: the value for key, else None. The result
is None if the store is absent or is not a key-value store.
§Panics
Panics if synchronized client state is poisoned or a response violates an invariant established by protocol validation.
Sourcepub async fn iq_kv_range<K: 'static, V: 'static>(
&self,
store: &str,
lo: &K,
hi: &K,
ks: &dyn Serde<K>,
vs: &dyn Serde<V>,
) -> Vec<(K, V)>
pub async fn iq_kv_range<K: 'static, V: 'static>( &self, store: &str, lo: &K, hi: &K, ks: &dyn Serde<K>, vs: &dyn Serde<V>, ) -> Vec<(K, V)>
Interactive-query KV range read over the inclusive [lo, hi] key span,
in store (memcmp) order. The result is empty if the store is absent or
is not a KV store.
§Panics
Panics if synchronized client state is poisoned or a response violates an invariant established by protocol validation.
Sourcepub async fn iq_kv_all<K: 'static, V: 'static>(
&self,
store: &str,
ks: &dyn Serde<K>,
vs: &dyn Serde<V>,
) -> Vec<(K, V)>
pub async fn iq_kv_all<K: 'static, V: 'static>( &self, store: &str, ks: &dyn Serde<K>, vs: &dyn Serde<V>, ) -> Vec<(K, V)>
Interactive-query read of every entry in a KV store, in store order.
§Panics
Panics if synchronized client state is poisoned or a response violates an invariant established by protocol validation.
Sourcepub async fn iq_kv_count(&self, store: &str) -> u64
pub async fn iq_kv_count(&self, store: &str) -> u64
Interactive-query approximate entry count for a KV store. The result is
0 if the store is absent.
Sourcepub async fn iq_window_fetch<K: 'static, V: 'static>(
&self,
store: &str,
key: &K,
from: i64,
to: i64,
ks: &dyn Serde<K>,
vs: &dyn Serde<V>,
) -> Vec<(i64, V)>
pub async fn iq_window_fetch<K: 'static, V: 'static>( &self, store: &str, key: &K, from: i64, to: i64, ks: &dyn Serde<K>, vs: &dyn Serde<V>, ) -> Vec<(i64, V)>
Interactive-query window read: (windowStart, value) for every window
of key whose start is in the inclusive [from, to] span, ascending by
window start. The result is empty if the store is absent or is not a
window store.
§Panics
Panics if synchronized client state is poisoned or a response violates an invariant established by protocol validation.
Sourcepub async fn iq_window_fetch_single<K: 'static, V: 'static>(
&self,
store: &str,
key: &K,
window_start: i64,
ks: &dyn Serde<K>,
vs: &dyn Serde<V>,
) -> Option<V>
pub async fn iq_window_fetch_single<K: 'static, V: 'static>( &self, store: &str, key: &K, window_start: i64, ks: &dyn Serde<K>, vs: &dyn Serde<V>, ) -> Option<V>
Interactive-query single-window read: value of the window of key that
starts exactly at window_start, else None.
§Panics
Panics if synchronized client state is poisoned or a response violates an invariant established by protocol validation.
Sourcepub async fn query<Q: Query>(
&self,
req: StateQuery<Q>,
) -> StateQueryResult<Q::Result>
pub async fn query<Q: Query>( &self, req: StateQuery<Q>, ) -> StateQueryResult<Q::Result>
Runs an IQv2 query against the single test graph, partition 0.
Position is empty, because the driver does not track source offsets.
Use unit tests on Position::dominates for bound behavior.
Sourcepub async fn iq_session_fetch<K: 'static, V: 'static>(
&self,
store: &str,
key: &K,
ks: &dyn Serde<K>,
vs: &dyn Serde<V>,
) -> Vec<((i64, i64), V)>
pub async fn iq_session_fetch<K: 'static, V: 'static>( &self, store: &str, key: &K, ks: &dyn Serde<K>, vs: &dyn Serde<V>, ) -> Vec<((i64, i64), V)>
Interactive-query session read: ((start, end), value) for every
session of key, in store order. The result is empty if the store is
absent or is not a session store.
§Panics
Panics if synchronized client state is poisoned or a response violates an invariant established by protocol validation.
Sourcepub fn read_output<KS, VS>(
&mut self,
topic: &str,
produced: impl Into<Produced<KS, VS>>,
) -> Option<(Option<KS::Target>, VS::Target)>
pub fn read_output<KS, VS>( &mut self, topic: &str, produced: impl Into<Produced<KS, VS>>, ) -> Option<(Option<KS::Target>, VS::Target)>
Pops and deserializes the next output record for topic.
produced is the same Produced::with(key_serde, value_serde) pair the
sink writing topic produced with.
§Panics
Panics if synchronized client state is poisoned or a response violates an invariant established by protocol validation.
Auto Trait Implementations§
impl !RefUnwindSafe for TopologyTestDriver
impl !Sync for TopologyTestDriver
impl !UnwindSafe for TopologyTestDriver
impl Freeze for TopologyTestDriver
impl Send for TopologyTestDriver
impl Unpin for TopologyTestDriver
impl UnsafeUnpin for TopologyTestDriver
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<K, Q> Comparable<Q> for K
impl<K, Q> Comparable<Q> for K
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<K, Q> Equivalent<Q> for K
impl<K, Q> Equivalent<Q> for K
§fn equivalent(&self, key: &Q) -> bool
fn equivalent(&self, key: &Q) -> bool
key and return true if they are equal.impl<T> ErasedDestructor for Twhere
T: 'static,
impl<T> Fruit for Twhere
T: Send + Downcast,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling [Attribute] value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi [Quirk] value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the [Condition] value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);