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

Function test_basic_usage

src/timely-util/src/reclock.rs:728–793  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

726
727 #[mz_ore::test]
728 fn test_basic_usage() {
729 let as_of = Antichain::from_elem(IntoTime::minimum());
730 harness(
731 as_of,
732 |worker, mut bindings, (mut data, data_cap), reclocked| {
733 // Reclock offsets 1 and 3 to timestamp 1000
734 bindings.update_at(Partitioned::minimum(), 0, Diff::ONE);
735 bindings.update_at(Partitioned::minimum(), 1000, Diff::MINUS_ONE);
736 for time in partitioned_frontier([(0, 4)]) {
737 bindings.update_at(time, 1000, Diff::ONE);
738 }
739 bindings.advance_to(1001);
740 bindings.flush();
741 data.activate().session(&data_cap).give_iterator(
742 vec![
743 (1, Partitioned::new_singleton(0, 1), Diff::ONE),
744 (1, Partitioned::new_singleton(0, 1), Diff::ONE),
745 (3, Partitioned::new_singleton(0, 3), Diff::ONE),
746 ]
747 .into_iter(),
748 );
749
750 step(worker);
751 assert_eq!(
752 reclocked.try_recv(),
753 Ok(Event::Messages(
754 0u64,
755 vec![
756 (1, 1000, Diff::ONE),
757 (1, 1000, Diff::ONE),
758 (3, 1000, Diff::ONE)
759 ]
760 ))
761 );
762 assert_eq!(
763 reclocked.try_recv(),
764 Ok(Event::Progress(vec![(0, -1), (1000, 1)]))
765 );
766
767 // Reclock more messages for offsets 3 to the same timestamp
768 data.activate().session(&data_cap).give_iterator(
769 vec![
770 (3, Partitioned::new_singleton(0, 3), Diff::ONE),
771 (3, Partitioned::new_singleton(0, 3), Diff::ONE),
772 ]
773 .into_iter(),
774 );
775 step(worker);
776 assert_eq!(
777 reclocked.try_recv(),
778 Ok(Event::Messages(
779 1000u64,
780 vec![(3, 1000, Diff::ONE), (3, 1000, Diff::ONE)]
781 ))
782 );
783
784 // Drop the capability which should advance the reclocked frontier to 1001.
785 drop(data_cap);

Callers

nothing calls this directly

Calls 8

advance_toMethod · 0.80
harnessFunction · 0.70
partitioned_frontierFunction · 0.70
stepFunction · 0.70
flushMethod · 0.45
sessionMethod · 0.45
activateMethod · 0.45
into_iterMethod · 0.45

Tested by

no test coverage detected