Skip to main content

Crate faucet_conformance

Crate faucet_conformance 

Source
Expand description

§faucet-conformance

A reusable test battery that any faucet connector can call from its own tests/ to prove it upholds the connector contract. Passing this battery is the Tier-1 criterion for a connector — there is no separate tiering scheme; a connector is “supported” exactly when it invokes and passes these checks in CI.

use faucet_conformance as conf;
let source = /* your Source */
conf::assert_config_schema_valid(&source);
conf::assert_bounded_memory(&source, 100, 1000).await;

All six checks are fully implemented:

  1. assert_config_schema_valid — the config schema is a valid JSON Schema.
  2. assert_bounded_memory — the source pages instead of buffering.
  3. assert_bookmark_roundtrip — an incremental source resumes from its bookmark rather than restarting.
  4. assert_idempotent_replay — re-delivering committed rows leaves no duplicates (atomic-watermark or keyed-upsert mechanism).
  5. assert_capabilities_truthful — advertised capabilities match real behaviour.
  6. assert_errors_not_panics — failures surface as a typed faucet_core::FaucetError, never a panic.

Each check has both a passing and a #[should_panic] failing test in this crate — a check that cannot fail is worthless.

Modules§

doubles
Synthetic Source / Sink doubles the battery drives (and that connector authors can reuse in their own tests).

Traits§

HasConfigSchema
Anything that can expose a config JSON Schema + a label — blanket-implemented for every Source so assert_config_schema_valid accepts a source directly. (Sinks can be checked via assert_config_schema_valid_value.)

Functions§

assert_bookmark_roundtrip
Check 3. Drive an incremental source to completion, capture the bookmark it emits, feed it back via apply_start_bookmark, and assert the second run resumes after that point — strictly fewer records reappear (zero for a fully-consumed static source).
assert_bounded_memory
Check 2. Drive stream_pages over a source that yields total records and assert the consumer never holds more than ~batch_size records live at once (i.e. the source pages instead of buffering everything).
assert_capabilities_truthful
Check 5. Assert a sink’s advertised capabilities match real behaviour:
assert_config_schema_valid
Check 1. Assert the connector’s config_schema() is a structurally valid JSON Schema that round-trips through serde_json.
assert_config_schema_valid_value
The value-level core of assert_config_schema_valid — usable for sinks: assert_config_schema_valid_value(&sink.config_schema(), sink.connector_name()).
assert_errors_not_panics
Check 6. Drive a source configured to fail (unreachable endpoint / bad config) and assert it surfaces a typed faucet_core::FaucetError without unwinding. Catches any panic and re-raises it as a check failure, so a connector that unwrap()s on bad input is caught rather than crashing the test process silently.
assert_idempotent_replay
Check 4. Assert re-delivering already-committed rows leaves no duplicates in the destination — the trust-critical effectively-once check.