MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / await_data

Function await_data

src/environmentd/tests/sql.rs:724–748  ·  view source on GitHub ↗

Asserts that the next data message is `data`. Ignores any progress messages that occur first. Returns the timestamp at which that data arrived.

(
                    client: &mut postgres::Client,
                    last_seen_ts: &mut u64,
                    data: &str,
                )

Source from the content-addressed store, hash-verified

722 //
723 // Returns the timestamp at which that data arrived.
724 fn await_data(
725 client: &mut postgres::Client,
726 last_seen_ts: &mut u64,
727 data: &str,
728 ) -> u64 {
729 // We have to try several times. It might be that the FETCH gets a
730 // progress statements rather than data. We retry until we get the batch
731 // that has the data.
732 debug!("awaiting data: {data}");
733 loop {
734 let rows = client.query("FETCH 1 c1", &[]).unwrap();
735 debug!(row = ?rows.first());
736 let data_row = match rows.first() {
737 Some(row) if row.try_get::<_, String>("data").is_ok() => row,
738 _ => continue, // retry
739 };
740 assert_eq!(data_row.get::<_, bool>("mz_progressed"), false);
741 assert_eq!(data_row.get::<_, i64>("mz_diff"), 1);
742 assert_eq!(data_row.get::<_, String>("data"), data);
743 let ts = data_row.get::<_, MzTimestamp>("mz_timestamp").0;
744 assert!(ts >= *last_seen_ts);
745 *last_seen_ts = ts;
746 return ts;
747 }
748 }
749
750 // Asserts that the next message has a timestamp of at least `ts` and is a progress message.
751 //

Callers 1

test_subscribe_progressFunction · 0.85

Calls 3

unwrapMethod · 0.80
queryMethod · 0.45
firstMethod · 0.45

Tested by

no test coverage detected