Expand description
Executes a text command script against clusterd.
Instead of recompiling a Rust scenario, a test (or an agent) writes a
crate::text script: a sequence of commands, each with an expected output
block (----) that is the assertion. The coarse orchestration verbs map almost
directly to Driver calls; define carries arbitrary MIR (as pretty-form
specs parsed by mz-expr-parser, the .spec test syntax) over the full
DataflowBuilder surface, including index imports, while define_index
stays as sugar for the common single-index shape. Explicit write_rows
payloads are typed against the schema token-by-token via cell_from_token
(reusing mz_repr::strconv) rather than Row’s opaque serde.
§Execution
run parses the script, executes each command, and compares its golden
output to the expected block — failing the run on a mismatch, or rewriting the
file when REWRITE is set. A command that fails renders as error: <message>,
so an expected failure is asserted by its golden block. Assertions are
level-triggered waits on monotonic frontiers, so a single sequential script is
deterministic regardless of how the dataflows interleave.
Shards are referenced by a string alias; the first command naming an alias
allocates a fresh ShardId for it. Object ids are raw u64s mapped to
GlobalId::User.
Structs§
- Build
Spec - A MIR object to build in a
definecommand. - Column
Spec - A column declaration in a
define_schemacommand. - Config
Setting - A single dyncfg update in an
update-configurationcommand: a config name, a type tag selecting howvalueis parsed (bool/u32/usize/f64/string/duration), and the value. Typed againstmz_dyncfgat execution. - Index
Entry 🔒 - What the registry remembers about an exported index, so a later
defineimport or count assertion can reconstruct the import without re-declaring it. - Script
State - Mutable state threaded through a script run.
Enums§
- Command
- A command read from the script stream.
- Export
Spec - An export in a
create-dataflowcommand, mirroring the export kinds a real dataflow produces (seemz_compute_types::sinks::ComputeSinkConnection).copy-tois intentionally absent: the parser rejects it as unimplemented. - Import
Spec - A collection to import in a
definecommand: a persist source or an existing index. Externally tagged:{"source": {…}}or{"index": {…}}.
Constants§
- DEFAULT_
ROW_ 🔒BYTES - The default payload padding (bytes) for synthetic rows when a command omits it.
- DEFAULT_
TIMEOUT_ 🔒SECS - The default timeout (seconds) for
await_frontierwhen a command omits it. - INTERNAL_
ID_ 🔒BASE - The base for ephemeral global ids the count sugar allocates. Far above any id a script would use, so its dataflows never collide with user objects.
Functions§
- cell_
from_ 🔒token - Type a raw row-value token against its column into an owned
Cell. - parse_
config_ 🔒val - Parse a configuration value string into a
ConfigVal, selecting the variant by a type tag. Each numeric/bool/duration type reusesmz_dyncfg’s ownConfigType::parse(so the accepted syntax — e.g.on/offfor bool, humantime for duration — matches the rest of the codebase);stringis taken verbatim. - register_
catalog_ 🔒object - Register a referenceable object in the parser
catalogunder its global-id name (e.g.u1000), recording the name-to-id mapping so the parsedGets — which carry the catalog’s own assigned ids — can be remapped back to the script’s ids. - relation_
desc 🔒 - Build a
RelationDescfrom column specs. - remap_
gets 🔒 - Rewrite every global
Getinexprfrom the catalog’s assigned id back to the script’s id, looked up by the object’s name. - render_
rows 🔒 - Render peeked rows as deterministic golden text: each row’s datums joined by spaces, with the rows sorted so the output is independent of arrangement order.
- render_
updates 🔒 - Render a subscribe’s updates as golden text:
<ts> <diff> <datums>per line. Updates are consolidated by(time, row)— so split batches and retractions collapse — net-zero rows dropped, and the lines sorted for determinism. - rows_
from_ 🔒tokens - Pack explicit row tokens against
desc, validating arity per row. - run
- Run a script: parse
contentinto stanzas, execute each command, and either compare its output to the stanza’s expected block or — whenREWRITEis set andpathis given — rewrite the file in place with the actual outputs. - scalar_
type_ 🔒from_ str - Map a JSON type name to a
SqlScalarType. The supported set is intentionally small and matchescrate::data::Cell; extend both together. - unquote 🔒
- Strip surrounding double quotes from a token, if present.
- up_
to_ 🔒antichain - Convert an optional
up_totimestamp into a sink’s exclusive upper antichain;Noneis the empty antichain (no bound — the sink runs indefinitely).